Skip to content

feat: OnboardingArrow component for ligretto onboarding flow#595

Merged
Themezv merged 6 commits into
masterfrom
feat/onboarding-arrow
Apr 24, 2026
Merged

feat: OnboardingArrow component for ligretto onboarding flow#595
Themezv merged 6 commits into
masterfrom
feat/onboarding-arrow

Conversation

@memebattle-dev
Copy link
Copy Markdown
Contributor

@memebattle-dev memebattle-dev commented Apr 10, 2026

Summary

Adds the OnboardingArrow component that dynamically draws hand-drawn curved SVG arrows between two DOM elements in the Ligretto onboarding flow. Shape is fully configurable via a builder function — the caller decides what curve to draw.

  • Dynamic positioning — accepts from / to refs, tracks their position via ResizeObserver. Renders as position: absolute inside its container, so scroll moves the arrow with the layout instead of triggering recalculation
  • Auto-anchors — when fromAnchor / toAnchor are omitted, each side picks the edge center closest to the other element (shortest-distance connection)
  • Function-based shape APIpath prop is an OnboardingArrowPathBuilder function. Five presets are shipped as importable functions (arcPath, sCurvePath, lassoPath, spiralPath, wavePath), and consumers can pass their own custom builder for one-off shapes
  • Hand-drawn look — SVG feTurbulence + feDisplacementMap filter displaces the stroke into a wobbly sketchy line. No external library (rough.js etc.). roughness, bowing, seed control the jitter; seed is derived from useId so the wobble stays stable across re-renders
  • Stroked chevron arrowhead — open two-line marker, not a filled triangle

API

import { OnboardingArrow, arcPath, sCurvePath } from '#shared/ui/OnboardingArrow'

<OnboardingArrow
  from={deckRef}
  to={playgroundRef}
  path={sCurvePath}         // any OnboardingArrowPathBuilder; default arcPath
  fromAnchor={undefined}    // auto-pick closest edge if omitted
  toAnchor={undefined}
  curvature={0.4}           // 0..1, how far the curve bows off the chord
  twist={1}                 // signed; magnitude scales secondary controls, sign flips side
  roughness={1}             // sketch displacement amount
  bowing={1}                // sketch wobble frequency
  seed={undefined}          // stable jitter seed; defaults to a hash of useId
  strokeWidth={2.5}
  color="white"
/>

Custom shape via function

const heart: OnboardingArrowPathBuilder = ({ from, to, chord, normal, tangent }) => {
  // return any SVG path `d` string
}

<OnboardingArrow from={a} to={b} path={heart} />

Container requirement

The component must be rendered inside a position: relative (or otherwise positioned) container that also contains the from / to elements. All anchor coordinates are computed relative to that container, which is why scrolling doesn't require a recalculation.

Files

File Description
OnboardingArrow.tsx Component: container wrapper + SVG + sketch filter + chevron marker
buildPath.ts Pure path builders (arcPath, sCurvePath, lassoPath, spiralPath, wavePath), PathBuilderArgs, computeGeometry
useElementAnchorPoints.ts Hook: ResizeObserver-driven anchor tracking, container-relative coords, auto-anchor fallback
index.ts Named exports (component + types + preset functions)
OnboardingArrow.stories.tsx CSF3 stories: one per preset, CustomBuilder, AutoAnchors, MultipleArrows, Playground with live controls

What's next

  • Wire into OnboardingPage.tsx with correct from/to targets per Figma layout
  • Tune curvature / twist per onboarding step to match Figma silhouettes (Vector 5 1064:209, Vector 6 1077:741, Vector 7 1077:742)

Closes #594

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2026

Storybook

Comment thread apps/ligretto-frontend/src/shared/ui/OnboardingArrow/OnboardingArrow.tsx Outdated
Comment thread apps/ligretto-frontend/src/shared/ui/OnboardingArrow/OnboardingArrow.tsx Outdated
Comment thread apps/ligretto-frontend/src/shared/ui/OnboardingArrow/OnboardingArrow.tsx Outdated
Comment thread apps/ligretto-frontend/src/shared/ui/OnboardingArrow/OnboardingArrow.tsx Outdated
Comment thread apps/ligretto-frontend/src/shared/ui/OnboardingArrow/useElementAnchorPoints.ts Outdated
Comment thread apps/ligretto-frontend/src/shared/ui/OnboardingArrow/OnboardingArrow.tsx Outdated
memebattle-dev and others added 5 commits April 24, 2026 15:15
Implements dynamic SVG arrows that visually connect two DOM elements.
Arrows recompute on resize and scroll via ResizeObserver.

- useElementAnchorPoints: hook tracking viewport-relative anchor points
  of two refs (ResizeObserver + scroll/resize listeners)
- OnboardingArrow: position:fixed SVG overlay with arc and loop variants,
  bezier paths computed from live anchor points, arrowhead via SVG marker
- 8 Storybook stories covering arc/loop, anchor variants, custom color,
  multiple arrows, and interactive playground

Closes #594

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace fixed arc/loop variants with five tunable presets (arc, sCurve,
lasso, spiral, wave) plus a function-based shape API for one-off curves.
Hand-drawn look comes from an feTurbulence + feDisplacementMap filter,
with roughness/bowing/seed knobs for stable jitter.

Stories ported to CSF3 (Meta/StoryObj) with one story per preset, a
CustomBuilder demo, and a Playground with live controls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Switch from position:fixed to position:absolute inside a container div,
  so scroll no longer triggers recalculation
- Compute anchor coords relative to the arrow's container rather than the
  viewport; drop the scroll listener
- Auto-pick closest edge anchor on each side when fromAnchor/toAnchor are
  omitted (shortest-distance defaults)
- Replace the 'shape' string-union prop with a 'path' builder-function prop;
  preset names dropped, preset functions still exported for direct use
- Replace filled-triangle arrowhead marker with a stroked open-chevron
- Drop the ':' strip from useId — not needed in React 19
- Remove className prop

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…efaults

Smaller chevron marker (6×6 vs 10×10). Reframe roughness/bowing as a 0..N
scale with sensible default 1: roughness now multiplies to 6 px max
displacement, bowing multiplies to a 0.02 baseFrequency — the previous
default expressed as a natural "1".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Themezv Themezv merged commit 05c0f52 into master Apr 24, 2026
7 checks passed
@Themezv Themezv deleted the feat/onboarding-arrow branch April 24, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement OnboardingArrow component for onboarding flow

2 participants