(
values: Record<string, unknown> = {},
)
| 57 | }; |
| 58 | |
| 59 | export const cursorExampleCode = ( |
| 60 | values: Record<string, unknown> = {}, |
| 61 | ): string => { |
| 62 | const variant = values.variant as string | undefined; |
| 63 | const size = values.size as number | undefined; |
| 64 | const rippleColor = values.rippleColor as string | undefined; |
| 65 | |
| 66 | const cursorProps: string[] = []; |
| 67 | if (variant !== undefined && variant !== "arrow") |
| 68 | cursorProps.push(`variant="${variant}"`); |
| 69 | if (size !== undefined && size !== 28) cursorProps.push(`size={${size}}`); |
| 70 | if (rippleColor !== undefined && rippleColor !== "#171717") |
| 71 | cursorProps.push(`rippleColor="${rippleColor}"`); |
| 72 | const cursorPropsStr = cursorProps.length ? ` ${cursorProps.join(" ")}` : ""; |
| 73 | |
| 74 | return `import { Cursor } from "@/components/remocn/cursor"; |
| 75 | import { useCursorPath } from "@/components/remocn/use-cursor-path"; |
| 76 | import { Button } from "@/components/remocn/button"; |
| 77 | import { useButtonTransition } from "@/components/remocn/use-button-transition"; |
| 78 | |
| 79 | const BTN_X = 280; |
| 80 | const BTN_Y = 160; |
| 81 | |
| 82 | export const Scene = () => { |
| 83 | // The cursor is value-channel driven: useCursorPath reads the frame and |
| 84 | // returns the animated CursorStyle; <Cursor> itself stays pure. |
| 85 | const cursorStyle = useCursorPath([ |
| 86 | { at: 0, x: 80, y: 60 }, |
| 87 | { at: 40, x: BTN_X, y: BTN_Y, duration: 28 }, |
| 88 | { at: 72, x: BTN_X, y: BTN_Y, click: true, duration: 0 }, |
| 89 | ]); |
| 90 | |
| 91 | // Button timeline is frame-synced with the cursor path above. |
| 92 | const buttonStyle = useButtonTransition([ |
| 93 | { at: 40, state: "hover", duration: 16 }, |
| 94 | { at: 68, state: "press", duration: 8 }, |
| 95 | { at: 76, state: "loading", duration: 6 }, |
| 96 | { at: 108, state: "success", duration: 16 }, |
| 97 | ]); |
| 98 | |
| 99 | return ( |
| 100 | <div style={{ position: "relative", width: "100%", height: "100%" }}> |
| 101 | <div |
| 102 | style={{ |
| 103 | position: "absolute", |
| 104 | left: "50%", |
| 105 | top: "50%", |
| 106 | transform: "translate(-50%, -50%)", |
| 107 | }} |
| 108 | > |
| 109 | <Button label="Continue" style={buttonStyle} /> |
| 110 | </div> |
| 111 | <Cursor style={cursorStyle}${cursorPropsStr} /> |
| 112 | </div> |
| 113 | ); |
| 114 | };`; |
| 115 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected