fix(customthemessettings): box order

This commit is contained in:
StroepWafel committed 2026-08-26 21:32:32 +09:30
1 parent dc3b77f82b
commit b064f2df8f
5 files changed
+63 -26

No files matched your search

@@ -232,18 +232,6 @@
const useTwoColumnLayout = $derived(listMode === 'downloaded' || listMode === 'custom');
</script>
{#snippet customThemeUploadZone()}
<button
type="button"
onclick={triggerFileUpload}
class="flex aspect-theme w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-zinc-300 bg-zinc-50 px-4 py-6 text-center transition hover:border-zinc-400 hover:bg-zinc-100 dark:border-zinc-600 dark:bg-zinc-900/40 dark:hover:border-zinc-500 dark:hover:bg-zinc-900 {useTwoColumnLayout ? 'col-span-2' : ''}"
>
<span class="text-2xl font-IconFamily text-zinc-500 dark:text-zinc-400" aria-hidden="true">&#xe9fc;</span>
<span class="text-base font-medium text-zinc-700 dark:text-zinc-200">Drag and drop theme files here</span>
<span class="text-sm text-zinc-500 dark:text-zinc-400">or click to upload</span>
</button>
{/snippet}
<div
class="relative mb-1 w-full {useTwoColumnLayout ? '' : 'max-w-lg mx-auto'}"
role="list"
@@ -278,6 +266,19 @@
{/if}
<div class="{useTwoColumnLayout ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-2 px-2'}">
{#if allowsFileImport}
<button
type="button"
onclick={triggerFileUpload}
class="flex aspect-[10/1] w-full items-center justify-center gap-3 rounded-xl border-2 border-dashed border-zinc-300 bg-zinc-50 px-4 text-center transition hover:border-zinc-400 hover:bg-zinc-100 dark:border-zinc-600 dark:bg-zinc-900/40 dark:hover:border-zinc-500 dark:hover:bg-zinc-900 {useTwoColumnLayout ? 'col-span-2' : ''}"
>
<span class="text-xl font-IconFamily text-zinc-500 dark:text-zinc-400" aria-hidden="true">&#xe9fc;</span>
<div class="text-left">
<span class="block text-sm font-medium text-zinc-700 dark:text-zinc-200">Drag and drop theme files here</span>
<span class="block text-xs text-zinc-500 dark:text-zinc-400">or click to upload</span>
</div>
</button>
{/if}
{#if themes}
{#each visibleThemes as theme (theme.id)}
<button
@@ -371,11 +372,8 @@
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">
Create your own theme, or follow our guide to get started.
Drag and drop a theme file above, create your own theme, or follow our guide to get started.
</p>
<div class="mt-6 w-full max-w-md">
{@render customThemeUploadZone()}
</div>
{:else if listMode === 'downloaded'}
<h3 class="text-xl font-semibold text-zinc-900 dark:text-white" style="text-wrap: balance">
No downloaded themes
@@ -422,10 +420,6 @@
</div>
{/if}
{#if allowsFileImport && themes && visibleThemes.length > 0 && !tempTheme}
{@render customThemeUploadZone()}
{/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>
+5 -3
View File
@@ -34,7 +34,7 @@
} from "@/seqta/utils/customThemes/buildThemeUploadFormData";
import type { CustomThemeOwner, CustomThemeFile } from "@/seqta/utils/customThemes/types";
import type { LoadedCustomTheme } from "@/types/CustomThemes";
import { isLocalCustomTheme } from "@/interface/utils/themeListFilters";
import { getCommunityInstalledThemeIds, isLocalCustomTheme } from "@/interface/utils/themeListFilters";
let {
searchTerm,
@@ -94,10 +94,12 @@
async function refreshInstalledThemes() {
const themes = await themeManager.getAvailableThemes();
currentThemes = themes.filter((t) => t !== null).map((t) => t.id);
currentThemes = getCommunityInstalledThemeIds(themes);
selectedThemeId = themeManager.getSelectedThemeId() || "";
installedThemeColors = Object.fromEntries(
themes.filter((t) => t != null).map((t) => [t.id, t.defaultColour]),
themes
.filter((t) => t != null && t.installedFromCommunity === true)
.map((t) => [t.id, t.defaultColour]),
);
}
+5 -3
View File
@@ -16,7 +16,7 @@
import Backgrounds from '../components/store/Backgrounds.svelte'
import { cloudAuth } from '@/seqta/utils/CloudAuth'
import SignInToFavoriteModal from '../components/SignInToFavoriteModal.svelte'
import { consumePendingHighlightThemeId } from '@/seqta/utils/openThemeStoreWithHighlight'
import { getStoreInstalledThemeIds } from '@/interface/utils/themeListFilters'
const themeManager = ThemeManager.getInstance();
type StoreTab = 'themes' | 'backgrounds';
@@ -75,10 +75,12 @@
const fetchCurrentThemes = async () => {
const themes = await themeManager.getAvailableThemes();
currentThemes = themes.filter(theme => theme !== null).map(theme => theme.id);
currentThemes = getStoreInstalledThemeIds(themes);
selectedThemeId = themeManager.getSelectedThemeId() || '';
installedThemeColors = Object.fromEntries(
themes.filter((theme) => theme != null).map((theme) => [theme.id, theme.defaultColour]),
themes
.filter((theme) => theme != null && theme.installedFromStore === true)
.map((theme) => [theme.id, theme.defaultColour]),
);
};
@@ -3,6 +3,8 @@ import type { Theme } from '@/interface/types/Theme';
import {
filterThemesByMode,
getThemeApplyButtonStyles,
getCommunityInstalledThemeIds,
getStoreInstalledThemeIds,
isDownloadedTheme,
isLocalCustomTheme,
isStoreThemeInstalled,
@@ -127,6 +129,31 @@ describe('filterThemesByMode', () => {
});
});
describe('getStoreInstalledThemeIds', () => {
it('returns only store-installed theme ids', () => {
const themes = [
makeCustomTheme({ id: 'store-1', name: 'Store', installedFromStore: true }),
makeCustomTheme({ id: 'local-1', name: 'Local' }),
makeCustomTheme({
id: 'same-as-store',
name: 'Imported copy',
installedFromStore: false,
}),
];
expect(getStoreInstalledThemeIds(themes)).toEqual(['store-1']);
});
});
describe('getCommunityInstalledThemeIds', () => {
it('returns only community-installed theme ids', () => {
const themes = [
makeCustomTheme({ id: 'community-1', name: 'Community', installedFromCommunity: true }),
makeCustomTheme({ id: 'local-1', name: 'Local' }),
];
expect(getCommunityInstalledThemeIds(themes)).toEqual(['community-1']);
});
});
describe('isStoreThemeInstalled', () => {
it('returns true when master id is installed', () => {
const theme = makeStoreTheme({ id: 'master-1', name: 'Master' });
+12
View File
@@ -42,6 +42,18 @@ export function filterThemesByMode(themes: CustomTheme[], mode: ThemeListMode):
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);
}
/** Installed theme ids from the community API only (excludes file imports / custom copies). */
export function getCommunityInstalledThemeIds(themes: CustomTheme[]): string[] {
return themes
.filter((theme) => theme.installedFromCommunity === true)
.map((theme) => theme.id);
}
export function isStoreThemeInstalled(theme: Theme, installedIds: string[]): boolean {
const installed = new Set(installedIds);
if (installed.has(theme.id)) return true;