design: update button and toast components

This commit is contained in:
James Xylight committed 2025-07-10 17:25:44 -07:00
1 parent 56e80351ab
commit 64c2e7f559
6 files changed
+85 -127

No files matched your search

+12 -11
View File
@@ -18,7 +18,7 @@
<script lang="ts">
import { Button } from 'mono-svelte'
import { onDestroy } from 'svelte'
import { Icon, XMark } from 'svelte-hero-icons'
import { Icon, XCircle, XMark } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { fly, slide } from 'svelte/transition'
@@ -44,19 +44,20 @@
out:slide={{ duration: 400, delay: 400, easing: expoOut }}
>
<div
class="flex flex-row p-1.5 bg-red-500/20 rounded-3xl border border-red-500/50 gap-2 items-center"
class="flex flex-row p-1.5 bg-red-100/50 dark:bg-red-900/10 rounded-xl border border-red-300/40 gap-2 items-center"
in:fly={{ y: -8, duration: 400, delay: 200, opacity: 0, easing: expoOut }}
out:fly={{ y: -8, duration: 400, opacity: 0, easing: expoOut }}
>
<div class="rounded-full p-0.5 bg-red-400">
<Icon
src={XMark}
class="text-red-500 dark:text-red-400 p-px rounded-full bg-white dark:bg-zinc-950"
size="20"
micro
/>
</div>
<div class="flex flex-col text-sm">
<Icon
src={XCircle}
size="28"
mini
class={[
'relative self-center shrink-0 p-0.5 rounded-full',
'bg-red-400 dark:bg-red-400 dark:text-red-900 text-red-50',
]}
/>
<div class="flex flex-col text-sm font-medium gap-4">
{#each scopedErrors as error}
{error.message}
{/each}
@@ -178,7 +178,7 @@
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
color={isSubscribed(community.subscribed)
? 'elevatedLow'
? 'secondary'
: 'primary'}
class="{isSubscribed(community.subscribed)
? 'text-slate-600 dark:text-zinc-400'
+7 -53
View File
@@ -32,14 +32,6 @@
hover:bg-slate-100 dark:hover:bg-zinc-800 dark:hover:border-zinc-700 dark:text-zinc-400 hover:text-inherit
dark:hover:text-inherit`,
elevated: `bg-slate-100 dark:bg-zinc-800 border border-slate-200
dark:border-zinc-700 hover:bg-zinc-200 dark:hover:bg-zinc-700 hover:border-slate-300
dark:hover:border-zinc-600`,
elevatedLow: `bg-slate-100 dark:bg-zinc-900 border border-slate-200
dark:border-zinc-800 hover:bg-slate-200 dark:hover:bg-zinc-800 hover:border-slate-300
dark:hover:border-zinc-700`,
'blue-subtle': `text-blue-500 hover:bg-blue-500 hover:text-inherit!`,
none: '',
@@ -65,50 +57,14 @@
custom: '',
}
type ButtonRoundness = 'pill' | 'xl' | 'lg' | 'md' | 'none'
type ButtonRoundingSide = 'all' | 'left' | 'right' | 'top' | 'bottom'
const buttonRounding = {
pill: {
all: 'rounded-full',
left: 'rounded-l-full',
right: 'rounded-r-full',
top: 'rounded-t-full',
bottom: 'rounded-b-full',
},
xl: {
all: 'rounded-xl',
left: 'rounded-l-xl',
right: 'rounded-r-xl',
top: 'rounded-t-xl',
bottom: 'rounded-b-xl',
},
lg: {
all: 'rounded-lg',
left: 'rounded-l-lg',
right: 'rounded-r-lg',
top: 'rounded-t-lg',
bottom: 'rounded-b-lg',
},
md: {
all: 'rounded-md',
left: 'rounded-l-md',
right: 'rounded-r-md',
top: 'rounded-t-md',
bottom: 'rounded-b-md',
},
none: {
all: '',
left: '',
right: '',
top: '',
bottom: '',
},
pill: 'rounded-full',
xl: 'rounded-xl',
lg: 'rounded-lg',
md: 'rounded-md',
none: '',
}
type ButtonRoundness = keyof typeof buttonRounding
interface Props
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
@@ -117,7 +73,6 @@
color?: ButtonColor
size?: ButtonSize
rounding?: ButtonRoundness
roundingSide?: ButtonRoundingSide
alignment?: ButtonAlignment
shadow?: ButtonShadow
column?: boolean
@@ -149,7 +104,6 @@
color = 'secondary',
size = 'md',
rounding = size == 'lg' ? 'xl' : 'lg',
roundingSide = 'all',
alignment = 'center',
shadow = color != 'tertiary' ? 'sm' : 'none',
column = false,
@@ -173,7 +127,7 @@
class={[
loading ? buttonColor.secondary : buttonColor[color],
buttonSize[size],
buttonRounding[rounding][roundingSide],
buttonRounding[rounding],
buttonShadow[shadow],
'text-sm transition-all font-medium cursor-pointer duration-75 disabled:opacity-50 disabled:pointer-events-none disabled:shadow-none',
disabled && 'pointer-events-none opacity-50 shadow-none',
+16 -7
View File
@@ -24,7 +24,7 @@
<div
class={[
toastColors[toast.type],
'relative rounded-xl overflow-hidden flex flex-row items-start',
'relative rounded-2xl overflow-hidden flex flex-row items-center gap-2 px-3 py-3 backdrop-blur-lg',
toast.long ? 'w-full max-w-lg' : 'w-80',
]}
transition:fly={{
@@ -40,9 +40,18 @@
</div>
{:else}
<Icon
size="20"
size="28"
mini
class="relative mt-4 mr-2 ml-4 shrink-0 opacity-80"
class={[
'relative self-center shrink-0 p-1 rounded-full',
toast.type == 'info'
? 'bg-slate-200 dark:bg-zinc-50 text-slate-700 dark:text-zinc-700'
: toast.type == 'success'
? 'bg-green-400 dark:bg-green-300 dark:text-green-900 text-green-50'
: toast.type == 'warning'
? 'bg-yellow-400 dark:bg-yellow-300 dark:text-yellow-900 text-yellow-50'
: 'bg-red-400 dark:bg-red-300 dark:text-red-900 text-red-50',
]}
src={toast.type == 'info'
? InformationCircle
: toast.type == 'success'
@@ -55,17 +64,17 @@
/>
{/if}
<div
class="flex flex-col p-4 pl-0 break-words max-w-full text-slate-900 dark:text-zinc-50"
class="flex flex-col break-words max-w-full text-slate-900 dark:text-zinc-50"
>
{#if toast.title}
<h1 class="text-base font-bold">{toast.title}</h1>
<h1 class="text-base font-semibold">{toast.title}</h1>
{/if}
<Markdown
source={toast.content}
class="{toast.long ? 'text-[15px]' : 'text-sm'} font-medium"
class={toast.long ? 'text-[15px]' : 'text-sm font-medium'}
/>
</div>
<div class="ml-auto flex items-center gap-1 m-2">
<div class="absolute top-0 right-0 flex items-center gap-1 m-1">
{#if toast.action}
<button
onclick={() => {
+4 -6
View File
@@ -3,12 +3,10 @@ import { writable } from 'svelte/store'
type ToastType = keyof typeof toastColors
export const toastColors = {
error: 'bg-white dark:bg-zinc-925 text-red-500 shadow-red-400/30 shadow-sm',
warning:
'bg-white dark:bg-zinc-925 text-yellow-500 shadow-yellow-400/30 shadow-sm',
success:
'bg-white dark:bg-zinc-925 text-green-600 dark:text-green-400 shadow-green-400/30 shadow-sm',
info: 'dark:bg-zinc-925 bg-white border border-slate-200 dark:border-zinc-800',
error: 'bg-red-100/50 dark:bg-red-900/20 border-red-300/40 border',
warning: 'bg-yellow-100/50 dark:bg-yellow-900/20 border-yellow-300/40 border',
success: 'bg-green-100/50 dark:bg-green-900/20 border-green-300/40 border',
info: 'dark:bg-zinc-925/90 bg-white border border-slate-200 dark:border-zinc-800',
}
export interface Toast {