Repository navigation
feat(registry): add hero-flow-field scroll-driven generative streamline block - #75
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughAdds FlowFieldHero: a new scroll-reactive canvas flow-field background (FlowFieldBackground) plus a full-viewport hero wrapper (FlowFieldHero) with default motion-animated content, and integrates the block into demos, component config, and registry/manifests. ChangesFlow Field Hero Component
Sequence DiagramsequenceDiagram
participant User as Page (scroll)
participant Scroll as ScrollListener
participant RAF as requestAnimationFrame loop
participant Canvas as FlowFieldBackground (canvas)
participant Reduce as useReducedMotion
User->>Scroll: window.scrollY changes
Scroll->>RAF: update target scroll (smoothed)
Reduce->>Reduce: check prefers-reduced-motion
alt Motion enabled
RAF->>Canvas: interpolate phase from smoothed scroll + idle drift
Canvas->>Canvas: compute streamline angles & draw streamlines + head particles
RAF->>RAF: schedule next frame
else Motion disabled
Reduce->>Canvas: render single static frame anchored to current scroll
end
🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
registry/blocks/hero/flow-field/component.tsx (1)
7-25: 💤 Low valueConsider exporting
FlowFieldBackgroundPropsandFlowFieldHeroPropstypes.Consumers who want to type their props (e.g., when building wrappers or storing config objects) cannot reference these types. Since
backgroundPropsexposesFlowFieldBackgroundPropsin the public API, exporting both improves DX.♻️ Proposed fix
-type FlowFieldBackgroundProps = { +export type FlowFieldBackgroundProps = {-type FlowFieldHeroProps = Omit<ComponentProps<"section">, "children"> & { +export type FlowFieldHeroProps = Omit<ComponentProps<"section">, "children"> & {Also applies to: 161-164
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@registry/blocks/hero/flow-field/component.tsx` around lines 7 - 25, The FlowFieldBackgroundProps and FlowFieldHeroProps types are currently internal; export both type declarations so downstream consumers can import them (e.g., for typing wrappers or config objects). Locate the type declarations named FlowFieldBackgroundProps and FlowFieldHeroProps in component.tsx and add exports (export type FlowFieldBackgroundProps = ... and export type FlowFieldHeroProps = ...) so they become part of the public API while leaving the implementations unchanged.registry/manifest.json (1)
68-68: ⚡ Quick winInconsistent grouping:
magnetic-textbreaks thehero-*component group.In the
orderarray,magnetic-text(line 68) is placed betweenhero-terminalandhero-flow-field, interrupting thehero-*component grouping pattern (lines 61-69). However, in thedocsOrderarray,magnetic-textappears at line 86, well before thehero-*group (lines 128-135).For consistency and maintainability,
magnetic-textshould be positioned outside thehero-*group in both arrays.♻️ Proposed fix to align grouping across arrays
"hero-magnetic-letters", "hero-terminal", - "magnetic-text", "hero-flow-field"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@registry/manifest.json` at line 68, The manifest's ordering is inconsistent: the "magnetic-text" entry currently interrupts the hero-* group in the order array (sitting between "hero-terminal" and "hero-flow-field") but is placed before the hero group in docsOrder; move the "magnetic-text" entry so it is located outside and consistently positioned relative to all "hero-*" entries in both arrays (order and docsOrder), ensuring the hero-* block remains contiguous (e.g., place magnetic-text before or after the entire hero-* block in both arrays).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/www/public/registry.json`:
- Line 4044: The FlowFieldBackground component uses the spacing prop directly
which can be <=0 or non-finite and break the render loop; before any grid math
(e.g., where cols/rows and step are computed in render and where spacing is used
elsewhere), validate and clamp spacing to a sensible positive finite value
(e.g., fallback to the existing default like 56 or a small minimum such as 8) so
downstream math in render, cols/rows, and loop stepping is always safe; update
references to spacing inside FlowFieldBackground (including render and any
derived vars like step/stepLen) to use the validated/clamped value.
In `@registry.json`:
- Line 4044: The render loop can lock up if spacing is 0/NaN/Infinity because
cols/rows are computed directly from the spacing prop; before using spacing
inside FlowFieldBackground (e.g., in render and variables cols/rows), normalize
it to a positive finite value (clamp or fallback) — for example compute a local
seedSpacing = Number.isFinite(spacing) && spacing > 0 ? spacing : 56 — and use
seedSpacing everywhere (cols, rows, step, stepLen) so the nested loops always
iterate a safe finite number of times.
- Line 4044: The reduced-motion path renders once but the resize() handler
doesn't redraw the canvas for reduced users; update the resize function (inside
the useEffect) to trigger a render when reduced is true — e.g., after setting
canvas.width/height and ctx.setTransform(...) call render(scroll * 0.0015 *
scrollStrength) (using the existing render, scroll and scrollStrength symbols)
so the canvas is repainted after container/viewport resizes; keep the existing
ResizeObserver (ro) and cleanup.
In `@registry/blocks/hero/flow-field/component.tsx`:
- Around line 223-238: The two button elements in
registry/blocks/hero/flow-field/component.tsx (the "Get started" button using
the class string starting with "group inline-flex..." and the "View source"
button using the class string starting with "inline-flex...") lack explicit
focus-visible styles; add consistent keyboard focus styles to both by appending
utility classes such as focus-visible:outline-none plus a visible ring (e.g.
focus-visible:ring-2, focus-visible:ring-offset-2, and a suitable color like
focus-visible:ring-white/40 or similar) so keyboard users get a clear,
consistent focus indicator that matches the existing hover/visual design.
---
Nitpick comments:
In `@registry/blocks/hero/flow-field/component.tsx`:
- Around line 7-25: The FlowFieldBackgroundProps and FlowFieldHeroProps types
are currently internal; export both type declarations so downstream consumers
can import them (e.g., for typing wrappers or config objects). Locate the type
declarations named FlowFieldBackgroundProps and FlowFieldHeroProps in
component.tsx and add exports (export type FlowFieldBackgroundProps = ... and
export type FlowFieldHeroProps = ...) so they become part of the public API
while leaving the implementations unchanged.
In `@registry/manifest.json`:
- Line 68: The manifest's ordering is inconsistent: the "magnetic-text" entry
currently interrupts the hero-* group in the order array (sitting between
"hero-terminal" and "hero-flow-field") but is placed before the hero group in
docsOrder; move the "magnetic-text" entry so it is located outside and
consistently positioned relative to all "hero-*" entries in both arrays (order
and docsOrder), ensuring the hero-* block remains contiguous (e.g., place
magnetic-text before or after the entire hero-* block in both arrays).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7e1ae295-bbca-40d7-8753-d585f55b76c4
📒 Files selected for processing (18)
apps/www/components/ui/hero-flow-field.tsxapps/www/config/components.tsapps/www/config/demos.tsxapps/www/config/docs-scenarios.tsapps/www/public/r/hero-flow-field.jsonapps/www/public/r/registry.jsonapps/www/public/registry.jsonapps/www/public/registry/changelogs.jsonapps/www/public/registry/hero-flow-field.jsonapps/www/public/registry/index.jsonapps/www/public/registry/particle-field.jsonregistry.jsonregistry/blocks/hero/flow-field/component.tsxregistry/blocks/hero/flow-field/demo.tsxregistry/components/hero-flow-field.jsonregistry/demos/demo-key-order.jsonregistry/demos/shared.tsxregistry/manifest.json
| <button | ||
| type="button" | ||
| className="group inline-flex h-11 items-center gap-2 rounded-full bg-white px-6 text-sm font-medium text-black transition-transform duration-200 hover:-translate-y-px" | ||
| > | ||
| <span>Get started</span> | ||
| <span aria-hidden className="transition-transform duration-200 group-hover:translate-x-0.5"> | ||
| → | ||
| </span> | ||
| </button> | ||
| <button | ||
| type="button" | ||
| className="inline-flex h-11 items-center gap-2 rounded-full border border-white/15 px-6 font-mono text-xs uppercase tracking-[0.18em] text-white/85 backdrop-blur transition-colors hover:bg-white/5" | ||
| > | ||
| View source | ||
| </button> | ||
| </motion.div> |
There was a problem hiding this comment.
Add focus-visible styles for keyboard accessibility.
Both buttons rely on the browser's default focus ring. Adding explicit focus-visible styles ensures consistent visibility across browsers and matches the existing hover styling.
♿ Proposed fix
<button
type="button"
- className="group inline-flex h-11 items-center gap-2 rounded-full bg-white px-6 text-sm font-medium text-black transition-transform duration-200 hover:-translate-y-px"
+ className="group inline-flex h-11 items-center gap-2 rounded-full bg-white px-6 text-sm font-medium text-black transition-transform duration-200 hover:-translate-y-px focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-[`#06070a`]"
>
<span>Get started</span>
<span aria-hidden className="transition-transform duration-200 group-hover:translate-x-0.5">
→
</span>
</button>
<button
type="button"
- className="inline-flex h-11 items-center gap-2 rounded-full border border-white/15 px-6 font-mono text-xs uppercase tracking-[0.18em] text-white/85 backdrop-blur transition-colors hover:bg-white/5"
+ className="inline-flex h-11 items-center gap-2 rounded-full border border-white/15 px-6 font-mono text-xs uppercase tracking-[0.18em] text-white/85 backdrop-blur transition-colors hover:bg-white/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-300 focus-visible:ring-offset-2 focus-visible:ring-offset-[`#06070a`]"
>
View source
</button>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@registry/blocks/hero/flow-field/component.tsx` around lines 223 - 238, The
two button elements in registry/blocks/hero/flow-field/component.tsx (the "Get
started" button using the class string starting with "group inline-flex..." and
the "View source" button using the class string starting with "inline-flex...")
lack explicit focus-visible styles; add consistent keyboard focus styles to both
by appending utility classes such as focus-visible:outline-none plus a visible
ring (e.g. focus-visible:ring-2, focus-visible:ring-offset-2, and a suitable
color like focus-visible:ring-white/40 or similar) so keyboard users get a
clear, consistent focus indicator that matches the existing hover/visual design.
|
Addressed all CodeRabbit findings in f6474b4:
Edits made on the source of truth ( |
Type
Summary
Builds backlog section F — the last unbuilt hero idea (#6). A
<canvas>flow field of streamlines whose phase is driven bywindow.scrollY, so the lines bend and wave as the page scrolls, with a glowing particle at each streamline head. Scroll-driven (not cursor-driven) and pure summed-sine generative — distinct from the cursor-drivenparticle-field/noise-dot-fieldand the gradient-mesh family.Screenshots / video (UI changes only)
Canvas/scroll-driven — not capturable as a static frame. Behavior: streamlines reflow as
window.scrollYchanges; idle drift keeps it alive at rest;prefers-reduced-motionrenders a single static frame (no rAF, no scroll listener).Test plan
pnpm test(66 repo + 92 www tests pass)pnpm build:registry— diff limited tohero-flow-field+ aggregates + expected ADR-0004 cross-link recompute (particle-fieldvia sharedfieldtag)pnpm registry:validate(64 entries) ·pnpm check:reduced-motion(covered)pnpm --dir apps/www build(docs site builds clean) ·tsc --noEmit·eslintNew component checklist
Registry sources
registry/blocks/hero/flow-field/component.tsxcreatedregistry/components/hero-flow-field.jsoncreated —registryblock +docsblock (name, description, category, props)orderanddocsOrderinregistry/manifest.json(viapnpm new:component)registry/blocks/hero/flow-field/demo.tsxadded + key appended toregistry/demos/demo-key-order.json;FlowFieldHeroimport added toregistry/demos/shared.tsxpnpm build:registryrun — no unexpectedgit diffin generated dirsComponent quality gate
"use client"at top (usesuseEffect/useRef/canvas)classNameand merges viacnOmit<ComponentProps<"section">, "children">)motionfrommotion/react; entrance usestype: "spring"useReducedMotion— static frame, no rAF/scroll animationResizeObserver, and scroll listener all cancelled/disconnected on unmountwindow/documentat module scope;getContextnull-guardedaria-hidden; CTAs are real<button>sdependencies(motion,clsx,tailwind-merge)apps/www/tests/blocks.test.tsx(auto-includes registered demos)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation & Demos