From 3aa948891a65f3da14d9f551fbc06a24551d45eb Mon Sep 17 00:00:00 2001 From: Xylight Date: Wed, 24 Jul 2024 21:32:10 -0700 Subject: [PATCH] feat: remake theme handling --- .../lemmy/comment/CommentVote.svelte | 1 - src/lib/components/ui/layout/Shell.svelte | 16 +- src/lib/components/ui/navbar/Profile.svelte | 10 +- .../components/ui/navbar/commands/actions.ts | 8 +- src/lib/ui/colors.ts | 316 +++++++++--------- src/lib/ui/presets.ts | 75 +++++ src/routes/+layout.svelte | 31 +- src/routes/theme/+page.svelte | 139 +++++++- src/routes/theme/ColorSwatch.svelte | 10 +- tailwind.config.js | 56 ++-- 10 files changed, 413 insertions(+), 249 deletions(-) create mode 100644 src/lib/ui/presets.ts diff --git a/src/lib/components/lemmy/comment/CommentVote.svelte b/src/lib/components/lemmy/comment/CommentVote.svelte index 4725b814..a7db5a1f 100644 --- a/src/lib/components/lemmy/comment/CommentVote.svelte +++ b/src/lib/components/lemmy/comment/CommentVote.svelte @@ -1,5 +1,4 @@ - {#if $site?.site_view} {$site?.site_view.site.name} {#if LINKED_INSTANCE_URL} diff --git a/src/routes/theme/+page.svelte b/src/routes/theme/+page.svelte index 2b039f4c..f7fee54e 100644 --- a/src/routes/theme/+page.svelte +++ b/src/routes/theme/+page.svelte @@ -8,25 +8,30 @@ modal, toast, } from 'mono-svelte' - import { defaultColors, type Colors, colors } from '$lib/ui/colors' import { ArrowDownTray, ArrowPath, ArrowUpTray, Bookmark, + CheckCircle, Icon, + Plus, } from 'svelte-hero-icons' import ColorSwatch from './ColorSwatch.svelte' import { t } from '$lib/translations' import Header from '$lib/components/ui/layout/pages/Header.svelte' - - const c = defaultColors - - const svelteIntellisenseSucks = (): (keyof Colors)[] => - ['slate', 'zinc', 'other'] as (keyof Colors)[] + import { + calculateVars, + getDefaultColors, + hexToRgb, + theme, + themeData, + } from '$lib/ui/colors' let importing = false let importText = '' + + $: defaultColors = getDefaultColors() {#if importing} @@ -37,7 +42,7 @@ if (importText == '') { throw new Error('Import is empty') } - $colors = JSON.parse(importText) + $theme.colors = JSON.parse(importText) toast({ content: $t('message.success'), type: 'success' }) importing = false } catch (err) { @@ -54,6 +59,70 @@
Theme
+
+ {#each $themeData.themes as theme} + + {/each} + +