mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 07:35:27 +03:00
Add platform aware sheet component
This commit is contained in:
parent
4716ab202f
commit
e11f4b8940
@ -29,6 +29,7 @@ import SearchSourceIcon from "../icons/SearchSourceIcon";
|
|||||||
import PlatformAwareDialog from "../overlay/dialog/PlatformAwareDialog";
|
import PlatformAwareDialog from "../overlay/dialog/PlatformAwareDialog";
|
||||||
import { FaArrowRight, FaClock } from "react-icons/fa";
|
import { FaArrowRight, FaClock } from "react-icons/fa";
|
||||||
import { useFormattedHour } from "@/hooks/use-date-utils";
|
import { useFormattedHour } from "@/hooks/use-date-utils";
|
||||||
|
import SearchFilterDialog from "../overlay/dialog/SearchFilterDialog";
|
||||||
|
|
||||||
type SearchFilterGroupProps = {
|
type SearchFilterGroupProps = {
|
||||||
className: string;
|
className: string;
|
||||||
@ -159,6 +160,16 @@ export default function SearchFilterGroup({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{filters.includes("general") && (
|
||||||
|
<GeneralFilterButton
|
||||||
|
allLabels={filterValues.labels}
|
||||||
|
selectedLabels={filter?.labels}
|
||||||
|
updateLabelFilter={(newLabels) => {
|
||||||
|
onUpdateFilter({ ...filter, labels: newLabels });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<SearchFilterDialog />
|
||||||
{filters.includes("date") && (
|
{filters.includes("date") && (
|
||||||
<CalendarRangeFilterButton
|
<CalendarRangeFilterButton
|
||||||
range={
|
range={
|
||||||
@ -191,15 +202,6 @@ export default function SearchFilterGroup({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{filters.includes("general") && (
|
|
||||||
<GeneralFilterButton
|
|
||||||
allLabels={filterValues.labels}
|
|
||||||
selectedLabels={filter?.labels}
|
|
||||||
updateLabelFilter={(newLabels) => {
|
|
||||||
onUpdateFilter({ ...filter, labels: newLabels });
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{filters.includes("sub") && (
|
{filters.includes("sub") && (
|
||||||
<SubFilterButton
|
<SubFilterButton
|
||||||
allSubLabels={allSubLabels}
|
allSubLabels={allSubLabels}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
|
import { MobilePage, MobilePageContent } from "@/components/mobile/MobilePage";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer";
|
import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer";
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/components/ui/popover";
|
} from "@/components/ui/popover";
|
||||||
|
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
|
||||||
import { isMobile } from "react-device-detect";
|
import { isMobile } from "react-device-detect";
|
||||||
|
|
||||||
type PlatformAwareDialogProps = {
|
type PlatformAwareDialogProps = {
|
||||||
@ -42,3 +45,42 @@ export default function PlatformAwareDialog({
|
|||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PlatformAwareSheetProps = {
|
||||||
|
trigger: JSX.Element;
|
||||||
|
content: JSX.Element;
|
||||||
|
triggerClassName?: string;
|
||||||
|
contentClassName?: string;
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
};
|
||||||
|
export function PlatformAwareSheet({
|
||||||
|
trigger,
|
||||||
|
content,
|
||||||
|
triggerClassName = "",
|
||||||
|
contentClassName = "",
|
||||||
|
open,
|
||||||
|
onOpenChange,
|
||||||
|
}: PlatformAwareSheetProps) {
|
||||||
|
if (isMobile) {
|
||||||
|
return (
|
||||||
|
<MobilePage open={open} onOpenChange={onOpenChange}>
|
||||||
|
<Button asChild onClick={() => onOpenChange(!open)}>
|
||||||
|
{trigger}
|
||||||
|
</Button>
|
||||||
|
<MobilePageContent className="max-h-[75dvh] overflow-hidden px-4">
|
||||||
|
{content}
|
||||||
|
</MobilePageContent>
|
||||||
|
</MobilePage>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Sheet open={open} onOpenChange={onOpenChange}>
|
||||||
|
<SheetTrigger asChild className={triggerClassName}>
|
||||||
|
{trigger}
|
||||||
|
</SheetTrigger>
|
||||||
|
<SheetContent className={contentClassName}>{content}</SheetContent>
|
||||||
|
</Sheet>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
28
web/src/components/overlay/dialog/SearchFilterDialog.tsx
Normal file
28
web/src/components/overlay/dialog/SearchFilterDialog.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { FaCog } from "react-icons/fa";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { PlatformAwareSheet } from "./PlatformAwareDialog";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
|
type SearchFilterDialogProps = {};
|
||||||
|
export default function SearchFilterDialog({}: SearchFilterDialogProps) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const trigger = (
|
||||||
|
<Button className="flex items-center gap-2" size="sm">
|
||||||
|
<FaCog className={"text-secondary-foreground"} />
|
||||||
|
More Filters
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
const content = <></>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PlatformAwareSheet
|
||||||
|
trigger={trigger}
|
||||||
|
content={content}
|
||||||
|
contentClassName="w-auto"
|
||||||
|
open={open}
|
||||||
|
onOpenChange={setOpen}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user