Skip to content

Commit a182d05

Browse files
committed
ID-426 Always lighten secondary nav with black.
Switch from lighten to tint as this always gets it a % of the way to white, rather than lighten which could send an already-light colour almost all the way to white and look ridiculous.
1 parent c6f6364 commit a182d05

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

less/mixins/wcag.less

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@result: if(@contrast-ratio-dark >= @contrast-ratio-light,
1212
@dark,
1313
@light
14-
)
14+
);
1515
}
1616

1717
// Similar to .contrast, but it will strongly prefer the preferred colour
@@ -21,7 +21,6 @@
2121
// If they don't, you may get a result that doesn't pass AA.
2222
.contrast-fallback(@background, @preferred, @fallback) {
2323
@contrast-ratio-preferred: #wcag.contrast-ratio(@background, @preferred)[@result];
24-
@contrast-ratio-fallback: #wcag.contrast-ratio(@background, @fallback)[@result];
2524

2625
@result: if(@contrast-ratio-preferred >= #wcag[@aa-contrast],
2726
@preferred,
@@ -34,12 +33,12 @@
3433
// Contrast on steroids. This function may also modify the background colour
3534
// in order to make a colour pass the contrast threshold, and it heavily
3635
// favours the light colour over the dark colour because of situations such
37-
// as navigation where
36+
// as navigation where the background colour is not known.
3837
.ultra-contrast(@background, @light, @dark) {
3938
@target-contrast: #wcag[@aa-contrast];
4039

41-
@lighter-background: lighten(@background, 25%);
42-
@darker-background: darken(@background, 15%);
40+
@lighter-background: tint(@background, 40%);
41+
@darker-background: screen(@background, darken(white, 30%));
4342

4443
@light-aa: boolean(#wcag.contrast-ratio(@background, @light)[@result] > @target-contrast);
4544
@dark-aa: boolean(#wcag.contrast-ratio(@background, @dark)[@result] > @target-contrast);
@@ -57,7 +56,9 @@
5756
{
5857
@msg: "Dark colour passes AA";
5958
@fg: @dark;
60-
@bg: @background;
59+
// @background would pass AA here but we've decided to go lighter for that extra boost,
60+
// as AA black text just doesn't appear as contrasting in practice.
61+
@bg: @lighter-background;
6162
},
6263
if(@enhanced-dark-aa,
6364
{

0 commit comments

Comments
 (0)