import { SizableText, XStack, YStack } from "tamagui"; import { Intent, type IntentProps } from "./Intent"; import { useIntentContext, useResolvedKnobs } from "./useResolvedKnobs"; export default { title: "Theme/Intent", component: Intent, parameters: { status: { type: "beta" }, docs: { description: { component: "Intent activates the named Tamagui sub-theme (layer 1) and publishes the intent name through IntentContext so useResolvedKnobs merges the preset's intent overrides (layer 2). The probe is a Tamagui stack painting $background / $color and spreading the resolved surface.", }, }, }, }; const intents: IntentProps["name"][] = ["accent", "error", "warning", "success"]; function Probe({ label }: { label: string }) { const intent = useIntentContext(); const { knobProps } = useResolvedKnobs(); const attrs = { "data-intent": intent ?? "none", "data-outlined": String(Boolean(knobProps.outlined)), "data-fill-style": knobProps.outlined ? "outlined" : "filled", } as Record; return ( {label} context: {intent ?? "none"} ); } /** The four intents beside an un-wrapped baseline. */ export const main = { name: "Main", render: () => ( {intents.map((name) => ( ))} ), }; /** Nesting replaces, never merges: the innermost intent wins. */ export const nested = { name: "Nested", render: () => ( ), }; /** An explicit `theme` keeps the intent context but paints another Tamagui theme. */ export const explicitTheme = { name: "Explicit theme", render: () => ( ), };