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",
|
||||
"version": "2.3.0",
|
||||
"version": "2.4.0",
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
"@capacitor/android": "^8.4.2",
|
||||
|
||||
@@ -82,6 +82,10 @@
|
||||
--font-sans: sans-serif;
|
||||
}
|
||||
|
||||
:root {
|
||||
interpolate-size: allow-keywords;
|
||||
}
|
||||
|
||||
body {
|
||||
@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>
|
||||
{/if}
|
||||
|
||||
<li
|
||||
class={['py-3 relative', clazz]}
|
||||
<details
|
||||
class={['py-3 relative comment', clazz]}
|
||||
id={node.comment_view.comment.id.toString()}
|
||||
bind:open
|
||||
>
|
||||
{#if meta}
|
||||
{@const creatorIsOp =
|
||||
node.comment_view.creator.id == node.comment_view.post.creator_id}
|
||||
<label
|
||||
for="comment-expand-{node.comment_view.comment.id}"
|
||||
<summary
|
||||
class="flex flex-row cursor-pointer gap-2 items-center group text-sm flex-wrap w-full z-0 group relative"
|
||||
>
|
||||
<div
|
||||
@@ -247,15 +247,9 @@
|
||||
#{node.comment_view.comment.id}
|
||||
</span>
|
||||
{/if}
|
||||
</label>
|
||||
</summary>
|
||||
{/if}
|
||||
<input
|
||||
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 class={['max-w-full', contentClass]}>
|
||||
<div id="comment-content">
|
||||
<div
|
||||
class={[
|
||||
@@ -310,22 +304,25 @@
|
||||
{@render children?.()}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</details>
|
||||
|
||||
<style>
|
||||
.expand {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
grid-template-columns: 100%;
|
||||
.comment {
|
||||
interpolate-size: allow-keywords;
|
||||
}
|
||||
|
||||
.comment::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;
|
||||
}
|
||||
|
||||
.comment-expand:checked + .expand {
|
||||
grid-template-rows: 1fr;
|
||||
}
|
||||
|
||||
.expand > * {
|
||||
min-height: 0;
|
||||
.comment[open]::details-content {
|
||||
height: auto;
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
@@ -6,11 +6,11 @@
|
||||
import { t } from '$lib/app/i18n'
|
||||
import VirtualList from '$lib/app/render/VirtualList.svelte'
|
||||
import { settings } from '$lib/app/settings.svelte'
|
||||
import { ReactiveState } from '$lib/app/util.svelte'
|
||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
|
||||
import { Button, Material, Spinner } from 'mono-svelte'
|
||||
import { onDestroy, untrack } from 'svelte'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
import {
|
||||
ArchiveBox,
|
||||
ArrowsPointingOut,
|
||||
@@ -20,12 +20,12 @@
|
||||
Icon,
|
||||
} from 'svelte-hero-icons/dist'
|
||||
import InfiniteScroll from 'svelte-infinite-scroll'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { SvelteSet } from 'svelte/reactivity'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { Post } from '..'
|
||||
import { filterPost, type FilteredItem } from '../filters.svelte'
|
||||
import { ReactiveState } from '$lib/app/util.svelte'
|
||||
|
||||
interface Props {
|
||||
posts: PostView[]
|
||||
@@ -196,7 +196,6 @@
|
||||
class={[
|
||||
'relative post-container',
|
||||
filter.value.action == 'hide' && 'hidden',
|
||||
row < 7 && '',
|
||||
]}
|
||||
{@attach intersectionAttach}
|
||||
>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@
|
||||
navigate
|
||||
bind:selected={data.filters.value.sort!}
|
||||
/>
|
||||
<ViewSelect placement="bottom" />
|
||||
<div class="hidden md:block">
|
||||
<ViewSelect placement="bottom" />
|
||||
</div>
|
||||
|
||||
<noscript>
|
||||
<Button class="self-end h-8.5 aspect-square" size="custom" submit>
|
||||
|
||||
Reference in new issue
Block a user