refactor(ui): merge Downloaded/Custom themes into My themes; space folder button like siblings

This commit is contained in:
SethBurkart123 committed 2026-10-29 10:59:45 +11:00
1 parent 9bfc0989c1
commit 0f9b8efc40
7 files changed
+53 -189

No files matched your search

@@ -13,7 +13,7 @@
import type { CustomTheme } from "@/types/CustomThemes";
import { ThemeManager } from "@/plugins/built-in/themes/theme-manager";
import { themeUpdates } from "@/interface/hooks/ThemeUpdates";
import { filterThemesByMode } from "@/interface/utils/themeListFilters";
import { isLocalCustomTheme } from "@/interface/utils/themeListFilters";
import { formatCustomThemeApiError } from "@/seqta/utils/customThemes/apiErrors";
let { communityState }: { communityState: CommunityThemesState } = $props();
@@ -30,7 +30,7 @@
localThemesLoading = true;
try {
const all = await themeManager.getAvailableThemes();
localThemes = filterThemesByMode(all, "custom");
localThemes = all.filter(isLocalCustomTheme);
} finally {
localThemesLoading = false;
}
@@ -101,7 +101,7 @@
</div>
{:else if localThemes.length === 0}
<p class="mt-3 text-sm text-zinc-500 dark:text-zinc-400">
No local custom themes yet. Use Create &amp; submit above or build one in Custom themes settings.
No local custom themes yet. Use Create &amp; submit above or build one in My themes.
</p>
{:else}
<ul class="mt-3 space-y-3">
@@ -8,17 +8,16 @@
import SignInToFavoriteModal from '@/interface/components/SignInToFavoriteModal.svelte'
import ThemeBlobImage from '@/interface/components/themes/ThemeBlobImage.svelte'
import ThemePlaceholderCover from '@/interface/components/themes/ThemePlaceholderCover.svelte'
import { filterThemesByMode, isLocalCustomTheme, type ThemeListMode } from '@/interface/utils/themeListFilters'
import { isLocalCustomTheme } from '@/interface/utils/themeListFilters'
import { closeExtensionPopup } from '@/seqta/utils/Closers/closeExtensionPopup'
import { formatCustomThemeApiError } from '@/seqta/utils/customThemes/apiErrors'
const themeManager = ThemeManager.getInstance();
let themes = $state<ThemeList | null>(null);
let { isEditMode, showNavigation = true, listMode = 'all' } = $props<{
let { isEditMode, showNavigation = true } = $props<{
isEditMode: boolean;
showNavigation?: boolean;
listMode?: ThemeListMode;
}>();
let favoriteStatus = $state<Record<string, boolean>>({});
let cloudLoggedIn = $state(cloudAuth.state.isLoggedIn);
@@ -112,11 +111,6 @@
await launchPageThemeBuilder(themeId)
}
const openCommunitySubmit = async () => {
const { openCommunityThemeSubmit } = await import('@/seqta/utils/openCommunityThemeSubmit')
await openCommunityThemeSubmit()
}
const submitCustomTheme = async (theme: CustomTheme, e: MouseEvent) => {
e.stopPropagation();
submitError = null;
@@ -135,9 +129,6 @@
}
}
const customThemeActionClass =
'flex h-12 items-center justify-center gap-2 w-full rounded-xl transition bg-zinc-100 text-xl dark:bg-zinc-900 dark:text-white hover:bg-zinc-200 dark:hover:bg-zinc-800'
const handleToggleFavorite = async (theme: CustomTheme, e: MouseEvent) => {
e.stopPropagation();
if (!cloudLoggedIn) {
@@ -164,11 +155,7 @@
themeUpdates.removeListener(fetchThemes);
})
const visibleThemes = $derived(
themes ? filterThemesByMode(themes.themes, listMode) : [],
);
const useTwoColumnLayout = $derived(listMode === 'downloaded' || listMode === 'custom');
const useTwoColumnLayout = $derived(!showNavigation);
</script>
<div
@@ -178,7 +165,7 @@
>
<div class="{useTwoColumnLayout ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-2 px-2'}">
{#if themes}
{#each visibleThemes as theme (theme.id)}
{#each themes.themes as theme (theme.id)}
<button
class="relative group w-full aspect-theme flex justify-center items-center rounded-xl transition ring dark:ring-white ring-zinc-300 {theme.id === themes.selectedTheme ? 'dark:ring-2 ring-4' : 'ring-0'}"
onclick={(e) => handleThemeClick(theme, e)}
@@ -234,18 +221,16 @@
>
<span class="text-lg font-IconFamily">&#xeaa5;</span>
</div>
{#if listMode === 'custom'}
<div
class="flex h-8 w-8 place-items-center rounded-full bg-black/50 p-2 text-white {submittingThemeId === theme.id ? 'opacity-60' : ''}"
onclick={(event) => void submitCustomTheme(theme, event)}
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') void submitCustomTheme(theme, event as unknown as MouseEvent) }}
role="button"
tabindex="-1"
title="Submit to community"
>
<span class="text-lg font-IconFamily">&#xe9fc;</span>
</div>
{/if}
<div
class="flex h-8 w-8 place-items-center rounded-full bg-black/50 p-2 text-white {submittingThemeId === theme.id ? 'opacity-60' : ''}"
onclick={(event) => void submitCustomTheme(theme, event)}
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') void submitCustomTheme(theme, event as unknown as MouseEvent) }}
role="button"
tabindex="-1"
title="Submit to community"
>
<span class="text-lg font-IconFamily">&#xe9fc;</span>
</div>
{/if}
</div>
{/if}
@@ -271,114 +256,39 @@
{/each}
{/if}
{#if themes && visibleThemes.length === 0}
{#if themes && themes.themes.length === 0}
<div class="flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center {useTwoColumnLayout ? 'col-span-2' : ''}">
{#if listMode === 'custom'}
<h3 class="text-xl font-semibold text-zinc-900 dark:text-white" style="text-wrap: balance">
No custom themes yet
</h3>
<p class="mt-2 max-w-md text-base text-zinc-500 dark:text-zinc-400" style="text-wrap: pretty">
Use the theme builder above to get started.
</p>
{:else if listMode === 'downloaded'}
<h3 class="text-xl font-semibold text-zinc-900 dark:text-white" style="text-wrap: balance">
No downloaded themes
</h3>
<p class="mt-2 max-w-md text-base text-zinc-500 dark:text-zinc-400" style="text-wrap: pretty">
Browse the theme store to find and install themes.
</p>
<div class="mt-6 grid w-full max-w-md grid-cols-1 gap-2">
<button
type="button"
onclick={() => void openStorePage()}
class="flex h-11 items-center justify-center gap-2 rounded-lg bg-zinc-200 px-4 font-medium text-zinc-900 transition-[background-color,color,transform] duration-150 hover:bg-zinc-300 active:scale-[0.96] focus:outline-none focus:ring-2 focus:ring-zinc-400 dark:bg-zinc-700 dark:text-white dark:hover:bg-zinc-600"
>
<span class="font-IconFamily text-lg" aria-hidden="true">&#xecc5;</span>
Browse the store
</button>
</div>
{:else}
<h3 class="text-xl font-semibold text-zinc-900 dark:text-white" style="text-wrap: balance">
No themes installed
</h3>
<p class="mt-2 max-w-md text-base text-zinc-500 dark:text-zinc-400" style="text-wrap: pretty">
Install a theme from the store or create one of your own.
</p>
<div class="mt-6 grid w-full max-w-md grid-cols-1 gap-2 sm:grid-cols-2">
<button
type="button"
onclick={() => void openStorePage()}
class="flex h-11 items-center justify-center gap-2 rounded-lg bg-zinc-200 px-4 font-medium text-zinc-900 transition-[background-color,color,transform] duration-150 hover:bg-zinc-300 active:scale-[0.96] focus:outline-none focus:ring-2 focus:ring-zinc-400 dark:bg-zinc-700 dark:text-white dark:hover:bg-zinc-600"
>
<span class="font-IconFamily text-lg" aria-hidden="true">&#xecc5;</span>
Install a theme
</button>
<button
type="button"
onclick={() => void openThemeCreator()}
class="flex h-11 items-center justify-center gap-2 rounded-lg bg-zinc-200 px-4 font-medium text-zinc-900 transition-[background-color,color,transform] duration-150 hover:bg-zinc-300 active:scale-[0.96] focus:outline-none focus:ring-2 focus:ring-zinc-400 dark:bg-zinc-700 dark:text-white dark:hover:bg-zinc-600"
>
<span class="font-IconFamily text-lg" aria-hidden="true">&#xec60;</span>
Create a theme
</button>
</div>
{/if}
<h3 class="text-xl font-semibold text-zinc-900 dark:text-white" style="text-wrap: balance">
No themes installed
</h3>
<p class="mt-2 max-w-md text-base text-zinc-500 dark:text-zinc-400" style="text-wrap: pretty">
Install a theme from the store or create one of your own.
</p>
</div>
{/if}
{#if themes && (listMode === 'custom' || (showNavigation && visibleThemes.length > 0) || (listMode === 'downloaded' && visibleThemes.length > 0))}
<div id="divider" class="w-full h-[1px] my-2 bg-zinc-100 dark:bg-zinc-600 {useTwoColumnLayout ? 'col-span-2' : ''}"></div>
{#if submitError}
<p class="whitespace-pre-line text-sm text-red-600 dark:text-red-400 {useTwoColumnLayout ? 'col-span-2' : ''}">{submitError}</p>
{/if}
{#if listMode === 'custom' && submitError}
<p class="col-span-2 whitespace-pre-line text-sm text-red-600 dark:text-red-400">{submitError}</p>
{/if}
{#if themes && showNavigation}
<div id="divider" class="w-full h-[1px] my-2 bg-zinc-100 dark:bg-zinc-600"></div>
{#if listMode === 'custom'}
<div class="grid grid-cols-2 gap-2 {useTwoColumnLayout ? 'col-span-2' : ''}">
<a
href="https://docs.betterseqta.org/theme-creation/"
target="_blank"
rel="noopener noreferrer"
class={customThemeActionClass}
>
<span class="text-2xl font-IconFamily" aria-hidden="true">{'\uecb3'}</span>
<span>View docs</span>
</a>
<button
onclick={() => void openStorePage()}
class="flex justify-center items-center w-full rounded-xl transition aspect-theme bg-zinc-100 dark:bg-zinc-900 dark:text-white"
>
<span class="text-xl font-IconFamily">&#xecc5;</span>
<span class="ml-2">Theme Store</span>
</button>
<button
type="button"
onclick={() => void openCommunitySubmit()}
class={customThemeActionClass}
>
<span class="text-2xl font-IconFamily" aria-hidden="true">&#xe9fc;</span>
<span>Create & submit</span>
</button>
</div>
{:else if listMode === 'downloaded'}
<button
onclick={() => void openStorePage()}
class="flex justify-center items-center w-full rounded-xl transition aspect-theme bg-zinc-100 dark:bg-zinc-900 dark:text-white {useTwoColumnLayout ? 'col-span-2' : ''}"
>
<span class="text-xl font-IconFamily">&#xecc5;</span>
<span class="ml-2">Theme Store</span>
</button>
{:else}
<button
onclick={() => void openStorePage()}
class="flex justify-center items-center w-full rounded-xl transition aspect-theme bg-zinc-100 dark:bg-zinc-900 dark:text-white"
>
<span class="text-xl font-IconFamily">&#xecc5;</span>
<span class="ml-2">Theme Store</span>
</button>
<button
onclick={() => void openThemeCreator()}
class="flex justify-center items-center w-full rounded-xl transition aspect-theme bg-zinc-100 dark:bg-zinc-900 dark:text-white"
>
<span class="text-xl font-IconFamily">&#xec60;</span>
<span class="ml-2">Create your own</span>
</button>
{/if}
<button
onclick={() => void openThemeCreator()}
class="flex justify-center items-center w-full rounded-xl transition aspect-theme bg-zinc-100 dark:bg-zinc-900 dark:text-white"
>
<span class="text-xl font-IconFamily">&#xec60;</span>
<span class="ml-2">Create your own</span>
</button>
{/if}
</div>
</div>
+6 -16
View File
@@ -35,7 +35,7 @@
} from "@/utils/githubReleaseUpdate";
type PageId = "settings" | "themes" | "backgrounds";
type StoreTab = "themes" | "backgrounds";
type ThemeView = "theme-settings" | "theme-store" | "community-themes" | "create-theme";
type ThemeView = "theme-settings" | "theme-store" | "community-themes";
type BackgroundView = "background-settings" | "background-store";
const loadSettingsBody = () => import("./settings/SettingsBody.svelte");
@@ -115,8 +115,7 @@
items: [
{ id: "theme-store", label: "Theme store" },
{ id: "community-themes", label: "Community themes" },
{ id: "theme-settings", label: "Downloaded themes" },
{ id: "create-theme", label: "Custom themes" },
{ id: "theme-settings", label: "My themes" },
],
},
];
@@ -165,8 +164,7 @@
const sectionTitle = $derived.by(() => {
if (activePage === "settings" && debouncedSettingsSearch.trim()) return "Search results";
if (activePage === "themes") {
if (activeThemeView === "theme-settings") return "Downloaded themes";
if (activeThemeView === "create-theme") return "Custom themes";
if (activeThemeView === "theme-settings") return "My themes";
if (activeThemeView === "community-themes") return "Community themes";
if (activeThemeView === "theme-store") return "Theme store";
return "Themes";
@@ -175,12 +173,6 @@
return [...userNav, ...appNav].find((item) => item.id === activeSection)?.label ?? "Settings";
});
const activeThemeListMode = $derived.by(() => {
if (activeThemeView === "create-theme") return "custom" as const;
if (activeThemeView === "theme-settings") return "downloaded" as const;
return "all" as const;
});
const isStoreView = $derived(
(activePage === "themes" &&
(activeThemeView === "theme-store" || activeThemeView === "community-themes")) ||
@@ -464,9 +456,7 @@
? "theme-store"
: destination.view === "community"
? "community-themes"
: destination.view === "custom"
? "create-theme"
: "theme-settings";
: "theme-settings";
} else if (destination.page === "backgrounds" && destination.view) {
activeBackgroundView = destination.view === "store" ? "background-store" : "background-settings";
}
@@ -717,8 +707,8 @@
{:else if activePage === "themes"}
<LazyPanel
loader={loadThemeSettings}
remountKey={`theme-settings-${activeThemeListMode}`}
props={{ section: "themes", listMode: activeThemeListMode }}
remountKey="theme-settings"
props={{ section: "themes" }}
/>
{:else}
<LazyPanel
+3 -5
View File
@@ -2,11 +2,9 @@
import BackgroundSelector from "@/interface/components/themes/BackgroundSelector.svelte"
import ThemeSelector from "@/interface/components/themes/ThemeSelector.svelte"
import { standalone } from "@/interface/utils/standalone.svelte"
import type { ThemeListMode } from "@/interface/utils/themeListFilters"
let { section = "all", listMode = "all" } = $props<{
let { section = "all" } = $props<{
section?: "all" | "themes" | "backgrounds";
listMode?: ThemeListMode;
}>();
// backgrounds
@@ -47,7 +45,7 @@
<BackgroundSelector isEditMode={editMode} bind:selectedBackground={selectedBackground} bind:selectNoBackground={selectNoBackground} />
{/if}
{#if showThemes}
{#if listMode === "custom"}
{#if section === "themes"}
<button
type="button"
class="mb-4 flex h-11 w-full items-center justify-center gap-2 rounded-xl bg-zinc-900 text-sm font-medium text-white dark:bg-zinc-100 dark:text-zinc-900"
@@ -60,7 +58,7 @@
Open theme builder
</button>
{/if}
<ThemeSelector isEditMode={editMode} showNavigation={section === "all"} {listMode} />
<ThemeSelector isEditMode={editMode} showNavigation={section === "all"} />
{/if}
</div>
{:else}
@@ -1,7 +1,6 @@
import type { CustomTheme } from '@/types/CustomThemes';
import type { Theme } from '@/interface/types/Theme';
import {
filterThemesByMode,
getThemeApplyButtonStyles,
getCommunityInstalledThemeIds,
getStoreInstalledThemeIds,
@@ -54,27 +53,6 @@ describe('resolveLocalThemeInstallId', () => {
});
});
describe('filterThemesByMode', () => {
const storeTheme = makeCustomTheme({
id: 'store-1',
name: 'Store Theme',
installedFromStore: true,
});
const communityTheme = makeCustomTheme({
id: 'community-1',
name: 'Community Theme',
installedFromCommunity: true,
});
const localTheme = makeCustomTheme({ id: 'local-1', name: 'Local Theme' });
it('splits store, community, and local themes by mode', () => {
const all = [storeTheme, communityTheme, localTheme];
expect(filterThemesByMode(all, 'all')).toEqual(all);
expect(filterThemesByMode(all, 'downloaded')).toEqual([storeTheme, communityTheme]);
expect(filterThemesByMode(all, 'custom')).toEqual([localTheme]);
});
});
describe('installed theme id helpers', () => {
it('returns store-only and community-only ids', () => {
const themes = [
-13
View File
@@ -2,8 +2,6 @@ import type { CustomTheme } from '@/types/CustomThemes';
import type { Theme } from '@/interface/types/Theme';
import { parseCssColor } from '@/seqta/ui/colors/parseCssColor';
export type ThemeListMode = 'downloaded' | 'custom' | 'all';
const DEFAULT_THEME_ACCENT = 'rgba(0, 123, 255, 1)';
/** Local themes: created in the editor or imported from a file (not store/community). */
@@ -11,11 +9,6 @@ export function isLocalCustomTheme(theme: CustomTheme): boolean {
return theme.installedFromStore !== true && theme.installedFromCommunity !== true;
}
/** Themes installed from the official store or community API. */
export function isDownloadedTheme(theme: CustomTheme): boolean {
return theme.installedFromStore === true || theme.installedFromCommunity === true;
}
/**
* When importing a local copy of a theme whose id already belongs to a store/community
* install, use a new id so both copies can coexist.
@@ -36,12 +29,6 @@ export function resolveLocalThemeInstallId(
return themeId;
}
export function filterThemesByMode(themes: CustomTheme[], mode: ThemeListMode): CustomTheme[] {
if (mode === 'all') return themes;
if (mode === 'custom') return themes.filter(isLocalCustomTheme);
return themes.filter(isDownloadedTheme);
}
/** Installed theme ids from the official store only (excludes file imports / custom copies). */
export function getStoreInstalledThemeIds(themes: CustomTheme[]): string[] {
return themes.filter((theme) => theme.installedFromStore === true).map((theme) => theme.id);
@@ -375,6 +375,7 @@
/* ── "Add to folder" button in message actions bar ── */
.bsplus-folder-btn {
position: relative;
margin-left: 8px;
}
.bsplus-folder-btn svg {