refactor: use native css w/ tailwindcss restrictions

This commit is contained in:
Xylight committed 2025-09-21 16:12:53 -07:00
1 parent 9a27e95a5f
commit e61d77f46e
12 files changed
+251 -66

No files matched your search

BIN
View File
Binary file not shown.
+1 -2
View File
@@ -14,7 +14,7 @@
"@sveltejs/kit": "^2.42.2",
"@sveltejs/vite-plugin-svelte": "^4.0.4",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/postcss": "^4.1.13",
"@tailwindcss/vite": "^4.1.13",
"@types/nprogress": "^0.2.3",
"@types/ua-parser-js": "^0.7.39",
"@xylightdev/svelte-hero-icons": "^2.2.7",
@@ -27,7 +27,6 @@
"marked-linkify-it": "^3.1.13",
"nprogress": "^0.2.0",
"openapi-fetch": "^0.14.0",
"postcss": "^8.5.6",
"prettier": "^3.6.2",
"prettier-plugin-svelte": "^3.4.0",
"svelte": "^5.39.2",
-5
View File
@@ -1,5 +0,0 @@
export default {
plugins: {
'@tailwindcss/postcss': {},
},
}
View File
File renamed without changes.
+52 -11
View File
@@ -32,25 +32,19 @@
</script>
<Button
color="none"
{...rest}
color="none"
rounding="none"
class={[
'shrink-0 lg:rounded-xl w-10 h-10 rounded-full',
adaptive ? 'lg:w-max lg:h-8' : 'lg:w-8 lg:h-8',
!rest.color &&
'hover:text-slate-900 dark:hover:text-zinc-50 transition-colors',
!rest.color &&
(isSelected
? 'text-primary-900 dark:text-primary-100 max-lg:bg-slate-100 max-lg:dark:bg-zinc-800'
: 'text-slate-500 dark:text-zinc-400'),
'nav-btn',
adaptive && 'nav-btn-dynamic',
isSelected && 'nav-btn-selected',
clazz,
]}
shadow="none"
size="custom"
rounding="none"
{href}
title={label}
style="transition-property: background-color, filter, transform, scale;"
aria-selected={isSelected}
>
{#snippet prefix()}
@@ -68,3 +62,50 @@
<span class="hidden {adaptive ? 'lg:block' : ''}">{label}</span>
{@render children?.()}
</Button>
<style>
@reference '../../../../app.css';
:global {
.nav-btn {
width: calc(var(--spacing) * 10);
height: calc(var(--spacing) * 10);
border-radius: 9999px;
color: var(--color-slate-500);
@variant dark {
color: var(--color-zinc-400);
}
@variant hover {
color: var(--color-slate-900);
@variant dark {
color: var(--color-zinc-50);
}
}
transition-property: color;
}
.nav-btn-dynamic {
@variant lg {
width: max-content;
}
}
.nav-btn-selected {
color: var(--color-primary-900);
@variant dark {
color: var(--color-primary-100);
}
@variant max-lg {
background-color: var(--color-slate-200);
@variant dark {
background-color: var(--color-zinc-800);
}
}
}
}
</style>
+179 -23
View File
@@ -10,19 +10,14 @@
}
export const buttonColor = {
primary: `border border-transparent bg-primary-900 text-slate-50 dark:bg-primary-100 dark:text-black`,
secondary: `border border-slate-200 border-b-slate-300 dark:border-zinc-800 bg-white dark:bg-zinc-900`,
tertiary:
' bg-transparent hover:bg-slate-200/50 dark:hover:bg-zinc-700/30 dark:text-zinc-200',
danger:
'border border-red-500 bg-red-500 hover:text-red-500 hover:bg-transparent text-white',
primary: 'btn-primary',
secondary: 'btn-secondary',
tertiary: 'btn-tertiary',
danger: 'btn-danger',
ghost: 'btn-ghost',
'danger-subtle': 'text-red-500 hover:bg-red-500 hover:text-inherit!',
'success-subtle': 'text-green-500 hover:bg-green-500 hover:text-inherit!',
'warning-subtle': 'text-yellow-500 hover:bg-yellow-500 hover:text-inherit!',
ghost: `border border-slate-200 dark:border-zinc-800 bg-transparent
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`,
'blue-subtle': `text-blue-500 hover:bg-blue-500 hover:text-inherit!`,
none: '',
@@ -36,15 +31,15 @@
export type ButtonSize = keyof typeof buttonSize
export const buttonSize = {
xs: 'px-2 py-1 text-xs',
sm: 'px-3 py-1.5 text-[12px]',
md: 'px-3 py-1.5 text-sm',
lg: 'px-4 py-2 text-sm',
xl: 'px-6 py-3 text-base',
'square-sm': 'w-6 h-6',
'square-md': 'w-8 h-8',
'square-lg': 'w-10 h-10',
'square-xl': 'w-12 h-12',
xs: 'btn-xs',
sm: 'btn-sm',
md: 'btn-md',
lg: 'btn-lg',
xl: 'btn-xl',
'square-sm': 'btn-square-sm',
'square-md': 'btn-square-md',
'square-lg': 'btn-square-lg',
'square-xl': 'btn-square-xl',
custom: '',
}
@@ -61,6 +56,7 @@
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
loading?: boolean
submit?: boolean
type?: 'button' | 'none'
color?: ButtonColor
size?: ButtonSize
rounding?: ButtonRoundness
@@ -93,6 +89,7 @@
let {
loading = false,
submit = false,
type = 'button',
color = 'secondary',
size = 'md',
rounding = 'xl',
@@ -117,15 +114,13 @@
{...rest}
tabindex={disabled ? -1 : undefined}
class={[
type == 'button' && 'btn',
buttonSize[size],
buttonRounding[rounding],
buttonShadow[shadow],
buttonColor[color],
buttonAlignment[alignment],
'transition-all font-medium cursor-pointer disabled:opacity-50 disabled:pointer-events-none',
'hover:brightness-98 hover:dark:brightness-95 active:brightness-90 active:dark:brightness-85 text-sm',
'flex flex-row items-center gap-1.5',
(disabled || loading) && 'pointer-events-none opacity-50 shadow-none',
(disabled || loading) && 'btn-disabled',
alignment == 'center'
? 'origin-center'
: alignment == 'left'
@@ -157,3 +152,164 @@
@slot `prefix` -- Will be replaced if `loading` is `true`.
@slot `suffix`
-->
<style>
@reference "../../../app.css";
:global {
.btn {
display: flex;
flex-direction: row;
align-items: center;
font-size: var(--text-sm);
gap: calc(var(--spacing) * 1.5);
font-weight: var(--font-weight-medium);
transition: 75ms linear;
@variant hover {
cursor: pointer;
}
}
.btn-primary {
border: 1px solid transparent;
background-color: var(--color-primary-900);
color: var(--color-slate-50);
@variant dark {
background-color: var(--color-primary-100) !important;
color: var(--color-zinc-900);
}
@variant hover {
filter: brightness(120%);
@variant dark {
filter: brightness(90%);
}
}
}
.btn-secondary {
border: 1px solid var(--color-slate-200);
border-bottom-color: var(--color-slate-300);
background-color: var(--color-white);
@variant dark {
border: 1px solid var(--color-zinc-800);
background-color: var(--color-zinc-900);
}
@variant hover {
background-color: var(--color-slate-50);
@variant dark {
background-color: var(--color-zinc-950);
}
}
}
.btn-tertiary {
background-color: transparent;
@variant hover {
background-color: --alpha(var(--color-slate-200) / 50%);
@variant dark {
background-color: --alpha(var(--color-zinc-700) / 30%);
}
}
}
.btn-danger {
/* border border-red-500 bg-red-500 hover:text-red-500 hover:bg-transparent text-white */
background-color: var(--color-red-600);
color: var(--color-white);
@variant dark {
background-color: var(--color-red-400);
color: var(--color-black);
}
@variant hover {
filter: brightness(120%);
@variant dark {
filter: brightness(90%);
}
}
}
.btn-ghost {
/* border border-slate-200 dark:border-zinc-800 bg-transparent
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 */
border: 1px solid var(--color-slate-200);
background-color: transparent;
@variant hover {
background-color: var(--color-slate-100);
}
@variant dark {
border-color: var(--color-zinc-800);
@variant hover {
background-color: var(--color-zinc-800);
border-color: var(--color-zinc-700);
color: var(--color-zinc-200);
}
}
}
.btn-xs {
padding: calc(var(--spacing) * 1) calc(var(--spacing) * 2);
font-size: var(--text-xs);
}
.btn-sm {
padding: calc(var(--spacing) * 1.5) calc(var(--spacing) * 3);
font-size: 12px;
}
.btn-md {
padding-block: calc(var(--spacing) * 1.5);
padding-inline: calc(var(--spacing) * 3);
font-size: var(--text-sm);
}
.btn-lg {
padding-block: calc(var(--spacing) * 2);
padding-inline: calc(var(--spacing) * 3);
font-size: var(--text-sm);
}
.btn-xl {
padding: calc(var(--spacing) * 3) calc(var(--spacing) * 6);
font-size: var(--text-base);
}
.btn-square-sm {
width: calc(var(--spacing) * 6);
height: calc(var(--spacing) * 6);
}
.btn-square-md {
width: calc(var(--spacing) * 8);
height: calc(var(--spacing) * 8);
}
.btn-square-lg {
width: calc(var(--spacing) * 10);
height: calc(var(--spacing) * 10);
}
.btn-square-xl {
width: calc(var(--spacing) * 12);
height: calc(var(--spacing) * 12);
}
.btn-disabled {
pointer-events: none;
filter: brightness(70%);
cursor: normal;
}
}
</style>
+7 -10
View File
@@ -3,8 +3,7 @@
value?: T | string | undefined
placeholder?: string | undefined
label?: string | undefined
size?: ButtonSize
shadow?: ButtonShadow
size?: 'md' | 'sm'
id?: string
class?: ClassValue
baseClass?: ClassValue
@@ -35,7 +34,7 @@
<script lang="ts" generics="T">
import { setContext, tick, type Snippet } from 'svelte'
import type { Placement } from 'svelte-floating-ui/core'
import type { Placement } from 'svelte-floating-ui/dom'
import {
CheckCircle,
ChevronUpDown,
@@ -48,8 +47,6 @@
buttonColor,
buttonShadow,
buttonSize,
type ButtonShadow,
type ButtonSize,
} from '../../button/Button.svelte'
import Menu from '../../popover/Menu.svelte'
import MenuButton from '../../popover/MenuButton.svelte'
@@ -77,7 +74,6 @@
placeholder = undefined,
label = undefined,
size = 'md',
shadow = 'none',
class: clazz = '',
baseClass = '',
selectClass = '',
@@ -105,10 +101,7 @@
bind:this={element}
class={[
buttonSize[size],
buttonShadow[shadow],
buttonColor.secondary,
'appearance-none transition-all rounded-xl text-sm w-full min-w-full cursor-pointer pr-6',
'hover:brightness-98 hover:dark:brightness-90',
'btn btn-secondary select rounded-xl appearance-none pr-6!',
selectClass,
clazz,
]}
@@ -187,3 +180,7 @@
{/if}
{/each}
</Menu>
<style>
@reference '../../../../app.css';
</style>
+2 -1
View File
@@ -39,10 +39,11 @@
<Button
{...rest}
{color}
type="none"
size="custom"
rounding="none"
class={[
'w-full px-3 py-1.5 min-h-7 duration-75 hover:cursor-default font-normal rounded-lg',
'w-full px-3 py-1.5 min-h-7 duration-75 hover:cursor-default font-normal rounded-lg flex items-center gap-1 text-sm',
disabled && 'opacity-70 pointer-events-none cursor-not-allowed',
color == 'tertiary' && 'dark:hover:bg-zinc-800/70',
clazz,
+1 -1
View File
@@ -22,7 +22,7 @@
import 'nprogress/nprogress.css'
import { onMount } from 'svelte'
import { Forward } from 'svelte-hero-icons'
import '../style/app.css'
import '../app.css'
interface Props {
children?: import('svelte').Snippet
}
+5 -11
View File
@@ -97,22 +97,16 @@
{$t('routes.accounts')}
{#snippet extended()}
<div class="flex">
<div class="flex gap-2 mr-auto">
<div class="flex gap-2 mr-auto items-center">
<Button
href="/accounts/login"
rounding="pill"
class="px-4"
color="primary"
icon={ArrowLeftOnRectangle}
>
{$t('account.login')}
</Button>
<Button
href="/signup"
rounding="pill"
class="px-4"
icon={Identification}
>
<Button href="/signup" rounding="pill" icon={Identification}>
{$t('account.signup')}
</Button>
{#if !LINKED_INSTANCE_URL}
@@ -165,9 +159,9 @@
{/if}
</span>
<span class="text-sm text-slate-600 dark:text-zinc-400">
<span class="capitalize"
>{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}</span
>
<span class="capitalize">
{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}
</span>
• {p.instance}
</span>
</div>
+2 -1
View File
@@ -47,7 +47,7 @@
<Header pageHeader class="lg:flex-row justify-between flex-col">
{$t('routes.inbox.title')}
<div class="flex items-center gap-2 tracking-normal">
<div class="flex gap-2 tracking-normal">
<Button
onclick={() => goto(page.url, { invalidateAll: true })}
size="custom"
@@ -63,6 +63,7 @@
rounding="pill"
color="primary"
icon={Check}
size="lg"
>
{$t('routes.inbox.markAsRead')}
</Button>
+2 -1
View File
@@ -1,8 +1,9 @@
import { sveltekit } from '@sveltejs/kit/vite'
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [sveltekit()],
plugins: [sveltekit(), tailwindcss()],
define: {
__VERSION__: JSON.stringify(process.env.npm_package_version),