Added sorting functionality
This commit is contained in:
@@ -13,7 +13,7 @@ const Filters = ({nameChecked, handleNameCheckbox, descriptionChecked, handleDes
|
||||
<fieldset className='filter'>
|
||||
<legend >Filter by</legend>
|
||||
<label><input type="checkbox" checked={nameChecked} onChange={handleNameCheckbox} />Name</label>
|
||||
<label><input type="checkbox" checked={descriptionChecked} onChange={handleDescriptionCheckbox} />Title</label>
|
||||
<label><input type="checkbox" checked={descriptionChecked} onChange={handleDescriptionCheckbox} />Website title</label>
|
||||
<label><input type="checkbox" checked={tagsChecked} onChange={handleTagsCheckbox} />Tags</label>
|
||||
</fieldset>
|
||||
</>
|
||||
|
||||
+12
-8
@@ -1,23 +1,27 @@
|
||||
import '../styles/Sort.css'
|
||||
|
||||
const Sort = ({ onExit }) => {
|
||||
const Sort = ({ sortBy, onExit }) => {
|
||||
function abort(e) {
|
||||
if (e.target.className === "sort-overlay") {
|
||||
onExit();
|
||||
}
|
||||
}
|
||||
|
||||
function sort(e) {
|
||||
sortBy(e.target.value);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='sort-overlay' onClick={abort}></div>
|
||||
<fieldset className='sort'>
|
||||
<fieldset className='sort' onClick={sort}>
|
||||
<legend>Sort by</legend>
|
||||
<label><input name="sort" type="radio" />Date (Newest first)</label>
|
||||
<label><input name="sort" type="radio" />Date (Oldest first)</label>
|
||||
<label><input name="sort" type="radio" />Name (A-Z)</label>
|
||||
<label><input name="sort" type="radio" />Name (Z-A)</label>
|
||||
<label><input name="sort" type="radio" />Title (A-Z)</label>
|
||||
<label><input name="sort" type="radio" />Title (Z-A)</label>
|
||||
<button className='sort-by-btn' value='Default'> Date (Newest first)</button>
|
||||
<button className='sort-by-btn' value='Date (Oldest first)'> Date (Oldest first)</button>
|
||||
<button className='sort-by-btn' value='Name (A-Z)'> Name (A-Z)</button>
|
||||
<button className='sort-by-btn' value='Name (Z-A)'> Name (Z-A)</button>
|
||||
<button className='sort-by-btn' value='Title (A-Z)'> Website title (A-Z)</button>
|
||||
<button className='sort-by-btn' value='Title (Z-A)'> Website title (Z-A)</button>
|
||||
</fieldset>
|
||||
</>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user