design: update button and toast components
This commit is contained in:
6 files changed
+47
-89
No files matched your search
@@ -18,7 +18,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { onDestroy } from '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 { expoOut } from 'svelte/easing'
|
||||||
import { fly, slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
|
||||||
@@ -44,19 +44,20 @@
|
|||||||
out:slide={{ duration: 400, delay: 400, easing: expoOut }}
|
out:slide={{ duration: 400, delay: 400, easing: expoOut }}
|
||||||
>
|
>
|
||||||
<div
|
<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 }}
|
in:fly={{ y: -8, duration: 400, delay: 200, opacity: 0, easing: expoOut }}
|
||||||
out:fly={{ y: -8, duration: 400, 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
|
<Icon
|
||||||
src={XMark}
|
src={XCircle}
|
||||||
class="text-red-500 dark:text-red-400 p-px rounded-full bg-white dark:bg-zinc-950"
|
size="28"
|
||||||
size="20"
|
mini
|
||||||
micro
|
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>
|
<div class="flex flex-col text-sm font-medium gap-4">
|
||||||
<div class="flex flex-col text-sm">
|
|
||||||
{#each scopedErrors as error}
|
{#each scopedErrors as error}
|
||||||
{error.message}
|
{error.message}
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@
|
|||||||
? $t('cards.community.subscribed')
|
? $t('cards.community.subscribed')
|
||||||
: $t('cards.community.subscribe')}
|
: $t('cards.community.subscribe')}
|
||||||
color={isSubscribed(community.subscribed)
|
color={isSubscribed(community.subscribed)
|
||||||
? 'elevatedLow'
|
? 'secondary'
|
||||||
: 'primary'}
|
: 'primary'}
|
||||||
class="{isSubscribed(community.subscribed)
|
class="{isSubscribed(community.subscribed)
|
||||||
? 'text-slate-600 dark:text-zinc-400'
|
? 'text-slate-600 dark:text-zinc-400'
|
||||||
|
|||||||
@@ -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
|
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`,
|
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!`,
|
'blue-subtle': `text-blue-500 hover:bg-blue-500 hover:text-inherit!`,
|
||||||
|
|
||||||
none: '',
|
none: '',
|
||||||
@@ -65,50 +57,14 @@
|
|||||||
custom: '',
|
custom: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
type ButtonRoundness = 'pill' | 'xl' | 'lg' | 'md' | 'none'
|
|
||||||
type ButtonRoundingSide = 'all' | 'left' | 'right' | 'top' | 'bottom'
|
|
||||||
|
|
||||||
const buttonRounding = {
|
const buttonRounding = {
|
||||||
pill: {
|
pill: 'rounded-full',
|
||||||
all: 'rounded-full',
|
xl: 'rounded-xl',
|
||||||
left: 'rounded-l-full',
|
lg: 'rounded-lg',
|
||||||
right: 'rounded-r-full',
|
md: 'rounded-md',
|
||||||
top: 'rounded-t-full',
|
none: '',
|
||||||
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: '',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
type ButtonRoundness = keyof typeof buttonRounding
|
||||||
|
|
||||||
interface Props
|
interface Props
|
||||||
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
|
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
|
||||||
@@ -117,7 +73,6 @@
|
|||||||
color?: ButtonColor
|
color?: ButtonColor
|
||||||
size?: ButtonSize
|
size?: ButtonSize
|
||||||
rounding?: ButtonRoundness
|
rounding?: ButtonRoundness
|
||||||
roundingSide?: ButtonRoundingSide
|
|
||||||
alignment?: ButtonAlignment
|
alignment?: ButtonAlignment
|
||||||
shadow?: ButtonShadow
|
shadow?: ButtonShadow
|
||||||
column?: boolean
|
column?: boolean
|
||||||
@@ -149,7 +104,6 @@
|
|||||||
color = 'secondary',
|
color = 'secondary',
|
||||||
size = 'md',
|
size = 'md',
|
||||||
rounding = size == 'lg' ? 'xl' : 'lg',
|
rounding = size == 'lg' ? 'xl' : 'lg',
|
||||||
roundingSide = 'all',
|
|
||||||
alignment = 'center',
|
alignment = 'center',
|
||||||
shadow = color != 'tertiary' ? 'sm' : 'none',
|
shadow = color != 'tertiary' ? 'sm' : 'none',
|
||||||
column = false,
|
column = false,
|
||||||
@@ -173,7 +127,7 @@
|
|||||||
class={[
|
class={[
|
||||||
loading ? buttonColor.secondary : buttonColor[color],
|
loading ? buttonColor.secondary : buttonColor[color],
|
||||||
buttonSize[size],
|
buttonSize[size],
|
||||||
buttonRounding[rounding][roundingSide],
|
buttonRounding[rounding],
|
||||||
buttonShadow[shadow],
|
buttonShadow[shadow],
|
||||||
'text-sm transition-all font-medium cursor-pointer duration-75 disabled:opacity-50 disabled:pointer-events-none disabled:shadow-none',
|
'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',
|
disabled && 'pointer-events-none opacity-50 shadow-none',
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
toastColors[toast.type],
|
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',
|
toast.long ? 'w-full max-w-lg' : 'w-80',
|
||||||
]}
|
]}
|
||||||
transition:fly={{
|
transition:fly={{
|
||||||
@@ -40,9 +40,18 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<Icon
|
<Icon
|
||||||
size="20"
|
size="28"
|
||||||
mini
|
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'
|
src={toast.type == 'info'
|
||||||
? InformationCircle
|
? InformationCircle
|
||||||
: toast.type == 'success'
|
: toast.type == 'success'
|
||||||
@@ -55,17 +64,17 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<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}
|
{#if toast.title}
|
||||||
<h1 class="text-base font-bold">{toast.title}</h1>
|
<h1 class="text-base font-semibold">{toast.title}</h1>
|
||||||
{/if}
|
{/if}
|
||||||
<Markdown
|
<Markdown
|
||||||
source={toast.content}
|
source={toast.content}
|
||||||
class="{toast.long ? 'text-[15px]' : 'text-sm'} font-medium"
|
class={toast.long ? 'text-[15px]' : 'text-sm font-medium'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</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}
|
{#if toast.action}
|
||||||
<button
|
<button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ import { writable } from 'svelte/store'
|
|||||||
type ToastType = keyof typeof toastColors
|
type ToastType = keyof typeof toastColors
|
||||||
|
|
||||||
export const toastColors = {
|
export const toastColors = {
|
||||||
error: 'bg-white dark:bg-zinc-925 text-red-500 shadow-red-400/30 shadow-sm',
|
error: 'bg-red-100/50 dark:bg-red-900/20 border-red-300/40 border',
|
||||||
warning:
|
warning: 'bg-yellow-100/50 dark:bg-yellow-900/20 border-yellow-300/40 border',
|
||||||
'bg-white dark:bg-zinc-925 text-yellow-500 shadow-yellow-400/30 shadow-sm',
|
success: 'bg-green-100/50 dark:bg-green-900/20 border-green-300/40 border',
|
||||||
success:
|
info: 'dark:bg-zinc-925/90 bg-white border border-slate-200 dark:border-zinc-800',
|
||||||
'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',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Toast {
|
export interface Toast {
|
||||||
|
|||||||
@@ -111,38 +111,34 @@
|
|||||||
|
|
||||||
<Header pageHeader class="text-3xl font-bold flex justify-between">
|
<Header pageHeader class="text-3xl font-bold flex justify-between">
|
||||||
{$t('settings.title')}
|
{$t('settings.title')}
|
||||||
<div class="flex items-center">
|
{#snippet extended()}
|
||||||
|
<div class="flex items-center tracking-normal gap-2">
|
||||||
<Button
|
<Button
|
||||||
size="square-lg"
|
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
importText = ''
|
importText = ''
|
||||||
importing = true
|
importing = true
|
||||||
}}
|
}}
|
||||||
class="font-normal"
|
rounding="pill"
|
||||||
title={$t('settings.import')}
|
|
||||||
roundingSide="left"
|
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={ArrowDownTray} mini size="18" />
|
<Icon src={ArrowDownTray} mini size="18" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
{$t('settings.import')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="square-lg"
|
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
const json = JSON.stringify(settings)
|
const json = JSON.stringify(settings)
|
||||||
navigator?.clipboard?.writeText?.(json)
|
navigator?.clipboard?.writeText?.(json)
|
||||||
toast({ content: $t('toast.copied') })
|
toast({ content: $t('toast.copied') })
|
||||||
}}
|
}}
|
||||||
class="font-normal"
|
rounding="pill"
|
||||||
title={$t('settings.export')}
|
|
||||||
rounding="none"
|
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={ArrowUpTray} mini size="18" />
|
<Icon src={ArrowUpTray} mini size="18" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
{$t('settings.export')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="square-lg"
|
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
toast({
|
toast({
|
||||||
content: $t('toast.resetSettings'),
|
content: $t('toast.resetSettings'),
|
||||||
@@ -151,15 +147,15 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
class="font-normal"
|
rounding="pill"
|
||||||
title={$t('settings.reset')}
|
|
||||||
roundingSide="right"
|
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={ArrowPath} mini size="18" />
|
<Icon src={ArrowPath} mini size="18" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
{$t('settings.reset')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<div class="flex items-center gap-2 flex-wrap w-full my-5">
|
<div class="flex items-center gap-2 flex-wrap w-full my-5">
|
||||||
|
|||||||
Reference in new issue
Block a user