-
Notifications
You must be signed in to change notification settings - Fork 227
fix(perf): card spread layout & safari perf #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,187 @@ | ||
| @reference "../../styles/globals.css"; | ||
|
|
||
| @layer components { | ||
| .card-spread-stage { | ||
| /* Quick throw, soft settle — expand on click only */ | ||
| .card-spread { | ||
| --ease-throw: cubic-bezier(0.22, 1.18, 0.36, 1); | ||
| --ease-gather: cubic-bezier(0.33, 1, 0.68, 1); | ||
| } | ||
|
|
||
| .card-spread-stage { | ||
| /* | ||
| * overflow-x: auto forces overflow-y: auto — pad vertically so spread | ||
| * tilt and hover peek are not clipped. | ||
| */ | ||
| @apply w-full px-4 py-8; | ||
| } | ||
|
|
||
| /* Deck: center the wide grid, clip sides — stack sits at grid center (col 1.5). */ | ||
| .card-spread:not(:has(.card-spread-toggle:checked)) .card-spread-stage { | ||
| @apply flex items-end justify-center overflow-x-hidden; | ||
| } | ||
|
|
||
| /* Spread: horizontal scroll when needed; center the row when it fits. */ | ||
| .card-spread:has(.card-spread-toggle:checked) .card-spread-stage { | ||
| @apply overflow-x-auto overscroll-x-contain; | ||
| } | ||
|
|
||
| @media (min-width: 64rem) { | ||
| .card-spread:has(.card-spread-toggle:checked) .card-spread-stage { | ||
| @apply flex items-end justify-center; | ||
| } | ||
| } | ||
|
|
||
| .card-spread-container { | ||
| --card-gap: 0.75rem; | ||
| /* 4× w-48 + 3× gap-3 — never shrink or deck offsets miss grid tracks */ | ||
| @apply grid w-fit min-w-[calc(4*12rem+3*0.75rem)] shrink-0 grid-cols-4 gap-3; | ||
| } | ||
|
|
||
| .card-spread-toggle { | ||
| @apply sr-only; | ||
| } | ||
|
|
||
| .card-spread-motion--expand { | ||
| .card-spread-open { | ||
| @apply relative inline-flex cursor-pointer items-center rounded-full border border-border bg-background px-3.5 py-1.5 text-sm font-medium text-foreground transition-colors select-none; | ||
| } | ||
|
|
||
| .card-spread-open:hover { | ||
| @apply bg-accent/10; | ||
| } | ||
|
|
||
| .card-spread-open:has(.card-spread-toggle:focus-visible) { | ||
| @apply outline-2 outline-[#ffcc00] outline-offset-2; | ||
| } | ||
|
|
||
| .card-spread-open__text--collapse { | ||
| @apply hidden; | ||
| } | ||
|
|
||
| .card-spread:has(.card-spread-toggle:checked) .card-spread-open__text--expand { | ||
| @apply hidden; | ||
| } | ||
|
|
||
| .card-spread:has(.card-spread-toggle:checked) .card-spread-open__text--collapse { | ||
| @apply inline; | ||
| } | ||
|
|
||
| .card-spread-item { | ||
| @apply origin-bottom; | ||
| } | ||
|
|
||
| .card-spread-item:nth-child(1) { | ||
| @apply z-10; | ||
| } | ||
|
|
||
| .card-spread-item:nth-child(2) { | ||
| @apply z-20; | ||
| } | ||
|
|
||
| .card-spread-item:nth-child(3) { | ||
| @apply z-30; | ||
| } | ||
|
|
||
| .card-spread-item:nth-child(4) { | ||
| @apply z-40; | ||
| } | ||
|
|
||
| .card-spread-item__internal { | ||
| @apply origin-bottom motion-reduce:transition-none; | ||
|
|
||
| transition: transform 520ms var(--ease-gather); | ||
| } | ||
|
|
||
| .card-spread:has(.card-spread-toggle:checked) .card-spread-item__internal { | ||
| transition: transform 480ms var(--ease-throw); | ||
| } | ||
|
|
||
| .card-spread-motion--collapse { | ||
| transition: transform 520ms cubic-bezier(0.33, 1, 0.68, 1); | ||
| /* | ||
| * Deck — 1×4 grid, pull each card toward col 1.5 via transform. | ||
| * Same explicit calc() on all breakpoints so spread animates on mobile too. | ||
| */ | ||
| .card-spread:not(:has(.card-spread-toggle:checked)) .card-spread-item:nth-child(1) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(calc(150% + 1.125rem), 0, 0); | ||
| } | ||
|
|
||
| .card-spread:not(:has(.card-spread-toggle:checked)) | ||
| .card-spread-item:nth-child(2) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(calc(50% + 0.375rem), 0, 0); | ||
| } | ||
|
|
||
| .card-spread:not(:has(.card-spread-toggle:checked)) | ||
| .card-spread-item:nth-child(3) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(calc(-50% - 0.375rem), 0, 0); | ||
| } | ||
|
|
||
| .card-spread:not(:has(.card-spread-toggle:checked)) | ||
| .card-spread-item:nth-child(4) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(calc(-150% - 1.125rem), 0, 0); | ||
| } | ||
|
|
||
| /* Spread — layout slots, light rotation */ | ||
| .card-spread:has(.card-spread-toggle:checked) .card-spread-item:nth-child(1) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(0, 0, 0) rotate(-2deg); | ||
| } | ||
|
|
||
| .card-spread:has(.card-spread-toggle:checked) | ||
| .card-spread-item:nth-child(2) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(0, 0.5rem, 0) rotate(3deg); | ||
| } | ||
|
|
||
| .card-spread:has(.card-spread-toggle:checked) | ||
| .card-spread-item:nth-child(3) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(0.25rem, 0, 0) rotate(-2deg); | ||
| } | ||
|
|
||
| .card-spread:has(.card-spread-toggle:checked) | ||
| .card-spread-item:nth-child(4) | ||
| .card-spread-item__internal { | ||
| transform: translate3d(0, 0, 0) rotate(2deg); | ||
| } | ||
|
|
||
| /* Hover peek — deck only */ | ||
| .card-spread-item__hover { | ||
| @apply origin-bottom transition-transform duration-300 ease-out motion-reduce:transition-none; | ||
| } | ||
|
|
||
| .card-spread:not(:has(.card-spread-toggle:checked)) | ||
| .card-spread-stage:hover | ||
| .card-spread-item:nth-child(1) | ||
| .card-spread-item__hover { | ||
| @apply -rotate-1; | ||
| } | ||
|
|
||
| .card-spread:not(:has(.card-spread-toggle:checked)) | ||
| .card-spread-stage:hover | ||
| .card-spread-item:nth-child(2) | ||
| .card-spread-item__hover { | ||
| @apply -rotate-2; | ||
| } | ||
|
|
||
| .card-spread-stage--expand { | ||
| transition: width 480ms var(--ease-throw); | ||
| .card-spread:not(:has(.card-spread-toggle:checked)) | ||
| .card-spread-stage:hover | ||
| .card-spread-item:nth-child(3) | ||
| .card-spread-item__hover { | ||
| @apply rotate-1; | ||
| } | ||
|
|
||
| .card-spread-stage--collapse { | ||
| transition: width 520ms cubic-bezier(0.33, 1, 0.68, 1); | ||
| .card-spread:not(:has(.card-spread-toggle:checked)) | ||
| .card-spread-stage:hover | ||
| .card-spread-item:nth-child(4) | ||
| .card-spread-item__hover { | ||
| @apply rotate-2; | ||
| } | ||
|
|
||
| @media (prefers-reduced-motion: reduce) { | ||
| .card-spread-motion--expand, | ||
| .card-spread-motion--collapse, | ||
| .card-spread-stage--expand, | ||
| .card-spread-stage--collapse { | ||
| transition-duration: 0.01ms !important; | ||
| .card-spread-item__internal, | ||
| .card-spread-item__hover { | ||
| @apply !duration-[0.01ms]; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.