-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
920 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 22 additions & 87 deletions
109
app/(saas)/projects/_features/browse-projects-filters/browse-projects-filters.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,32 @@ | ||
import { Filter } from "lucide-react"; | ||
import { useMemo } from "react"; | ||
|
||
import { ProjectCategoryReactQueryAdapter } from "@/core/application/react-query-adapter/project-category"; | ||
|
||
import { Badge } from "@/design-system/atoms/badge"; | ||
import { Button } from "@/design-system/atoms/button/variants/button-default"; | ||
import { Popover } from "@/design-system/atoms/popover"; | ||
import { Typo } from "@/design-system/atoms/typo"; | ||
import { CheckboxButton } from "@/design-system/molecules/checkbox-button"; | ||
|
||
import { EcosystemFilter } from "@/shared/features/filters/ecosystem-filter/ecosystem-filter"; | ||
import { LanguageFilter } from "@/shared/features/filters/language-filter/language-filter"; | ||
import { CategoriesFilter } from "@/shared/filters/categories-filter/categories-filter"; | ||
import { EcosystemsFilter } from "@/shared/filters/ecosystems-filter/ecosystems-filter"; | ||
import { LanguagesFilter } from "@/shared/filters/languages-filter/languages-filter"; | ||
import { ProjectTagsFilter } from "@/shared/filters/project-tags-filter/project-tags-filter"; | ||
import { Input } from "@/shared/ui/input"; | ||
|
||
import { useBrowseProjectsContext } from "./browse-projects-filters.context"; | ||
|
||
export function BrowseProjectsFilters() { | ||
const { | ||
filters: { values: filters, set, count, clear, isCleared }, | ||
filters: { values: filters, set }, | ||
} = useBrowseProjectsContext(); | ||
|
||
const { data } = ProjectCategoryReactQueryAdapter.client.useGetProjectCategories({}); | ||
const categories = useMemo(() => data?.categories ?? [], [data?.categories]); | ||
|
||
return ( | ||
<Popover placement="bottom-end"> | ||
<Popover.Trigger> | ||
{() => ( | ||
<div> | ||
<Button | ||
variant={count ? "primary" : "secondary"} | ||
size="sm" | ||
startIcon={{ component: Filter, classNames: { base: "text-components-buttons-button-secondary-fg" } }} | ||
iconOnly={!count} | ||
endContent={ | ||
count ? ( | ||
<Badge size="xxs" shape="rounded" color={count ? "brand" : "grey"} variant={count ? "solid" : "flat"}> | ||
{count} | ||
</Badge> | ||
) : null | ||
} | ||
/> | ||
</div> | ||
)} | ||
</Popover.Trigger> | ||
|
||
<Popover.Content> | ||
{() => ( | ||
<div className="flex min-w-[250px] max-w-[360px] flex-col gap-lg"> | ||
<div className="flex items-center justify-between gap-md"> | ||
<Typo>Filters</Typo> | ||
|
||
{!isCleared ? ( | ||
<Button onClick={clear} size="sm" variant="secondary"> | ||
Clear | ||
</Button> | ||
) : null} | ||
</div> | ||
|
||
<LanguageFilter selectedLanguages={filters.languageIds} onSelect={languageIds => set({ languageIds })} /> | ||
|
||
<EcosystemFilter | ||
selectedEcosystems={filters.ecosystemIds} | ||
onSelect={ecosystemIds => set({ ecosystemIds })} | ||
/> | ||
|
||
{categories.length ? ( | ||
<div className="flex flex-col gap-lg"> | ||
<Typo size="xs" color="secondary"> | ||
Categories | ||
</Typo> | ||
|
||
<div className="flex flex-wrap gap-xs"> | ||
{categories.map(category => ( | ||
<CheckboxButton | ||
key={`project-category-${category.id}`} | ||
value={filters.categoryIds.includes(category.id)} | ||
onChange={checked => { | ||
set({ | ||
categoryIds: checked | ||
? [...filters.categoryIds, category.id] | ||
: filters.categoryIds.filter(id => id !== category.id), | ||
}); | ||
}} | ||
> | ||
{category.name} | ||
</CheckboxButton> | ||
))} | ||
</div> | ||
</div> | ||
) : null} | ||
</div> | ||
)} | ||
</Popover.Content> | ||
</Popover> | ||
<div className="flex flex-row items-center justify-between gap-4"> | ||
<div className="flex-[1]"> | ||
<Input | ||
placeholder="Search" | ||
className="w-full" | ||
value={filters.search} | ||
onChange={e => set({ search: e.target.value })} | ||
/> | ||
</div> | ||
<div className="flex flex-[3] flex-row items-center justify-end gap-2"> | ||
<LanguagesFilter languagesIds={filters.languageIds} onSelect={languageIds => set({ languageIds })} /> | ||
<EcosystemsFilter ecosystemsIds={filters.ecosystemIds} onSelect={ecosystemIds => set({ ecosystemIds })} /> | ||
<CategoriesFilter categoriesIds={filters.categoryIds} onSelect={categoryIds => set({ categoryIds })} /> | ||
<ProjectTagsFilter tags={filters.tags} onSelect={tags => set({ tags })} /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.