You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
const React = require('react');
|
|
|
|
function ToggleOption({ children, filter, activeFilters, setFilters }) {
|
|
return (
|
|
<button
|
|
className={
|
|
'toggle__option ' + (activeFilters[filter] ? 'is-toggled' : '')
|
|
}
|
|
onClick={() =>
|
|
setFilters({
|
|
...activeFilters,
|
|
[filter]: !activeFilters[filter]
|
|
})
|
|
}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
module.exports = function FilterToggle({ activeFilters, setFilters }) {
|
|
return (
|
|
<div className="toggle">
|
|
<div className="toggle__label">Filter:</div>
|
|
<div className="toggle__options">
|
|
<ToggleOption
|
|
filter="low"
|
|
activeFilters={activeFilters}
|
|
setFilters={setFilters}
|
|
>
|
|
Low
|
|
</ToggleOption>
|
|
<ToggleOption
|
|
filter="medium"
|
|
activeFilters={activeFilters}
|
|
setFilters={setFilters}
|
|
>
|
|
Medium
|
|
</ToggleOption>
|
|
<ToggleOption
|
|
filter="high"
|
|
activeFilters={activeFilters}
|
|
setFilters={setFilters}
|
|
>
|
|
High
|
|
</ToggleOption>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|