From 08e5c791c8d6d7273f2531f08450282505c20c5e Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 7 May 2024 09:00:25 -0500 Subject: [PATCH] Use cn() for class names throughout (#11278) * add scrollbar on ptz presets dropdown * use cn function for class names throughout * Revert "add scrollbar on ptz presets dropdown" This reverts commit 2cee93dc3ecf0f77c78b8ef5bcd3c7135227ecd3. --- web/src/components/Logo.tsx | 4 +++- web/src/components/camera/ResizingCameraImage.tsx | 3 ++- web/src/components/card/ExportCard.tsx | 6 +++++- web/src/components/dynamic/CameraFeatureToggle.tsx | 9 ++++++--- web/src/components/filter/CameraGroupSelector.tsx | 7 ++++++- web/src/components/icons/FrigatePlusIcon.tsx | 3 ++- web/src/components/indicators/Chip.tsx | 6 +++++- .../components/indicators/ImageLoadingIndicator.tsx | 5 +++-- .../components/indicators/activity-indicator.tsx | 3 ++- web/src/components/menu/AccountSettings.tsx | 9 ++++++++- web/src/components/navigation/Bottombar.tsx | 6 +++++- web/src/components/navigation/NavItem.tsx | 9 ++++++--- web/src/components/player/BirdseyeLivePlayer.tsx | 6 +++++- web/src/components/player/LivePlayer.tsx | 12 +++++++++--- web/src/components/player/PreviewPlayer.tsx | 13 +++++++++++-- web/src/components/player/VideoControls.tsx | 6 +++++- .../player/dynamic/DynamicVideoPlayer.tsx | 6 +++++- web/src/pages/Logs.tsx | 7 ++++++- 18 files changed, 94 insertions(+), 26 deletions(-) diff --git a/web/src/components/Logo.tsx b/web/src/components/Logo.tsx index 32cd52eda..ca2897ac4 100644 --- a/web/src/components/Logo.tsx +++ b/web/src/components/Logo.tsx @@ -1,9 +1,11 @@ +import { cn } from "@/lib/utils"; + type LogoProps = { className?: string; }; export default function Logo({ className }: LogoProps) { return ( - + ); diff --git a/web/src/components/camera/ResizingCameraImage.tsx b/web/src/components/camera/ResizingCameraImage.tsx index f19c40ff3..47b25124e 100644 --- a/web/src/components/camera/ResizingCameraImage.tsx +++ b/web/src/components/camera/ResizingCameraImage.tsx @@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import useSWR from "swr"; import ActivityIndicator from "../indicators/activity-indicator"; import { useResizeObserver } from "@/hooks/resize-observer"; +import { cn } from "@/lib/utils"; type CameraImageProps = { className?: string; @@ -95,7 +96,7 @@ export default function CameraImage({ return (
{enabled ? ( diff --git a/web/src/components/card/ExportCard.tsx b/web/src/components/card/ExportCard.tsx index f7dd7f588..2ce048562 100644 --- a/web/src/components/card/ExportCard.tsx +++ b/web/src/components/card/ExportCard.tsx @@ -18,6 +18,7 @@ import useKeyboardListener from "@/hooks/use-keyboard-listener"; import { DeleteClipType, Export } from "@/types/export"; import { MdEditSquare } from "react-icons/md"; import { baseUrl } from "@/api/baseUrl"; +import { cn } from "@/lib/utils"; type ExportProps = { className: string; @@ -104,7 +105,10 @@ export default function ExportCard({
setHovered(true) diff --git a/web/src/components/dynamic/CameraFeatureToggle.tsx b/web/src/components/dynamic/CameraFeatureToggle.tsx index b0418c556..a31bafb9d 100644 --- a/web/src/components/dynamic/CameraFeatureToggle.tsx +++ b/web/src/components/dynamic/CameraFeatureToggle.tsx @@ -5,6 +5,7 @@ import { TooltipTrigger, } from "@/components/ui/tooltip"; import { isDesktop } from "react-device-detect"; +import { cn } from "@/lib/utils"; const variants = { primary: { @@ -38,9 +39,11 @@ export default function CameraFeatureToggle({ const content = (
diff --git a/web/src/components/icons/FrigatePlusIcon.tsx b/web/src/components/icons/FrigatePlusIcon.tsx index 1a9ff2e05..24ee06eb5 100644 --- a/web/src/components/icons/FrigatePlusIcon.tsx +++ b/web/src/components/icons/FrigatePlusIcon.tsx @@ -1,5 +1,6 @@ import { LuPlus } from "react-icons/lu"; import Logo from "../Logo"; +import { cn } from "@/lib/utils"; type FrigatePlusIconProps = { className?: string; @@ -11,7 +12,7 @@ export default function FrigatePlusIcon({ }: FrigatePlusIconProps) { return (
diff --git a/web/src/components/indicators/Chip.tsx b/web/src/components/indicators/Chip.tsx index 7a2c4f5b5..e9abcf5e6 100644 --- a/web/src/components/indicators/Chip.tsx +++ b/web/src/components/indicators/Chip.tsx @@ -1,3 +1,4 @@ +import { cn } from "@/lib/utils"; import { LogSeverity } from "@/types/log"; import { ReactNode, useMemo, useRef } from "react"; import { CSSTransition } from "react-transition-group"; @@ -32,7 +33,10 @@ export default function Chip({ >
{children} diff --git a/web/src/components/indicators/ImageLoadingIndicator.tsx b/web/src/components/indicators/ImageLoadingIndicator.tsx index 32531ea2b..dc3054181 100644 --- a/web/src/components/indicators/ImageLoadingIndicator.tsx +++ b/web/src/components/indicators/ImageLoadingIndicator.tsx @@ -1,5 +1,6 @@ import { isSafari } from "react-device-detect"; import { Skeleton } from "../ui/skeleton"; +import { cn } from "@/lib/utils"; export default function ImageLoadingIndicator({ className, @@ -13,8 +14,8 @@ export default function ImageLoadingIndicator({ } return isSafari ? ( -
+
) : ( - + ); } diff --git a/web/src/components/indicators/activity-indicator.tsx b/web/src/components/indicators/activity-indicator.tsx index edabf1f1b..5591c9b7d 100644 --- a/web/src/components/indicators/activity-indicator.tsx +++ b/web/src/components/indicators/activity-indicator.tsx @@ -1,9 +1,10 @@ +import { cn } from "@/lib/utils"; import { LuLoader2 } from "react-icons/lu"; export default function ActivityIndicator({ className = "w-full", size = 30 }) { return (
diff --git a/web/src/components/menu/AccountSettings.tsx b/web/src/components/menu/AccountSettings.tsx index a5068c753..f6afa1d99 100644 --- a/web/src/components/menu/AccountSettings.tsx +++ b/web/src/components/menu/AccountSettings.tsx @@ -3,6 +3,7 @@ import { TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; +import { cn } from "@/lib/utils"; import { TooltipPortal } from "@radix-ui/react-tooltip"; import { isDesktop } from "react-device-detect"; import { VscAccount } from "react-icons/vsc"; @@ -15,7 +16,13 @@ export default function AccountSettings({ className }: AccountSettingsProps) {
diff --git a/web/src/components/navigation/Bottombar.tsx b/web/src/components/navigation/Bottombar.tsx index d0059ffcf..d71dfba12 100644 --- a/web/src/components/navigation/Bottombar.tsx +++ b/web/src/components/navigation/Bottombar.tsx @@ -14,6 +14,7 @@ import { StatusMessage, } from "@/context/statusbar-provider"; import { Link } from "react-router-dom"; +import { cn } from "@/lib/utils"; function Bottombar() { const navItems = useNavigation("secondary"); @@ -75,7 +76,10 @@ function StatusAlertNav({ className }: StatusAlertNavProps) {
{Object.entries(messages).map(([key, messageArray]) => ( diff --git a/web/src/components/navigation/NavItem.tsx b/web/src/components/navigation/NavItem.tsx index acda54ebe..41f5aeff4 100644 --- a/web/src/components/navigation/NavItem.tsx +++ b/web/src/components/navigation/NavItem.tsx @@ -8,6 +8,7 @@ import { isDesktop } from "react-device-detect"; import { TooltipPortal } from "@radix-ui/react-tooltip"; import { NavData } from "@/types/navigation"; import { IconType } from "react-icons"; +import { cn } from "@/lib/utils"; const variants = { primary: { @@ -42,9 +43,11 @@ export default function NavItem({ to={item.url} onClick={onClick} className={({ isActive }) => - `flex flex-col justify-center items-center rounded-lg ${className ?? ""} ${ - variants[item.variant ?? "primary"][isActive ? "active" : "inactive"] - }` + cn( + "flex flex-col justify-center items-center rounded-lg", + className, + variants[item.variant ?? "primary"][isActive ? "active" : "inactive"], + ) } > diff --git a/web/src/components/player/BirdseyeLivePlayer.tsx b/web/src/components/player/BirdseyeLivePlayer.tsx index a14756039..b9c64379b 100644 --- a/web/src/components/player/BirdseyeLivePlayer.tsx +++ b/web/src/components/player/BirdseyeLivePlayer.tsx @@ -4,6 +4,7 @@ import ActivityIndicator from "../indicators/activity-indicator"; import JSMpegPlayer from "./JSMpegPlayer"; import MSEPlayer from "./MsePlayer"; import { LivePlayerMode } from "@/types/live"; +import { cn } from "@/lib/utils"; type LivePlayerProps = { className?: string; @@ -57,7 +58,10 @@ export default function BirdseyeLivePlayer({ return (
diff --git a/web/src/components/player/LivePlayer.tsx b/web/src/components/player/LivePlayer.tsx index 840b6413c..3e1503d28 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -13,6 +13,7 @@ import useCameraLiveMode from "@/hooks/use-camera-live-mode"; import { getIconForLabel } from "@/utils/iconUtil"; import Chip from "../indicators/Chip"; import { capitalizeFirstLetter } from "@/utils/stringUtil"; +import { cn } from "@/lib/utils"; type LivePlayerProps = { cameraRef?: (ref: HTMLDivElement | null) => void; @@ -150,11 +151,16 @@ export default function LivePlayer({
diff --git a/web/src/components/player/PreviewPlayer.tsx b/web/src/components/player/PreviewPlayer.tsx index 8554c0669..03a6c47d2 100644 --- a/web/src/components/player/PreviewPlayer.tsx +++ b/web/src/components/player/PreviewPlayer.tsx @@ -15,6 +15,7 @@ import { baseUrl } from "@/api/baseUrl"; import { isAndroid, isChrome, isMobile } from "react-device-detect"; import { TimeRange } from "@/types/timeline"; import { Skeleton } from "../ui/skeleton"; +import { cn } from "@/lib/utils"; type PreviewPlayerProps = { className?: string; @@ -238,7 +239,11 @@ function PreviewVideoPlayer({ return (
{video && features.volume && (
diff --git a/web/src/components/player/dynamic/DynamicVideoPlayer.tsx b/web/src/components/player/dynamic/DynamicVideoPlayer.tsx index 0c095de97..7d1c7e4d9 100644 --- a/web/src/components/player/dynamic/DynamicVideoPlayer.tsx +++ b/web/src/components/player/dynamic/DynamicVideoPlayer.tsx @@ -11,6 +11,7 @@ import { TimeRange } from "@/types/timeline"; import ActivityIndicator from "@/components/indicators/activity-indicator"; import { VideoResolutionType } from "@/types/live"; import axios from "axios"; +import { cn } from "@/lib/utils"; /** * Dynamically switches between video playback and scrubbing preview player. @@ -202,7 +203,10 @@ export default function DynamicVideoPlayer({ onUploadFrame={onUploadFrameToPlus} />