Spaces:
Running
Running
Download bioai-platform/frontend/src/lib/theme-canvas.ts from Samad14/bio-nexus-api: direct link, hf CLI and curl.
- Browser
- Download file 801 Bytes
-
https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/lib/theme-canvas.ts
- Command line
-
hf download hf://spaces/Samad14/bio-nexus-api/bioai-platform/frontend/src/lib/theme-canvas.ts
-
curl -L -o theme-canvas.ts https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/lib/theme-canvas.ts
801 Bytes
| /** | |
| * Resolve a theme-driven CSS variable to a concrete color string at runtime. | |
| * Used by canvas/export code (fillStyle, SVG serialization, 3D viewers) where a | |
| * bare `var(--x)` cannot be passed to a non-CSS API. Safe for SSR. | |
| */ | |
| export function cssColor(name: string, fallback: string): string { | |
| if (typeof document === 'undefined') return fallback; | |
| const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim(); | |
| if (!value) return fallback; | |
| // Triplet tokens ("11 12 20") -> rgb(11 12 20); full colors pass through. | |
| if (/^\d[\d\s]*$/.test(value)) return `rgb(${value})`; | |
| return value; | |
| } | |
| /** Resolved scene/canvas background (driven by --viewer-bg). */ | |
| export function viewerBg(fallback = '#0B0C14'): string { | |
| return cssColor('--viewer-bg', fallback); | |
| } | |