blakeblackshear.frigate/web/src/Sidebar.jsx

52 lines
1.7 KiB
React
Raw Normal View History

import { h, Fragment } from 'preact';
2021-02-02 05:28:25 +01:00
import LinkedLogo from './components/LinkedLogo';
import { Match } from 'preact-router/match';
import { memo } from 'preact/compat';
import { useConfig } from './api';
import NavigationDrawer, { Destination, Separator } from './components/NavigationDrawer';
import { useCallback, useMemo } from 'preact/hooks';
export default function Sidebar() {
const { data: config } = useConfig();
const cameras = useMemo(() => Object.keys(config.cameras), [config]);
2021-01-09 18:26:46 +01:00
return (
<NavigationDrawer header={<Header />}>
<Destination href="/" text="Cameras" />
2021-02-05 00:19:47 +01:00
<Match path="/cameras/:camera/:other?">
{({ matches }) =>
matches ? (
<Fragment>
<Separator />
{cameras.map((camera) => (
<Destination href={`/cameras/${camera}`} text={camera} />
))}
<Separator />
</Fragment>
) : null
}
</Match>
<Destination href="/events" text="Events" />
<Destination href="/debug" text="Debug" />
<Separator />
<div className="flex flex-grow" />
2021-02-07 22:46:05 +01:00
{import.meta.env.MODE !== 'production' ? (
<Fragment>
<Destination href="/styleguide" text="Style Guide" />
<Separator />
</Fragment>
) : null}
<Destination className="self-end" href="https://blakeblackshear.github.io/frigate" text="Documentation" />
<Destination className="self-end" href="https://github.com/blakeblackshear/frigate" text="GitHub" />
</NavigationDrawer>
2021-01-09 18:26:46 +01:00
);
}
const Header = memo(function Header() {
2021-01-09 18:26:46 +01:00
return (
<div class="text-gray-500">
<LinkedLogo />
</div>
2021-01-09 18:26:46 +01:00
);
});