Skip to content

fix(perf): card spread layout & safari perf#504

Merged
sudhashrestha merged 3 commits into
mainfrom
feat/card-spread-layout
Jun 12, 2026
Merged

fix(perf): card spread layout & safari perf#504
sudhashrestha merged 3 commits into
mainfrom
feat/card-spread-layout

Conversation

@sudhashrestha

@sudhashrestha sudhashrestha commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor

    • Redesigned Card Spread to a CSS-driven layout and interaction model, simplifying markup and animation control for deck vs. spread states.
  • Bug Fixes

    • Resolved Safari jitter during spread animations.
  • Documentation

    • Expanded Card Spread docs with details on hover peek, spread/deck easing, responsive grid behavior, and customization guidance.

sudhashrestha and others added 2 commits June 12, 2026 10:56
Drop React state and width animation for a checkbox-driven grid.
Stack offsets use transform; deck centers on large screens; narrow
viewports scroll horizontally. Fixes Safari jitter from width tween.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use deck calc() offsets on all breakpoints instead of absolute-to-grid
snap. Add grid min-width so narrow containers keep correct stack math.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sudhashrestha sudhashrestha requested a review from hari June 12, 2026 08:07
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploying animata with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1e11334
Status: ✅  Deploy successful!
Preview URL: https://3c882765.animata.pages.dev
Branch Preview URL: https://feat-card-spread-layout.animata.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07030557-4aeb-4632-ab5b-57ff87f53300

📥 Commits

Reviewing files that changed from the base of the PR and between 35dfc91 and 1e11334.

📒 Files selected for processing (2)
  • animata/card/card-spread.css
  • animata/card/card-spread.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • animata/card/card-spread.css
  • animata/card/card-spread.tsx

📝 Walkthrough

Walkthrough

Convert Card Spread from React-driven transforms to a CSS-first design: a checkbox toggle and :has() selectors control deck vs spread states, easing variables centralize timing, per-card transforms live in CSS, component markup is simplified, and docs are updated to document customization.

Changes

Card Spread Animation Refactoring

Layer / File(s) Summary
CSS Variables, Layout System, and Controls
animata/card/card-spread.css
Add --ease-throw/--ease-gather, update .card-spread-stage layout, implement state selectors via :has(.card-spread-toggle:checked), add .card-spread-container, hidden .card-spread-toggle, and .card-spread-open with text swap.
Animation System Setup (Stacking and Timing)
animata/card/card-spread.css
Assign per-card z-* by nth-child() and centralize transition timing on .card-spread-item__internal, switching durations between gather and throw and adding reduced-motion overrides.
Card Transform Animations (Deck and Spread States)
animata/card/card-spread.css
Define deck-state translate3d() offsets to stack toward center and spread-state translate3d()+rotate() offsets per nth-child to place cards in the four-column spread.
Hover Peek and Accessibility
animata/card/card-spread.css
Apply hover "peek" rotations only when unchecked (deck) via .card-spread-item__hover, and force minimal durations under prefers-reduced-motion.
React Component Simplification
animata/card/card-spread.tsx
Remove use client, useState, and transform/z-index computation; add cards tuple and render a checkbox-controlled wrapper mapping to simplified card-spread-item DOM nodes, delegating layout to CSS.
Documentation and Changelog Updates
content/docs/card/card-spread.mdx, content/docs/changelog/2026-06.mdx
Rewrite description and Installation/How it works/Customization sections to document CSS-first behavior, spread/deck mechanics, grid layout, and note Safari jitter fix in changelog.

Sequence Diagram

sequenceDiagram
  participant User
  participant Toggle as Checkbox Toggle
  participant CSS as :has() Selectors
  participant Layout as Card Transforms

  User->>Toggle: Click open button
  Toggle->>CSS: Toggle checked state
  CSS->>Layout: Activate spread rules (nth-child transforms + rotate)
  Layout->>Layout: Apply translate3d() and rotate()

  User->>Toggle: Hover card (deck state)
  CSS->>Layout: Apply peek rotation for hovered nth-child

  User->>Toggle: Click open button again
  Toggle->>CSS: Uncheck toggle
  CSS->>Layout: Activate deck rules (gather transforms)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • hari

