import { NAME, pattern, UI, type VNode, Writable } from "commonfabric"; import { Controls, SelectControl, TextControl } from "../ui/controls/index.ts"; // Self-contained avatar images (data-URI SVG) so the story renders with no // network access / CSP allowance required. const svgAvatar = (rgb: string, label: string): string => "data:image/svg+xml," + encodeURIComponent( `` + `` + `${label}`, ); const ADA_IMG = svgAvatar("rgb(99,102,241)", "AL"); const sizeItems = [ { label: "xs", value: "xs" }, { label: "sm", value: "sm" }, { label: "md", value: "md" }, { label: "lg", value: "lg" }, { label: "xl", value: "xl" }, ]; // deno-lint-ignore no-empty-interface interface AvatarStoryInput {} export interface AvatarStoryOutput { [NAME]: string; [UI]: VNode; controls: VNode; } const sectionLabel = { fontSize: "0.75rem", fontWeight: "600", textTransform: "uppercase", letterSpacing: "0.04em", color: "#6b7280", margin: "0 0 8px", }; export default pattern(() => { const src = new Writable(""); const name = new Writable("Ada Lovelace"); const size = new Writable<"xs" | "sm" | "md" | "lg" | "xl">("lg"); const shape = new Writable<"circle" | "square">("circle"); return { [NAME]: "cf-avatar Story", [UI]: (
Leave “src” empty for initials; paste an image URL or an emoji.

Render modes — image · glyph · initials

Sizes — xs · sm · md · lg · xl

Shapes — circle · square

), controls: ( <> ), }; });