@@ -5,16 +5,57 @@ import { Button } from "../../dist/Button";
55import { fr } from "../../dist/fr" ;
66import { NonPostableEvt } from "evt" ;
77import { useEvt } from "evt/hooks" ;
8+ import { Select } from "../../dist/Select" ;
9+ import { colorDecisionAndCorrespondingOption } from "../../dist/fr/generatedFromCss/colorDecisionAndCorrespondingOptions" ;
810
9- type Props = {
11+ const colors = Array . from (
12+ new Set (
13+ colorDecisionAndCorrespondingOption . map (
14+ ( { parsedColorDecisionName } ) => parsedColorDecisionName . colorName
15+ )
16+ )
17+ ) ;
18+ const contextes = Array . from (
19+ new Set (
20+ colorDecisionAndCorrespondingOption . map (
21+ ( { parsedColorDecisionName } ) => parsedColorDecisionName . context
22+ )
23+ )
24+ ) ;
25+ const usages = Array . from (
26+ new Set (
27+ colorDecisionAndCorrespondingOption . map (
28+ ( { parsedColorDecisionName } ) => parsedColorDecisionName . usage
29+ )
30+ )
31+ ) ;
32+
33+ export type Props = {
1034 className ?: string ;
1135 search : string ;
1236 onSearchChange : ( search : string ) => void ;
1337 evtAction : NonPostableEvt < "scroll to" > ;
38+ context : typeof contextes [ number ] | undefined ;
39+ onContextChange : ( context : typeof contextes [ number ] | undefined ) => void ;
40+ color : typeof colors [ number ] | undefined ;
41+ onColorChange : ( color : typeof colors [ number ] | undefined ) => void ;
42+ usage : typeof usages [ number ] | undefined ;
43+ onUsageChange : ( usage : typeof usages [ number ] | undefined ) => void ;
1444} ;
1545
1646export function Search ( props : Props ) {
17- const { className, search, onSearchChange, evtAction } = props ;
47+ const {
48+ className,
49+ search,
50+ onSearchChange,
51+ evtAction,
52+ context,
53+ onContextChange,
54+ color,
55+ onColorChange,
56+ usage,
57+ onUsageChange
58+ } = props ;
1859
1960 const [ inputElement , setInputElement ] = useState < HTMLInputElement | null > ( null ) ;
2061 const [ searchBarWrapperElement , setSearchBarWrapperElement ] = useState < HTMLDivElement | null > (
@@ -62,7 +103,6 @@ export function Search(props: Props) {
62103 "onChange" : event => onSearchChange ( event . target . value )
63104 } }
64105 />
65-
66106 < Button
67107 className = { classes . filterButton }
68108 iconId = { areFiltersOpen ? "ri-arrow-down-s-fill" : "ri-arrow-up-s-fill" }
@@ -78,13 +118,48 @@ export function Search(props: Props) {
78118 }
79119 className = { classes . filtersWrapper }
80120 >
81- { /*
82- <p>Ok</p>
83- <p>Ok</p>
84- <p>Ok</p>
85- <p>Ok</p>
86- <p>Ok</p>
87- */ }
121+ < Select
122+ label = "Filter by context"
123+ nativeSelectProps = { {
124+ "onChange" : event =>
125+ onContextChange ( event . target . value || ( undefined as any ) ) ,
126+ "defaultValue" : context ?? ""
127+ } }
128+ >
129+ { [ undefined , ...contextes ] . map ( context => (
130+ < option value = { context ?? "" } key = { context ?? 0 } >
131+ { context ?? "No no context selected..." }
132+ </ option >
133+ ) ) }
134+ </ Select >
135+ < Select
136+ label = "Filter by color name"
137+ nativeSelectProps = { {
138+ "onChange" : event =>
139+ onColorChange ( event . target . value || ( undefined as any ) ) ,
140+ "defaultValue" : color ?? ""
141+ } }
142+ >
143+ { [ undefined , ...colors ] . map ( color => (
144+ < option value = { color ?? "" } key = { color ?? 0 } >
145+ { color ?? "No no color selected..." }
146+ </ option >
147+ ) ) }
148+ </ Select >
149+ < Select
150+ label = "Filter by usage"
151+ nativeSelectProps = { {
152+ "onChange" : event =>
153+ onUsageChange ( event . target . value || ( undefined as any ) ) ,
154+ "defaultValue" : usage ?? ""
155+ } }
156+ >
157+ { [ undefined , ...usages ] . map ( usage => (
158+ < option value = { usage ?? "" } key = { usage ?? 0 } >
159+ { usage ?? "No usage selected..." }
160+ </ option >
161+ ) ) }
162+ </ Select >
88163 </ div >
89164 </ >
90165 ) ;
@@ -105,13 +180,20 @@ const useStyles = makeStyles<{ filterWrapperMaxHeight: number }>({ "name": { Sea
105180 "backgroundColor" : theme . decisions . background . actionLow . blueFrance . hover
106181 } ,
107182 "color" : theme . decisions . text . actionHigh . blueFrance . default ,
108- "marginLeft" : fr . spacing ( "4v" ) ,
109- "display" : "none"
183+ "marginLeft" : fr . spacing ( "4v" )
110184 } ,
111185 "filtersWrapper" : {
112186 "transition" : "max-height 0.2s ease-out" ,
113187 "maxHeight" : filterWrapperMaxHeight ,
114- "overflow" : "hidden"
188+ "overflow" : "hidden" ,
189+ "display" : "flex" ,
190+ "marginTop" : fr . spacing ( "3v" ) ,
191+ "& > *" : {
192+ "flex" : 1 ,
193+ ...fr . spacing ( "padding" , {
194+ "rightLeft" : "4v"
195+ } )
196+ }
115197 }
116198 } )
117199) ;
0 commit comments