44import React , { useMemo , useEffect , type ReactNode } from "react" ;
55import * as mui from "@mui/material/styles" ;
66import { fr } from "../fr" ;
7+ import type { FrCoreClassName } from "../fr/generatedFromCss/classNames" ;
78import { useIsDark } from "../useIsDark" ;
89import { typography } from "../fr/generatedFromCss/typography" ;
910import { spacingTokenByValue } from "../fr/generatedFromCss/spacing" ;
10- import { assert } from "tsafe/assert" ;
11+ import { assert , type Equals } from "tsafe/assert" ;
1112import { objectKeys } from "tsafe/objectKeys" ;
1213import { id } from "tsafe/id" ;
1314import { useBreakpointsValuesPx , type BreakpointsValues } from "../useBreakpointsValuesPx" ;
@@ -571,11 +572,18 @@ export function createDsfrCustomBrandingProvider(params: {
571572 [ `.${ fr . cx ( "fr-footer__bottom-copy" ) } ` ] : {
572573 display : "none"
573574 } ,
574- [ `. ${ fr . cx ( "fr-btn" ) } ` ] : {
575+ [ getPrimaryButtonClassSelector ( ) ] : {
575576 "--hover-tint" : theme . palette . primary . dark ,
576577 "--active-tint" : mui . darken ( theme . palette . primary . main , 0.24 ) ,
577- "&:hover, &:active" : {
578- color : theme . palette . primary . contrastText
578+ color : theme . palette . primary . contrastText
579+ } ,
580+ [ `.${ fr . cx ( "fr-header__tools-links" ) } ` ] : {
581+ [ `&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& .${ fr . cx ( "fr-btn" ) } ` ] : {
582+ color : theme . palette . primary . main ,
583+ "--hover-tint" :
584+ fr . colors . decisions . background . raised . grey . hover ,
585+ "--active-tint" :
586+ fr . colors . decisions . background . raised . grey . active
579587 }
580588 } ,
581589 [ `.${ fr . cx ( "fr-input" ) } , .${ fr . cx ( "fr-select" ) } ` ] : {
@@ -596,3 +604,57 @@ export function createDsfrCustomBrandingProvider(params: {
596604
597605 return { DsfrCustomBrandingProvider } ;
598606}
607+
608+ function getPrimaryButtonClassSelector ( ) {
609+ type BtnClassNames = Extract < FrCoreClassName , `fr-btn--${string } `> ;
610+
611+ type BtnVariant = BtnClassNames extends `fr-btn--${infer Variant } ` ? Variant : never ;
612+
613+ type BtnVariantWithoutPosition = Exclude <
614+ BtnVariant ,
615+ "align-on-content" | "icon-left" | "icon-right" | "sm" | "lg"
616+ > ;
617+
618+ const btnVariants = [
619+ "close" ,
620+ "tooltip" ,
621+ "fullscreen" ,
622+ "display" ,
623+ "account" ,
624+ "team" ,
625+ "briefcase" ,
626+ "sort" ,
627+ "secondary" ,
628+ "tertiary" ,
629+ "tertiary-no-outline" ,
630+ "facebook" ,
631+ "linkedin" ,
632+ "mastodon" ,
633+ "threads" ,
634+ "twitter" ,
635+ "twitter-x" ,
636+ "mail" ,
637+ "copy" ,
638+ "dailymotion" ,
639+ "github" ,
640+ "instagram" ,
641+ "snapchat" ,
642+ "telegram" ,
643+ "tiktok" ,
644+ "twitch" ,
645+ "vimeo" ,
646+ "youtube" ,
647+ "menu" ,
648+ "search"
649+ ] as const ;
650+
651+ assert < Equals < BtnVariantWithoutPosition , typeof btnVariants [ number ] > > ( ) ;
652+
653+ let selector = `.${ fr . cx ( "fr-btn" ) } ` ;
654+
655+ for ( const btnVariant of btnVariants ) {
656+ selector += `:not(.${ fr . cx ( `fr-btn--${ btnVariant } ` ) } )` ;
657+ }
658+
659+ return selector ;
660+ }
0 commit comments