diff --git a/public/assets/images/food-image.png b/public/assets/images/food-image.png new file mode 100644 index 0000000..35dc7f1 Binary files /dev/null and b/public/assets/images/food-image.png differ diff --git a/src/app/globals.css b/src/app/globals.css index 3e86ccd..76ff273 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -71,4 +71,37 @@ input[type="password"] { /* add spacing to better separate each image */ letter-spacing: 2px; +} + +/* Hide scrollbar for Chrome, Safari and Opera */ +.noscrollbar::-webkit-scrollbar { + display: none; +} + +/* Hide scrollbar for IE, Edge and Firefox */ +.noscrollbar { + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ +} + +/* width */ +::-webkit-scrollbar { + width: 10px; + height: 6px; +} + +/* Track */ +::-webkit-scrollbar-track { + background: transparent; +} + +/* Handle */ +::-webkit-scrollbar-thumb { + border-radius: 12px; + background: #888; +} + +/* Handle on hover */ +::-webkit-scrollbar-thumb:hover { + background: #555; } \ No newline at end of file diff --git a/src/app/menu/page.tsx b/src/app/menu/page.tsx index 72cb79a..9960e81 100644 --- a/src/app/menu/page.tsx +++ b/src/app/menu/page.tsx @@ -1,20 +1,87 @@ 'use client'; +import { useCallback, useState } from "react"; import SearchBox from "@/components/input/SearchBox"; -import { useState } from "react"; +import CategoryItemRenderer from "@/components/listview/CategoryItemRenderer"; +import HorizontalScrollView from "@/components/listview/HorizontalScrollView"; +import Image from "next/image"; + +const categories = [ + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + }, + { + title: 'خوراک', icon: '', + } +] export default function MenuIndex() { const [search, setSearch] = useState(''); + const [selectedCategory, setSelectedCategory] = useState(0); + + const updateSearch = useCallback((e: React.ChangeEvent) => { + setSearch(e.target.value); + }, []); + + const updateCategory = useCallback((id: number) => { + setSelectedCategory(id); + }, []); - const updateSearch = (e: React.ChangeEvent) => { - if (e) { - setSearch(() => e.target.value); - } - } return (
+ { + return updateCategory(index)} key={index}>{child} + }}> + {categories.map((item, index) => { + return ( +
+ category image + {item.title} +
+ ) + })} +
); } diff --git a/src/components/listview/CategoryItemRenderer.tsx b/src/components/listview/CategoryItemRenderer.tsx new file mode 100644 index 0000000..c4e1fe7 --- /dev/null +++ b/src/components/listview/CategoryItemRenderer.tsx @@ -0,0 +1,20 @@ +import React from 'react'; + +type Props = { + children: React.ReactNode; +} & React.HTMLAttributes; + +function CategoryItemRenderer({ children, ...rest }: Props) { + return ( +
+
+ {children} +
+
+ ); +} + +export default CategoryItemRenderer; diff --git a/src/components/listview/HorizontalScrollView.tsx b/src/components/listview/HorizontalScrollView.tsx new file mode 100644 index 0000000..d592115 --- /dev/null +++ b/src/components/listview/HorizontalScrollView.tsx @@ -0,0 +1,33 @@ +import React, { ReactElement, ReactNode } from 'react'; + +type Props = { + itemRenderer?: (child: ReactNode, index: number) => ReactElement; + children: ReactNode; +} & React.OlHTMLAttributes; + +function HorizontalScrollView({ itemRenderer, children, ...restProps }: Props) { + const items = React.Children.toArray(children); + + return ( +
    + {items.map((child, index) => ( +
  • + {itemRenderer ? itemRenderer(child, index) : child} +
  • + ))} +
+ ); +} + +export default HorizontalScrollView;