From 49af5f86768ab291d1f63a7890ec7f72701661f9 Mon Sep 17 00:00:00 2001 From: Karlen9 Date: Wed, 7 Aug 2024 13:33:27 +0400 Subject: [PATCH] feat: filterBar + sorting --- apps/common/components/AppCard.tsx | 2 +- apps/common/components/CategorySection.tsx | 2 +- apps/common/components/FilterBar.tsx | 30 +++++++++++++++++++ apps/common/components/SortingBar.tsx | 35 ++++++++++++++++++++++ apps/common/utils/constants.ts | 9 +++++- pages/home/[category].tsx | 13 ++++++++ 6 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 apps/common/components/FilterBar.tsx create mode 100644 apps/common/components/SortingBar.tsx diff --git a/apps/common/components/AppCard.tsx b/apps/common/components/AppCard.tsx index 2d4ac8421..87c30e46c 100644 --- a/apps/common/components/AppCard.tsx +++ b/apps/common/components/AppCard.tsx @@ -2,8 +2,8 @@ import Image from 'next/image'; import Link from 'next/link'; import {IconShare} from '@common/icons/IconShare'; -import type {TApp} from 'pages/home/[category]'; import type {ReactElement} from 'react'; +import type {TApp} from '@common/types/category'; type TAppCardProps = { app: TApp; diff --git a/apps/common/components/CategorySection.tsx b/apps/common/components/CategorySection.tsx index ddf857b3a..035bf5f48 100644 --- a/apps/common/components/CategorySection.tsx +++ b/apps/common/components/CategorySection.tsx @@ -2,8 +2,8 @@ import {IconChevron} from '@common/icons/IconChevron'; import {AppCard} from './AppCard'; -import type {TApp} from 'pages/home/[category]'; import type {ReactElement} from 'react'; +import type {TApp} from '@common/types/category'; type TAppSectionProps = { title: string; diff --git a/apps/common/components/FilterBar.tsx b/apps/common/components/FilterBar.tsx new file mode 100644 index 000000000..64c1035e9 --- /dev/null +++ b/apps/common/components/FilterBar.tsx @@ -0,0 +1,30 @@ +import {cl} from '@builtbymom/web3/utils'; +import {CATEGORY_PAGE_FILTERS} from '@common/utils/constants'; + +import type {ReactElement} from 'react'; + +function FilterItem({isActive, title}: {isActive: boolean; title: string}): ReactElement { + return ( +
+ {title} +
+ ); +} + +export function FilterBar({selectedFilter}: {selectedFilter: {title: string; value: string}}): ReactElement { + return ( +
+ {CATEGORY_PAGE_FILTERS.map(filter => ( + + ))} +
+ ); +} diff --git a/apps/common/components/SortingBar.tsx b/apps/common/components/SortingBar.tsx new file mode 100644 index 000000000..0d8d1668a --- /dev/null +++ b/apps/common/components/SortingBar.tsx @@ -0,0 +1,35 @@ +import {type ReactElement, useState} from 'react'; +import {IconChevron} from '@common/icons/IconChevron'; + +function SortItem({isActive, title}: {isActive: boolean; title: string}): ReactElement { + return
{title}
; +} + +export function SortingBar(): ReactElement { + const [isOpen, set_isOpen] = useState(false); + return ( + <> + + {isOpen && ( +
+ {Array(4) + .fill('List Item') + .map((item, i) => ( + + ))} +
+ )} + + ); +} diff --git a/apps/common/utils/constants.ts b/apps/common/utils/constants.ts index c88a6a9ac..983f95ec3 100644 --- a/apps/common/utils/constants.ts +++ b/apps/common/utils/constants.ts @@ -1,7 +1,7 @@ import {arbitrum, base, fantom, mainnet, optimism, polygon} from 'viem/chains'; import {toAddress} from '@builtbymom/web3/utils'; -import type {TApp} from 'pages/home/[category]'; +import type {TApp} from '@common/types/category'; export const DEFAULT_SLIPPAGE = 0.5; export const DEFAULT_MAX_LOSS = 1n; @@ -133,3 +133,10 @@ export const MENU_TABS = [ {title: 'Community Apps', route: 'community'}, {title: 'Yearn X Projects', route: 'yearn-x'} ]; + +export const CATEGORY_PAGE_FILTERS = [ + {title: 'All', value: 'all'}, + {title: 'Filter', value: 'filter'}, + {title: 'Tab', value: 'tab'}, + {title: 'Large Filter', value: 'large-filter'} +]; diff --git a/pages/home/[category].tsx b/pages/home/[category].tsx index 6adb44494..85e11cb5d 100644 --- a/pages/home/[category].tsx +++ b/pages/home/[category].tsx @@ -1,5 +1,7 @@ import {usePathname} from 'next/navigation'; import {AppCard} from '@common/components/AppCard'; +import {FilterBar} from '@common/components/FilterBar'; +import {SortingBar} from '@common/components/SortingBar'; import {CATEGORIES_DICT} from '@common/utils/constants'; import type {ReactElement} from 'react'; @@ -22,6 +24,17 @@ export default function Index(): ReactElement {

+ +
{currentCatrgory?.apps.map(app => )}