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

Function alertDialogExampleCode

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

Source from the content-addressed store, hash-verified

46 actionLabel={p.actionLabel ?? "Delete"}
47 cancelLabel={p.cancelLabel ?? "Cancel"}
48 style={dialog}
49 />
50 </>
51 );
52};
53
54export const alertDialogExampleCode = (
55 values: Record<string, unknown> = {},
56): string => {
57 const title = values.title as string | undefined;
58 const description = values.description as string | undefined;
59 const actionLabel = values.actionLabel as string | undefined;
60 const cancelLabel = values.cancelLabel as string | undefined;
61
62 const alertDialogProps: string[] = [];
63 if (title !== undefined && title !== "Delete account?")
64 alertDialogProps.push(`title="${title}"`);
65 if (
66 description !== undefined &&
67 description !==
68 "This action cannot be undone. This will permanently remove your data from our servers."
69 )
70 alertDialogProps.push(`description="${description}"`);
71 if (actionLabel !== undefined && actionLabel !== "Delete")
72 alertDialogProps.push(`actionLabel="${actionLabel}"`);
73 if (cancelLabel !== undefined && cancelLabel !== "Cancel")
74 alertDialogProps.push(`cancelLabel="${cancelLabel}"`);
75
76 const alertDialogPropsStr = alertDialogProps.length
77 ? ` ${alertDialogProps.join(" ")}`
78 : "";
79
80 return `import { AlertDialog } from "@/components/remocn/alert-dialog";
81import { useAlertDialogTransition } from "@/components/remocn/use-alert-dialog-transition";
82import { Button } from "@/components/remocn/button";
83import { useButtonTransition } from "@/components/remocn/use-button-transition";
84
85export const Scene = () => {
86 const trigger = useButtonTransition(
87 [
88 { at: 14, state: "hover" },
89 { at: 26, state: "press" },
90 ],
91 { variant: "destructive" },
92 );

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected