-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix chosen tags #258
base: main
Are you sure you want to change the base?
Fix chosen tags #258
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,12 +42,23 @@ const ProjectsPage = () => { | |
setLoading(true); | ||
const existingTags = structuredClone(tags); | ||
|
||
// we set tag active to true | ||
for (const exisitingTag of existingTags) { | ||
// we set tags chosen to active and all the others to not | ||
if (existingTags.every(value => value.isActive)) { | ||
existingTags.forEach(existingTag => { | ||
existingTag.isActive = false; | ||
}); | ||
} | ||
|
||
existingTags.forEach(exisitingTag => { | ||
if (exisitingTag.name === tag.name) { | ||
exisitingTag.isActive = !exisitingTag.isActive; | ||
break; | ||
} | ||
}); | ||
|
||
if (existingTags.every(value => !value.isActive)) { | ||
existingTags.forEach(existingTag => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can save the And you will save one array function |
||
existingTag.isActive = true; | ||
}); | ||
} | ||
|
||
setTags(existingTags); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,17 +12,17 @@ const FilterBtnsGroup = ({ | |
filters, | ||
handleFilterOptionChange, | ||
}: FilterBtnsGroupProps) => { | ||
const handleBtnFilterClick = (filter: ProjectFilter) => { | ||
handleFilterOptionChange(filter); | ||
}; | ||
// const handleBtnFilterClick = (filter: ProjectFilter) => { | ||
// handleFilterOptionChange(filter); | ||
// }; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the comments please |
||
return ( | ||
<div className="flex gap-2 flex-wrap"> | ||
{filters.map(filter => ( | ||
<FilterBtn | ||
key={filter.name} | ||
filter={filter} | ||
onBtnClick={() => handleBtnFilterClick(filter)} | ||
onBtnClick={() => handleFilterOptionChange(filter)} | ||
/> | ||
))} | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import Radiobox from '@/components/utils/Radiobox'; | ||
import React, { Ref } from 'react'; | ||
import { useTranslations } from 'next-intl'; | ||
import FilterTagBtn from './FilterTagBtn'; | ||
import { ProjectFilter } from '@/types'; | ||
|
||
interface FiltersWindow { | ||
filterRef: Ref<HTMLDivElement>; | ||
sortOptions: string[]; | ||
selectedSortOption: any; | ||
handleCategoryOptionSelection: any; | ||
filters: ProjectFilter[]; | ||
handleFilterOptionChange: any; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change the name to Also don't use |
||
const FiltersWindow = ({ | ||
filterRef, | ||
sortOptions, | ||
selectedSortOption, | ||
handleCategoryOptionSelection, | ||
filters, | ||
handleFilterOptionChange, | ||
}: FiltersWindow) => { | ||
const t = useTranslations('Projects.FiltersBar'); | ||
|
||
return ( | ||
<div> | ||
<div | ||
ref={filterRef} | ||
className="z-[101] absolute -bottom-[23.5rem] md:-bottom-[16.75rem] right-2 px-[34px] py-[27px] rounded-md border border-blue-600 min-w-[300px] md:min-w-0 md:w-[863px] min-h-[260px] md:h-[209px] p-5 bg-gray-50 dark:bg-gray-600" | ||
> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need the |
||
<div className="flex flex-col gap-[22px]"> | ||
<h3 className="text-base font-bold leading-normal"> | ||
{t('projectsFilters')}{' '} | ||
</h3> | ||
{/* sort by ProjectPaginationFilter (sortoptions,sortoptionsmapper) */} | ||
<div className="flex gap-4 md:gap-[26px] justify-center md:justify-normal md:items-center"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this comment |
||
<span className="body-roman text-gray-500 dark:text-gray-400 w-[60px] max-w-[60px]"> | ||
{t('filters')} | ||
</span> | ||
<div className="flex gap-[18px] md:gap-10 flex-wrap w-full"> | ||
{sortOptions.map(sortOption => ( | ||
<Radiobox | ||
key={sortOption} | ||
id={sortOption} | ||
value={sortOption} | ||
checked={selectedSortOption === sortOption} | ||
onChange={handleCategoryOptionSelection} | ||
/> | ||
))} | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional - This could be extracted into a separate component, let's say |
||
</div> | ||
{/* sort by set languages */} | ||
<div className="flex gap-4 md:gap-[26px] justify-center md:justify-normal md:items-center"> | ||
<span className="body-roman text-gray-500 dark:text-gray-400 w-[60px] max-w-[60px] leading-tight"> | ||
{t('tags')} | ||
</span> | ||
<div className="flex gap-2 flex-wrap w-full"> | ||
{filters.map(filter => ( | ||
<FilterTagBtn | ||
key={filter.name} | ||
btnText={filter.name} | ||
toggleIsFilterActive={() => handleFilterOptionChange(filter)} | ||
isSelected={filter.isActive} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
<div className="absolute -top-[0.75rem] right-[10px] -mb-[1px] inline-block overflow-hidden"> | ||
<div className="h-3 w-[18px] origin-bottom-left rotate-45 transform border border-blue-600 bg-gray-50 dark:bg-gray-500 "></div> | ||
</div> | ||
</div> | ||
<div className="fixed z-[100] top-0 left-0 w-full h-screen opacity-[30%] bg-gray-900" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FiltersWindow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of putting comment explaining your code you could extract this part into a function and call it