Skip to content

Commit 8169593

Browse files
committed
ensure enough contrast for active activity bar selectin
1 parent 0211ebc commit 8169593

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/app/src/app/pages/Sandbox/Editor/Navigation/elements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const IconContainer = styled(Stack)<{
5151
5252
${props.selected &&
5353
css`
54-
color: ${props.theme.colors.activityBar.selected};
54+
color: ${props.theme.colors.activityBar.selectedForeground};
5555
`};
5656
5757
${props.isDisabled &&

packages/components/src/utils/polyfill-theme.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const polyfillTheme = vsCodeTheme => {
159159
const addedColors = {
160160
mutedForeground,
161161
activityBar: {
162-
selected: uiColors.sideBar.foreground,
162+
selectedForeground: uiColors.sideBar.foreground,
163163
inactiveForeground: mutedForeground,
164164
hoverBackground: uiColors.sideBar.border,
165165
},
@@ -199,6 +199,14 @@ const polyfillTheme = vsCodeTheme => {
199199
uiColors.switch.toggle = designLanguage.colors.grays[200];
200200
}
201201

202+
// ensure enough contrast from inactive state
203+
uiColors.activityBar.selectedForeground = withContrast(
204+
uiColors.activityBar.selectedForeground,
205+
uiColors.activityBar.inactiveForeground,
206+
type,
207+
'icon'
208+
);
209+
202210
return uiColors;
203211
};
204212

@@ -219,8 +227,11 @@ const darken = (color, value) =>
219227
.darken(value)
220228
.hex();
221229

222-
const withContrast = (color, background, type) => {
223-
if (Color(color).contrast(Color(background)) > 4.5) return color;
230+
const withContrast = (color, background, type, contrastType = 'text') => {
231+
const contrastRatio = { text: 4.5, icon: 3 };
232+
const contrast = contrastRatio[contrastType];
233+
234+
if (Color(color).contrast(Color(background)) > contrast) return color;
224235

225236
// can't fix that
226237
if (color === '#FFFFFF' || color === '#000000') return color;

0 commit comments

Comments
 (0)