design: improve commonlist contrast

This commit is contained in:
James Xylight committed 2025-07-26 12:56:05 -07:00
1 parent 782a748711
commit 6dc1795930
10 files changed
+98 -26

No files matched your search

+81 -9
View File
@@ -1,19 +1,36 @@
<script lang="ts" generics="T">
import type { Snippet } from 'svelte'
const sizeDelay: Record<'lg' | 'md' | 'sm', number> = {
lg: 120,
md: 80,
sm: 40,
}
interface Props {
items?: T[]
item?: Snippet<[T, number]>
children?: Snippet
animate?: boolean
size?: 'lg' | 'md' | 'sm'
}
let { items, item: itemSnippet, children }: Props = $props()
let {
items,
item: itemSnippet,
children,
animate = true,
size = 'sm',
}: Props = $props()
</script>
<ul class="divide-y-3 divide-slate-25 dark:divide-zinc-925">
<ul class="divide-y-3 divide-slate-50 dark:divide-zinc-925">
{#if items}
{#each items as item, index (item)}
<li class="@container group/li">
<li
class={['group/li', animate && 'animate']}
style="--i: {index < 10 ? index * sizeDelay[size] : 0}ms;"
>
{@render itemSnippet?.(item, index)}
</li>
{/each}
@@ -23,38 +40,93 @@
<style>
ul > :global(li) {
padding-block: calc(var(--spacing) * 2);
padding-inline: calc(var(--spacing) * 3);
padding-block: calc(var(--spacing) * 3);
padding-inline: calc(var(--spacing) * 3.5);
transition: background-color 0.1s;
background-color: var(--color-slate-50);
background-color: var(--color-white);
container-type: inline-size;
border-left: 1px solid var(--color-slate-100);
border-right: 1px solid var(--color-slate-100);
&:first-child {
border-top-left-radius: var(--radius-2xl);
border-top-right-radius: var(--radius-2xl);
border-top: 1px solid var(--color-slate-100);
}
&:last-child {
border-bottom-left-radius: var(--radius-2xl);
border-bottom-right-radius: var(--radius-2xl);
border-bottom: 1px solid var(--color-slate-100);
}
&:hover {
background-color: var(--color-zinc-50);
background-color: var(--color-slate-25);
}
}
@media screen and (min-width: 40rem) {
ul > :global(li) {
padding-block: calc(var(--spacing) * 2);
padding-inline: calc(var(--spacing) * 3);
padding-block: calc(var(--spacing) * 3);
padding-inline: calc(var(--spacing) * 4);
}
}
:global(.dark) ul > :global(li) {
background-color: var(--color-zinc-950);
border-left: 1px solid var(--color-zinc-900);
border-right: 1px solid var(--color-zinc-900);
&:first-child {
border-top: 1px solid var(--color-zinc-900);
}
&:last-child {
border-bottom: 1px solid var(--color-zinc-900);
}
&:hover {
background-color: var(--color-zinc-900);
}
}
@keyframes pop-in {
from {
transform: translateY(16px);
opacity: 0;
}
to {
transform: translateY(0px);
opacity: 1;
}
}
.animate {
--delay: var(--i, 0ms);
}
:global(.animate > *:only-child) {
animation: pop-in 1s forwards cubic-bezier(0.16, 1, 0.3, 1);
animation-delay: var(--delay, 0ms);
opacity: 0;
}
:global(.animate:not(:has(> * + *))) {
animation: pop-in 1s forwards cubic-bezier(0.16, 1, 0.3, 1);
animation-delay: var(--delay, 0ms);
opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
:global(.animate > *:only-child) {
animation: none;
opacity: 1;
}
:global(.animate:not(:has(> * + *))) {
animation: none;
opacity: 1;
}
}
</style>
+5 -5
View File
@@ -46,7 +46,7 @@
>
{@render navbar?.({
class: [
'bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900',
'bg-slate-100/50 dark:bg-zinc-950/90 border-slate-200 dark:border-zinc-900',
'pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0',
'rounded-full lg:rounded-none',
],
@@ -55,20 +55,20 @@
</div>
<div
class={[
'content divide-x divide-slate-100 dark:divide-zinc-900 min-h-screen',
'content divide-x divide-slate-200 dark:divide-zinc-900 min-h-screen',
settings.newWidth && 'limit-width',
]}
>
{@render sidebar?.({
class: `hidden md:flex sticky top-0 lg:top-16 left-0 h-max bg-slate-50 dark:bg-zinc-950 z-40`,
class: `hidden md:flex sticky top-0 lg:top-16 left-0 h-max bg-slate-100 dark:bg-zinc-950 z-40`,
style: 'grid-area: sidebar; width: 100% !important;',
})}
{@render main?.({
class: `w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-xs main max-lg:pb-22 lg:pt-20!`,
class: `w-full bg-slate-50 dark:bg-zinc-925 justify-self-center shadow-xs main max-lg:pb-22 lg:pt-20!`,
style: 'grid-area: main',
})}
{@render suffix?.({
class: `max-xl:hidden w-full sticky lg:top-20 h-max max-h-screen overflow-auto left-0 bg-slate-50 dark:bg-zinc-950 z-40`,
class: `max-xl:hidden w-full sticky lg:top-20 h-max max-h-screen overflow-auto left-0 bg-slate-100 dark:bg-zinc-950 z-40`,
style: 'grid-area: suffix;',
})}
</div>
@@ -29,7 +29,7 @@
class={[
pageHeader &&
`w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)]
bg-slate-50 dark:bg-zinc-950 -m-4 sm:-m-6 mb-0 sm:mb-0 sm:p-6 p-3
bg-slate-100 dark:bg-zinc-950 -m-3 sm:-m-6 mb-0 sm:mb-0 sm:p-6 p-4
border-b border-slate-200 dark:border-zinc-800 margin`,
]}
{style}
+1 -1
View File
@@ -151,7 +151,7 @@ items-center px-2 w-max top-6 lg:top-22"
class="self-center justify-self-center my-auto"
/>
{:else}
<CommonList items={data.inbox.value}>
<CommonList items={data.inbox.value} size="md">
{#snippet item(item)}
<InboxItem {item} />
{/snippet}
+1 -1
View File
@@ -133,7 +133,7 @@
</div>
<ProgressBar progress={batch.progress} />
{#if data.items?.value && data.items?.value.length > 0}
<CommonList items={data.items?.value}>
<CommonList items={data.items?.value} size="lg">
{#snippet item(item)}
<Material
rounding={item.length == 1 ? 'none' : '2xl'}
+1 -1
View File
@@ -71,7 +71,7 @@
description="Save posts or comments, and they'll be here to refer to them later."
/>
{:else}
<CommonList items={data.data}>
<CommonList items={data.data} size="lg">
{#snippet item(item)}
{#if isComment(item)}
<CommentItem comment={item} />
+3 -3
View File
@@ -6,10 +6,12 @@
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import PostItem from '$lib/components/lemmy/post/PostItem.svelte'
import UserItem from '$lib/components/lemmy/user/UserItem.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/i18n/translations.js'
import {
@@ -30,8 +32,6 @@
import { expoOut } from 'svelte/easing'
import { fly, slide } from 'svelte/transition'
import SearchBar from './SearchBar.svelte'
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
import PostItem from '$lib/components/lemmy/post/PostItem.svelte'
let { data } = $props()
@@ -165,7 +165,7 @@
</div>
{/if}
{/await}
<CommonList items={data.results.value}>
<CommonList items={data.results.value} animate size="lg">
{#snippet item(result)}
{#if isPostView(result)}
<PostItem post={result} />
+2 -2
View File
@@ -79,8 +79,8 @@
<Icon
src={icon}
size="32"
class="bg-red-200/20 dark:bg-red-800/20 p-1.5 rounded-lg color
text-red-500 dark:text-red-400 float-left mr-2 clear-both"
class="bg-red-200/20 dark:bg-red-600/20 p-1.5 rounded-lg color
text-red-500 dark:text-red-300 float-left mr-2 clear-both"
style="grid-area: icon;"
/>
{/if}
+2 -2
View File
@@ -77,8 +77,8 @@
<Icon
src={icon}
size="32"
class="bg-red-200/20 dark:bg-red-800/20 p-1.5 self-center
rounded-lg color text-red-500 dark:text-red-400"
class="bg-red-200/20 dark:bg-red-600/20 p-1.5 self-center
rounded-lg color text-red-500 dark:text-red-300"
/>
{/if}
<Switch
+1 -1
View File
@@ -66,7 +66,7 @@
}
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-100 text-slate-900 dark:bg-zinc-950 dark:text-zinc-100 accent-slate-950 dark:accent-zinc-50;
}
.dark {