diff --git a/src/app/[name]/page.tsx b/src/app/[name]/page.tsx index 5411724..1283401 100644 --- a/src/app/[name]/page.tsx +++ b/src/app/[name]/page.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useCallback, useMemo, useState } from "react"; +import { MouseEventHandler, useCallback, useMemo, useState } from "react"; import SearchBox from "@/components/input/SearchBox"; import CategoryItemRenderer from "@/components/listview/CategoryItemRenderer"; import HorizontalScrollView from "@/components/listview/HorizontalScrollView"; @@ -11,9 +11,9 @@ import VerticalScrollView from "@/components/listview/VerticalScrollView"; import MenuItemRenderer from "@/components/listview/MenuItemRenderer"; import React from "react"; import MenuItem from "@/components/listview/MenuItem"; -import CloseIcon from "@/components/icons/CloseIcon"; import Button from "@/components/button/PrimaryButton"; import AnimatedBottomSheet from "@/components/bottomsheet/AnimatedBottomSheet"; +import MultiOption, { DropdownOption } from "@/components/dropdown/MultiOption"; const categories = new Array(13).fill({ title: "خوراک", icon: "" }); @@ -118,10 +118,26 @@ const foods = [ } ]; +const sortings = [ + 'محبوب ترین', + 'بالاترین امتیاز', + 'جدید ترین', + 'ارزان ترین', + 'گران ترین', +] + +const contents: Array = [ + { id: '0', title: 'گیاهی' }, + { id: '1', title: 'حیوانی' } +] + const MenuIndex = () => { const [search, setSearch] = useState(""); const [selectedCategory, setSelectedCategory] = useState(0); const [filterModal, setFilterModal] = useState(false); + const [sortingModal, setSortingModal] = useState(false); + const [sorting, setSorting] = useState(0); + const [selectedContentId, setSelectedContentId] = useState('0'); const updateSearch = useCallback((e: React.ChangeEvent) => { setSearch(e.target.value); @@ -135,6 +151,17 @@ const MenuIndex = () => { setFilterModal((state) => !state); }, []); + const toggleSortingModal = useCallback(() => { + setSortingModal((state) => !state); + }, []); + + const changeSorting = (index: number) => { + setSorting(() => index); + } + + const changeSelectedContent = (e: React.MouseEvent, index: number) => { + setSelectedContentId(() => contents[index]?.id || contents[0].id); + } const filteredReceiptItems = useMemo(() => { const lowerSearch = search.toLowerCase(); @@ -178,7 +205,7 @@ const MenuIndex = () => { فیلتر بر اساس - @@ -193,15 +220,16 @@ const MenuIndex = () => { - -
-
فیلتر ها
-
- -
+ +
+
-
-
+
+
@@ -210,6 +238,21 @@ const MenuIndex = () => {
+ + +
+ {sortings.map((v, i) => { + return ( +
+
changeSorting(i)} className="text-sm2 font-medium cursor-pointer"> + {v} +
+ {i < sortings.length - 1 &&
} +
+ ) + })} +
+
); }; diff --git a/src/components/bottomsheet/AnimatedBottomSheet.tsx b/src/components/bottomsheet/AnimatedBottomSheet.tsx index 0edda7e..f814e0f 100644 --- a/src/components/bottomsheet/AnimatedBottomSheet.tsx +++ b/src/components/bottomsheet/AnimatedBottomSheet.tsx @@ -15,7 +15,10 @@ const AnimatedBottomSheet = (props: Props) => { className={clsx( 'absolute -bottom-full left-0 w-full bg-white/64 rounded-t-4xl pt-[39px] pb-6', 'data-[visible=true]:bottom-0 transition-all duration-150' - )}> + )} + style={{ + backdropFilter: 'blur(44px)' + }}>
{props.title}
diff --git a/src/components/dropdown/MultiOption.tsx b/src/components/dropdown/MultiOption.tsx new file mode 100644 index 0000000..55a5c80 --- /dev/null +++ b/src/components/dropdown/MultiOption.tsx @@ -0,0 +1,79 @@ +import React, { useState } from 'react' +import ArrowDownIcon from '../icons/ArrowDownIcon'; + +export interface DropdownOption { + id: string; + title: string; +} + +type Props = { + title: string; + options: Array; + expanded?: boolean; + selectedId: string; + onSelectionChange: (e: React.MouseEvent, index: number) => void, +} & React.HTMLAttributes + +function MultiOption({ title, options, expanded, selectedId, onSelectionChange, ...props }: Props) { + const [expand, setExpand] = useState(expanded); + const toggleExpand = () => { + setExpand((state) => !state); + } + + return ( +
+
+ + + +
+ {options.filter(x => x.id === selectedId)[0]?.title ?? ''} +
+ + +
+ + {expand && +
+ {options.map((v, i) => { + return ( +
{setExpand(() => false); onSelectionChange(e, i) }} + key={v.id} + data-selected={v.id === selectedId} + className='flex items-center justify-end px-3 py-3 cursor-pointer hover:bg-gray-50 first:rounded-t-xl last:rounded-b-xl' + tabIndex={0} + role='option' + aria-selected> + + {v.title} + +
+ ) + })} +
+ } +
+ ) +} + +export default MultiOption \ No newline at end of file diff --git a/src/components/icons/ArrowDownIcon.tsx b/src/components/icons/ArrowDownIcon.tsx new file mode 100644 index 0000000..c7f8ea1 --- /dev/null +++ b/src/components/icons/ArrowDownIcon.tsx @@ -0,0 +1,34 @@ +import React from 'react'; + +interface ArrowDownIconProps extends React.SVGProps { + width?: number; + height?: number; + strokeColor?: string; +} + +const ArrowDownIcon: React.FC = ({ + width = 16, + height = 16, + strokeColor = '#999999', + ...props +}) => ( + + + +); + +export default ArrowDownIcon; diff --git a/src/components/listview/CategoryItemRenderer.tsx b/src/components/listview/CategoryItemRenderer.tsx index c4e1fe7..ea0f180 100644 --- a/src/components/listview/CategoryItemRenderer.tsx +++ b/src/components/listview/CategoryItemRenderer.tsx @@ -6,7 +6,7 @@ type Props = { function CategoryItemRenderer({ children, ...rest }: Props) { return ( -
+