Masonry layout

This commit is contained in:
Nicolas Mowen 2024-02-07 08:21:40 -07:00
parent 26b78b1bd6
commit d66298bd80
3 changed files with 28 additions and 8 deletions

View File

@ -1,5 +1,5 @@
import WebRtcPlayer from "./WebRTCPlayer"; import WebRtcPlayer from "./WebRTCPlayer";
import { CameraConfig, FrigateConfig } from "@/types/frigateConfig"; import { CameraConfig } from "@/types/frigateConfig";
import AutoUpdatingCameraImage from "../camera/AutoUpdatingCameraImage"; import AutoUpdatingCameraImage from "../camera/AutoUpdatingCameraImage";
import ActivityIndicator from "../ui/activity-indicator"; import ActivityIndicator from "../ui/activity-indicator";
import { Button } from "../ui/button"; import { Button } from "../ui/button";
@ -11,7 +11,6 @@ import { Label } from "../ui/label";
import { usePersistence } from "@/hooks/use-persistence"; import { usePersistence } from "@/hooks/use-persistence";
import MSEPlayer from "./MsePlayer"; import MSEPlayer from "./MsePlayer";
import JSMpegPlayer from "./JSMpegPlayer"; import JSMpegPlayer from "./JSMpegPlayer";
import useSWR from "swr";
import { MdCircle } from "react-icons/md"; import { MdCircle } from "react-icons/md";
import Chip from "../Chip"; import Chip from "../Chip";
@ -30,7 +29,6 @@ export default function LivePlayer({
cameraConfig, cameraConfig,
liveMode = "mse", liveMode = "mse",
}: LivePlayerProps) { }: LivePlayerProps) {
const { data: config } = useSWR<FrigateConfig>("config");
const [showSettings, setShowSettings] = useState(false); const [showSettings, setShowSettings] = useState(false);
const [options, setOptions] = usePersistence( const [options, setOptions] = usePersistence(
@ -76,10 +74,11 @@ export default function LivePlayer({
); );
} else if (liveMode == "mse") { } else if (liveMode == "mse") {
if ("MediaSource" in window || "ManagedMediaSource" in window) { if ("MediaSource" in window || "ManagedMediaSource" in window) {
const camera = cameraConfig.name == "front_doorbell_cam" ? "portrait_cam" : cameraConfig.name
player = ( player = (
<MSEPlayer <MSEPlayer
className="rounded-2xl" className="rounded-2xl"
camera={cameraConfig.live.stream_name} camera={camera}
/> />
); );
} else { } else {
@ -132,9 +131,13 @@ export default function LivePlayer({
return ( return (
<div className={`relative flex justify-center ${className}`}> <div className={`relative flex justify-center ${className}`}>
{player} {player}
<Chip className="absolute right-2 top-2 bg-gray-500 bg-gradient-to-br">
<MdCircle className="w-2 h-2 text-danger" />
<div className="ml-1 capitalize text-white text-xs">
{cameraConfig.name.replaceAll("_", " ")}
</div>
</Chip>
</div> </div>
); );
} }

View File

@ -77,12 +77,20 @@ function Live() {
</ScrollArea> </ScrollArea>
)} )}
<div className="mt-4 grid grid-cols-1 md:grid-cols-2 2xl:grid-cols-3 gap-4"> <div className="mt-4 grid grid-rows-masonry grid-cols-3 gap-4">
{cameras.map((camera) => { {cameras.map((camera) => {
let grow;
if (camera.detect.width / camera.detect.height > 2) {
grow = "h-[424px] col-end-span-2";
} else if (camera.name == "front_doorbell_cam") {
grow = "h-[840px]";
} else {
grow = "h-[425px]";
}
return ( return (
<LivePlayer <LivePlayer
key={camera.name} key={camera.name}
className="rounded-2xl bg-black h-[428px]" className={`rounded-2xl bg-black ${grow}`}
cameraConfig={camera} cameraConfig={camera}
/> />
); );

View File

@ -82,6 +82,15 @@ module.exports = {
"3xl": "1920px", "3xl": "1920px",
"4xl": "2560px", "4xl": "2560px",
}, },
gridTemplateColumns: {
'3': 'repeat(3, 1fr)',
},
gridTemplateRows: {
'masonry': 'masonry',
},
gridColumnEnd: {
'span-2': 'span 2',
},
}, },
}, },
plugins: [require("tailwindcss-animate")], plugins: [require("tailwindcss-animate")],