import { computed, NAME, pattern, UI, type VNode, Writable, } from "commonfabric"; import { Controls, SwitchControl } from "../ui/controls/index.ts"; // deno-lint-ignore no-empty-interface interface PickerStoryInput {} export interface PickerStoryOutput { [NAME]: string; [UI]: VNode; controls: VNode; } interface PickerCardInput { title: string; body: string; color: string; } export interface PickerCardOutput { [NAME]: string; [UI]: VNode; } const PickerCard = pattern( ({ title, body, color }) => { return { [NAME]: "Picker Card", [UI]: (
{title}
{body}
), }; }, ); export default pattern(() => { const selectedIndex = new Writable(0); const disabled = new Writable(false); const sunrise = PickerCard({ title: "Sunrise", body: "A warm gradient card used for preview content.", color: "#fde68a", }); const ocean = PickerCard({ title: "Ocean", body: "Cards can be any renderable pattern output.", color: "#bfdbfe", }); const forest = PickerCard({ title: "Forest", body: "Use arrow keys or swipe to move between items.", color: "#bbf7d0", }); const items = computed(() => [sunrise, ocean, forest]); const selectedLabel = computed(() => { const labels = ["Sunrise", "Ocean", "Forest"]; return labels[selectedIndex.get()] ?? "Unknown"; }); return { [NAME]: "cf-picker Story", [UI]: (
Selected: {selectedLabel} (index {selectedIndex})
), controls: ( <> ), }; });