11import React from "react" ;
22import type { ColorDecisionAndCorrespondingOption } from "../../scripts/build/cssToTs/colorDecisionAndCorrespondingOptions" ;
3- import { useColors } from "../../dist/useColors" ;
43import { fr } from "../../dist/fr" ;
54import Tooltip from "@mui/material/Tooltip" ;
65import { useStyles } from "./makeStyles" ;
76import { CopyToClipboardButton } from "./CopyToClipboardButton" ;
87import { Accordion } from "../../dist/Accordion" ;
8+ import { Evt } from "evt" ;
9+ import { useConst } from "powerhooks/useConst" ;
910
1011export function ColorDecisionCard (
1112 props : { className ?: string } & ColorDecisionAndCorrespondingOption
1213) {
1314 const { className, colorDecisionName, themePath, colorOption } = props ;
1415
15- const theme = useColors ( ) ;
16-
1716 const { cx, css } = useStyles ( ) ;
1817
18+ const evtCopyToClipboardButtonAction = useConst ( ( ) => Evt . create < "trigger click" > ( ) ) ;
19+
1920 return (
2021 < div
2122 className = { cx (
2223 css ( {
2324 "borderWidth" : 2 ,
2425 "borderStyle" : "solid" ,
25- "borderColor" : theme . decisions . border . default . grey . default ,
26+ "borderColor" : fr . colors . decisions . border . default . grey . default ,
2627 "&:hover" : {
27- "borderColor" : theme . decisions . border . plain . grey . default
28+ "borderColor" : fr . colors . decisions . border . plain . grey . default
2829 } ,
2930 "boxShadow" : "0px 6px 10px 0px rgba(0,0,0,0.07)" ,
3031 "padding" : fr . spacing ( "4v" )
@@ -35,20 +36,11 @@ export function ColorDecisionCard(
3536 < div >
3637 < span
3738 style = { {
38- "color" : theme . decisions . text . mention . grey . default
39- } }
40- >
41- CSS variable:{ " " }
42- </ span >
43- < code > { colorDecisionName } </ code >
44- </ div >
45- < div style = { { "marginTop" : fr . spacing ( "3v" ) } } >
46- < span
47- style = { {
48- "color" : theme . decisions . text . mention . grey . default
39+ "color" : fr . colors . decisions . text . mention . grey . default
4940 } }
5041 >
51- Decision path{ " " }
42+ Color Decision path
43+ { /*
5244 <Tooltip
5345 title={
5446 <a href="https://guides.react-dsfr.fr/css-in-js#colors" target="_blank">
@@ -60,15 +52,51 @@ export function ColorDecisionCard(
6052 >
6153 <i className={fr.cx("ri-information-line")} />
6254 </Tooltip>{" "}
55+ */ }
6356 :
64- </ span > { " " }
57+ </ span >
58+
6559 < code >
66- theme.decisions.< strong > { themePath . join ( "." ) } </ strong >
60+ < Tooltip
61+ title = {
62+ < code
63+ style = { {
64+ "fontSize" : "1.2em"
65+ } }
66+ >
67+ var({ colorDecisionName } )
68+ </ code >
69+ }
70+ placement = "top-end"
71+ >
72+ < span
73+ style = { { "display" : "inline-block" , "cursor" : "pointer" } }
74+ onClick = { ( ) => evtCopyToClipboardButtonAction . post ( "trigger click" ) }
75+ >
76+ fr.colors.decisions.< strong > { themePath . join ( "." ) } </ strong >
77+ </ span >
78+ </ Tooltip >
6779 </ code >
6880 < CopyToClipboardButton
6981 textToCopy = { [ "theme" , "decisions" , ...themePath ] . join ( "." ) }
82+ evtAction = { evtCopyToClipboardButtonAction }
7083 />
7184 </ div >
85+ < div
86+ style = { {
87+ "marginTop" : fr . spacing ( "3v" )
88+ } }
89+ >
90+ < span
91+ style = { {
92+ "color" : fr . colors . decisions . text . mention . grey . default
93+ } }
94+ >
95+ CSS variable name:
96+ </ span >
97+
98+ < code > { colorDecisionName } </ code >
99+ </ div >
72100
73101 < div style = { { "marginTop" : fr . spacing ( "2v" ) } } >
74102 { typeof colorOption . color === "string" ? (
@@ -79,7 +107,7 @@ export function ColorDecisionCard(
79107 < >
80108 < span
81109 style = { {
82- "color" : theme . decisions . text . mention . grey . default
110+ "color" : fr . colors . decisions . text . mention . grey . default
83111 } }
84112 >
85113 Dark mode:{ " " }
@@ -88,7 +116,7 @@ export function ColorDecisionCard(
88116
89117 < span
90118 style = { {
91- "color" : theme . decisions . text . mention . grey . default
119+ "color" : fr . colors . decisions . text . mention . grey . default
92120 } }
93121 >
94122 Light mode:{ " " }
@@ -104,7 +132,7 @@ export function ColorDecisionCard(
104132 < p >
105133 < span
106134 style = { {
107- "color" : theme . decisions . text . mention . grey . default
135+ "color" : fr . colors . decisions . text . mention . grey . default
108136 } }
109137 >
110138 CSS variable:{ " " }
@@ -118,7 +146,7 @@ export function ColorDecisionCard(
118146 >
119147 < span
120148 style = { {
121- "color" : theme . decisions . text . mention . grey . default
149+ "color" : fr . colors . decisions . text . mention . grey . default
122150 } }
123151 >
124152 Option path:{ " " }
@@ -135,8 +163,6 @@ export function ColorDecisionCard(
135163function ColoredSquare ( props : { hexColorCode : string } ) {
136164 const { hexColorCode } = props ;
137165
138- const theme = useColors ( ) ;
139-
140166 return (
141167 < div
142168 style = { {
@@ -150,7 +176,7 @@ function ColoredSquare(props: { hexColorCode: string }) {
150176 "display" : "inline-block" ,
151177 "borderWidth" : 2 ,
152178 "borderStyle" : "solid" ,
153- "borderColor" : theme . decisions . border . default . grey . default ,
179+ "borderColor" : fr . colors . decisions . border . default . grey . default ,
154180 "width" : 30 ,
155181 "height" : 30 ,
156182 "backgroundColor" : hexColorCode ,
0 commit comments