1
1
import React from "react" ;
2
- import { ConformanceState , SpecEdition } from "../types" ;
2
+ import { ConformanceState , FilterOption , SpecEdition } from "../types" ;
3
3
4
4
import styles from "./styles.module.css" ;
5
5
import Link from "@docusaurus/Link" ;
@@ -11,9 +11,12 @@ type ResultsNavProps = {
11
11
sliceNavToIndex : ( number ) => void ;
12
12
setEcmaScriptFlag : ( string ) => void ;
13
13
setSortOption : ( string ) => void ;
14
+ setFilterOption : ( string ) => void ;
14
15
} ;
15
16
16
- export default function ResultNavigation ( props : ResultsNavProps ) : JSX . Element {
17
+ export default function ResultNavigation (
18
+ props : ResultsNavProps ,
19
+ ) : JSX . Element {
17
20
return (
18
21
< div className = { styles . resultsNav } >
19
22
< div className = { styles . navSection } >
@@ -25,6 +28,10 @@ export default function ResultNavigation(props: ResultsNavProps): JSX.Element {
25
28
sortValue = { props . state . sortOption }
26
29
setSortOption = { props . setSortOption }
27
30
/>
31
+ < FilterDropdown
32
+ filterOption = { props . state . filterOption }
33
+ setFilterOption = { props . setFilterOption }
34
+ />
28
35
</ div >
29
36
< div className = { styles . navSection } >
30
37
< NavBreadCrumbs
@@ -168,3 +175,40 @@ function SortingDropdown(props: SortProps): JSX.Element {
168
175
</ div >
169
176
) ;
170
177
}
178
+
179
+ type FilterProps = {
180
+ filterOption : FilterOption ;
181
+ setFilterOption : ( string ) => void ;
182
+ } ;
183
+
184
+ function FilterDropdown ( props : FilterProps ) : JSX . Element {
185
+ const [ filterValue , setFilterValue ] = React . useState < string > (
186
+ props . filterOption ?? FilterOption . None ,
187
+ ) ;
188
+
189
+ React . useEffect ( ( ) => {
190
+ setFilterValue ( props . filterOption ) ;
191
+ } , [ props . filterOption ] ) ;
192
+
193
+ const handlefilterSelection = ( e ) => {
194
+ setFilterValue ( e . target . value ) ;
195
+ props . setFilterOption ( e . target . value ) ;
196
+ } ;
197
+
198
+ return (
199
+ < div className = { styles . dropdownContainer } >
200
+ < Heading as = "h4" style = { { padding : "0.125rem 0.5rem" , height : "5" } } >
201
+ Filter:
202
+ </ Heading >
203
+ < select value = { filterValue } onChange = { handlefilterSelection } >
204
+ { Object . values ( FilterOption ) . map ( ( key ) => {
205
+ return (
206
+ < option key = { key } value = { key } >
207
+ { key }
208
+ </ option >
209
+ ) ;
210
+ } ) }
211
+ </ select >
212
+ </ div >
213
+ ) ;
214
+ }
0 commit comments