FAQ: animate answers open and closed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fb239a97cb
commit
87ff1c477f
2 files changed
+21
-1
No files matched your search
@@ -509,6 +509,26 @@ @layer components {
|
||||
.legal-content td {
|
||||
@apply border border-neutral-300 px-3 py-2;
|
||||
}
|
||||
|
||||
/* FAQ answers slide open/closed. ::details-content and interpolate-size
|
||||
(animating to height: auto) have no utility; browsers without them just
|
||||
open instantly. User-triggered, so the height change doesn't count
|
||||
toward CLS. */
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.faq-item {
|
||||
interpolate-size: allow-keywords;
|
||||
}
|
||||
|
||||
.faq-item::details-content {
|
||||
block-size: 0;
|
||||
overflow-y: clip;
|
||||
transition: block-size 0.3s ease, content-visibility 0.3s allow-discrete;
|
||||
}
|
||||
|
||||
.faq-item[open]::details-content {
|
||||
block-size: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes text-dance {
|
||||
|
||||
@@ -72,7 +72,7 @@ class="w-full h-auto lg:sticky lg:top-42"
|
||||
@foreach ($section->items as $faq)
|
||||
@php $number++; @endphp
|
||||
|
||||
<details id="{{ $faq->slug }}" class="group scroll-mt-28">
|
||||
<details id="{{ $faq->slug }}" class="faq-item group scroll-mt-28">
|
||||
<summary class="flex cursor-pointer list-none items-center gap-4 border-b border-transparent py-4 font-display text-2xl font-bold group-open:border-black [&::-webkit-details-marker]:hidden">
|
||||
<span class="w-8 shrink-0 tabular-nums" aria-hidden="true">{{ str_pad($number, 2, '0', STR_PAD_LEFT) }}</span>
|
||||
<span class="flex-1" data-stoic="faqs/{{ $faq->slug }}#name">{{ $faq->name }}</span>
|
||||
|
||||
Reference in new issue
Block a user