@@ -61,18 +61,23 @@ function RouteComponent() {
6161 ) ;
6262}
6363
64- const Color = ( { name, value } ) => (
65- < div
66- style = { {
67- backgroundColor : value ,
68- // Makes sure the text has enough contrast by calculating the color based on the background color
69- // This will yield a color that is either black or white
70- // Refer to: https://til.jakelazaroff.com/css/swap-between-black-and-white-text-based-on-background-color/
71- color : `lch(from ${ value } calc((54 - l) * infinity) 0 0)` ,
72- border : value === '#fff' ? '1px solid var(--gm-color-blue-dark)' : '' ,
73- } }
74- className = "grid h-32 w-32 items-end"
75- >
76- < span className = "block p-2 text-sm" > { name } </ span >
77- </ div >
78- ) ;
64+ const Color = ( { name, value } ) => {
65+ const color = `rgb(${ value . split ( ' ' ) . join ( ', ' ) } )` ;
66+
67+ return (
68+ < div
69+ style = { {
70+ backgroundColor : color ,
71+ // Makes sure the text has enough contrast by calculating the color based on the background color
72+ // This will yield a color that is either black or white
73+ // Refer to: https://til.jakelazaroff.com/css/swap-between-black-and-white-text-based-on-background-color/
74+ color : `lch(from ${ color } calc((54 - l) * infinity) 0 0)` ,
75+ border :
76+ name === 'white' ? '1px solid rgb(var(--gm-color-blue-dark))' : '' ,
77+ } }
78+ className = "grid h-32 w-32 items-end"
79+ >
80+ < span className = "block p-2 text-sm" > { name } </ span >
81+ </ div >
82+ ) ;
83+ } ;
0 commit comments