perf: use animated <details> for expandables, optimize CSS animations
This commit is contained in:
12 files changed
+105
-68
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "2.3.0",
|
"version": "2.4.0",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/android": "^8.4.2",
|
"@capacitor/android": "^8.4.2",
|
||||||
|
|||||||
@@ -82,6 +82,10 @@
|
|||||||
--font-sans: sans-serif;
|
--font-sans: sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
interpolate-size: allow-keywords;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@apply bg-slate-50 text-slate-900 dark:bg-zinc-950 dark:text-zinc-100 accent-slate-950 dark:accent-zinc-50;
|
@apply bg-slate-50 text-slate-900 dark:bg-zinc-950 dark:text-zinc-100 accent-slate-950 dark:accent-zinc-50;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,15 +116,15 @@
|
|||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<li
|
<details
|
||||||
class={['py-3 relative', clazz]}
|
class={['py-3 relative comment', clazz]}
|
||||||
id={node.comment_view.comment.id.toString()}
|
id={node.comment_view.comment.id.toString()}
|
||||||
|
bind:open
|
||||||
>
|
>
|
||||||
{#if meta}
|
{#if meta}
|
||||||
{@const creatorIsOp =
|
{@const creatorIsOp =
|
||||||
node.comment_view.creator.id == node.comment_view.post.creator_id}
|
node.comment_view.creator.id == node.comment_view.post.creator_id}
|
||||||
<label
|
<summary
|
||||||
for="comment-expand-{node.comment_view.comment.id}"
|
|
||||||
class="flex flex-row cursor-pointer gap-2 items-center group text-sm flex-wrap w-full z-0 group relative"
|
class="flex flex-row cursor-pointer gap-2 items-center group text-sm flex-wrap w-full z-0 group relative"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -247,15 +247,9 @@
|
|||||||
#{node.comment_view.comment.id}
|
#{node.comment_view.comment.id}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</label>
|
</summary>
|
||||||
{/if}
|
{/if}
|
||||||
<input
|
<div class={['max-w-full', contentClass]}>
|
||||||
class="appearance-none absolute top-0 left-0 h-8 w-full pointer-events-none comment-expand"
|
|
||||||
type="checkbox"
|
|
||||||
id="comment-expand-{node.comment_view.comment.id}"
|
|
||||||
bind:checked={open}
|
|
||||||
/>
|
|
||||||
<div class={['expand max-w-full', contentClass]} inert={!open}>
|
|
||||||
<div id="comment-content">
|
<div id="comment-content">
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
@@ -310,22 +304,25 @@
|
|||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</details>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.expand {
|
.comment {
|
||||||
display: grid;
|
interpolate-size: allow-keywords;
|
||||||
grid-template-rows: 0fr;
|
}
|
||||||
grid-template-columns: 100%;
|
|
||||||
|
.comment::details-content {
|
||||||
|
height: 0;
|
||||||
|
opacity: 0;
|
||||||
overflow: hidden;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-expand:checked + .expand {
|
.comment[open]::details-content {
|
||||||
grid-template-rows: 1fr;
|
height: auto;
|
||||||
}
|
opacity: 1;
|
||||||
|
|
||||||
.expand > * {
|
|
||||||
min-height: 0;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
import VirtualList from '$lib/app/render/VirtualList.svelte'
|
import VirtualList from '$lib/app/render/VirtualList.svelte'
|
||||||
import { settings } from '$lib/app/settings.svelte'
|
import { settings } from '$lib/app/settings.svelte'
|
||||||
|
import { ReactiveState } from '$lib/app/util.svelte'
|
||||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||||
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
|
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
|
||||||
import { Button, Material, Spinner } from 'mono-svelte'
|
import { Button, Material, Spinner } from 'mono-svelte'
|
||||||
import { onDestroy, untrack } from 'svelte'
|
import { onDestroy, untrack } from 'svelte'
|
||||||
import type { Attachment } from 'svelte/attachments'
|
|
||||||
import {
|
import {
|
||||||
ArchiveBox,
|
ArchiveBox,
|
||||||
ArrowsPointingOut,
|
ArrowsPointingOut,
|
||||||
@@ -20,12 +20,12 @@
|
|||||||
Icon,
|
Icon,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import InfiniteScroll from 'svelte-infinite-scroll'
|
import InfiniteScroll from 'svelte-infinite-scroll'
|
||||||
|
import type { Attachment } from 'svelte/attachments'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { SvelteSet } from 'svelte/reactivity'
|
import { SvelteSet } from 'svelte/reactivity'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
import { Post } from '..'
|
import { Post } from '..'
|
||||||
import { filterPost, type FilteredItem } from '../filters.svelte'
|
import { filterPost, type FilteredItem } from '../filters.svelte'
|
||||||
import { ReactiveState } from '$lib/app/util.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
posts: PostView[]
|
posts: PostView[]
|
||||||
@@ -196,7 +196,6 @@
|
|||||||
class={[
|
class={[
|
||||||
'relative post-container',
|
'relative post-container',
|
||||||
filter.value.action == 'hide' && 'hidden',
|
filter.value.action == 'hide' && 'hidden',
|
||||||
row < 7 && '',
|
|
||||||
]}
|
]}
|
||||||
{@attach intersectionAttach}
|
{@attach intersectionAttach}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
class="gap-1 p-0.5 px-1 flex flex-row items-center"
|
class="gap-1 p-0.5 px-1 flex flex-row items-center"
|
||||||
rounding="full"
|
rounding="full"
|
||||||
padding="none"
|
padding="none"
|
||||||
color="uniform"
|
color="distinct"
|
||||||
onclick={(e) => e.stopPropagation()}
|
onclick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
<div class="min-h-screen flex flex-col">
|
<div class="min-h-screen flex flex-col">
|
||||||
<div
|
<div
|
||||||
class={['shell-navbar-holder', !dockVisible && 'max-md:-bottom-24!']}
|
class={['shell-navbar-holder', !dockVisible && 'auto-hidden']}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<div class="md:hidden flex justify-between" dir="ltr">
|
<div class="md:hidden flex justify-between" dir="ltr">
|
||||||
@@ -71,11 +71,20 @@
|
|||||||
|
|
||||||
.shell-navbar-holder {
|
.shell-navbar-holder {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
|
||||||
z-index: 50;
|
z-index: 50;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
width: 100%;
|
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 {
|
@variant md {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
@@ -108,7 +117,6 @@
|
|||||||
background-color: var(--color-zinc-950);
|
background-color: var(--color-zinc-950);
|
||||||
border-color: var(--color-zinc-900);
|
border-color: var(--color-zinc-900);
|
||||||
@variant md {
|
@variant md {
|
||||||
background-color: --alpha(var(--color-zinc-950) / 70%);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,9 @@
|
|||||||
|
|
||||||
let matchType = $derived<('search' | 'pathname')[]>(
|
let matchType = $derived<('search' | 'pathname')[]>(
|
||||||
routes.map((i) =>
|
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
|
// me on 2025/10/9: no shi buh
|
||||||
const usePathname = !routes.some(
|
const usePathname = !routes.some(
|
||||||
(i) =>
|
(i) =>
|
||||||
new Set(new URL(`https://example.com${i.href}`).searchParams.values()).intersection(
|
new Set(
|
||||||
currentSearch,
|
new URL(`https://example.com${i.href}`).searchParams.values(),
|
||||||
).size > 0,
|
).intersection(currentSearch).size > 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
const hasSearchParam = hrefSearch.intersection(currentSearch).size > 0
|
const hasSearchParam = hrefSearch.intersection(currentSearch).size > 0
|
||||||
@@ -91,8 +93,10 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
flex-wrap: wrap;
|
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
|
overflow-x: auto;
|
||||||
|
max-width: 100%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
@variant sm {
|
@variant sm {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
@@ -102,10 +106,9 @@
|
|||||||
.tab-bar.bar-header {
|
.tab-bar.bar-header {
|
||||||
padding: calc(var(--spacing) * 0.5);
|
padding: calc(var(--spacing) * 0.5);
|
||||||
gap: calc(var(--spacing) * 1) calc(var(--spacing) * 1);
|
gap: calc(var(--spacing) * 1) calc(var(--spacing) * 1);
|
||||||
justify-content: center;
|
margin-top: calc(var(--spacing) * -1);
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-top: calc(var(--spacing) * -1);
|
|
||||||
|
|
||||||
@variant sm {
|
@variant sm {
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
|
|||||||
@@ -188,6 +188,7 @@
|
|||||||
|
|
||||||
@variant hover {
|
@variant hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition-duration: 0s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,14 +197,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
.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;
|
box-shadow: 0px 1.5px 0px 0px var(--color-slate-500) inset;
|
||||||
color: var(--color-slate-50);
|
color: var(--color-slate-50);
|
||||||
border: 1px solid var(--color-slate-900);
|
border: 1px solid var(--color-slate-900);
|
||||||
|
|
||||||
@variant dark {
|
@variant dark {
|
||||||
border-color: var(--color-primary-200);
|
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);
|
color: var(--color-zinc-900);
|
||||||
box-shadow: 0px 2.5px 0px -1px var(--color-white) inset;
|
box-shadow: 0px 2.5px 0px -1px var(--color-white) inset;
|
||||||
}
|
}
|
||||||
@@ -294,7 +303,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-danger {
|
.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);
|
border: 1px solid var(--color-red-700);
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0px 1.5px 0px 0px inset --alpha(var(--color-red-50) / 50%),
|
0px 1.5px 0px 0px inset --alpha(var(--color-red-50) / 50%),
|
||||||
@@ -302,7 +315,11 @@
|
|||||||
color: var(--color-white);
|
color: var(--color-white);
|
||||||
|
|
||||||
@variant dark {
|
@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);
|
color: var(--color-black);
|
||||||
border-color: var(--color-red-900);
|
border-color: var(--color-red-900);
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
|
|||||||
@@ -18,40 +18,40 @@
|
|||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
const id = $props.id()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div {...rest} class={['w-full relative', clazz]}>
|
<details {...rest} class={['w-full relative disclosure', clazz]} bind:open>
|
||||||
<label for={id} class="w-full">
|
<summary class="discosure-summary">
|
||||||
{@render summary?.({ open })}
|
{@render summary?.({ open })}
|
||||||
</label>
|
</summary>
|
||||||
{@render extended?.()}
|
{@render extended?.()}
|
||||||
<input
|
<div class="expand">
|
||||||
{id}
|
|
||||||
class="appearance-none absolute w-full h-full inset-0 pointer-events-none"
|
|
||||||
type="checkbox"
|
|
||||||
bind:checked={open}
|
|
||||||
/>
|
|
||||||
<div class="expand" inert={!open}>
|
|
||||||
{@render children?.({ open })}
|
{@render children?.({ open })}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</details>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.expand {
|
.disclosure {
|
||||||
display: grid;
|
interpolate-size: allow-keywords;
|
||||||
grid-template-rows: 0fr;
|
will-change: height;
|
||||||
grid-template-columns: 100%;
|
}
|
||||||
|
|
||||||
|
.disclosure::details-content {
|
||||||
|
height: 0;
|
||||||
|
opacity: 0;
|
||||||
overflow: hidden;
|
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 {
|
.disclosure[open]::details-content {
|
||||||
grid-template-rows: 1fr;
|
height: auto;
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.expand > :global(*) {
|
summary {
|
||||||
min-height: 0;
|
list-style: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -189,6 +189,7 @@
|
|||||||
border-radius: var(--radius-xl);
|
border-radius: var(--radius-xl);
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
@variant disabled {
|
@variant disabled {
|
||||||
background: var(--color-slate-100);
|
background: var(--color-slate-100);
|
||||||
|
|||||||
@@ -134,7 +134,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.material-distinct {
|
.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);
|
border: 1px solid var(--color-slate-200);
|
||||||
box-shadow: 0px -2px 0px -1px --alpha(var(--color-slate-200) / 90%) inset;
|
box-shadow: 0px -2px 0px -1px --alpha(var(--color-slate-200) / 90%) inset;
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
@@ -167,9 +171,11 @@
|
|||||||
.material-uniform {
|
.material-uniform {
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-color: var(--color-slate-200);
|
border-color: var(--color-slate-200);
|
||||||
|
background-color: var(--color-slate-50);
|
||||||
|
|
||||||
@variant dark {
|
@variant dark {
|
||||||
border-color: var(--color-zinc-900);
|
border-color: var(--color-zinc-900);
|
||||||
|
background-color: var(--color-zinc-950);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,9 @@
|
|||||||
navigate
|
navigate
|
||||||
bind:selected={data.filters.value.sort!}
|
bind:selected={data.filters.value.sort!}
|
||||||
/>
|
/>
|
||||||
<ViewSelect placement="bottom" />
|
<div class="hidden md:block">
|
||||||
|
<ViewSelect placement="bottom" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
<Button class="self-end h-8.5 aspect-square" size="custom" submit>
|
<Button class="self-end h-8.5 aspect-square" size="custom" submit>
|
||||||
|
|||||||
Reference in new issue
Block a user