mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 10:45:21 +03:00
Add hover functionality to Cameras component
This commit is contained in:
parent
dd02958f7c
commit
ca09f5d2d3
@ -2,12 +2,13 @@ import { h, Fragment } from 'preact';
|
|||||||
import ActivityIndicator from '../components/ActivityIndicator';
|
import ActivityIndicator from '../components/ActivityIndicator';
|
||||||
import Card from '../components/Card';
|
import Card from '../components/Card';
|
||||||
import CameraImage from '../components/CameraImage';
|
import CameraImage from '../components/CameraImage';
|
||||||
|
import JSMpegPlayer from '../components/JSMpegPlayer';
|
||||||
import AudioIcon from '../icons/Audio';
|
import AudioIcon from '../icons/Audio';
|
||||||
import ClipIcon from '../icons/Clip';
|
import ClipIcon from '../icons/Clip';
|
||||||
import MotionIcon from '../icons/Motion';
|
import MotionIcon from '../icons/Motion';
|
||||||
import SnapshotIcon from '../icons/Snapshot';
|
import SnapshotIcon from '../icons/Snapshot';
|
||||||
import { useAudioState, useDetectState, useRecordingsState, useSnapshotsState } from '../api/ws';
|
import { useAudioState, useDetectState, useRecordingsState, useSnapshotsState } from '../api/ws';
|
||||||
import { useMemo } from 'preact/hooks';
|
import { useMemo, useState } from 'preact/hooks';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
export default function Cameras() {
|
export default function Cameras() {
|
||||||
@ -99,13 +100,27 @@ function Camera({ name, config }) {
|
|||||||
[config, audioValue, sendAudio, detectValue, sendDetect, recordValue, sendRecordings, snapshotValue, sendSnapshots]
|
[config, audioValue, sendAudio, detectValue, sendDetect, recordValue, sendRecordings, snapshotValue, sendSnapshots]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [isHovered, setIsHovered] = useState(false); // Add a state to track if the mouse is over the card
|
||||||
|
|
||||||
|
const handleMouseEnter = () => {
|
||||||
|
setIsHovered(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseLeave = () => {
|
||||||
|
setIsHovered(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
buttons={buttons}
|
buttons={buttons}
|
||||||
href={href}
|
href={href}
|
||||||
header={cleanName}
|
header={cleanName}
|
||||||
icons={icons}
|
icons={icons}
|
||||||
media={<CameraImage camera={name} stretch />}
|
//media={<CameraImage camera={name} stretch />}
|
||||||
|
media={isHovered ? <JSMpegPlayer camera={name} stretch /> : <CameraImage camera={name} stretch />} // Use the state to decide which component to render
|
||||||
|
onMouseEnter={handleMouseEnter} // Handle mouse enter event
|
||||||
|
onMouseLeave={handleMouseLeave} // Handle mouse leave event
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user