design: improve click response and visual coherency

This commit is contained in:
Xylight committed 2026-02-12 19:12:07 -08:00
1 parent 16bcd76bd0
commit f77740b5cb
12 files changed
+115 -81

No files matched your search

+18 -15
View File
@@ -2,7 +2,7 @@
import type { View } from '$lib/app/settings.svelte' import type { View } from '$lib/app/settings.svelte'
import { parseURL } from '$lib/ui/form/Link.svelte' import { parseURL } from '$lib/ui/form/Link.svelte'
import { Material } from 'mono-svelte' import { Material } from 'mono-svelte'
import { ArrowTopRightOnSquare, Icon, Link } from 'svelte-hero-icons/dist' import { Icon, Link } from 'svelte-hero-icons/dist'
import { optimizeImageURL } from './helpers' import { optimizeImageURL } from './helpers'
interface Props { interface Props {
@@ -10,6 +10,7 @@
thumbnail_url?: string thumbnail_url?: string
nsfw?: boolean nsfw?: boolean
embed_title?: string embed_title?: string
embed_body?: string
view?: View view?: View
} }
@@ -18,6 +19,7 @@
thumbnail_url, thumbnail_url,
nsfw = false, nsfw = false,
embed_title, embed_title,
embed_body,
view = 'cozy', view = 'cozy',
}: Props = $props() }: Props = $props()
@@ -34,7 +36,7 @@
class={[ class={[
'post-link group/link hover:bg-slate-50 hover:dark:bg-zinc-800 transition-colors', 'post-link group/link hover:bg-slate-50 hover:dark:bg-zinc-800 transition-colors',
]} ]}
rounding="xl" rounding="2xl"
element="a" element="a"
padding="none" padding="none"
href={url} href={url}
@@ -48,6 +50,11 @@
</div> </div>
{/if} {/if}
<p class="post-link-title">{embed_title}</p> <p class="post-link-title">{embed_title}</p>
{#if embed_body}
<p class="post-link-body">
{embed_body?.slice(0, 200)}{#if embed_body.length >= 200}...{/if}
</p>
{/if}
</div> </div>
{#if thumbnail_url} {#if thumbnail_url}
<div class="post-link-image"> <div class="post-link-image">
@@ -76,19 +83,6 @@
class:blur-3xl={nsfw} class:blur-3xl={nsfw}
/> />
</picture> </picture>
<Material
padding="xs"
color="uniform"
class="absolute top-0 right-0 m-2 z-50"
role="presentation"
>
<Icon
src={ArrowTopRightOnSquare}
size="16"
micro
class="text-slate-500 dark:text-zinc-300"
/>
</Material>
</div> </div>
{/if} {/if}
</Material> </Material>
@@ -154,6 +148,15 @@
max-width: calc(var(--spacing) * 108); max-width: calc(var(--spacing) * 108);
} }
.post-link-body {
color: var(--color-slate-500);
overflow: hidden;
max-height: 100%;
@variant dark {
color: var(--color-zinc-500);
}
}
.post-link-image { .post-link-image {
flex-shrink: 0; flex-shrink: 0;
margin-bottom: auto; margin-bottom: auto;
+4 -5
View File
@@ -94,7 +94,6 @@
onclick={() => castVote(vote == targetNum ? 0 : targetNum)} onclick={() => castVote(vote == targetNum ? 0 : targetNum)}
class={[ class={[
'flex items-center gap-0.5 transition-colors relative cursor-pointer h-full p-2', 'flex items-center gap-0.5 transition-colors relative cursor-pointer h-full p-2',
'first:rounded-l-[inherit] last:rounded-r-[inherit]',
'last:flex-row-reverse', 'last:flex-row-reverse',
vote == targetNum vote == targetNum
? shouldShowVoteColor( ? shouldShowVoteColor(
@@ -138,7 +137,7 @@
<div <div
class={[ class={[
buttonColor.secondary, buttonColor.secondary,
'rounded-xl h-full font-medium flex relative hover:bg-transparent! shadow-xs', 'rounded-xl h-full font-medium flex relative hover:bg-transparent! overflow-hidden',
voteRatio < 85 && settings.voteRatioBar && 'vote-ratio', voteRatio < 85 && settings.voteRatioBar && 'vote-ratio',
]} ]}
aria-label={$t('aria.vote.group')} aria-label={$t('aria.vote.group')}
@@ -160,7 +159,7 @@
} }
.vote-ratio::before { .vote-ratio::before {
border-radius: var(--radius-3xl); border-radius: inherit;
content: ''; content: '';
position: absolute; position: absolute;
height: 100%; height: 100%;
@@ -171,8 +170,8 @@
z-index: -10; z-index: -10;
background: linear-gradient( background: linear-gradient(
to right, to right,
var(--color-indigo-500) calc(var(--vote-ratio) - 4%), var(--color-indigo-400) calc(var(--vote-ratio) - 2%),
var(--color-red-500) calc(var(--vote-ratio) + 4%) var(--color-red-400) calc(var(--vote-ratio) + 2%)
); );
} }
</style> </style>
@@ -52,6 +52,7 @@
thumbnail_url={post.thumbnail_url} thumbnail_url={post.thumbnail_url}
nsfw={post.nsfw} nsfw={post.nsfw}
embed_title={post.embed_title} embed_title={post.embed_title}
embed_body={post.embed_description}
{view} {view}
{...rest} {...rest}
/> />
@@ -61,12 +61,12 @@
<div <div
class={[ class={[
'relative overflow-hidden rounded-2xl max-h-full h-full', 'relative overflow-hidden rounded-2xl max-h-full h-full',
'border border-slate-200 dark:border-zinc-800 hover-scale-effect bg-slate-200 dark:bg-zinc-800', 'border border-slate-200 dark:border-zinc-800 hover-scale-effect bg-slate-200 dark:bg-zinc-900',
]} ]}
> >
{#if post.thumbnail_url || type == 'image'} {#if post.thumbnail_url || type == 'image'}
{@const thumbnail = post.thumbnail_url != undefined && type != 'image'} {@const thumbnail = post.thumbnail_url != undefined && type != 'image'}
<picture> <picture class="rounded-[inherit]">
<!--I would add AVIF, but lemmy.world's AVIF is broken as of currently--> <!--I would add AVIF, but lemmy.world's AVIF is broken as of currently-->
{#each ['webp'] as format} {#each ['webp'] as format}
<source <source
@@ -94,7 +94,7 @@
src={blur ? '' : bestImageURL(post, thumbnail, -1, null)} src={blur ? '' : bestImageURL(post, thumbnail, -1, null)}
loading="lazy" loading="lazy"
class={[ class={[
'object-cover relative overflow-hidden rounded-xl h-full', 'object-cover relative overflow-hidden rounded-[inherit] h-full',
size, size,
]} ]}
alt={post.alt_text ?? ' '} alt={post.alt_text ?? ' '}
@@ -102,11 +102,7 @@
/> />
</picture> </picture>
{#if type != 'image'} {#if type != 'image'}
<div <div class="post-media-indicator">
class={[
'absolute w-8 h-8 bottom-1 left-1 rounded-xl bg-slate-25 dark:bg-zinc-900 grid place-items-center',
]}
>
<Icon src={type == 'iframe' ? VideoCamera : Link} micro size="16" /> <Icon src={type == 'iframe' ? VideoCamera : Link} micro size="16" />
</div> </div>
{/if} {/if}
@@ -150,6 +146,7 @@
</div> </div>
<style> <style>
@reference '../../../../app.css';
.hover-scale-effect > *, .hover-scale-effect > *,
.hover-scale-effect > picture > img { .hover-scale-effect > picture > img {
transition: transform 200ms var(--ease-cubic); transition: transform 200ms var(--ease-cubic);
@@ -162,4 +159,30 @@
.hover-scale-effect:active > picture > img { .hover-scale-effect:active > picture > img {
transform: scale(90%); transform: scale(90%);
} }
.post-media-indicator {
/*bg-linear-180 from-zinc-900/0 to-zinc-900/95 h-16 absolute bottom-0 w-full left-0 flex items-end p-2*/
position: absolute;
bottom: 0;
left: 0;
display: flex;
align-items: end;
padding: calc(var(--spacing) * 2);
height: calc(var(--spacing) * 16);
width: 100%;
background-image: linear-gradient(
to bottom,
--alpha(var(--color-slate-50) / 0%),
--alpha(var(--color-slate-50) / 95%)
);
@variant dark {
background-image: linear-gradient(
to bottom,
--alpha(var(--color-zinc-900) / 0%),
--alpha(var(--color-zinc-900) / 95%)
);
}
}
</style> </style>
+4 -4
View File
@@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import { tick } from 'svelte' import { tick } from 'svelte'
import type { HTMLAttributes } from 'svelte/elements' import type { ClassValue, HTMLTextareaAttributes } from 'svelte/elements'
let textarea: HTMLTextAreaElement | undefined = $state() let textarea = $state<HTMLTextAreaElement>()
async function adjustHeight() { async function adjustHeight() {
await tick() await tick()
@@ -11,11 +11,11 @@
textarea.style.height = `${textarea.scrollHeight}px` // Set height to the scrollHeight textarea.style.height = `${textarea.scrollHeight}px` // Set height to the scrollHeight
} }
} }
interface Props extends HTMLAttributes<HTMLTextAreaElement> { interface Props extends HTMLTextareaAttributes {
label?: string | undefined label?: string | undefined
value: string value: string
required?: boolean required?: boolean
class?: string class?: ClassValue
} }
let { let {
+1 -1
View File
@@ -127,7 +127,7 @@
@variant md { @variant md {
width: max-content; width: max-content;
height: max-content; height: max-content;
padding: calc(var(--spacing) * 1.25) calc(var(--spacing) * 3); padding: calc(var(--spacing) * 1.125) calc(var(--spacing) * 3);
@variant hover { @variant hover {
background-color: --alpha(var(--color-slate-200) / 50%); background-color: --alpha(var(--color-slate-200) / 50%);
+8 -2
View File
@@ -106,7 +106,7 @@
size = 'md', size = 'md',
rounding = size == 'lg' || size == 'square-lg' ? '2xl' : 'xl', rounding = size == 'lg' || size == 'square-lg' ? '2xl' : 'xl',
alignment = 'center', alignment = 'center',
shadow = color == 'primary' || color == 'secondary' ? 'sm' : 'none', shadow = 'none',
gap = 'md', gap = 'md',
disabled, disabled,
loaderWidth = undefined, loaderWidth = undefined,
@@ -230,8 +230,14 @@
background-color: var(--color-white); background-color: var(--color-white);
@variant dark { @variant dark {
border: 1px solid var(--color-zinc-800); border: 1px solid
color-mix(
in oklab,
var(--color-zinc-800) 50%,
var(--color-zinc-900) 50%
);
background-color: var(--color-zinc-900); background-color: var(--color-zinc-900);
border-top-color: var(--color-zinc-800);
} }
@variant hover { @variant hover {
+9 -6
View File
@@ -29,7 +29,6 @@
<style> <style>
.btn-group { .btn-group {
gap: var(--spacing);
flex-shrink: 0; flex-shrink: 0;
} }
@@ -41,14 +40,18 @@
& > button, & > button,
& > a { & > a {
position: relative; position: relative;
border-radius: 8px !important;
&:first-child { &:not(:first-child):not(:last-child) {
border-radius: 24px 12px 12px 24px !important; border-radius: 0px !important;
} }
&:last-child { &:first-child:not(:last-child) {
border-radius: 12px 24px 24px 12px !important; border-radius: var(--radius-xl) 0px 0px var(--radius-xl) !important;
border-right: 0px;
}
&:last-child:not(:first-child) {
border-radius: 0px var(--radius-xl) var(--radius-xl) 0px !important;
} }
} }
} }
+1 -1
View File
@@ -95,7 +95,7 @@
bind:this={element} bind:this={element}
class={[ class={[
buttonSize[size], buttonSize[size],
'btn btn-secondary select rounded-xl appearance-none pr-6! w-full shadow-xs', 'btn btn-secondary select rounded-xl appearance-none pr-6! w-full',
selectClass, selectClass,
clazz, clazz,
]} ]}
+8 -3
View File
@@ -115,13 +115,18 @@
border-top-color: var(--color-zinc-700); border-top-color: var(--color-zinc-700);
@variant hover { @variant hover {
@variant dark { background-color: var(--color-zinc-925);
background-color: var(--color-zinc-925); }
} @variant active {
background-color: var(--color-zinc-950);
} }
} }
@variant hover { @variant hover {
background-color: var(--color-slate-50);
}
@variant active {
background-color: var(--color-slate-100); background-color: var(--color-slate-100);
} }
} }
+13 -10
View File
@@ -22,10 +22,16 @@
pushError, pushError,
} from '$lib/ui/info/ErrorContainer.svelte' } from '$lib/ui/info/ErrorContainer.svelte'
import { Header } from '$lib/ui/layout' import { Header } from '$lib/ui/layout'
import { Button, Note, Spinner, TextInput, toast } from 'mono-svelte' import {
Button,
ButtonGroup,
Note,
Spinner,
TextInput,
toast,
} from 'mono-svelte'
import { debounce } from 'mono-svelte/util/time' import { debounce } from 'mono-svelte/util/time'
import { import {
Icon,
Identification, Identification,
QuestionMarkCircle, QuestionMarkCircle,
UserCircle, UserCircle,
@@ -236,21 +242,18 @@
{$t('account.login')} {$t('account.login')}
</Button> </Button>
<hr class="border-slate-200 dark:border-zinc-800" /> <hr class="border-slate-200 dark:border-zinc-800" />
<div class="flex flex-row items-center gap-2 overflow-auto *:shrink-0"> <ButtonGroup orientation="horizontal" class="flex overflow-auto">
<Button rounding="pill" color="ghost" href="/signup"> <Button href="/signup" icon={Identification}>
<Icon src={Identification} mini size="16" />
{$t('account.signup')} {$t('account.signup')}
</Button> </Button>
<Button rounding="pill" color="ghost" href="/login_reset"> <Button href="/login_reset" icon={QuestionMarkCircle}>
<Icon src={QuestionMarkCircle} mini size="16" />
{$t('form.forgotpassword')} {$t('form.forgotpassword')}
</Button> </Button>
{#if !LINKED_INSTANCE_URL} {#if !LINKED_INSTANCE_URL}
<Button rounding="pill" color="ghost" href="/login/guest"> <Button href="/login/guest" icon={UserCircle}>
<Icon src={UserCircle} mini size="16" />
{$t('account.guest')} {$t('account.guest')}
</Button> </Button>
{/if} {/if}
</div> </ButtonGroup>
</form> </form>
</div> </div>
+17 -26
View File
@@ -1,7 +1,8 @@
<script lang="ts"> <script lang="ts">
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { type Theme, theme as themeData } from '$lib/app/theme/theme.svelte' import { type Theme, theme as themeData } from '$lib/app/theme/theme.svelte'
import { action, Button, Material, modal, TextInput } from 'mono-svelte' import FreeTextInput from '$lib/ui/form/FreeTextInput.svelte'
import { action, Button, Material, modal } from 'mono-svelte'
import { CheckCircle, Icon, Trash } from 'svelte-hero-icons/dist' import { CheckCircle, Icon, Trash } from 'svelte-hero-icons/dist'
interface Props { interface Props {
@@ -10,6 +11,7 @@
let { theme = $bindable() }: Props = $props() let { theme = $bindable() }: Props = $props()
let selected = $derived(theme.id == themeData.data.currentTheme)
let editingName = $state(false) let editingName = $state(false)
</script> </script>
@@ -17,14 +19,13 @@
<Material <Material
padding="none" padding="none"
rounding="none" rounding="none"
class="{theme.id == themeData.data.currentTheme color="default"
? 'ring-2 ring-primary-900 dark:ring-primary-100' class={[
: ''} rounded-2xl flex relative cursor-pointer h-full flex-col text-left p-0.5" 'rounded-2xl flex relative cursor-pointer h-full flex-col text-left p-0.5',
]}
> >
<div <div
class={[ class={['h-20 w-full rounded-xl flex flex-row flex-wrap p-3 gap-2']}
'h-20 w-full rounded-2xl rounded-b-none flex flex-row flex-wrap p-3 gap-2',
]}
style="background-color: rgb({theme.colors[ style="background-color: rgb({theme.colors[
'zinc' 'zinc'
][900]}); color: rgb({theme.colors['zinc'][50]});" ][900]}); color: rgb({theme.colors['zinc'][50]});"
@@ -46,25 +47,15 @@
/> />
{/if} {/if}
<div class="px-4 py-2 flex items-center gap-1 justify-between"> <div class="px-4 py-2 flex items-center gap-1 justify-between">
{#if editingName} <FreeTextInput
<form bind:value={theme.name}
onsubmit={(e) => { disabled={theme.id <= 0}
e.preventDefault() class={[
editingName = false 'text-left font-medium text-lg font-display disabled:pointer-events-none',
}} ]}
> >
<TextInput bind:value={theme.name}></TextInput> {theme.name}
</form> </FreeTextInput>
{:else}
<button
onclick={() => {
if (theme.id > 0) editingName = true
}}
class="text-left font-medium text-lg font-display"
>
{theme.name}
</button>
{/if}
{#if theme.id > 0} {#if theme.id > 0}
<Button <Button
color="ghost" color="ghost"