Skip to content

Commit

Permalink
feat: update the context
Browse files Browse the repository at this point in the history
  • Loading branch information
Megio committed Aug 14, 2023
1 parent 523bd3f commit abaf4e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function FilterDropdown({
useLayoutEffect(() => {
document.addEventListener('click', handleClickOutside, true);
return () => {
document.removeEventListener('clic', handleClickOutside, true);
document.removeEventListener('click', handleClickOutside, true);
};
});
return (
Expand All @@ -78,8 +78,8 @@ export default function FilterDropdown({
<CloseIcon />
</CloseBtn>
</CloseWrapper>
{allItems.map(({ name, color }, index) => (
<MenuItemContainer role="none" onClick={() => selectOption?.(name)}>
{allItems.map(({ name, color }) => (
<MenuItemContainer role="none" onClick={() => selectOption?.(name)} key={name}>
<MenuItem role="menuitem" tabIndex={-1}>
{name === selected ? <CorrectIcon /> : <NotSelected />}
<MenuItemContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ StarteDevRepo.args = {
pulls: 18,
subscribers_count: 8,
default_branch: 'main',
fork: false,
archived: false
},
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRepoFilter } from '../../context/RepoFilterContext';
import FilterDropdown from '../filter-dropdown/FilterDropdown';
import { RepoBookIcon } from '../icons';
import {
Expand All @@ -24,13 +25,14 @@ export default function RepoFilter({
const typeOptions = Object.values(FILTER_TYPE_OPTIONS);
const sortOptions = Object.values(SORT_OPTIONS);
const languageOptions = ['All', 'HTML', 'CSS', 'PHP'];
const {filterType, setFilterType} = useRepoFilter();

return (
<Container>
<RepoFilterWrapper>
<SearchInput />
<FiltersWrapper>
<FilterDropdown name="Type" items={typeOptions} />
<FilterDropdown name="Type" items={typeOptions} selectOption={setFilterType} selected={filterType}/>
<FilterDropdown name="Sort" items={sortOptions} />
<FilterDropdown
name="Language"
Expand Down

0 comments on commit abaf4e3

Please sign in to comment.