4
4
import React , { useMemo , useEffect , type ReactNode } from "react" ;
5
5
import * as mui from "@mui/material/styles" ;
6
6
import { fr } from "../fr" ;
7
+ import type { FrCoreClassName } from "../fr/generatedFromCss/classNames" ;
7
8
import { useIsDark } from "../useIsDark" ;
8
9
import { typography } from "../fr/generatedFromCss/typography" ;
9
10
import { spacingTokenByValue } from "../fr/generatedFromCss/spacing" ;
10
- import { assert } from "tsafe/assert" ;
11
+ import { assert , type Equals } from "tsafe/assert" ;
11
12
import { objectKeys } from "tsafe/objectKeys" ;
12
13
import { id } from "tsafe/id" ;
13
14
import { useBreakpointsValuesPx , type BreakpointsValues } from "../useBreakpointsValuesPx" ;
@@ -571,11 +572,18 @@ export function createDsfrCustomBrandingProvider(params: {
571
572
[ `.${ fr . cx ( "fr-footer__bottom-copy" ) } ` ] : {
572
573
display : "none"
573
574
} ,
574
- [ `. ${ fr . cx ( "fr-btn" ) } ` ] : {
575
+ [ getPrimaryButtonClassSelector ( ) ] : {
575
576
"--hover-tint" : theme . palette . primary . dark ,
576
577
"--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
579
587
}
580
588
} ,
581
589
[ `.${ fr . cx ( "fr-input" ) } , .${ fr . cx ( "fr-select" ) } ` ] : {
@@ -596,3 +604,57 @@ export function createDsfrCustomBrandingProvider(params: {
596
604
597
605
return { DsfrCustomBrandingProvider } ;
598
606
}
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