diff --git a/web/src/components/filter/CameraGroupSelector.tsx b/web/src/components/filter/CameraGroupSelector.tsx new file mode 100644 index 000000000..362c58c00 --- /dev/null +++ b/web/src/components/filter/CameraGroupSelector.tsx @@ -0,0 +1,66 @@ +import { FrigateConfig } from "@/types/frigateConfig"; +import { isMobile } from "react-device-detect"; +import useSWR from "swr"; +import { MdHome } from "react-icons/md"; +import { FaCar, FaCircle, FaLeaf } from "react-icons/fa"; +import useOverlayState from "@/hooks/use-overlay-state"; +import { Button } from "../ui/button"; +import { useNavigate } from "react-router-dom"; + +export function CameraGroupSelector() { + const { data: config } = useSWR("config"); + const navigate = useNavigate(); + const [group, setGroup] = useOverlayState("cameraGroup"); + + if (isMobile) { + return ( +
+ + {Object.entries(config?.camera_groups ?? {}).map(([name, config]) => { + return ( + + ); + })} +
+ ); + } + + return
; +} + +function getGroupIcon(icon: string) { + switch (icon) { + case "car": + return ; + case "leaf": + return ; + default: + return ; + } +} + +/** + * {config && + } + */ diff --git a/web/src/components/ui/button.tsx b/web/src/components/ui/button.tsx index e96ee22f3..8e97b5778 100644 --- a/web/src/components/ui/button.tsx +++ b/web/src/components/ui/button.tsx @@ -22,7 +22,7 @@ const buttonVariants = cva( }, size: { default: "h-10 px-4 py-2", - xs: "h-6 rounded-md", + xs: "size-6 rounded-md", sm: "h-9 rounded-md px-3", lg: "h-11 rounded-md px-8", icon: "h-10 w-10", diff --git a/web/src/hooks/use-overlay-state.tsx b/web/src/hooks/use-overlay-state.tsx index 4585e77a2..3b7b45982 100644 --- a/web/src/hooks/use-overlay-state.tsx +++ b/web/src/hooks/use-overlay-state.tsx @@ -1,7 +1,9 @@ -import { useCallback } from "react"; +import { useCallback, useMemo } from "react"; import { useLocation, useNavigate } from "react-router-dom"; -export default function useOverlayState(key: string) { +export default function useOverlayState( + key: string, +): [string | undefined, (value: string) => void] { const location = useLocation(); const navigate = useNavigate(); const currentLocationState = location.state; @@ -17,6 +19,10 @@ export default function useOverlayState(key: string) { [key, navigate], ); - const overlayStateValue = location.state && location.state[key]; + const overlayStateValue = useMemo( + () => location.state && location.state[key], + [location, key], + ); + return [overlayStateValue, setOverlayStateValue]; }