perf: use animated <details> for expandables, optimize CSS animations
This commit is contained in:
12 files changed
+105
-68
No files matched your search
@@ -188,6 +188,7 @@
|
||||
|
||||
@variant hover {
|
||||
cursor: pointer;
|
||||
transition-duration: 0s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,14 +197,22 @@
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-image: linear-gradient(to bottom, var(--color-primary-800), var(--color-primary-900));
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--color-primary-800),
|
||||
var(--color-primary-900)
|
||||
);
|
||||
box-shadow: 0px 1.5px 0px 0px var(--color-slate-500) inset;
|
||||
color: var(--color-slate-50);
|
||||
border: 1px solid var(--color-slate-900);
|
||||
|
||||
@variant dark {
|
||||
border-color: var(--color-primary-200);
|
||||
background-image: linear-gradient(to bottom, var(--color-primary-100), var(--color-primary-200));
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--color-primary-100),
|
||||
var(--color-primary-200)
|
||||
);
|
||||
color: var(--color-zinc-900);
|
||||
box-shadow: 0px 2.5px 0px -1px var(--color-white) inset;
|
||||
}
|
||||
@@ -294,7 +303,11 @@
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: linear-gradient(to bottom, var(--color-red-400), var(--color-red-500));
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
var(--color-red-400),
|
||||
var(--color-red-500)
|
||||
);
|
||||
border: 1px solid var(--color-red-700);
|
||||
box-shadow:
|
||||
0px 1.5px 0px 0px inset --alpha(var(--color-red-50) / 50%),
|
||||
@@ -302,7 +315,11 @@
|
||||
color: var(--color-white);
|
||||
|
||||
@variant dark {
|
||||
background-image: linear-gradient(to bottom, var(--color-red-300), var(--color-red-400));
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--color-red-300),
|
||||
var(--color-red-400)
|
||||
);
|
||||
color: var(--color-black);
|
||||
border-color: var(--color-red-900);
|
||||
background-clip: padding-box;
|
||||
|
||||
@@ -18,40 +18,40 @@
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
const id = $props.id()
|
||||
</script>
|
||||
|
||||
<div {...rest} class={['w-full relative', clazz]}>
|
||||
<label for={id} class="w-full">
|
||||
<details {...rest} class={['w-full relative disclosure', clazz]} bind:open>
|
||||
<summary class="discosure-summary">
|
||||
{@render summary?.({ open })}
|
||||
</label>
|
||||
</summary>
|
||||
{@render extended?.()}
|
||||
<input
|
||||
{id}
|
||||
class="appearance-none absolute w-full h-full inset-0 pointer-events-none"
|
||||
type="checkbox"
|
||||
bind:checked={open}
|
||||
/>
|
||||
<div class="expand" inert={!open}>
|
||||
<div class="expand">
|
||||
{@render children?.({ open })}
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<style>
|
||||
.expand {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
grid-template-columns: 100%;
|
||||
.disclosure {
|
||||
interpolate-size: allow-keywords;
|
||||
will-change: height;
|
||||
}
|
||||
|
||||
.disclosure::details-content {
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
overflow: hidden;
|
||||
transition: grid-template-rows 0.5s cubic-bezier(0.19, 1, 0.22, 1);
|
||||
transition:
|
||||
height 0.5s cubic-bezier(0.19, 1, 0.22, 1),
|
||||
opacity 0.5s cubic-bezier(0.19, 1, 0.22, 1),
|
||||
content-visibility 0.4s allow-discrete;
|
||||
}
|
||||
|
||||
input:checked + .expand {
|
||||
grid-template-rows: 1fr;
|
||||
.disclosure[open]::details-content {
|
||||
height: auto;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.expand > :global(*) {
|
||||
min-height: 0;
|
||||
summary {
|
||||
list-style: none;
|
||||
}
|
||||
</style>
|
||||
@@ -189,6 +189,7 @@
|
||||
border-radius: var(--radius-xl);
|
||||
font-size: var(--text-sm);
|
||||
z-index: 10;
|
||||
width: 100%;
|
||||
|
||||
@variant disabled {
|
||||
background: var(--color-slate-100);
|
||||
|
||||
@@ -134,7 +134,11 @@
|
||||
}
|
||||
|
||||
.material-distinct {
|
||||
background-image: linear-gradient(to bottom, var(--color-white), var(--color-slate-50));
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--color-white),
|
||||
var(--color-slate-50)
|
||||
);
|
||||
border: 1px solid var(--color-slate-200);
|
||||
box-shadow: 0px -2px 0px -1px --alpha(var(--color-slate-200) / 90%) inset;
|
||||
background-clip: padding-box;
|
||||
@@ -167,9 +171,11 @@
|
||||
.material-uniform {
|
||||
border-width: 1px;
|
||||
border-color: var(--color-slate-200);
|
||||
background-color: var(--color-slate-50);
|
||||
|
||||
@variant dark {
|
||||
border-color: var(--color-zinc-900);
|
||||
background-color: var(--color-zinc-950);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user