@@ -2,7 +2,8 @@ import chroma from 'chroma-js';
22
33import { avatarColor } from '@cardstack/theme' ;
44
5- const buildRgba = ( color , alpha = 1 ) => `rgba(${ chroma ( color ) . rgb ( ) } ,${ alpha } )` ;
5+ const buildRgba = ( color : string , alpha = 1 ) =>
6+ `rgba(${ chroma ( color ) . rgb ( ) } ,${ alpha } )` ;
67
78const colors = {
89 appleBlue : '#0E76FD' , // '14, 118, 253'
@@ -34,27 +35,16 @@ const colors = {
3435 alpha : buildRgba ,
3536} ;
3637
37- const isColorLight = targetColor =>
38- chroma ( targetColor || colors . white ) . luminance ( ) > 0.5 ;
38+ export const getFallbackTextColor = ( backgroundColor ?: string ) => {
39+ const dark = colors . alpha ( colors . blueGreyDark , 0.5 ) ;
40+ const light = colors . whiteLabel ;
41+ const isColorLight =
42+ chroma ( backgroundColor || colors . white ) . luminance ( ) > 0.5 ;
3943
40- const getTextColorForBackground = ( targetColor , textColors = { } ) => {
41- const { dark = colors . black , light = colors . white } = textColors ;
42-
43- return isColorLight ( targetColor ) ? dark : light ;
44+ return isColorLight ? dark : light ;
4445} ;
4546
46- const getFallbackTextColor = bg =>
47- colors . getTextColorForBackground ( bg , {
48- dark : colors . alpha ( colors . blueGreyDark , 0.5 ) ,
49- light : colors . whiteLabel ,
50- } ) ;
51-
5247export const getRandomColor = ( ) =>
5348 Math . floor ( Math . random ( ) * avatarColor . length ) ;
5449
55- export default {
56- ...colors ,
57- getTextColorForBackground,
58- getFallbackTextColor,
59- getRandomColor,
60- } ;
50+ export default colors ;
0 commit comments