(p: TooltipExampleProps = {})
| 22 | } |
| 23 | |
| 24 | export const TooltipExampleScene = (p: TooltipExampleProps = {}) => { |
| 25 | // Cursor: park top-left → ease onto button (arrives 28) → hover → |
| 26 | // move away at frame 90 (arrives 110). |
| 27 | const cursorStyle = useCursorPath([ |
| 28 | { at: 0, x: 80, y: 60 }, |
| 29 | { at: 28, x: BTN_X, y: BTN_Y, duration: 24 }, |
| 30 | { at: 110, x: AWAY_X, y: AWAY_Y, duration: 20 }, |
| 31 | ]); |
| 32 | |
| 33 | // Button: idle → hover as cursor arrives, back to idle as cursor leaves. |
| 34 | const buttonStyle = useButtonTransition([ |
| 35 | { at: 28, state: "hover", duration: 8 }, |
| 36 | { at: 100, state: "idle", duration: 8 }, |
| 37 | ]); |
| 38 | |
| 39 | // Tooltip: fades in shortly after cursor arrives, fades out as cursor leaves. |
| 40 | const tooltipStyle = useTooltipTransition([ |
| 41 | { at: 36, state: "visible", duration: 8 }, |
| 42 | { at: 100, state: "hidden", duration: 8 }, |
| 43 | ]); |
| 44 | |
| 45 | return ( |
| 46 | <div style={{ position: "relative", width: "100%", height: "100%" }}> |
| 47 | {/* Anchor — the button is centered in the canvas. */} |
| 48 | <div |
| 49 | style={{ |
| 50 | width: "100%", |
| 51 | position: "absolute", |
| 52 | left: "50%", |
| 53 | top: "50%", |
| 54 | transform: "translate(-50%, -50%)", |
| 55 | }} |
| 56 | > |
| 57 | <Button label="Hover me" style={buttonStyle} /> |
| 58 | |
| 59 | {/* Tooltip is anchored relative to the button: centered above it. */} |
| 60 | <div |
| 61 | style={{ |
| 62 | position: "absolute", |
| 63 | bottom: "calc(100% + 32px)", |
| 64 | left: "50%", |
| 65 | transform: "translateX(-50%)", |
| 66 | }} |
| 67 | > |
| 68 | <Tooltip |
| 69 | label={p.label ?? "Add to library"} |
| 70 | side="top" |
| 71 | style={tooltipStyle} |
| 72 | /> |
| 73 | </div> |
| 74 | </div> |
| 75 | |
| 76 | <Cursor style={cursorStyle} variant="pointer" /> |
| 77 | </div> |
| 78 | ); |
| 79 | }; |
| 80 | |
| 81 | export const tooltipExampleCode = ( |
nothing calls this directly
no test coverage detected