@@ -55,7 +55,7 @@ const labelCss = css`
5555const numberCss = css `
5656 ${ textSansBold20 } ;
5757 grid- area: home-stat;
58- color : var( - - match- stat- team - colour) ;
58+ color : ${ palette ( '--football- match-stat-text' ) } ;
5959` ;
6060
6161const largeNumberCss = css `
@@ -64,24 +64,6 @@ const largeNumberCss = css`
6464 }
6565` ;
6666
67- const numberLightContrastCss = css `
68- @media (prefers-color-scheme : light) {
69- color : ${ palette ( '--football-match-stat-text' ) } ;
70- }
71- [data-color-scheme = 'light' ] & {
72- color : ${ palette ( '--football-match-stat-text' ) } ;
73- }
74- ` ;
75-
76- const numberDarkContrastCss = css `
77- @media (prefers-color-scheme : dark) {
78- color : ${ palette ( '--football-match-stat-text' ) } ;
79- }
80- [data-color-scheme = 'dark' ] & {
81- color : ${ palette ( '--football-match-stat-text' ) } ;
82- }
83- ` ;
84-
8567const awayStatCss = css `
8668 grid- area: away- stat;
8769 justify- self: end;
@@ -100,7 +82,7 @@ const barCss = css`
10082 bor der- radius: 8px;
10183` ;
10284
103- const barLightContrastCss = css `
85+ const barAddContrastLightCss = css `
10486 @media (prefers-color-scheme : light) {
10587 border : 1px solid ${ palette ( '--football-match-stat-border' ) } ;
10688 }
@@ -109,7 +91,7 @@ const barLightContrastCss = css`
10991 }
11092` ;
11193
112- const barDarkContrastCss = css `
94+ const barAddContrastDarkCss = css `
11395 @media (prefers-color-scheme : dark) {
11496 border : 1px solid ${ palette ( '--football-match-stat-border' ) } ;
11597 }
@@ -147,7 +129,7 @@ export const FootballMatchStat = ({
147129 const homePercentage = ( home . value / ( home . value + away . value ) ) * 100 ;
148130 const awayPercentage = ( away . value / ( home . value + away . value ) ) * 100 ;
149131
150- const minimumContrast = 3.1 ; // https://www.w3.org/TR /WCAG21/#contrast-minimum
132+ const minimumContrast = 3.1 ; // https://www.w3.org/WAI /WCAG21/Understanding/non-text-contrast.html
151133
152134 const backgroundLight = sourcePalette . neutral [ 97 ] ;
153135 const backgroundDark = sourcePalette . neutral [ 10 ] ;
@@ -161,27 +143,12 @@ export const FootballMatchStat = ({
161143 const awayNeedsContrastWhenDark =
162144 getContrast ( away . teamColour , backgroundDark ) < minimumContrast ;
163145
164- /**
165- * If either team colour lacks sufficient contrast we adjust both numbers
166- * so we don't appear to be favouring one team over the other. For the chart
167- * we keep the team colour and apply a contrasting border colour.
168- */
169- const numbersNeedContrastWhenLight =
170- homeNeedsContrastWhenLight || awayNeedsContrastWhenLight ;
171- const numbersNeedContrastWhenDark =
172- homeNeedsContrastWhenDark || awayNeedsContrastWhenDark ;
173-
174146 return (
175147 < div css = { containerCss } >
176148 < div css = { [ headerCss , raiseLabelOnDesktop && raiseLabelCss ] } >
177149 < span css = { labelCss } > { label } </ span >
178150 < span
179- css = { [
180- numberCss ,
181- largeNumbersOnDesktop && largeNumberCss ,
182- numbersNeedContrastWhenLight && numberLightContrastCss ,
183- numbersNeedContrastWhenDark && numberDarkContrastCss ,
184- ] }
151+ css = { [ numberCss , largeNumbersOnDesktop && largeNumberCss ] }
185152 style = { { '--match-stat-team-colour' : home . teamColour } }
186153 >
187154 < span
@@ -198,8 +165,6 @@ export const FootballMatchStat = ({
198165 numberCss ,
199166 awayStatCss ,
200167 largeNumbersOnDesktop && largeNumberCss ,
201- numbersNeedContrastWhenLight && numberLightContrastCss ,
202- numbersNeedContrastWhenDark && numberDarkContrastCss ,
203168 ] }
204169 style = { { '--match-stat-team-colour' : away . teamColour } }
205170 >
@@ -217,8 +182,8 @@ export const FootballMatchStat = ({
217182 < div
218183 css = { [
219184 barCss ,
220- homeNeedsContrastWhenLight && barLightContrastCss ,
221- homeNeedsContrastWhenDark && barDarkContrastCss ,
185+ homeNeedsContrastWhenLight && barAddContrastLightCss ,
186+ homeNeedsContrastWhenDark && barAddContrastDarkCss ,
222187 ] }
223188 style = { {
224189 '--match-stat-percentage' : `${ homePercentage } %` ,
@@ -228,8 +193,8 @@ export const FootballMatchStat = ({
228193 < div
229194 css = { [
230195 barCss ,
231- awayNeedsContrastWhenLight && barLightContrastCss ,
232- awayNeedsContrastWhenDark && barDarkContrastCss ,
196+ awayNeedsContrastWhenLight && barAddContrastLightCss ,
197+ awayNeedsContrastWhenDark && barAddContrastDarkCss ,
233198 ] }
234199 style = { {
235200 '--match-stat-percentage' : `${ awayPercentage } %` ,
0 commit comments