README / src /Interactive.jsx
compute1's picture
Upload src/Interactive.jsx with huggingface_hub
3bdbf6f verified
Raw History Blame Contribute Delete
1.02 kB
import { useState } from 'react'
import colorSvg from './assets/logo-horizontal.svg?raw'
import monoSvg from './assets/logo-horizontal-mono-white.svg?raw'
import Card from './Card.jsx'
import SignalBar from './SignalBar.jsx'
// Client-only build: inline both logos as data URIs at runtime.
const uri = (svg) =>
'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg)))
// Client-only entry for the Space. React does the actual work here:
// theme state (with the brand-required logo swap), and the React-driven
// signal bar. The static org card never runs this file.
export default function Interactive() {
// ?theme=dark lets the dark card be shared/previewed directly.
const [dark, setDark] = useState(
() =>
typeof location !== 'undefined' &&
new URLSearchParams(location.search).get('theme') === 'dark',
)
return (
<Card
logoSrc={dark ? uri(monoSvg) : uri(colorSvg)}
dark={dark}
onToggle={() => setDark((d) => !d)}
bar={<SignalBar />}
/>
)
}