Poem

🐰 I tossed the cards with CSS flair,
No state to hold, no JS to spare.
Checked or not, they spin and glide,
Eased and rotated, side to side.
A rabbit hops — the layout's neat!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: refactoring card spread from JS-driven animations to CSS-only layout with improved performance and Safari compatibility.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/card-spread-layout

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
content/docs/card/card-spread.mdx (1)

23-29: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Align the manual install path with the actual source tree.

components/animata/card doesn’t match the file locations shown below or the component source under animata/card. Update the manual instructions so users create and paste the files in the same place. Cross-checked against animata/card/card-spread.tsx and animata/card/card-spread.css.

💡 Proposed fix
-This creates `card-spread.tsx` and `card-spread.css` in `components/animata/card`.
+This creates `card-spread.tsx` and `card-spread.css` in `animata/card`.

-mkdir -p components/animata/card && touch components/animata/card/card-spread.tsx components/animata/card/card-spread.css
+mkdir -p animata/card && touch animata/card/card-spread.tsx animata/card/card-spread.css
🤖 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 `@content/docs/card/card-spread.mdx` around lines 23 - 29, The manual install
path is incorrect—update the documentation so the mkdir/touch command and the
written instructions create the files under animata/card (matching the source),
not components/animata/card; specifically change references of
components/animata/card to animata/card and ensure the command creates
animata/card/card-spread.tsx and animata/card/card-spread.css to align with the
actual files (card-spread.tsx and card-spread.css) shown and imported elsewhere.
🤖 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 `@animata/card/card-spread.css`:
- Around line 87-90: Stylelint reports a declaration-spacing error for the
transition line inside .card-spread-item__internal; fix it by adding a single
blank line immediately before the "transition: transform 520ms
var(--ease-gather);" declaration so the block has an empty line between the
`@apply` rule and the transition declaration (adjust the
.card-spread-item__internal block accordingly).

In `@animata/card/card-spread.tsx`:
- Around line 48-60: The map is using item.component.name as the React key which
can break in production when names are minified; update the cards data (the
cards tuple/array) to include a stable unique identifier property (e.g., id or
key) for each entry (for entries like Reminders, RemodelNotes and other
components), then change the render to use that stable property (e.g., item.id)
instead of item.component.name in the key attribute inside the cards.map block
so reconciliation is based on an explicit, non-minified identifier.

---

Outside diff comments:
In `@content/docs/card/card-spread.mdx`:
- Around line 23-29: The manual install path is incorrect—update the
documentation so the mkdir/touch command and the written instructions create the
files under animata/card (matching the source), not components/animata/card;
specifically change references of components/animata/card to animata/card and
ensure the command creates animata/card/card-spread.tsx and
animata/card/card-spread.css to align with the actual files (card-spread.tsx and
card-spread.css) shown and imported elsewhere.
🪄 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: 23848817-3403-43ac-a7ee-e0dcc1cd1bce

📥 Commits

Reviewing files that changed from the base of the PR and between b304337 and 35dfc91.

📒 Files selected for processing (4)
  • animata/card/card-spread.css
  • animata/card/card-spread.tsx
  • content/docs/card/card-spread.mdx
  • content/docs/changelog/2026-06.mdx

Comment thread animata/card/card-spread.css
Comment thread animata/card/card-spread.tsx
Add blank line between @apply and transition in deck motion CSS.
Use explicit card ids for React keys instead of minified names.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sudhashrestha sudhashrestha merged commit dfd68cb into main Jun 12, 2026
6 checks passed
@sudhashrestha sudhashrestha deleted the feat/card-spread-layout branch June 12, 2026 08:46
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.

2 participants