@@ -48,10 +48,12 @@ import {
4848 updateContrastPreference ,
4949 updateIconContrastPreference ,
5050 updateThemePreference ,
51+ updateUnderlineLinksPreference ,
5152} from "~/services/dashboardPreferences.server" ;
5253import {
5354 normalizeIconContrast ,
5455 normalizeThemeContrast ,
56+ normalizeUnderlineLinks ,
5557 normalizeThemePreference ,
5658 type ThemePreference ,
5759} from "~/utils/themePreference" ;
@@ -189,6 +191,20 @@ export const action: ActionFunction = async ({ request }) => {
189191 return json ( { success : true } ) ;
190192 }
191193
194+ if ( formData . get ( "action" ) === "update-underline-links" ) {
195+ const user = await requireUser ( request ) ;
196+ const showThemeSwitcher =
197+ user . admin || ( await cachedFlag ( { key : "hasThemeSwitcher" , defaultValue : false } ) ) ;
198+ if ( ! showThemeSwitcher ) {
199+ return json ( { error : "Not available" } , { status : 404 } ) ;
200+ }
201+ await updateUnderlineLinksPreference ( {
202+ user,
203+ underlineLinks : formData . get ( "underlineLinks" ) === "true" ,
204+ } ) ;
205+ return json ( { success : true } ) ;
206+ }
207+
192208 const formSchema = createSchema ( {
193209 isEmailUnique : async ( email ) => {
194210 const existingUser = await prisma . user . findFirst ( {
@@ -360,6 +376,12 @@ export default function Page() {
360376 typeof pendingIconContrast === "string"
361377 ? pendingIconContrast === "true"
362378 : normalizeIconContrast ( user . dashboardPreferences . iconContrast ) ;
379+ const underlineLinksFetcher = useFetcher ( ) ;
380+ const pendingUnderlineLinks = underlineLinksFetcher . formData ?. get ( "underlineLinks" ) ;
381+ const underlineLinks =
382+ typeof pendingUnderlineLinks === "string"
383+ ? pendingUnderlineLinks === "true"
384+ : normalizeUnderlineLinks ( user . dashboardPreferences . underlineLinks ) ;
363385 const pendingTheme = themeFetcher . formData ?. get ( "theme" ) ;
364386 const pendingContrast = contrastFetcher . formData ?. get ( "contrast" ) ;
365387 const contrast =
@@ -613,6 +635,30 @@ export default function Page() {
613635 </ div >
614636 </ div >
615637 </ div >
638+ < div className = "flex min-h-16 w-full items-center border-b border-grid-dimmed" >
639+ < div className = "flex w-full items-center justify-between gap-4" >
640+ < div className = { cn ( "flex-1" , SETTINGS_ROW_TITLE_GAP ) } >
641+ < Label > Underline links</ Label >
642+ < SettingsRowDescription > Underline links in body text</ SettingsRowDescription >
643+ </ div >
644+ < div className = "flex flex-none items-center" >
645+ < Switch
646+ variant = "minimal/medium"
647+ aria-label = "Underline links"
648+ checked = { underlineLinks }
649+ onCheckedChange = { ( checked ) =>
650+ underlineLinksFetcher . submit (
651+ {
652+ action : "update-underline-links" ,
653+ underlineLinks : checked ? "true" : "false" ,
654+ } ,
655+ { method : "post" }
656+ )
657+ }
658+ />
659+ </ div >
660+ </ div >
661+ </ div >
616662 </ >
617663 ) }
618664 </ MainHorizontallyCenteredContainer >
0 commit comments