File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,16 @@ function styleFromSize(size: number) {
117117 } ;
118118}
119119
120+ // Bright tiles (Yellow, Orange) need dark letters for contrast; the rest read
121+ // best with white.
122+ function letterColorForBackground ( hex : string ) : string {
123+ const match = / ^ # ? ( [ 0 - 9 a - f ] { 6 } ) $ / i. exec ( hex ) ;
124+ if ( ! match ) return "#fff" ;
125+ const n = parseInt ( match [ 1 ] , 16 ) ;
126+ const luminance = 0.299 * ( ( n >> 16 ) & 255 ) + 0.587 * ( ( n >> 8 ) & 255 ) + 0.114 * ( n & 255 ) ;
127+ return luminance > 140 ? "#272A2E" : "#fff" ;
128+ }
129+
120130function AvatarLetters ( {
121131 avatar,
122132 size,
@@ -132,15 +142,13 @@ function AvatarLetters({
132142
133143 const style = {
134144 backgroundColor : avatar . hex ,
145+ color : letterColorForBackground ( avatar . hex ) ,
135146 } ;
136147
137148 const scaleFactor = includePadding ? 0.8 : 1 ;
138149
139150 return (
140- < span
141- className = "grid shrink-0 place-items-center overflow-hidden text-white"
142- style = { styleFromSize ( size ) }
143- >
151+ < span className = "grid shrink-0 place-items-center overflow-hidden" style = { styleFromSize ( size ) } >
144152 { /* This is the square container */ }
145153 < span
146154 className = { cn (
Original file line number Diff line number Diff line change @@ -81,7 +81,12 @@ export function RadioButtonCircle({
8181 outerCircleClassName
8282 ) }
8383 >
84- < Circle className = { cn ( "size-2 fill-white text-white" , innerCircleClassName ) } />
84+ < Circle
85+ className = { cn (
86+ "size-2 fill-white text-white dark:fill-text-bright dark:text-text-bright" ,
87+ innerCircleClassName
88+ ) }
89+ />
8590 </ div >
8691 ) }
8792 </ div >
@@ -134,7 +139,7 @@ export const RadioGroupItem = React.forwardRef<
134139 ) }
135140 >
136141 < RadioGroupPrimitive . Indicator className = "flex h-full w-full items-center justify-center rounded-full bg-indigo-600" >
137- < Circle className = "size-2 fill-white text-white" />
142+ < Circle className = "size-2 fill-white text-white dark:fill-text-bright dark:text-text-bright " />
138143 </ RadioGroupPrimitive . Indicator >
139144 </ div >
140145 < div className = { cn ( icon ? "flex h-full flex-col justify-end" : "" ) } >
Original file line number Diff line number Diff line change @@ -96,7 +96,10 @@ export const Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.
9696 ) }
9797 >
9898 < SwitchPrimitives . Thumb
99- className = { cn ( thumb , "pointer-events-none block rounded-full bg-white transition" ) }
99+ className = { cn (
100+ thumb ,
101+ "pointer-events-none block rounded-full bg-white transition dark:bg-charcoal-200 dark:group-data-[state=checked]:bg-text-bright"
102+ ) }
100103 />
101104 </ div >
102105 ) ;
Original file line number Diff line number Diff line change @@ -122,7 +122,10 @@ export async function updateThemePreference({
122122 return prisma . $executeRaw `
123123 UPDATE "User"
124124 SET "dashboardPreferences" = jsonb_set(
125- COALESCE("dashboardPreferences", '{}'::jsonb),
125+ COALESCE(
126+ "dashboardPreferences",
127+ '{"version":"1","projects":{}}'::jsonb
128+ ),
126129 '{theme}',
127130 to_jsonb(${ theme } ::text)
128131 )
You can’t perform that action at this time.
0 commit comments