diff --git a/README.md b/README.md index db70314d..b3d9dc44 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ It is designed for all features to have an appealing and intuitive design, while ![image](https://github.com/Xyphyn/photon/assets/80978739/e36468f6-03c5-4267-94e8-3bba60b6ccb2) - ## Self-hosting Put Photon on your own domain for easier onboarding. @@ -66,7 +65,8 @@ These are the most important environment variables that you can change: | PUBLIC_FAVICON | URL | `/img/logo-background.svg | | PUBLIC_SSR_ENABLED | `bool` | `false` | | PUBLIC_MIGRATE_COOKIE | `bool` | `false` | -| PUBLIC_THEME | system\|dark\|light | system | +| PUBLIC_THEME | JSON | Photon's default colors | +| PUBLIC_COLORSCHEME | system\|dark\|light | system | | PUBLIC_EXPANDABLE_IMAGES | `bool` | true | | PUBLIC_MARK_READ_POSTS | `bool` | true | | PUBLIC_DEFAULT_FEED_SORT | `SortType` | Active | 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..fcbf87dc 100644 --- a/src/routes/theme/+page.svelte +++ b/src/routes/theme/+page.svelte @@ -3,30 +3,32 @@ Button, Material, Modal, + Note, TextArea, action, 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, hexToRgb, theme, themeData } from '$lib/ui/colors' + import { getDefaultColors } from '$lib/ui/presets' + import ThemePreset from './ThemePreset.svelte' let importing = false let importText = '' + + $: defaultColors = getDefaultColors() {#if importing} @@ -37,7 +39,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,19 +56,52 @@
Theme
+
+ {#each $themeData.themes as theme} + + {/each} + +
- -

{$t('routes.theme.accent')}

- - - - {$t('nav.menu.colorscheme.light')} - - - {$t('nav.menu.colorscheme.dark')} - -
-
- {#each svelteIntellisenseSucks() as category} - -

{category}

-
- {#each Object.keys(c[category]) as shade} -
- - - {shade} -
- {/each} -
-
- {/each} + {#if $theme.id <= 0} + + {$t('routes.theme.preset.description')} + + {/if} +
+ +

{$t('routes.theme.accent')}

+ { + $theme.colors.primary[900] = e.detail + }} + backgroundColor={defaultColors.primary[900]} + on:contextmenu={(e) => { + e.preventDefault() + $theme.colors.primary[900] = + // @ts-ignore + defaultColors.primary[900] + + return true + }} + class="!w-12 !h-12 col-span-1" + /> + { + $theme.colors.primary[100] = e.detail + }} + backgroundColor={defaultColors.primary[100]} + on:contextmenu={(e) => { + e.preventDefault() + $theme.colors.primary[100] = + // @ts-ignore + defaultColors.primary[100] + + return true + }} + class="!w-12 !h-12 col-span-1" + /> + + {$t('nav.menu.colorscheme.light')} + + + {$t('nav.menu.colorscheme.dark')} + +
+
+ {#each Object.entries(defaultColors) as [category, value]} + +

{category}

+
+ {#each Object.entries(value) as [shade, color]} +
+ + { + $theme.colors[category][shade] = e.detail + }} + on:contextmenu={(e) => { + e.preventDefault() + $theme.colors[category][shade] = + // @ts-ignore + defaultColors[category][shade] + + return true + }} + /> + {shade} +
+ {/each} +
+
+ {/each} +
- export let backgroundColor: string = '' + import { hexToRgb } from '$lib/ui/colors' + import { createEventDispatcher } from 'svelte' + export let value: string + + const dispatch = createEventDispatcher<{ change: string }>()
dispatch('change', hexToRgb(value))} + on:contextmenu />
diff --git a/src/routes/theme/ThemePreset.svelte b/src/routes/theme/ThemePreset.svelte new file mode 100644 index 00000000..eed62a27 --- /dev/null +++ b/src/routes/theme/ThemePreset.svelte @@ -0,0 +1,97 @@ + + + + {/if} + {#if theme.id > 0} + + {/if} +
+ + diff --git a/tailwind.config.js b/tailwind.config.js index e7892981..cb0b044c 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -30,39 +30,39 @@ export default { }, colors: { slate: { - 25: 'var(--c-s-25,#fcfdfe)', - 50: `var(--c-s-50,${colors.slate[50]})`, - 100: `var(--c-s-100,${colors.slate[100]})`, - 200: `var(--c-s-200,#e8edf4)`, - 300: `var(--c-s-300,${colors.slate[300]})`, - 400: `var(--c-s-400,${colors.slate[400]})`, - 500: `var(--c-s-500,${colors.slate[500]})`, - 600: `var(--c-s-600,${colors.slate[600]})`, - 700: `var(--c-s-700,${colors.slate[700]})`, - 800: `var(--c-s-800,${colors.slate[800]})`, - 900: `var(--c-s-900,${colors.slate[900]})`, - 950: `var(--c-s-950,${colors.slate[950]})`, + 25: 'rgb(var(--c-s-25,252 253 254) / )', + 50: 'rgb(var(--c-s-50,248 250 252) / )', + 100: 'rgb(var(--c-s-100,241 245 249) / )', + 200: 'rgb(var(--c-s-200,226 232 240) / )', + 300: 'rgb(var(--c-s-300,203 213 225) / )', + 400: 'rgb(var(--c-s-400,148 163 184) / )', + 500: 'rgb(var(--c-s-500,100 116 139) / )', + 600: 'rgb(var(--c-s-600,71 85 105) / )', + 700: 'rgb(var(--c-s-700,51 65 85) / )', + 800: 'rgb(var(--c-s-800,30 41 59) / )', + 900: 'rgb(var(--c-s-900,15 23 42) / )', + 950: 'rgb(var(--c-s-950,2 6 23) / )', }, zinc: { - 50: `var(--c-z-50,${colors.zinc[50]})`, - 100: `var(--c-z-100,${colors.zinc[100]})`, - 200: `var(--c-z-200,${colors.zinc[200]})`, - 300: `var(--c-z-300,${colors.zinc[300]})`, - 400: `var(--c-z-400,${colors.zinc[400]})`, - 500: `var(--c-z-500,${colors.zinc[500]})`, - 600: `var(--c-z-600,${colors.zinc[600]})`, - 700: 'var(--c-z-700,#34343b)', - 800: 'var(--c-z-800,#1f1f24)', - 900: 'var(--c-z-900,#121215)', - 925: 'var(--c-z-925,#0c0c0e)', - 950: `var(--c-z-950,${colors.zinc[950]})`, + 50: `rgb(var(--c-z-50,249 250 251) / )`, + 100: `rgb(var(--c-z-100,243 244 246) / )`, + 200: `rgb(var(--c-z-200,229 231 235) / )`, + 300: `rgb(var(--c-z-300,209 213 219) / )`, + 400: `rgb(var(--c-z-400,156 163 175) / )`, + 500: `rgb(var(--c-z-500,107 114 128) / )`, + 600: `rgb(var(--c-z-600,75 85 99) / )`, + 700: 'rgb(var(--c-z-700,50 60 76) / )', + 800: 'rgb(var(--c-z-800,22 31 45) / )', + 900: 'rgb(var(--c-z-900,17 24 39) / )', + 925: 'rgb(var(--c-z-925,8 12 25) / )', + 950: `rgb(var(--c-z-950,5 9 16) / )`, }, primary: { - 100: 'var(--c-p-100,#f1f5f9)', - 900: 'var(--c-p-900,#0f172a)', + 100: 'rgb(var(--c-p-100,241 245 249) / )', + 900: 'rgb(var(--c-p-900,15 23 42) / )', }, - black: `#000`, - white: `var(--c-o-white,#fff)`, + black: `rgb(var(--c-o-black,0 0 0) / )`, + white: `rgb(var(--c-o-white,255 255 255) / )`, }, }, },