perf: use animated <details> for expandables, optimize CSS animations
This commit is contained in:
12 files changed
+105
-68
No files matched your search
@@ -53,7 +53,7 @@
|
||||
class="gap-1 p-0.5 px-1 flex flex-row items-center"
|
||||
rounding="full"
|
||||
padding="none"
|
||||
color="uniform"
|
||||
color="distinct"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
{@render children?.()}
|
||||
<div class="min-h-screen flex flex-col">
|
||||
<div
|
||||
class={['shell-navbar-holder', !dockVisible && 'max-md:-bottom-24!']}
|
||||
class={['shell-navbar-holder', !dockVisible && 'auto-hidden']}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="md:hidden flex justify-between" dir="ltr">
|
||||
@@ -71,11 +71,20 @@
|
||||
|
||||
.shell-navbar-holder {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
z-index: 50;
|
||||
pointer-events: none;
|
||||
width: 100%;
|
||||
transition: bottom 0.4s cubic-bezier(0.075, 0.82, 0.165, 1);
|
||||
bottom: 0;
|
||||
|
||||
translate: 0% 0%;
|
||||
transition: translate 0.4s cubic-bezier(0.19, 1, 0.22, 1);
|
||||
will-change: translate;
|
||||
|
||||
@variant max-md {
|
||||
&.auto-hidden {
|
||||
translate: 0% 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
@variant md {
|
||||
position: sticky;
|
||||
@@ -108,7 +117,6 @@
|
||||
background-color: var(--color-zinc-950);
|
||||
border-color: var(--color-zinc-900);
|
||||
@variant md {
|
||||
background-color: --alpha(var(--color-zinc-950) / 70%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
|
||||
let matchType = $derived<('search' | 'pathname')[]>(
|
||||
routes.map((i) =>
|
||||
new URL(`https://example.com${i.href}`)?.search != '' ? 'search' : 'pathname',
|
||||
new URL(`https://example.com${i.href}`)?.search != ''
|
||||
? 'search'
|
||||
: 'pathname',
|
||||
),
|
||||
)
|
||||
|
||||
@@ -40,9 +42,9 @@
|
||||
// me on 2025/10/9: no shi buh
|
||||
const usePathname = !routes.some(
|
||||
(i) =>
|
||||
new Set(new URL(`https://example.com${i.href}`).searchParams.values()).intersection(
|
||||
currentSearch,
|
||||
).size > 0,
|
||||
new Set(
|
||||
new URL(`https://example.com${i.href}`).searchParams.values(),
|
||||
).intersection(currentSearch).size > 0,
|
||||
)
|
||||
|
||||
const hasSearchParam = hrefSearch.intersection(currentSearch).size > 0
|
||||
@@ -91,8 +93,10 @@
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
flex-wrap: wrap;
|
||||
z-index: 20;
|
||||
overflow-x: auto;
|
||||
max-width: 100%;
|
||||
flex-shrink: 0;
|
||||
|
||||
@variant sm {
|
||||
margin-top: 0;
|
||||
@@ -102,10 +106,9 @@
|
||||
.tab-bar.bar-header {
|
||||
padding: calc(var(--spacing) * 0.5);
|
||||
gap: calc(var(--spacing) * 1) calc(var(--spacing) * 1);
|
||||
justify-content: center;
|
||||
margin-top: calc(var(--spacing) * -1);
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-top: calc(var(--spacing) * -1);
|
||||
|
||||
@variant sm {
|
||||
justify-content: start;
|
||||
|
||||
@@ -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