import preview from "../../../.storybook/preview.js"; import * as platform from "@solid-primitives/platform"; import readme from "../README.md?raw"; import { Section, BoolRow, Container } from "../../../.storybook/ui/index.js"; const meta = preview.meta({ title: "Utilities/Platform", tags: ["autodocs"], parameters: { layout: "centered", docs: { description: { component: readme, }, }, }, }); export default meta; export const AllDetections = meta.story({ name: "Platform Detection", parameters: { docs: { description: { story: "All constants are plain `boolean` values evaluated once at module load time from `navigator.userAgent` and browser API checks. Green = `true` for the current browser.", }, }, }, render: () => (

Current Environment

), }); export const ConditionalRendering = meta.story({ name: "Conditional Rendering", parameters: { docs: { description: { story: "Because the constants are plain booleans (not signals), they slot naturally into `Show`, `Switch/Match`, or plain `if` statements without any reactivity overhead.", }, }, }, render: () => { const device = platform.isIOS ? "iOS" : platform.isAndroid ? "Android" : platform.isWindows ? "Windows" : platform.isMac ? "macOS" : "Unknown OS"; const browser = platform.isChrome ? "Chrome" : platform.isFirefox ? "Firefox" : platform.isSafari ? "Safari" : platform.isEdge ? "Edge" : platform.isBrave ? "Brave" : platform.isOpera ? "Opera" : "Unknown Browser"; const engine = platform.isBlink ? "Blink" : platform.isGecko ? "Gecko" : platform.isWebKit ? "WebKit" : platform.isTrident ? "Trident" : "Unknown Engine"; const badge = (label: string, color: string) => ( {label} ); return (

You are running…

Device {badge(device, "#6366f1")}
Browser {badge(browser, "#0ea5e9")}
Engine {badge(engine, "#10b981")}
Mobile {badge(platform.isMobile ? "Yes" : "No", platform.isMobile ? "#f59e0b" : "#94a3b8")}

These are compile-time constants — no signals, no overhead.

); }, });