mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
UI cleanup (#10567)
* Fix selected items text * Use action icons from design and fix spacing * Fix icons for live grid * Fix viewed select api * Setup default theme as system * Make conig editor respect system theme
This commit is contained in:
parent
5af083cd8a
commit
8babe57d63
@ -1,8 +1,10 @@
|
|||||||
import { LuCheckSquare, LuFileUp, LuTrash } from "react-icons/lu";
|
import { FaCircleCheck } from "react-icons/fa6";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { isDesktop } from "react-device-detect";
|
import { isDesktop } from "react-device-detect";
|
||||||
|
import { FaCompactDisc } from "react-icons/fa";
|
||||||
|
import { HiTrash } from "react-icons/hi";
|
||||||
|
|
||||||
type ReviewActionGroupProps = {
|
type ReviewActionGroupProps = {
|
||||||
selectedReviews: string[];
|
selectedReviews: string[];
|
||||||
@ -21,8 +23,7 @@ export default function ReviewActionGroup({
|
|||||||
}, [setSelectedReviews]);
|
}, [setSelectedReviews]);
|
||||||
|
|
||||||
const onMarkAsReviewed = useCallback(async () => {
|
const onMarkAsReviewed = useCallback(async () => {
|
||||||
const idList = selectedReviews.join(",");
|
await axios.post(`reviews/viewed`, { ids: selectedReviews });
|
||||||
await axios.post(`reviews/viewed`, { ids: idList });
|
|
||||||
setSelectedReviews([]);
|
setSelectedReviews([]);
|
||||||
pullLatestData();
|
pullLatestData();
|
||||||
}, [selectedReviews, setSelectedReviews, pullLatestData]);
|
}, [selectedReviews, setSelectedReviews, pullLatestData]);
|
||||||
@ -36,16 +37,20 @@ export default function ReviewActionGroup({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="absolute inset-x-2 inset-y-0 md:left-auto md:right-2 p-2 flex gap-2 justify-between items-center bg-background">
|
<div className="absolute inset-x-2 inset-y-0 md:left-auto md:right-2 p-2 flex gap-2 justify-between items-center bg-background">
|
||||||
<div className="flex items-center">
|
<div className="mx-1 flex justify-center items-center text-sm text-muted-foreground">
|
||||||
<div className="text-sm text-gray-500 mr-2">{`${selectedReviews.length} selected | `}</div>
|
<div className="p-1">{`${selectedReviews.length} selected`}</div>
|
||||||
<Button size="xs" variant="link" onClick={onClearSelected}>
|
<div className="p-1">{"|"}</div>
|
||||||
|
<div
|
||||||
|
className="p-2 text-primary-foreground cursor-pointer hover:bg-secondary hover:rounded-lg"
|
||||||
|
onClick={onClearSelected}
|
||||||
|
>
|
||||||
Unselect
|
Unselect
|
||||||
</Button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1 md:gap-2">
|
<div className="flex items-center gap-1 md:gap-2">
|
||||||
{selectedReviews.length == 1 && (
|
{selectedReviews.length == 1 && (
|
||||||
<Button
|
<Button
|
||||||
className="flex items-center"
|
className="p-2 flex items-center gap-2"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -53,26 +58,26 @@ export default function ReviewActionGroup({
|
|||||||
onClearSelected();
|
onClearSelected();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LuFileUp className="mr-1" />
|
<FaCompactDisc />
|
||||||
{isDesktop && "Export"}
|
{isDesktop && "Export"}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
className="flex items-center"
|
className="p-2 flex items-center gap-2"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={onMarkAsReviewed}
|
onClick={onMarkAsReviewed}
|
||||||
>
|
>
|
||||||
<LuCheckSquare className="mr-1" />
|
<FaCircleCheck />
|
||||||
{isDesktop && "Mark as reviewed"}
|
{isDesktop && "Mark as reviewed"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
className="flex items-center"
|
className="p-2 flex items-center gap-1"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={onDelete}
|
onClick={onDelete}
|
||||||
>
|
>
|
||||||
<LuTrash className="mr-1" />
|
<HiTrash />
|
||||||
{isDesktop && "Delete"}
|
{isDesktop && "Delete"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
42
web/src/components/icons/LiveIcons.tsx
Normal file
42
web/src/components/icons/LiveIcons.tsx
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
type LiveIconProps = {
|
||||||
|
layout?: "list" | "grid";
|
||||||
|
};
|
||||||
|
|
||||||
|
export function LiveGridIcon({ layout }: LiveIconProps) {
|
||||||
|
return (
|
||||||
|
<div className="size-full flex flex-col gap-0.5 rounded-md overflow-hidden">
|
||||||
|
<div
|
||||||
|
className={`h-1 w-full ${layout == "grid" ? "bg-selected" : "bg-muted-foreground"}`}
|
||||||
|
/>
|
||||||
|
<div className="h-1 w-full flex gap-0.5">
|
||||||
|
<div
|
||||||
|
className={`w-full ${layout == "grid" ? "bg-selected" : "bg-muted-foreground"}`}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={`w-full ${layout == "grid" ? "bg-selected" : "bg-muted-foreground"}`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="h-1 w-full flex gap-0.5">
|
||||||
|
<div
|
||||||
|
className={`w-full ${layout == "grid" ? "bg-selected" : "bg-muted-foreground"}`}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={`w-full ${layout == "grid" ? "bg-selected" : "bg-muted-foreground"}`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LiveListIcon({ layout }: LiveIconProps) {
|
||||||
|
return (
|
||||||
|
<div className="size-full flex flex-col gap-0.5 rounded-md overflow-hidden">
|
||||||
|
<div
|
||||||
|
className={`size-full ${layout == "list" ? "bg-selected" : "bg-muted-foreground"}`}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={`size-full ${layout == "list" ? "bg-selected" : "bg-muted-foreground"}`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
@ -13,7 +13,7 @@ function providers({ children }: TProvidersProps) {
|
|||||||
return (
|
return (
|
||||||
<RecoilRoot>
|
<RecoilRoot>
|
||||||
<ApiProvider>
|
<ApiProvider>
|
||||||
<ThemeProvider defaultTheme="light" storageKey="frigate-ui-theme">
|
<ThemeProvider defaultTheme="system" storageKey="frigate-ui-theme">
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<IconContext.Provider value={{ size: "20" }}>
|
<IconContext.Provider value={{ size: "20" }}>
|
||||||
{children}
|
{children}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { createContext, useContext, useEffect, useState } from "react";
|
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
type Theme = "dark" | "light" | "system";
|
type Theme = "dark" | "light" | "system";
|
||||||
type ColorScheme =
|
type ColorScheme =
|
||||||
@ -41,6 +41,7 @@ type ThemeProviderProps = {
|
|||||||
|
|
||||||
type ThemeProviderState = {
|
type ThemeProviderState = {
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
|
systemTheme?: Theme;
|
||||||
colorScheme: ColorScheme;
|
colorScheme: ColorScheme;
|
||||||
setTheme: (theme: Theme) => void;
|
setTheme: (theme: Theme) => void;
|
||||||
setColorScheme: (colorScheme: ColorScheme) => void;
|
setColorScheme: (colorScheme: ColorScheme) => void;
|
||||||
@ -48,6 +49,7 @@ type ThemeProviderState = {
|
|||||||
|
|
||||||
const initialState: ThemeProviderState = {
|
const initialState: ThemeProviderState = {
|
||||||
theme: "system",
|
theme: "system",
|
||||||
|
systemTheme: undefined,
|
||||||
colorScheme: "theme-default",
|
colorScheme: "theme-default",
|
||||||
setTheme: () => null,
|
setTheme: () => null,
|
||||||
setColorScheme: () => null,
|
setColorScheme: () => null,
|
||||||
@ -86,6 +88,16 @@ export function ThemeProvider({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const systemTheme = useMemo<Theme | undefined>(() => {
|
||||||
|
if (theme != "system") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||||
|
? "dark"
|
||||||
|
: "light";
|
||||||
|
}, [theme]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//localStorage.removeItem(storageKey);
|
//localStorage.removeItem(storageKey);
|
||||||
//console.log(localStorage.getItem(storageKey));
|
//console.log(localStorage.getItem(storageKey));
|
||||||
@ -95,21 +107,17 @@ export function ThemeProvider({
|
|||||||
|
|
||||||
root.classList.add(theme, colorScheme);
|
root.classList.add(theme, colorScheme);
|
||||||
|
|
||||||
if (theme === "system") {
|
if (systemTheme) {
|
||||||
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
|
|
||||||
.matches
|
|
||||||
? "dark"
|
|
||||||
: "light";
|
|
||||||
|
|
||||||
root.classList.add(systemTheme);
|
root.classList.add(systemTheme);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
root.classList.add(theme);
|
root.classList.add(theme);
|
||||||
}, [theme, colorScheme]);
|
}, [theme, colorScheme, systemTheme]);
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
theme,
|
theme,
|
||||||
|
systemTheme,
|
||||||
colorScheme,
|
colorScheme,
|
||||||
setTheme: (theme: Theme) => {
|
setTheme: (theme: Theme) => {
|
||||||
localStorage.setItem(storageKey, JSON.stringify({ theme, colorScheme }));
|
localStorage.setItem(storageKey, JSON.stringify({ theme, colorScheme }));
|
||||||
|
@ -19,7 +19,7 @@ function ConfigEditor() {
|
|||||||
|
|
||||||
const { data: config } = useSWR<string>("config/raw");
|
const { data: config } = useSWR<string>("config/raw");
|
||||||
|
|
||||||
const { theme } = useTheme();
|
const { theme, systemTheme } = useTheme();
|
||||||
const [error, setError] = useState<string | undefined>();
|
const [error, setError] = useState<string | undefined>();
|
||||||
|
|
||||||
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
|
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
|
||||||
@ -107,7 +107,7 @@ function ConfigEditor() {
|
|||||||
language: "yaml",
|
language: "yaml",
|
||||||
model: modelRef.current,
|
model: modelRef.current,
|
||||||
scrollBeyondLastLine: false,
|
scrollBeyondLastLine: false,
|
||||||
theme: theme == "dark" ? "vs-dark" : "vs-light",
|
theme: (systemTheme || theme) == "dark" ? "vs-dark" : "vs-light",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { useFrigateReviews } from "@/api/ws";
|
import { useFrigateReviews } from "@/api/ws";
|
||||||
import Logo from "@/components/Logo";
|
import Logo from "@/components/Logo";
|
||||||
import { CameraGroupSelector } from "@/components/filter/CameraGroupSelector";
|
import { CameraGroupSelector } from "@/components/filter/CameraGroupSelector";
|
||||||
|
import { LiveGridIcon, LiveListIcon } from "@/components/icons/LiveIcons";
|
||||||
import { AnimatedEventThumbnail } from "@/components/image/AnimatedEventThumbnail";
|
import { AnimatedEventThumbnail } from "@/components/image/AnimatedEventThumbnail";
|
||||||
import BirdseyeLivePlayer from "@/components/player/BirdseyeLivePlayer";
|
import BirdseyeLivePlayer from "@/components/player/BirdseyeLivePlayer";
|
||||||
import LivePlayer from "@/components/player/LivePlayer";
|
import LivePlayer from "@/components/player/LivePlayer";
|
||||||
@ -12,7 +13,6 @@ import { CameraConfig, FrigateConfig } from "@/types/frigateConfig";
|
|||||||
import { ReviewSegment } from "@/types/review";
|
import { ReviewSegment } from "@/types/review";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { isDesktop, isMobile, isSafari } from "react-device-detect";
|
import { isDesktop, isMobile, isSafari } from "react-device-detect";
|
||||||
import { CiGrid2H, CiGrid31 } from "react-icons/ci";
|
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
|
||||||
type LiveDashboardViewProps = {
|
type LiveDashboardViewProps = {
|
||||||
@ -89,26 +89,26 @@ export default function LiveDashboardView({
|
|||||||
<CameraGroupSelector />
|
<CameraGroupSelector />
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Button
|
<Button
|
||||||
className={
|
className={`p-1 ${
|
||||||
layout == "grid"
|
layout == "grid"
|
||||||
? "text-selected bg-blue-900 focus:bg-blue-900 bg-opacity-60 focus:bg-opacity-60"
|
? "bg-blue-900 focus:bg-blue-900 bg-opacity-60 focus:bg-opacity-60"
|
||||||
: "text-muted-foreground bg-muted"
|
: "bg-muted"
|
||||||
}
|
}`}
|
||||||
size="xs"
|
size="xs"
|
||||||
onClick={() => setLayout("grid")}
|
onClick={() => setLayout("grid")}
|
||||||
>
|
>
|
||||||
<CiGrid31 className="m-1" />
|
<LiveGridIcon layout={layout} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
className={
|
className={`p-1 ${
|
||||||
layout == "list"
|
layout == "list"
|
||||||
? "text-selected bg-blue-900 focus:bg-blue-900 bg-opacity-60 focus:bg-opacity-60"
|
? "bg-blue-900 focus:bg-blue-900 bg-opacity-60 focus:bg-opacity-60"
|
||||||
: "text-muted-foreground bg-muted"
|
: "bg-muted"
|
||||||
}
|
}`}
|
||||||
size="xs"
|
size="xs"
|
||||||
onClick={() => setLayout("list")}
|
onClick={() => setLayout("list")}
|
||||||
>
|
>
|
||||||
<CiGrid2H className="m-1" />
|
<LiveListIcon layout={layout} />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user