@@ -3,9 +3,10 @@ import { Input } from "../dist/Input";
33import { resolveColorHexCodeToDecision } from "../dist/fr/colorResolver" ;
44import type { ColorDecision } from "../dist/fr/colorResolver" ;
55import { useColors } from "../dist/useColors" ;
6+ import { fr } from "../dist" ;
67
78export function ColorResolver ( ) {
8- const [ hexColorCode , setHexColorCode ] = useState ( "#161616 " ) ;
9+ const [ hexColorCode , setHexColorCode ] = useState ( "#C9191E " ) ;
910
1011 const onChange = ( event : React . ChangeEvent < HTMLInputElement > ) =>
1112 setHexColorCode ( event . target . value ) ;
@@ -21,7 +22,7 @@ export function ColorResolver() {
2122 < div >
2223 < Input
2324 label = "Hex color code"
24- hintText = "Color code, starting by # "
25+ hintText = "A color that you know belongs to the DSFR pallet "
2526 nativeInputProps = { {
2627 "value" : hexColorCode ,
2728 onChange
@@ -40,35 +41,94 @@ export function ColorResolver() {
4041function ColorDecisionShowcase ( props : ColorDecision ) {
4142 const { cssVarName, decisionObjectPath, option } = props ;
4243
44+ const theme = useColors ( ) ;
45+
4346 return (
44- < div >
47+ < div
48+ style = { {
49+ "borderWidth" : 2 ,
50+ "borderStyle" : "solid" ,
51+ "borderColor" : theme . decisions . border . default . grey . default ,
52+ "boxShadow" : "0px 6px 10px 0px rgba(0,0,0,0.07)" ,
53+ "padding" : fr . spacing ( "4v" ) ,
54+ "marginTop" : fr . spacing ( "4v" )
55+ } }
56+ >
57+ < h5 > Color decision:</ h5 >
4558 < p >
46- < span > CSS variable: </ span > : { cssVarName }
59+ < span
60+ style = { {
61+ "color" : theme . decisions . text . mention . grey . default
62+ } }
63+ >
64+ CSS variable:{ " " }
65+ </ span >
66+ { cssVarName }
4767 </ p >
4868 < p >
49- < span > Decision path: </ span > { " " }
50- < code > theme.decisions.{ decisionObjectPath . join ( "." ) } </ code >
69+ < span
70+ style = { {
71+ "color" : theme . decisions . text . mention . grey . default
72+ } }
73+ >
74+ Decision path:{ " " }
75+ </ span > { " " }
76+ < code >
77+ theme.decisions.< strong > { decisionObjectPath . join ( "." ) } </ strong >
78+ </ code >
5179 </ p >
52- < p > Corresponding color option:</ p >
80+ < h5 > Corresponding color option:</ h5 >
5381 < p >
54- < span > CSS variable: </ span > : { option . cssVarName }
82+ < span
83+ style = { {
84+ "color" : theme . decisions . text . mention . grey . default
85+ } }
86+ >
87+ CSS variable:{ " " }
88+ </ span >
89+ : { option . cssVarName }
5590 </ p >
56- < p >
57- < span > Option path: </ span > { " " }
58- < code > theme.options.{ option . optionObjectPath . join ( "." ) } </ code >
91+ < p
92+ style = { {
93+ "marginBottom" : 12
94+ } }
95+ >
96+ < span
97+ style = { {
98+ "color" : theme . decisions . text . mention . grey . default
99+ } }
100+ >
101+ Option path:{ " " }
102+ </ span > { " " }
103+ < code >
104+ theme.options.< strong > { option . optionObjectPath . join ( "." ) } </ strong >
105+ </ code >
59106 </ p >
60107
61108 { typeof option . color === "string" ? (
62109 < p >
63110 < span > Colors: </ span > : < ColoredSquare hexColorCode = { option . color } />
64111 </ p >
65112 ) : (
66- < p >
67- < span > Colors: </ span > :< span > Light: </ span >
113+ < >
114+ < span
115+ style = { {
116+ "color" : theme . decisions . text . mention . grey . default
117+ } }
118+ >
119+ Dark mode:{ " " }
120+ </ span >
68121 < ColoredSquare hexColorCode = { option . color . light } />
69- < span > Dark: </ span >
122+
123+ < span
124+ style = { {
125+ "color" : theme . decisions . text . mention . grey . default
126+ } }
127+ >
128+ Light mode:{ " " }
129+ </ span >
70130 < ColoredSquare hexColorCode = { option . color . dark } />
71- </ p >
131+ </ >
72132 ) }
73133 </ div >
74134 ) ;
@@ -80,18 +140,26 @@ function ColoredSquare(props: { hexColorCode: string }) {
80140 const theme = useColors ( ) ;
81141
82142 return (
83- < >
84- < span > { hexColorCode } </ span > :
143+ < div
144+ style = { {
145+ display : "inline"
146+ } }
147+ >
148+ < code > { hexColorCode } </ code >
149+
85150 < div
86151 style = { {
87- "borderWidth" : "2" ,
152+ "display" : "inline-block" ,
153+ "borderWidth" : 2 ,
88154 "borderStyle" : "solid" ,
89155 "borderColor" : theme . decisions . border . default . grey . default ,
90156 "width" : 30 ,
91157 "height" : 30 ,
92- "backgroundColor" : hexColorCode
158+ "backgroundColor" : hexColorCode ,
159+ "position" : "relative" ,
160+ "top" : 8
93161 } }
94162 />
95- </ >
163+ </ div >
96164 ) ;
97165}
0 commit comments