okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221apps/host: the owner's UI and the Node App Host0b3299a01

main
1.4 KiB24 linesraw
1import { tr } from '../lib/i18n';
2/** The approved three-bar mark and outlined wordmark, sized as artwork. */
3import { useEffect, useState, type CSSProperties } from 'react';
4import { useMedia } from '../lib/responsive';
5import { useStore } from '../lib/store';
6export function Brand({ variant, height, decorative = false, className = '', }: {
7    variant: 'mark' | 'lockup';
8    height: number;
9    decorative?: boolean;
10    className?: string;
11}) {
12    const preference = useStore(s => s.theme);
13    const systemDark = useMedia('(prefers-color-scheme: dark)');
14    const theme = preference === 'system' ? (systemDark ? 'dark' : 'light') : preference;
15    const src = `/brand/strata-${variant}-${theme}.svg`;
16    const [failed, setFailed] = useState(false);
17    useEffect(() => setFailed(false), [src]);
18    const width = variant === 'mark' ? height : height * 182 / 48;
19    const style = { width, height } satisfies CSSProperties;
20    return <span className={`brand brand--${variant} ${className}`} style={style} role={decorative ? undefined : 'img'} aria-label={tr(decorative ? undefined : 'Strata')} aria-hidden={decorative || undefined}>
21    {tr(!failed ? <img className="brand__img" src={src} width={width} height={height} alt={tr("")} onError={() => setFailed(true)}/> : null)}
22    <span className="brand__fallback" aria-hidden="true">{tr(variant === 'mark' ? 'S' : 'Strata')}</span>
23  </span>;
24}