diff --git a/src/svelte-interface/pages/themeCreator.svelte b/src/svelte-interface/pages/themeCreator.svelte
index e1ad90e5..8bbc73b0 100644
--- a/src/svelte-interface/pages/themeCreator.svelte
+++ b/src/svelte-interface/pages/themeCreator.svelte
@@ -1,8 +1,9 @@
{#snippet settingItem(item: SettingItem)}
-
-
-
{item.title}
-
{item.description}
-
- {#if item.type === 'switch'}
-
- {:else if item.type === 'button'}
-
- {:else if item.type === 'slider'}
-
- {:else if item.type === 'colourPicker'}
-
- {:else if item.type === 'codeEditor'}
-
- {:else if item.type === 'imageUpload'}
- {#each theme.CustomImages as image (image.id)}
-
-
-
})
-
-
onImageVariableChange(image.id, e.currentTarget.value)}
- placeholder="CSS Variable Name"
- class="flex-grow flex-[3] w-full p-2 transition-all duration-300 rounded-lg focus:outline-none ring-0 focus:ring-1 ring-zinc-100 dark:ring-zinc-700 dark:bg-zinc-800/50 dark:text-white"
- />
-
-
- {/each}
+
+
+
{ item.direction === 'vertical' && toggleAccordion(item.title) }}
+ onkeydown={(e) => { e.key === 'Enter' && item.direction === 'vertical' && toggleAccordion(item.title) }}
+ class="flex justify-between pr-4 {item.direction === 'vertical' ? 'cursor-pointer w-full select-none' : ''}">
+
+
{item.title}
+
{item.description}
+
-
-
{'\uec60'}
-
Add image
-
+ {#if item.direction === 'vertical'}
+
+ {'\ue9e6'}
+
+ {/if}
+
+
+ {#if !closedAccordions.includes(item.title)}
+
+ {#if item.type === 'switch'}
+
+ {:else if item.type === 'button'}
+
+ {:else if item.type === 'slider'}
+
+ {:else if item.type === 'colourPicker'}
+
+ {:else if item.type === 'codeEditor'}
+
+ {:else if item.type === 'imageUpload'}
+ {#each theme.CustomImages as image (image.id)}
+
+
+

+
+
onImageVariableChange(image.id, e.currentTarget.value)}
+ placeholder="CSS Variable Name"
+ class="flex-grow flex-[3] w-full p-2 transition-all duration-300 rounded-lg focus:outline-none ring-0 focus:ring-1 ring-zinc-100 dark:ring-zinc-700 dark:bg-zinc-800/50 dark:text-white"
+ />
+
+
+ {/each}
+
+
+ {'\uec60'}
+ Add image
+
+
+ {/if}
{/if}
@@ -147,7 +186,7 @@
type='text'
placeholder='What is your theme called?'
bind:value={theme.name}
- class='w-full p-2 mb-4 transition-all duration-300 rounded-lg focus:outline-none ring-0 focus:ring-1 ring-zinc-100 dark:ring-zinc-700 dark:bg-zinc-900 dark:text-white' />
+ class='w-full p-2 mb-4 transition border-0 rounded-lg placeholder-zinc-300 bg-zinc-100 dark:bg-zinc-700 focus:bg-zinc-200/50 dark:focus:bg-zinc-600' />
@@ -156,12 +195,12 @@
id='themeDescription'
placeholder="Don't worry, this one's optional!"
bind:value={theme.description}
- class='w-full p-2 rounded-lg focus:outline-none ring-0 focus:ring-1 ring-zinc-100 dark:ring-zinc-700 dark:bg-zinc-900 dark:text-white'>
+ class='w-full p-2 transition border-0 rounded-lg placeholder-zinc-300 bg-zinc-100 dark:bg-zinc-700 focus:outline-none focus:ring-1 focus:ring-zinc-100 dark:focus:ring-zinc-700 focus:bg-zinc-200/50 dark:focus:bg-zinc-600'>
-
+
{'\uec60'}
@@ -172,7 +211,7 @@
{/if}
{#if theme.coverImage}
-
})
+

{/if}
diff --git a/src/svelte-interface/utils/themeImageHandlers.ts b/src/svelte-interface/utils/themeImageHandlers.ts
index 2f555f5d..977d02ff 100644
--- a/src/svelte-interface/utils/themeImageHandlers.ts
+++ b/src/svelte-interface/utils/themeImageHandlers.ts
@@ -1,10 +1,10 @@
-import type { CustomTheme } from '@/types/CustomThemes';
+import type { LoadedCustomTheme } from '@/types/CustomThemes';
export function generateImageId(): string {
return Math.random().toString(36).substr(2, 9);
}
-export function handleImageUpload(event: Event, theme: CustomTheme): Promise
| CustomTheme {
+export function handleImageUpload(event: Event, theme: LoadedCustomTheme): Promise | LoadedCustomTheme {
const input = event.target as HTMLInputElement;
const file = input.files?.[0];
input.value = '';
@@ -17,7 +17,7 @@ export function handleImageUpload(event: Event, theme: CustomTheme): Promise image.id !== imageId),
- };
+ } as LoadedCustomTheme;
}
-export function handleImageVariableChange(imageId: string, variableName: string, theme: CustomTheme): CustomTheme {
+export function handleImageVariableChange(imageId: string, variableName: string, theme: LoadedCustomTheme): LoadedCustomTheme {
return {
...theme,
CustomImages: theme.CustomImages.map((image) =>
image.id === imageId ? { ...image, variableName } : image
),
- };
+ } as LoadedCustomTheme;
}
-export function handleCoverImageUpload(event: Event, theme: CustomTheme): Promise {
+export function handleCoverImageUpload(event: Event, theme: LoadedCustomTheme): Promise {
const input = event.target as HTMLInputElement;
const file = input.files?.[0];
input.value = '';
@@ -51,7 +51,7 @@ export function handleCoverImageUpload(event: Event, theme: CustomTheme): Promis
const reader = new FileReader();
reader.onload = async () => {
const imageBlob = await fetch(reader.result as string).then(res => res.blob());
- resolve({ ...theme, coverImage: imageBlob });
+ resolve({ ...theme, coverImage: imageBlob, coverImageUrl: URL.createObjectURL(imageBlob) });
};
reader.readAsDataURL(file);
});
diff --git a/src/types/CustomThemes.ts b/src/types/CustomThemes.ts
index a7c508a7..78c2ec6b 100644
--- a/src/types/CustomThemes.ts
+++ b/src/types/CustomThemes.ts
@@ -15,6 +15,16 @@ export type CustomTheme = {
forceDark?: boolean;
}
+export type LoadedCustomTheme = CustomTheme & {
+ CustomImages: Array<{
+ id: string;
+ blob: Blob;
+ variableName: string;
+ url: string | null;
+ }>;
+ coverImageUrl?: string;
+};
+
export type DownloadedTheme = CustomTheme & {
webURL: string;
}