MCPcopy Create free account
hub / github.com/Remocn/remocn / buttonExampleCode

Function buttonExampleCode

components/docs/examples/button-example.tsx:58–101  ·  view source on GitHub ↗
(
  values: Record<string, unknown> = {},
)

Source from the content-addressed store, hash-verified

56 * a value differs from its control default — never a prop the component ignores.
57 */
58export const buttonExampleCode = (
59 values: Record<string, unknown> = {},
60): string => {
61 const label = values.label as string | undefined;
62 const variant = values.variant as string | undefined;
63 const size = values.size as string | undefined;
64 const primary = values.primary as string | undefined;
65
66 const props: string[] = [];
67 if (label !== undefined && label !== "Continue")
68 props.push(`label="${label}"`);
69 if (variant !== undefined && variant !== "default")
70 props.push(`variant="${variant}"`);
71 if (size !== undefined && size !== "default") props.push(`size="${size}"`);
72 if (primary !== undefined && primary !== "#171717")
73 props.push(`primary="${primary}"`);
74
75 // Default scene renders `<Button label="Continue" style={style} />`; honored
76 // overrides are appended before `style` so the timeline prop stays last.
77 const propsStr = props.length ? `${props.join(" ")} ` : "";
78
79 // Color-affecting props are ALSO forwarded into the transition hook so the
80 // animated background tracks them (size/label only need the component prop).
81 const hookOpts: string[] = [];
82 if (variant !== undefined && variant !== "default")
83 hookOpts.push(`variant: "${variant}"`);
84 if (primary !== undefined && primary !== "#171717")
85 hookOpts.push(`primary: "${primary}"`);
86 const optsStr = hookOpts.length ? `, { ${hookOpts.join(", ")} }` : "";
87
88 return `import { Button } from "@/components/remocn/button";
89import { useButtonTransition } from "@/components/remocn/use-button-transition";
90
91export const Scene = () => {
92 const style = useButtonTransition([
93 { at: 12, state: "hover" },
94 { at: 30, state: "press" },
95 { at: 48, state: "loading", duration: 6 },
96 { at: 96, state: "success", duration: 16 },
97 ]${optsStr});
98
99 return <Button ${propsStr}style={style} />;
100};`;
101};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected