design: redesign Tabs and distinct material, improve button danger style

This commit is contained in:
Xylight committed 2026-07-10 14:37:20 -07:00
1 parent 308bdee650
commit 296b029057
12 files changed
+184 -83

No files matched your search

+1
View File
@@ -20,3 +20,4 @@ test-results
# Used for automated screenshot workflow # Used for automated screenshot workflow
.github/__pycache__/ .github/__pycache__/
.zed
+46 -8
View File
@@ -146,10 +146,8 @@
{/if} {/if}
<div <div
class={[ class={[
'flex flex-col border border-slate-200 border-b-slate-300 dark:border-zinc-800', 'focus-within:ring-3 ring-slate-300 dark:ring-zinc-700',
'focus-within:border-primary-900 dark:focus-within:border-primary-100 focus-within:ring-3 ring-slate-300 dark:ring-zinc-700', 'markdown-editor',
'bg-white dark:bg-zinc-950',
'rounded-2xl overflow-hidden transition-colors shadow-xs',
label && 'mt-1', label && 'mt-1',
clazz, clazz,
]} ]}
@@ -290,7 +288,7 @@
{/if} {/if}
<!--Actual text area--> <!--Actual text area-->
<TextArea <TextArea
class="bg-inherit z-0 border-0 rounded-none ring-0! focus:ring-transparent! transition-none! resize-none" class="z-0 focus:ring-transparent! transition-none! resize-none"
bind:value bind:value
bind:element={textArea} bind:element={textArea}
onkeydown={(e) => { onkeydown={(e) => {
@@ -305,6 +303,7 @@
} }
} }
}} }}
unstyled
oninput={adjustHeight} oninput={adjustHeight}
onpaste={(e) => { onpaste={(e) => {
if (!e.clipboardData?.files) return if (!e.clipboardData?.files) return
@@ -320,9 +319,7 @@
{/if} {/if}
{#if previewButton} {#if previewButton}
<div <div class="p-2 flex flex-row items-center w-full gap-1">
class="p-2 flex flex-row items-center w-full bg-slate-50 border-t border-slate-200 dark:border-zinc-900 dark:bg-zinc-925 gap-1"
>
{#if previewButton} {#if previewButton}
<MultiSelect <MultiSelect
bind:selected={previewing} bind:selected={previewing}
@@ -335,3 +332,44 @@
{/if} {/if}
</div> </div>
</div> </div>
<style>
@reference '../../../app.css';
.markdown-editor {
--primary-box-shadow: 0px -1px 0px 0px --alpha(var(--color-slate-900) / 20%)
inset;
--ring-box-shadow: 0px 0px 0px 2px --alpha(var(--color-primary-900) / 30%);
display: flex;
flex-direction: column;
border: 1px solid var(--color-slate-200);
box-shadow: var(--primary-box-shadow);
border-radius: var(--radius-2xl);
overflow: hidden;
font-size: var(--text-sm);
background-color: var(--color-white);
transition: all 150ms var(--ease-cubic);
@variant dark {
--primary-box-shadow: 0px 1.5px 0px 0px inset
--alpha(var(--color-zinc-800) / 100%);
--ring-box-shadow: 0px 0px 0px 2px --alpha(var(--color-primary-100) / 30%);
background: linear-gradient(
to bottom,
var(--color-zinc-925) 25%,
var(--color-zinc-900)
);
border-color: --alpha(var(--color-black) / 20%);
}
&:focus-within {
box-shadow: var(--primary-box-shadow), var(--ring-box-shadow);
border-color: var(--color-primary-900);
@variant dark {
border-color: var(--color-primary-100);
}
}
}
</style>
+7 -4
View File
@@ -8,7 +8,7 @@
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
import { placeholders } from '$lib/app/util.svelte' import { placeholders } from '$lib/app/util.svelte'
import { Button, Menu, MenuButton, toast } from 'mono-svelte' import { Button, Menu, MenuButton, toast } from 'mono-svelte'
import { Icon, Language, XMark } from 'svelte-hero-icons/dist' import { ArrowUp, Icon, Language, XMark } from 'svelte-hero-icons/dist'
import type { ClassValue, HTMLTextareaAttributes } from 'svelte/elements' import type { ClassValue, HTMLTextareaAttributes } from 'svelte/elements'
interface Props extends Omit<HTMLTextareaAttributes, 'oncancel'> { interface Props extends Omit<HTMLTextareaAttributes, 'oncancel'> {
@@ -149,11 +149,10 @@
<div class="flex-1"></div> <div class="flex-1"></div>
{#if actions} {#if actions}
<Button <Button
size="custom"
title={$t('common.cancel')} title={$t('common.cancel')}
onclick={() => oncancel?.(true)} onclick={() => oncancel?.(true)}
color="tertiary" color="tertiary"
class="w-8 h-8" size="square-md"
rounding="xl" rounding="xl"
> >
<Icon <Icon
@@ -169,8 +168,12 @@
rounding="xl" rounding="xl"
{loading} {loading}
disabled={locked || loading || banned} disabled={locked || loading || banned}
title={$t('form.submit')}
size="square-lg"
> >
{$t('form.submit')} {#snippet prefix()}
<Icon src={ArrowUp} size="20" mini />
{/snippet}
</Button> </Button>
{/if} {/if}
</MarkdownEditor> </MarkdownEditor>
+3 -4
View File
@@ -2,9 +2,9 @@ import { browser } from '$app/environment'
import type { import type {
CommentView, CommentView,
CommunityView, CommunityView,
FeedView,
GetComments, GetComments,
GetCommunityResponse, GetCommunityResponse,
GetMultiCommunityResponse,
GetPersonDetails, GetPersonDetails,
GetPersonDetailsResponse, GetPersonDetailsResponse,
GetPost, GetPost,
@@ -115,12 +115,11 @@ export interface FeedTypes {
] ]
'/f/[id]': [ '/f/[id]': [
GetPosts, GetPosts,
{ {
posts: PostView[] posts: PostView[]
multi: GetMultiCommunityResponse
next_page?: string next_page?: string
params: GetPosts & { page_cursor: string } params: GetPosts
feed: Promise<FeedView | undefined>
client: { client: {
itemHeights?: (number | null)[] itemHeights?: (number | null)[]
lastSeen?: number lastSeen?: number
@@ -61,7 +61,7 @@
<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-900', 'btn-secondary hover-scale-effect',
]} ]}
> >
{#if post.thumbnail_url || type == 'image'} {#if post.thumbnail_url || type == 'image'}
@@ -115,7 +115,7 @@
])} ])}
<div <div
class={[ class={[
'bg-slate-100 dark:bg-zinc-900 w-full h-full rounded-xl grid place-items-center', ' w-full h-full rounded-xl grid place-items-center',
'text-slate-600 dark:text-zinc-400', 'text-slate-600 dark:text-zinc-400',
]} ]}
> >
+2 -6
View File
@@ -44,7 +44,7 @@
</script> </script>
<fieldset <fieldset
class="flex items-center gap-1 w-max max-w-full z-0 relative overflow-auto" class="flex items-center gap-1 w-max max-w-full z-0 p-0.5 relative overflow-auto border border-slate-200 dark:border-zinc-800 rounded-full"
> >
{#each options as option, index} {#each options as option, index}
<label> <label>
@@ -56,11 +56,7 @@
id="{id}-{option?.toString()}" id="{id}-{option?.toString()}"
class="hidden" class="hidden"
/> />
<TabButton <TabButton selected={selectedIndex == index} disabled={disabled[index]} element="div">
selected={selectedIndex == index}
disabled={disabled[index]}
element="div"
>
{optionNames[index] || option} {optionNames[index] || option}
</TabButton> </TabButton>
</label> </label>
+31 -8
View File
@@ -29,11 +29,7 @@
<svelte:element <svelte:element
this={element} this={element}
class={[ class={[sizes[size], 'tab-button', selected && 'material-distinct']}
sizes[size],
'tab-button',
selected ? 'btn-primary' : 'btn-secondary',
]}
onclick={href ? undefined : onselect} onclick={href ? undefined : onselect}
{disabled} {disabled}
{href} {href}
@@ -47,11 +43,38 @@
.tab-button { .tab-button {
font-size: var(--text-sm); font-size: var(--text-sm);
border-radius: var(--radius-xl); border-radius: 9999px;
font-weight: var(--font-weight-medium); font-weight: var(--font-weight-medium);
transition: all 75ms var(--default-transition-timing-function);
position: relative; position: relative;
box-shadow: var(--shadow-xs);
cursor: pointer; cursor: pointer;
padding: calc(var(--spacing) * 1.5) calc(var(--spacing) * 3.5);
&:hover {
background-color: --alpha(var(--color-slate-300) / 40%);
@variant dark {
background-color: --alpha(var(--color-zinc-700) / 50%);
}
}
&:active {
background-color: --alpha(var(--color-slate-400) / 40%);
@variant dark {
background-color: --alpha(var(--color-zinc-800) / 50%);
}
}
}
.tab-button-selected {
background-color: --alpha(var(--color-slate-300) / 40%);
@variant dark {
background-color: --alpha(var(--color-zinc-700) / 50%);
}
&:hover {
background-color: --alpha(var(--color-zinc-400) / 40%);
@variant dark {
background-color: --alpha(var(--color-zinc-600) / 50%);
}
}
} }
</style> </style>
+3 -3
View File
@@ -46,9 +46,9 @@
<nav <nav
aria-label={$t('aria.pagination.nav')} aria-label={$t('aria.pagination.nav')}
class={[ class={[
'flex flex-row gap-2 items-center justify-center bg-white dark:bg-zinc-950', 'flex flex-row gap-4 items-center justify-center',
'border border-slate-200 dark:border-zinc-800 rounded-full overflow-hidden w-max mx-auto p-0.5', 'rounded-full overflow-hidden w-max mx-auto p-1',
'shadow-md', 'material-distinct',
]} ]}
> >
{#if children} {#if children}
+6 -27
View File
@@ -56,7 +56,7 @@
<nav <nav
class={[ class={[
'tab-bar rounded-full', 'tab-bar rounded-full',
style == 'header' ? 'bar-header material-distinct' : 'gap-2', style == 'header' ? 'bar-header material-uniform' : 'gap-2',
margin && 'my-2', margin && 'my-2',
margin && style == 'subpage' && 'mb-3', margin && style == 'subpage' && 'mb-3',
clazz, clazz,
@@ -71,7 +71,7 @@
{#if style == 'header'} {#if style == 'header'}
<a <a
href={buildUrl(currentRoute, route.href)} href={buildUrl(currentRoute, route.href)}
class={['tab-item ', selected && 'tab-selected']} class={['tab-item ', selected && 'material-distinct tab-selected']}
> >
{route.name} {route.name}
</a> </a>
@@ -100,8 +100,8 @@
} }
.tab-bar.bar-header { .tab-bar.bar-header {
padding: calc(var(--spacing) * 1.5); padding: calc(var(--spacing) * 0.5);
gap: calc(var(--spacing) * 1) calc(var(--spacing) * 2); gap: calc(var(--spacing) * 1) calc(var(--spacing) * 1);
justify-content: center; justify-content: center;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@@ -112,27 +112,6 @@
} }
} }
.tab-selected {
position: relative;
color: var(--color-primary-900);
@variant dark {
color: var(--color-primary-100);
}
@variant hover {
cursor: default !important;
}
}
.tab-selected::before {
content: '';
position: absolute;
inset: calc(var(--spacing) * -1) calc(var(--spacing) * -3);
z-index: -10;
border-radius: 9999px;
}
.tab-item { .tab-item {
&:not(.tab-selected) { &:not(.tab-selected) {
color: var(--color-slate-500); color: var(--color-slate-500);
@@ -140,11 +119,11 @@
@variant dark { @variant dark {
color: var(--color-zinc-500); color: var(--color-zinc-500);
} }
border: 1px solid transparent;
} }
padding: calc(var(--spacing)) calc(var(--spacing) * 3); padding: calc(var(--spacing) * 1.5) calc(var(--spacing) * 4);
border-radius: 999px; border-radius: 999px;
font-weight: var(--font-weight-medium); font-weight: var(--font-weight-medium);
transition: all cubic-bezier(0.075, 0.82, 0.165, 1) 75ms;
z-index: 0; z-index: 0;
flex-shrink: 0; flex-shrink: 0;
+7 -4
View File
@@ -294,14 +294,17 @@
} }
.btn-danger { .btn-danger {
/* border border-red-500 bg-red-500 hover:text-red-500 hover:bg-transparent text-white */ background: linear-gradient(to bottom, var(--color-red-400), var(--color-red-500));
border: 1px solid var(--color-red-600);
background-color: var(--color-red-600); box-shadow:
0px 1.5px 0px 0px inset --alpha(var(--color-red-50) / 50%),
0px -1px 0px 0px inset --alpha(var(--color-red-900) / 50%);
color: var(--color-white); color: var(--color-white);
@variant dark { @variant dark {
background-color: var(--color-red-400); background: linear-gradient(to bottom, var(--color-red-300), var(--color-red-400));
color: var(--color-black); color: var(--color-black);
border: 1px solid var(--color-red-900);
} }
@variant hover { @variant hover {
+62 -9
View File
@@ -21,6 +21,7 @@
id?: string id?: string
rows?: number rows?: number
element?: HTMLTextAreaElement | undefined element?: HTMLTextAreaElement | undefined
unstyled?: boolean
class?: ClassValue class?: ClassValue
customLabel?: import('svelte').Snippet customLabel?: import('svelte').Snippet
suffix?: import('svelte').Snippet suffix?: import('svelte').Snippet
@@ -45,6 +46,7 @@
id = generateID(), id = generateID(),
rows = 4, rows = 4,
element = $bindable(), element = $bindable(),
unstyled = false,
class: clazz = '', class: clazz = '',
customLabel, customLabel,
suffix, suffix,
@@ -65,9 +67,8 @@
{@render customLabel?.()} {@render customLabel?.()}
</Label> </Label>
{/if} {/if}
<div <div class={[!unstyled && 'text-area-container', clazz]}>
class="rounded-xl flex flex-col items-center text-sm bg-white dark:bg-zinc-950 {clazz}" e button danger style)
>
<textarea <textarea
{id} {id}
{placeholder} {placeholder}
@@ -78,12 +79,9 @@
{...rest} {...rest}
class={[ class={[
sizeClass[size], sizeClass[size],
borderClass, 'text-area transition-all peer',
`focus:border-slate-800 dark:focus:border-zinc-200 bg-white dark:bg-zinc-950 !unstyled && borderClass,
focus:outline-hidden focus:ring-2 ring-slate-800/50 rounded-xl dark:ring-zinc-200/50 !unstyled && 'focus:ring-2 ring-slate-800/50 dark:ring-zinc-200/50',
transition-all text-sm w-full disabled:bg-slate-100
disabled:cursor-not-allowed dark:disabled:bg-zinc-900 invalid:border-red-500!
peer invalid:text-red-500 z-10`,
suffix && 'rounded-b-none border-b-0', suffix && 'rounded-b-none border-b-0',
clazz, clazz,
]} ]}
@@ -101,3 +99,58 @@
</div> </div>
{@render children?.()} {@render children?.()}
</div> </div>
<style>
@reference '../../../../app.css';
.text-area-container {
border-radius: var(--radius-xl);
display: flex;
flex-direction: column;
align-items: center;
font-size: var(--text-sm);
background: linear-gradient(
to top,
var(--color-white),
var(--color-slate-100)
);
@variant dark {
background: linear-gradient(
to bottom,
var(--color-zinc-900),
color-mix(
in oklab,
var(--color-zinc-800) 50%,
var(--color-zinc-900) 50%
)
);
}
@variant focus-within {
border-color: var(--color-primary-900);
@variant dark {
border-color: var(--color-primary-100);
}
}
}
.text-area {
border-radius: inherit;
width: 100%;
@variant focus {
outline: none;
}
@variant disabled {
cursor: not-allowed;
background-color: var(--color-slate-100);
@variant dark {
background: var(--color-zinc-900);
}
}
}
</style>
+14 -8
View File
@@ -86,7 +86,12 @@
]} ]}
> >
{#if icon} {#if icon}
<Icon src={icon} size="20" mini class="inline-block rounded-lg clear-both float-left mr-2" /> <Icon
src={icon}
size="20"
mini
class="inline-block rounded-lg clear-both float-left mr-2"
/>
{/if} {/if}
{@render children?.()} {@render children?.()}
</svelte:element> </svelte:element>
@@ -130,8 +135,7 @@
.material-distinct { .material-distinct {
background-color: --alpha(var(--color-slate-50) / 70%); background-color: --alpha(var(--color-slate-50) / 70%);
border-width: 1px; border: 1px solid var(--color-slate-200);
border-color: var(--color-slate-200);
box-shadow: 0px 1.5px 0px 0px --alpha(var(--color-white) / 90%) inset; box-shadow: 0px 1.5px 0px 0px --alpha(var(--color-white) / 90%) inset;
@variant not-dark { @variant not-dark {
@@ -139,9 +143,13 @@
} }
@variant dark { @variant dark {
background-color: --alpha(var(--color-zinc-925) / 70%); background: linear-gradient(
border-color: --alpha(var(--color-black) / 30%); to bottom,
box-shadow: 0px 1.5px 0px 0px --alpha(var(--color-zinc-800) / 80%) inset; var(--color-zinc-800),
var(--color-zinc-900)
);
border-color: oklab(0.2 0 00%);
box-shadow: 0px 1.5px 0px 0px --alpha(var(--color-zinc-700) / 80%) inset;
} }
} }
@@ -160,12 +168,10 @@
} }
.material-uniform { .material-uniform {
background-color: white;
border-width: 1px; border-width: 1px;
border-color: var(--color-slate-200); border-color: var(--color-slate-200);
@variant dark { @variant dark {
background-color: var(--color-zinc-950);
border-color: var(--color-zinc-900); border-color: var(--color-zinc-900);
} }
} }