diff --git a/web/src/features/menu/list/ListItem.tsx b/web/src/features/menu/list/ListItem.tsx index ec6eede..e38a2d8 100644 --- a/web/src/features/menu/list/ListItem.tsx +++ b/web/src/features/menu/list/ListItem.tsx @@ -1,14 +1,10 @@ -import { Box, Flex, Stack, Spacer, Text } from "@chakra-ui/react"; +import { Box, Flex, Stack, Spacer, Text, IconProps } from "@chakra-ui/react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { forwardRef } from "react"; - -interface Item { - label: string; - value: string | string[]; -} +import type { MenuItem } from "./index"; interface Props { - item: Item; + item: MenuItem; index: number; scrollIndex: number; } @@ -30,25 +26,34 @@ const ListItem = forwardRef, Props>(({ item, index, return (ref.current = [...ref.current, element]); }} > - {Array.isArray(item.value) ? ( - - - - {item.label} - - {item.value[scrollIndex]} - - - - - - - - ) : ( - + + {item.icon && ( + + )} + {Array.isArray(item.value) ? ( + + + + {item.label} + + {item.value[scrollIndex]} + + + + + + + + ) : ( {item.label} - - )} + )} + ); }); diff --git a/web/src/features/menu/list/index.tsx b/web/src/features/menu/list/index.tsx index c2b6004..25ff06a 100644 --- a/web/src/features/menu/list/index.tsx +++ b/web/src/features/menu/list/index.tsx @@ -5,11 +5,18 @@ import { debugData } from "../../../utils/debugData"; import ListItem from "./ListItem"; import Header from "./Header"; import FocusTrap from "focus-trap-react"; +import { IconProp } from "@fortawesome/fontawesome-svg-core"; + +export interface MenuItem { + label: string; + value: string | string[]; + icon?: IconProp; +} interface MenuSettings { position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; title: string; - items: Array<{ label: string; value: string | string[] }>; + items: Array; } debugData([ @@ -19,9 +26,9 @@ debugData([ // position: "bottom-left", title: "Vehicle garage", items: [ - { label: "Option 1", value: "option1" }, - { label: "Option 2", value: "option2" }, - { label: "Vehicle class", value: ["Nice", "Super nice", "Extra nice"] }, + { label: "Option 1", value: "option1", icon: "heart" }, + { label: "Option 2", value: "option2", icon: "basket-shopping" }, + { label: "Vehicle class", value: ["Nice", "Super nice", "Extra nice"], icon: "tag" }, { label: "Option 1", value: "option1" }, { label: "Option 2", value: "option2" }, { label: "Vehicle class", value: ["Nice", "Super nice", "Extra nice"] },