theming improvements
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import ZapIcon from '@lucide/svelte/icons/zap';
|
import ZapIcon from '@lucide/svelte/icons/zap';
|
||||||
|
import PlusIcon from '@lucide/svelte/icons/plus';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import ColorPicker from 'svelte-awesome-color-picker';
|
import ColorPicker from 'svelte-awesome-color-picker';
|
||||||
|
|
||||||
@@ -66,12 +67,13 @@
|
|||||||
goto(`${$currentOrgPath}/settings${pathname}`);
|
goto(`${$currentOrgPath}/settings${pathname}`);
|
||||||
}
|
}
|
||||||
let isCustomTheme = $derived($currentOrg?.theme?.includes('#'));
|
let isCustomTheme = $derived($currentOrg?.theme?.includes('#'));
|
||||||
|
let hex = $derived($currentOrg.theme.includes('#') ? $currentOrg.theme : null);
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
console.log('$currentOrg?.theme', $currentOrg?.theme);
|
console.log('$currentOrg?.theme', $currentOrg?.theme);
|
||||||
|
console.log('hex', hex);
|
||||||
console.log('isCustomTheme', isCustomTheme);
|
console.log('isCustomTheme', isCustomTheme);
|
||||||
});
|
});
|
||||||
let hex = $derived($currentOrg.theme.includes('#') ? $currentOrg.theme : undefined);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<UnsavedChanges bind:hasUnsavedChanges />
|
<UnsavedChanges bind:hasUnsavedChanges />
|
||||||
@@ -106,7 +108,7 @@
|
|||||||
<Field.Field>
|
<Field.Field>
|
||||||
<div class="flex items-center gap-5">
|
<div class="flex items-center gap-5">
|
||||||
<button
|
<button
|
||||||
class="rounded-full border-2 {$currentOrg.theme === themes.blue &&
|
class="cursor-pointer rounded-full border-2 {$currentOrg.theme === themes.blue &&
|
||||||
'border-[#1d4ee2]'} flex h-fit items-center justify-center"
|
'border-[#1d4ee2]'} flex h-fit items-center justify-center"
|
||||||
onclick={handleChangeTheme(themes.blue)}
|
onclick={handleChangeTheme(themes.blue)}
|
||||||
aria-label="Default blue theme"
|
aria-label="Default blue theme"
|
||||||
@@ -115,7 +117,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="rounded-full border-2 {$currentOrg.theme === themes.rose &&
|
class="cursor-pointer rounded-full border-2 {$currentOrg.theme === themes.rose &&
|
||||||
'border-[#be1241]'} flex h-fit items-center justify-center"
|
'border-[#be1241]'} flex h-fit items-center justify-center"
|
||||||
onclick={handleChangeTheme(themes.rose)}
|
onclick={handleChangeTheme(themes.rose)}
|
||||||
aria-label="Rose theme"
|
aria-label="Rose theme"
|
||||||
@@ -124,7 +126,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="rounded-full border-2 {$currentOrg.theme === themes.green &&
|
class="cursor-pointer rounded-full border-2 {$currentOrg.theme === themes.green &&
|
||||||
'border-[#0c891b]'} flex h-fit items-center justify-center"
|
'border-[#0c891b]'} flex h-fit items-center justify-center"
|
||||||
onclick={handleChangeTheme(themes.green)}
|
onclick={handleChangeTheme(themes.green)}
|
||||||
aria-label="Green theme"
|
aria-label="Green theme"
|
||||||
@@ -133,7 +135,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="rounded-full border-2 {$currentOrg.theme === themes.orange &&
|
class="cursor-pointer rounded-full border-2 {$currentOrg.theme === themes.orange &&
|
||||||
'border-[#cc4902]'} flex h-fit items-center justify-center"
|
'border-[#cc4902]'} flex h-fit items-center justify-center"
|
||||||
onclick={handleChangeTheme(themes.orange)}
|
onclick={handleChangeTheme(themes.orange)}
|
||||||
aria-label="Orange theme"
|
aria-label="Orange theme"
|
||||||
@@ -142,7 +144,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="rounded-full border-2 {$currentOrg.theme === themes.purple &&
|
class="cursor-pointer rounded-full border-2 {$currentOrg.theme === themes.purple &&
|
||||||
'border-purple-600'} flex h-fit items-center justify-center"
|
'border-purple-600'} flex h-fit items-center justify-center"
|
||||||
onclick={handleChangeTheme(themes.purple)}
|
onclick={handleChangeTheme(themes.purple)}
|
||||||
aria-label="Purple theme"
|
aria-label="Purple theme"
|
||||||
@@ -152,22 +154,15 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
style={`border-color: ${isCustomTheme ? $currentOrg.theme : 'dark:border-neutral-700'};`}
|
style={`border-color: ${isCustomTheme ? $currentOrg.theme : 'dark:border-neutral-700'};`}
|
||||||
class="group relative h-auto w-fit rounded-full border-2"
|
class="group relative cursor-pointer h-auto w-fit rounded-full border-2"
|
||||||
>
|
>
|
||||||
<!-- plus icon positioned over the color picker -->
|
<!-- plus icon positioned over the color picker -->
|
||||||
<div
|
<div
|
||||||
class="pointer-events-none absolute inset-0 flex items-center justify-center transition-opacity duration-200"
|
class="pointer-events-none absolute inset-0 flex items-center justify-center transition-opacity duration-200"
|
||||||
>
|
>
|
||||||
<svg
|
<PlusIcon
|
||||||
class="h-6 w-6 text-{isCustomTheme ? 'white' : 'black'} z-10 opacity-100 dark:text-white"
|
class="size-6 z-10 {!!hex ? 'stroke-white' : 'stroke-gray-500'}"
|
||||||
fill="none"
|
/>
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="2"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4"></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
position="responsive"
|
position="responsive"
|
||||||
@@ -241,4 +236,8 @@
|
|||||||
:global(.dark .alpha) {
|
:global(.dark .alpha) {
|
||||||
background: #333 !important;
|
background: #333 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:global(.color::before) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export function injectCustomTheme(hex: string) {
|
|||||||
|
|
||||||
const styleContent = `
|
const styleContent = `
|
||||||
body[data-theme="${hex}"] {
|
body[data-theme="${hex}"] {
|
||||||
--primary: ${shades[600]};
|
--primary: ${shades[700]};
|
||||||
--primary-foreground: ${shades[50]};
|
--primary-foreground: ${shades[50]};
|
||||||
--ring: ${shades[400]};
|
--ring: ${shades[400]};
|
||||||
--chart-1: ${shades[300]};
|
--chart-1: ${shades[300]};
|
||||||
@@ -45,7 +45,7 @@ export function injectCustomTheme(hex: string) {
|
|||||||
--chart-3: ${shades[600]};
|
--chart-3: ${shades[600]};
|
||||||
--chart-4: ${shades[700]};
|
--chart-4: ${shades[700]};
|
||||||
--chart-5: ${shades[800]};
|
--chart-5: ${shades[800]};
|
||||||
--sidebar-primary: ${shades[600]};
|
--sidebar-primary: ${shades[700]};
|
||||||
--sidebar-primary-foreground: ${shades[50]};
|
--sidebar-primary-foreground: ${shades[50]};
|
||||||
--sidebar-accent: ${shades[50]};
|
--sidebar-accent: ${shades[50]};
|
||||||
--sidebar-accent-foreground: ${shades[700]};
|
--sidebar-accent-foreground: ${shades[700]};
|
||||||
|
|||||||
Reference in New Issue
Block a user