11import React from "react" ;
2- import { ConformanceState , SpecEdition } from "../types" ;
2+ import { ConformanceState , FilterOption , SpecEdition } from "../types" ;
33
44import styles from "./styles.module.css" ;
55import Link from "@docusaurus/Link" ;
@@ -11,9 +11,12 @@ type ResultsNavProps = {
1111 sliceNavToIndex : ( number ) => void ;
1212 setEcmaScriptFlag : ( string ) => void ;
1313 setSortOption : ( string ) => void ;
14+ setFilterOption : ( string ) => void ;
1415} ;
1516
16- export default function ResultNavigation ( props : ResultsNavProps ) : JSX . Element {
17+ export default function ResultNavigation (
18+ props : ResultsNavProps ,
19+ ) : JSX . Element {
1720 return (
1821 < div className = { styles . resultsNav } >
1922 < div className = { styles . navSection } >
@@ -25,6 +28,10 @@ export default function ResultNavigation(props: ResultsNavProps): JSX.Element {
2528 sortValue = { props . state . sortOption }
2629 setSortOption = { props . setSortOption }
2730 />
31+ < FilterDropdown
32+ filterOption = { props . state . filterOption }
33+ setFilterOption = { props . setFilterOption }
34+ />
2835 </ div >
2936 < div className = { styles . navSection } >
3037 < NavBreadCrumbs
@@ -168,3 +175,40 @@ function SortingDropdown(props: SortProps): JSX.Element {
168175 </ div >
169176 ) ;
170177}
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