DateRangeFilter component for Searchkit
npm install searchkit-daterangefilter --save
Similar to the classic RangeFilter, but with a date field
import { DateRangeFilter } from "searchkit-daterangefilter"
<DateRangeFilter
id="year"
field="publication_date"
title="Publication Date"
min={2005}
max={new Date().getFullYear()}
interval="year"
showHistogram={true} />
const Demo = React.createClass({
render() {
return (
<SearchkitProvider searchkit={searchkit}>
<Layout>
<TopBar>
<SearchBox
autofocus={true}
searchOnChange={true}
prefixQueryFields={["actors^1","type^2","languages","title^10"]}/>
</TopBar>
<LayoutBody>
<SideBar>
<HierarchicalMenuFilter
fields={["type.raw", "genres.raw"]}
title="Categories"
id="categories"/>
<DateRangeFilter
id="year"
field="publication_date"
title="Publication Date"
min={2005}
max={new Date().getFullYear()}
interval="year"
showHistogram={true} />
</SideBar>
<LayoutResults>
<Hits mod="sk-hits-grid" hitsPerPage={10} itemComponent={MovieHitsGridItem}
sourceFilter={["title", "poster", "imdbId"]}/>
<NoHits/>
</LayoutResults>
</LayoutBody>
</Layout>
</SearchkitProvider>
)
}
})
Licensed under the MIT license
Made with ♥ by @GregoryPotdevin at AppCraft