(
values: Record<string, unknown> = {},
)
| 57 | </div> |
| 58 | <Cursor style={cursorStyle} variant="pointer" /> |
| 59 | </div> |
| 60 | ); |
| 61 | }; |
| 62 | |
| 63 | export const sliderExampleCode = ( |
| 64 | values: Record<string, unknown> = {}, |
| 65 | ): string => { |
| 66 | const showValue = values.showValue as boolean | undefined; |
| 67 | |
| 68 | const props: string[] = []; |
| 69 | if (showValue !== undefined && showValue !== true) |
| 70 | props.push(`showValue={${showValue}}`); |
| 71 | |
| 72 | const sliderPropsStr = props.length ? ` ${props.join(" ")}` : ""; |
| 73 | return `import { Cursor } from "@/components/remocn/cursor"; |
| 74 | import { useCursorPath } from "@/components/remocn/use-cursor-path"; |
| 75 | import { Slider } from "@/components/remocn/slider"; |
| 76 | import { useSliderTransition } from "@/components/remocn/use-slider-transition"; |
| 77 | |
| 78 | // Track is 320px wide, centered on the canvas. |
| 79 | // Adjust these to match your canvas dimensions and slider position. |
| 80 | const THUMB_START_X = 544; // canvas x at value 20 |
| 81 | const THUMB_END_X = 736; // canvas x at value 80 |
| 82 | const THUMB_Y = 360; // canvas y of track center |
| 83 | |
| 84 | export const Scene = () => { |
| 85 | // Cursor eases to the thumb, holds press, drags to the right, then releases. |
| 86 | const cursorStyle = useCursorPath([ |
| 87 | { at: 0, x: 80, y: 60 }, |
| 88 | { at: 30, x: THUMB_START_X, y: THUMB_Y, duration: 26 }, |
| 89 | { at: 44, x: THUMB_START_X, y: THUMB_Y, press: true, duration: 0 }, |
| 90 | { at: 100, x: THUMB_END_X, y: THUMB_Y, press: true, duration: 56 }, |
| 91 | { at: 108, x: THUMB_END_X, y: THUMB_Y, duration: 0 }, |
| 92 | ]); |
| 93 | |
| 94 | // Slider dual-channel: value eases 20 → 80 in sync with the cursor drag; |
| 95 | // thumb visual transitions idle → hover → press → idle. |
| 96 | const sliderStyle = useSliderTransition([ |
| 97 | { at: 0, value: 20, thumbState: "idle" }, |
| 98 | { at: 30, thumbState: "hover", duration: 8 }, |
| 99 | { at: 44, thumbState: "press", duration: 6 }, |
| 100 | { at: 44, value: 20 }, |
| 101 | // Match the cursor's default inOut easing so the thumb tracks the cursor exactly. |
| 102 | { at: 100, value: 80, duration: 56, easing: "inOut" }, |
| 103 | { at: 108, thumbState: "idle", duration: 8 }, |
| 104 | ]); |
| 105 | |
| 106 | return ( |
| 107 | <div style={{ position: "relative", width: "100%", height: "100%" }}> |
| 108 | <div |
| 109 | style={{ |
| 110 | position: "absolute", |
| 111 | left: "50%", |
| 112 | top: "50%", |
| 113 | transform: "translate(-50%, -50%)", |
| 114 | }} |
| 115 | > |
| 116 | <Slider style={sliderStyle} width={320}${sliderPropsStr} /> |
nothing calls this directly
no outgoing calls
no test coverage detected