Compare commits
7
Commits
4d57184b73
...
51f5fa3e46
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51f5fa3e46 | ||
|
|
07cbfa39a6 | ||
|
|
11aefee7ed | ||
|
|
5eea428802 | ||
|
|
760bd9a283 | ||
|
|
47c022642f | ||
|
|
5613c3be25 |
No files matched your search
@@ -32,8 +32,8 @@
|
||||
"script-src": "'self' 'unsafe-inline' 'unsafe-eval' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://analytics.ez-pp.farm",
|
||||
"worker-src": ["'self'", "blob:"],
|
||||
"style-src": "'self' 'unsafe-inline' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:*",
|
||||
"img-src": "'self' asset: http://asset.localhost https://asset.localhost blob: data: http://127.0.0.1:* https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct",
|
||||
"connect-src": "'self' ipc: http://ipc.localhost asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://ez-pp.farm https://api.ez-pp.farm https://c.ez-pp.farm https://analytics.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://osu.ppy.sh https://api.fontsource.org https://cdn.jsdelivr.net",
|
||||
"img-src": "'self' asset: http://asset.localhost https://asset.localhost blob: data: http://127.0.0.1:* https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://themes.ez-pp.farm",
|
||||
"connect-src": "'self' ipc: http://ipc.localhost asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://ez-pp.farm https://api.ez-pp.farm https://c.ez-pp.farm https://analytics.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://osu.ppy.sh https://api.fontsource.org https://cdn.jsdelivr.net https://themes.ez-pp.farm",
|
||||
"media-src": "'self' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* blob:",
|
||||
"font-src": [
|
||||
"'self'",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { config } from './config';
|
||||
import { normalizeThemeVersion } from './themeV2';
|
||||
import {
|
||||
reloadThemes,
|
||||
themesDirectory,
|
||||
@@ -727,6 +728,13 @@ export async function publishThemeToWorkshop(options: {
|
||||
throw new Error('You must be logged in to EZPPFarm to publish themes.');
|
||||
}
|
||||
|
||||
const version = normalizeThemeVersion(options.version ?? '1.0.0');
|
||||
if (!version) {
|
||||
throw new Error(
|
||||
'Theme version must use semantic versioning, for example 1.2.3 or 1.2.3-beta.1.'
|
||||
);
|
||||
}
|
||||
|
||||
onProgress('Packaging theme archive...', 5);
|
||||
|
||||
const baseThemesDir = await themesDirectory();
|
||||
@@ -771,7 +779,7 @@ export async function publishThemeToWorkshop(options: {
|
||||
themeId: options.workshopId || options.themeId,
|
||||
name: options.name,
|
||||
description: options.description || '',
|
||||
version: options.version || '1.0.0',
|
||||
version,
|
||||
apiVersion: options.apiVersion || '2.0.0',
|
||||
totalSize,
|
||||
totalChunks,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Logo from '$assets/logo.png';
|
||||
import { publishThemeToWorkshop } from '$lib/communityThemes';
|
||||
import { fetchCommunityThemeDetails, publishThemeToWorkshop } from '$lib/communityThemes';
|
||||
import FontPreview from '$lib/components/theme/FontPreview.svelte';
|
||||
import ThemeBehaviorInspector from '$lib/components/theme/ThemeBehaviorInspector.svelte';
|
||||
import ThemeElementInspector from '$lib/components/theme/ThemeElementInspector.svelte';
|
||||
@@ -75,6 +75,7 @@
|
||||
normalizeChrome,
|
||||
normalizeThemeTags,
|
||||
normalizeThemeV2,
|
||||
normalizeThemeVersion,
|
||||
themeAssetName,
|
||||
themeHasLaunchButton,
|
||||
type ThemeV2Asset,
|
||||
@@ -173,6 +174,7 @@
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import { open, save as saveDialog } from '@tauri-apps/plugin-dialog';
|
||||
import * as fs from '@tauri-apps/plugin-fs';
|
||||
import semver from 'semver';
|
||||
import { sileo } from 'sileo';
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
||||
@@ -287,6 +289,7 @@
|
||||
let panStart = { x: 0, y: 0, panX: 0, panY: 0 };
|
||||
const canvasScale = $derived(canvasFitScale * canvasZoom);
|
||||
let statusMessage = $state('Ready');
|
||||
let lastPublishedVersion = $state<string | undefined>(undefined);
|
||||
let renamingId = $state<string | undefined>(undefined);
|
||||
let draggingLayer = $state<LayerDragItem | undefined>(undefined);
|
||||
let dropTarget = $state<LayerDropTarget | undefined>(undefined);
|
||||
@@ -1803,6 +1806,7 @@
|
||||
|
||||
async function loadContext() {
|
||||
loading = true;
|
||||
lastPublishedVersion = undefined;
|
||||
try {
|
||||
const context = await invoke<ThemeEditorContext>('theme_editor_context');
|
||||
const parsed = context.themeJson
|
||||
@@ -2920,6 +2924,12 @@
|
||||
notifyError('Add an author name so people know who made the theme.');
|
||||
return false;
|
||||
}
|
||||
const version = normalizeThemeVersion(definition.version);
|
||||
if (!version) {
|
||||
notifyError('The version must use semantic versioning, for example 1.2.3 or 1.2.3-beta.1.');
|
||||
return false;
|
||||
}
|
||||
if (definition.version !== version) definition.version = version;
|
||||
const folderName = savedFolder ?? toSafeName(definition.name);
|
||||
if (!folderName.replace(/_/g, '')) {
|
||||
notifyError('The theme name needs at least one letter or number.');
|
||||
@@ -3016,8 +3026,10 @@
|
||||
|
||||
if (!definition.name.trim()) error('The theme needs a name.');
|
||||
if (!definition.author.trim()) error('The theme needs an author.');
|
||||
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(definition.version.trim())) {
|
||||
warning('The version should use semantic versioning, for example 1.0.0.');
|
||||
if (!normalizeThemeVersion(definition.version)) {
|
||||
error(
|
||||
'The version must use semantic versioning, for example 1.0.0 or 1.0.0-beta.1, with no "v" prefix.'
|
||||
);
|
||||
}
|
||||
if (!themeHasLaunchButton(definition)) {
|
||||
error(
|
||||
@@ -3340,10 +3352,68 @@
|
||||
let publishStatusMessage = $state('');
|
||||
let publishProgress = $state(0);
|
||||
|
||||
async function checkPublishVersion(): Promise<
|
||||
{ ok: true; version: string } | { ok: false; error: string }
|
||||
> {
|
||||
const proposed = normalizeThemeVersion(definition.version);
|
||||
if (!proposed) {
|
||||
return {
|
||||
ok: false,
|
||||
error: 'Use a semantic version such as 1.2.3 in the Theme tab before publishing.',
|
||||
};
|
||||
}
|
||||
|
||||
let publishedVersion = lastPublishedVersion;
|
||||
const workshopId = definition.workshopId?.trim();
|
||||
if (workshopId) {
|
||||
let remoteVersion: string;
|
||||
try {
|
||||
remoteVersion = (await fetchCommunityThemeDetails(workshopId)).version?.trim() ?? '';
|
||||
} catch (error) {
|
||||
console.warn('[Workshop] Could not verify the published theme version:', error);
|
||||
return {
|
||||
ok: false,
|
||||
error:
|
||||
'Could not verify the current workshop version. Check your connection and try again.',
|
||||
};
|
||||
}
|
||||
|
||||
const validRemote = normalizeThemeVersion(remoteVersion);
|
||||
if (!validRemote) {
|
||||
return {
|
||||
ok: false,
|
||||
error:
|
||||
'The current workshop version could not be read. Contact a workshop administrator.',
|
||||
};
|
||||
}
|
||||
if (!publishedVersion || semver.gt(validRemote, publishedVersion)) {
|
||||
publishedVersion = validRemote;
|
||||
}
|
||||
}
|
||||
|
||||
if (publishedVersion) {
|
||||
if (semver.eq(proposed, publishedVersion)) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `Version ${proposed} has already been published. Increase the version before publishing again.`,
|
||||
};
|
||||
}
|
||||
if (!semver.gt(proposed, publishedVersion)) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `Version ${proposed} must be higher than the last published version ${publishedVersion}.`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return { ok: true, version: proposed };
|
||||
}
|
||||
|
||||
async function openPublishDialog() {
|
||||
if (exporting || saving || publishing) return;
|
||||
|
||||
if (!$currentUser) {
|
||||
const user = $currentUser;
|
||||
if (!user) {
|
||||
sileo.error({
|
||||
title: 'Authentication Required',
|
||||
description:
|
||||
@@ -3361,8 +3431,23 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (dirty) {
|
||||
await saveTheme({ notify: false });
|
||||
const versionCheck = await checkPublishVersion();
|
||||
if (!versionCheck.ok) {
|
||||
sileo.error({
|
||||
title: 'Version not publishable',
|
||||
description: versionCheck.error,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const versionChanged = definition.version !== versionCheck.version;
|
||||
if (versionChanged) definition.version = versionCheck.version;
|
||||
|
||||
const authorIdChanged = definition.authorId !== user.id;
|
||||
if (authorIdChanged) definition.authorId = user.id;
|
||||
|
||||
if (dirty || authorIdChanged || versionChanged) {
|
||||
const saved = await saveTheme({ notify: false });
|
||||
if (!saved) return;
|
||||
}
|
||||
|
||||
publishThemeId = definition.workshopId ?? '';
|
||||
@@ -3399,17 +3484,34 @@
|
||||
|
||||
async function handlePublishToWorkshop() {
|
||||
if (publishing) return;
|
||||
if (!savedFolder) {
|
||||
await saveTheme({ notify: false });
|
||||
if (!savedFolder) return;
|
||||
}
|
||||
|
||||
const firstPublish = !definition.workshopId;
|
||||
publishing = true;
|
||||
publishProgress = 5;
|
||||
publishStatusMessage = 'Packaging theme archive...';
|
||||
publishStatusMessage = 'Checking version...';
|
||||
|
||||
try {
|
||||
const versionCheck = await checkPublishVersion();
|
||||
if (!versionCheck.ok) {
|
||||
sileo.error({
|
||||
title: 'Version not publishable',
|
||||
description: versionCheck.error,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (definition.version !== versionCheck.version) {
|
||||
definition.version = versionCheck.version;
|
||||
const saved = await saveTheme({ notify: false });
|
||||
if (!saved) return;
|
||||
}
|
||||
|
||||
if (!savedFolder) {
|
||||
const saved = await saveTheme({ notify: false });
|
||||
if (!saved || !savedFolder) return;
|
||||
}
|
||||
|
||||
publishStatusMessage = 'Packaging theme archive...';
|
||||
const baseThemesDir = await themesDirectory();
|
||||
const themeFolder = await path.join(baseThemesDir, savedFolder);
|
||||
const themeId = savedFolder || toSafeName(definition.name);
|
||||
@@ -3420,7 +3522,7 @@
|
||||
workshopId: definition.workshopId,
|
||||
name: definition.name,
|
||||
description: definition.description || '',
|
||||
version: definition.version || '1.0.0',
|
||||
version: versionCheck.version,
|
||||
apiVersion: definition.apiVersion || '2.0.0',
|
||||
tags: definition.tags ?? [],
|
||||
allowForking: definition.allowForking !== false,
|
||||
@@ -3430,6 +3532,8 @@
|
||||
},
|
||||
});
|
||||
|
||||
lastPublishedVersion = versionCheck.version;
|
||||
|
||||
if (result.themeId) {
|
||||
// Persist the server-assigned ID so the next publish updates this
|
||||
// workshop record instead of creating another one.
|
||||
@@ -6983,7 +7087,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-[10px] leading-relaxed text-muted-foreground/70">
|
||||
These details come from the Theme tab. Change them there before publishing.
|
||||
These details come from the Theme tab. Published versions cannot be reused, so increase
|
||||
the version before every update.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -646,6 +646,8 @@ export type ThemeV2Definition = {
|
||||
version: string;
|
||||
apiVersion: '2.0';
|
||||
author: string;
|
||||
/** EZPPFarm user ID of the publisher, written when the theme is published. */
|
||||
authorId?: number;
|
||||
description?: string;
|
||||
/** Workshop discovery tags for this theme. */
|
||||
tags?: string[];
|
||||
@@ -746,6 +748,16 @@ export const normalizeThemeTags = (raw: unknown): string[] => {
|
||||
return tags;
|
||||
};
|
||||
|
||||
const THEME_VERSION_PATTERN =
|
||||
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
||||
|
||||
/** Accept only strict SemVer 2.0.0, preserving prerelease and build metadata. */
|
||||
export const normalizeThemeVersion = (raw: unknown): string | undefined => {
|
||||
if (typeof raw !== 'string') return undefined;
|
||||
const version = raw.trim();
|
||||
return version.length > 0 && THEME_VERSION_PATTERN.test(version) ? version : undefined;
|
||||
};
|
||||
|
||||
const WORKSHOP_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
||||
|
||||
/** Keep a server-assigned workshop ID while preserving legacy slug IDs. */
|
||||
@@ -755,6 +767,11 @@ const normalizeWorkshopId = (raw: unknown): string | undefined => {
|
||||
return WORKSHOP_ID_PATTERN.test(id) ? id : undefined;
|
||||
};
|
||||
|
||||
const normalizeAuthorId = (raw: unknown): number | undefined => {
|
||||
if (typeof raw !== 'number' || !Number.isSafeInteger(raw) || raw <= 0) return undefined;
|
||||
return raw;
|
||||
};
|
||||
|
||||
const clampInteger = (value: unknown, fallback: number, min: number, max: number) =>
|
||||
Math.round(clamp(value, fallback, min, max));
|
||||
|
||||
@@ -1913,6 +1930,7 @@ export const normalizeThemeV2 = (raw: Partial<ThemeV2Definition>): ThemeV2Defini
|
||||
version: text(raw.version, '1.0.0'),
|
||||
apiVersion: '2.0',
|
||||
author: text(raw.author, 'Unknown'),
|
||||
authorId: normalizeAuthorId(raw.authorId),
|
||||
description: text(raw.description),
|
||||
tags: normalizeThemeTags(raw.tags),
|
||||
workshopId: normalizeWorkshopId(raw.workshopId),
|
||||
|
||||
@@ -16,6 +16,8 @@ export type Theme = {
|
||||
version: string;
|
||||
apiVersion: string;
|
||||
author: string;
|
||||
/** EZPPFarm user ID stored in the manifest when the theme is published. */
|
||||
authorId?: number;
|
||||
description: string;
|
||||
nsfw: boolean;
|
||||
scriptUrl: string;
|
||||
@@ -44,6 +46,7 @@ export type ThemeInfo = {
|
||||
apiVersion?: string;
|
||||
workshopId?: string;
|
||||
author?: string;
|
||||
authorId?: number;
|
||||
description?: string;
|
||||
nsfw?: boolean;
|
||||
entry?: string;
|
||||
@@ -173,6 +176,12 @@ const themeFromFolder = async (
|
||||
version: parsed.version ?? '1.0.0',
|
||||
apiVersion,
|
||||
author: parsed.author ?? 'Unknown',
|
||||
authorId:
|
||||
typeof parsed.authorId === 'number' &&
|
||||
Number.isSafeInteger(parsed.authorId) &&
|
||||
parsed.authorId > 0
|
||||
? parsed.authorId
|
||||
: undefined,
|
||||
description: parsed.description ?? '',
|
||||
nsfw: parsed.nsfw === true,
|
||||
scriptUrl,
|
||||
@@ -523,6 +532,7 @@ export const reloadThemes = async () => {
|
||||
preview: theme.preview,
|
||||
version: theme.version,
|
||||
author: theme.author,
|
||||
authorId: theme.authorId,
|
||||
apiVersion: theme.apiVersion,
|
||||
description: theme.description,
|
||||
nsfw: theme.nsfw,
|
||||
|
||||
+266
-171
@@ -163,6 +163,7 @@
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
Clock,
|
||||
Ellipsis,
|
||||
ExternalLink,
|
||||
Flag,
|
||||
Globe,
|
||||
@@ -421,6 +422,14 @@
|
||||
return ownedWorkshopThemeNames.includes(theme.name.trim().toLowerCase());
|
||||
};
|
||||
|
||||
const themeAuthorAvatarUrl = (theme: Theme) => {
|
||||
if (theme.authorId && theme.authorId > 0) {
|
||||
return `https://a.ez-pp.farm/${theme.authorId}`;
|
||||
}
|
||||
const author = theme.author.trim();
|
||||
return author ? `https://a.ez-pp.farm/${encodeURIComponent(author)}` : undefined;
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
let loadedUserId: number | undefined;
|
||||
return currentUser.subscribe((user) => {
|
||||
@@ -505,6 +514,29 @@
|
||||
await config.value<string>('theme').set(theme.name);
|
||||
};
|
||||
|
||||
const uninstallInstalledTheme = async (theme: Theme) => {
|
||||
try {
|
||||
const deleteResult = await deleteTheme(theme);
|
||||
if (deleteResult) {
|
||||
sileo.success({
|
||||
title: 'Theme uninstalled',
|
||||
description: `"${theme.name}" was removed from your library.`,
|
||||
});
|
||||
} else {
|
||||
sileo.error({
|
||||
title: 'Could not uninstall theme',
|
||||
description: 'The theme files could not be removed.',
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
sileo.error({
|
||||
title: 'Could not uninstall theme',
|
||||
description: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const updateInstalledTheme = async (theme: Theme) => {
|
||||
const wasActive = $active_custom_theme?.folder_name === theme.folder_name;
|
||||
const updateResult = await downloadTheme(theme, true);
|
||||
@@ -3911,6 +3943,28 @@
|
||||
{#each filteredThemes as theme, index (theme.folder_name)}
|
||||
{@const isActive =
|
||||
$active_custom_theme?.folder_name === theme.folder_name}
|
||||
{@const canEditTheme =
|
||||
theme.status === 'installed' && Boolean(theme.definition)}
|
||||
{@const canRestoreTheme =
|
||||
theme.status === 'installed' && (theme.backups?.length ?? 0) > 0}
|
||||
{@const canUpdateTheme =
|
||||
theme.status === 'installed' && theme.updateAvailable}
|
||||
{@const canReportTheme =
|
||||
Boolean($currentUser && ownedWorkshopLoaded) &&
|
||||
!isOwnInstalledTheme(theme) &&
|
||||
theme.status === 'installed' &&
|
||||
theme.name !== 'Default' &&
|
||||
theme.folder_name !== 'default'}
|
||||
{@const canUninstallTheme =
|
||||
(theme.status === 'installed' || theme.status === 'deleting') &&
|
||||
!isActive &&
|
||||
theme.name !== 'Default'}
|
||||
{@const hasThemeMenu =
|
||||
canEditTheme ||
|
||||
canRestoreTheme ||
|
||||
canUpdateTheme ||
|
||||
canReportTheme ||
|
||||
canUninstallTheme}
|
||||
<div
|
||||
class="group flex flex-col overflow-hidden rounded-xl border bg-theme-900/30 {isActive
|
||||
? 'border-primary/60 ring-1 ring-primary/15'
|
||||
@@ -3925,7 +3979,7 @@
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="relative h-36 w-full shrink-0 overflow-hidden bg-theme-950/60"
|
||||
class="relative aspect-video w-full shrink-0 overflow-hidden bg-theme-950/60"
|
||||
>
|
||||
<div
|
||||
class="h-full w-full {$reduceAnimations
|
||||
@@ -3966,17 +4020,37 @@
|
||||
<div
|
||||
class="pointer-events-none absolute inset-0 bg-gradient-to-t from-theme-950/75 via-transparent to-transparent"
|
||||
></div>
|
||||
{#if isActive}
|
||||
<Badge class="absolute top-1.5 left-1.5 text-[9px]">In use</Badge>
|
||||
{/if}
|
||||
{#if theme.name !== 'Default' && theme.folder_name !== 'default' && theme.apiVersion}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
class="absolute top-1.5 right-1.5 bg-black/50 px-1.5 py-0 text-[9px] backdrop-blur-sm"
|
||||
<div
|
||||
class="absolute top-1.5 left-1.5 flex max-w-[calc(100%-4.5rem)] flex-wrap items-center gap-1"
|
||||
>
|
||||
{#if isActive}
|
||||
<Badge class="text-[9px]">In use</Badge>
|
||||
{/if}
|
||||
{#if theme.name !== 'Default' && theme.folder_name !== 'default' && theme.apiVersion}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
class="bg-black/50 px-1.5 py-0 text-[9px] backdrop-blur-sm"
|
||||
>
|
||||
API {theme.apiVersion.startsWith('2') ? '2.0' : '1.0'}
|
||||
</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="absolute top-1.5 right-1.5 flex items-center gap-1">
|
||||
{#if theme.nsfw}
|
||||
<Badge
|
||||
variant="destructive"
|
||||
class="px-1.5 py-0 text-[9px]"
|
||||
title="Adult content"
|
||||
>
|
||||
18+
|
||||
</Badge>
|
||||
{/if}
|
||||
<span
|
||||
class="rounded-md bg-black/60 px-1.5 py-0.5 text-[9px] font-medium text-white/90 backdrop-blur-sm"
|
||||
>
|
||||
API {theme.apiVersion.startsWith('2') ? '2.0' : '1.0'}
|
||||
</Badge>
|
||||
{/if}
|
||||
v{theme.version}
|
||||
</span>
|
||||
</div>
|
||||
{#if theme.nsfw && !revealedNsfw.includes(theme.name)}
|
||||
<button
|
||||
type="button"
|
||||
@@ -3992,192 +4066,213 @@
|
||||
{:else if theme.nsfw}
|
||||
<button
|
||||
type="button"
|
||||
class="absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 rounded-full bg-black/60 px-1.5 py-0.5 text-[8px] font-medium text-white/80 backdrop-blur-sm hover:bg-black/75 hover:text-white"
|
||||
class="absolute right-1.5 bottom-10 z-10 flex items-center gap-1 rounded-full bg-black/60 px-1.5 py-0.5 text-[8px] font-medium text-white/80 backdrop-blur-sm hover:bg-black/75 hover:text-white"
|
||||
onclick={() => toggleNsfwPreview(theme.name)}
|
||||
>
|
||||
<ThemeIcon name="eye-off" set={iconSet} class="size-3" />
|
||||
Hide preview
|
||||
</button>
|
||||
{/if}
|
||||
{#if theme.nsfw}
|
||||
<Badge
|
||||
variant="destructive"
|
||||
class="absolute right-1.5 bottom-1.5 px-1.5 py-0 text-[9px]"
|
||||
title="Adult content"
|
||||
>
|
||||
18+
|
||||
</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex flex-1 flex-col gap-1.5 p-2.5">
|
||||
<div class="flex items-start justify-between gap-1.5">
|
||||
<div class="min-w-0">
|
||||
<span
|
||||
class="block truncate text-[13px] leading-tight font-semibold"
|
||||
<div
|
||||
class="absolute right-2 bottom-2 left-2 flex items-center justify-between gap-2"
|
||||
>
|
||||
<div class="flex min-w-0 items-center gap-1.5">
|
||||
<Avatar.Root
|
||||
class="size-5 shrink-0 border border-white/20 bg-theme-800"
|
||||
>
|
||||
{theme.name}
|
||||
</span>
|
||||
<Avatar.Image
|
||||
src={themeAuthorAvatarUrl(theme)}
|
||||
alt={theme.author || 'Unknown author'}
|
||||
class="object-cover"
|
||||
/>
|
||||
<Avatar.Fallback
|
||||
class="text-[9px] font-bold text-white/80 uppercase"
|
||||
>
|
||||
{theme.author.trim().charAt(0) || '?'}
|
||||
</Avatar.Fallback>
|
||||
</Avatar.Root>
|
||||
<span
|
||||
class="mt-0.5 block truncate text-[10px] text-muted-foreground"
|
||||
class="truncate text-[11px] font-semibold text-white/95 drop-shadow-sm"
|
||||
>
|
||||
by {theme.author}
|
||||
{theme.author || 'Unknown author'}
|
||||
</span>
|
||||
</div>
|
||||
<span
|
||||
class="shrink-0 rounded-full bg-theme-800/50 px-1.5 py-0.5 text-[9px] whitespace-nowrap tabular-nums text-muted-foreground"
|
||||
class="shrink-0 text-[9px] {theme.updateAvailable
|
||||
? 'text-primary'
|
||||
: 'text-muted-foreground/90'}"
|
||||
>
|
||||
{#if theme.updateAvailable && theme.availableVersion}
|
||||
v{theme.version} <span class="text-primary">→</span>
|
||||
v{theme.availableVersion}
|
||||
{:else}
|
||||
v{theme.version}
|
||||
{/if}
|
||||
{theme.updateAvailable ? 'Update available' : 'Installed'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-1 flex-col gap-2 p-3">
|
||||
<h3 class="truncate text-[13px] font-bold text-theme-50">
|
||||
{theme.name}
|
||||
</h3>
|
||||
{#if theme.description}
|
||||
<p
|
||||
class="line-clamp-2 text-[10px] leading-snug text-muted-foreground"
|
||||
class="line-clamp-2 text-[10px] leading-relaxed text-muted-foreground"
|
||||
>
|
||||
{theme.description}
|
||||
</p>
|
||||
{/if}
|
||||
<div class="mt-auto flex items-center gap-1 pt-0.5">
|
||||
<Button
|
||||
class="relative h-8 min-w-0 flex-1 overflow-hidden px-2 text-xs {theme.status ===
|
||||
'downloading' || theme.status === 'extracting'
|
||||
? 'disabled:bg-primary disabled:opacity-100'
|
||||
: ''}"
|
||||
size="sm"
|
||||
aria-busy={theme.status === 'downloading' ||
|
||||
theme.status === 'extracting'}
|
||||
disabled={isActive ||
|
||||
theme.status === 'downloading' ||
|
||||
theme.status === 'extracting' ||
|
||||
theme.status === 'deleting'}
|
||||
onclick={() => requestThemeApply(theme)}
|
||||
>
|
||||
{#if theme.status === 'downloading' || theme.status === 'extracting'}
|
||||
<span
|
||||
class="absolute inset-y-0 left-0 bg-white/20 transition-[width] duration-300 ease-out"
|
||||
style={`width: ${Math.min(100, Math.max(0, theme.progress * 100))}%`}
|
||||
></span>
|
||||
{#if !$reduceAnimations}
|
||||
<span
|
||||
class="theme-download-shimmer absolute inset-y-0 left-0 w-1/2 bg-gradient-to-r from-transparent via-white/25 to-transparent"
|
||||
></span>
|
||||
{/if}
|
||||
<div
|
||||
class="mt-auto flex items-center justify-between gap-2 border-t border-theme-800/40 pt-2.5"
|
||||
>
|
||||
<span class="min-w-0 truncate text-[9px] text-muted-foreground">
|
||||
{#if theme.updateAvailable && theme.availableVersion}
|
||||
<span class="text-primary"
|
||||
>v{theme.availableVersion} available</span
|
||||
>
|
||||
{:else if isActive}
|
||||
Active theme
|
||||
{:else}
|
||||
Installed
|
||||
{/if}
|
||||
<span
|
||||
class="relative z-10 flex items-center justify-center gap-2"
|
||||
</span>
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<Button
|
||||
class="relative h-7 min-w-0 max-w-44 overflow-hidden px-2.5 text-xs {theme.status ===
|
||||
'downloading' || theme.status === 'extracting'
|
||||
? 'disabled:bg-primary disabled:opacity-100'
|
||||
: ''}"
|
||||
size="sm"
|
||||
aria-busy={theme.status === 'downloading' ||
|
||||
theme.status === 'extracting'}
|
||||
disabled={isActive ||
|
||||
theme.status === 'downloading' ||
|
||||
theme.status === 'extracting' ||
|
||||
theme.status === 'deleting'}
|
||||
onclick={() => requestThemeApply(theme)}
|
||||
>
|
||||
{#if theme.status === 'extracting'}
|
||||
<ThemeIcon
|
||||
name="loader"
|
||||
set={iconSet}
|
||||
class="size-4 animate-spin"
|
||||
/>
|
||||
{#if theme.status === 'downloading' || theme.status === 'extracting'}
|
||||
<span
|
||||
class="absolute inset-y-0 left-0 bg-white/20 transition-[width] duration-300 ease-out"
|
||||
style={`width: ${Math.min(100, Math.max(0, theme.progress * 100))}%`}
|
||||
></span>
|
||||
{#if !$reduceAnimations}
|
||||
<span
|
||||
class="theme-download-shimmer absolute inset-y-0 left-0 w-1/2 bg-gradient-to-r from-transparent via-white/25 to-transparent"
|
||||
></span>
|
||||
{/if}
|
||||
{/if}
|
||||
<TextMorph
|
||||
text={themeButtonLabel(
|
||||
theme,
|
||||
$active_custom_theme?.folder_name
|
||||
)}
|
||||
duration={260}
|
||||
ease="cubic-bezier(0.19, 1, 0.22, 1)"
|
||||
disabled={$reduceAnimations}
|
||||
class="whitespace-nowrap"
|
||||
/>
|
||||
</span>
|
||||
</Button>
|
||||
{#if theme.status === 'installed' && theme.definition}
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
class="size-7 shrink-0"
|
||||
title="Edit theme"
|
||||
onclick={() => openThemeEditor(theme)}
|
||||
>
|
||||
<ThemeIcon name="edit" set={iconSet} class="size-3.5" />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if theme.status === 'installed' && (theme.backups?.length ?? 0) > 0}
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
class="size-7 shrink-0"
|
||||
title="Restore previous version ({new Date(
|
||||
theme.backups![0].createdAt
|
||||
).toLocaleDateString()})"
|
||||
onclick={() => requestThemeRestore(theme, theme.backups![0])}
|
||||
>
|
||||
<ThemeIcon name="history" set={iconSet} class="size-3.5" />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if theme.status === 'installed' && theme.updateAvailable}
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
class="size-7 shrink-0"
|
||||
title={`Update theme${theme.availableVersion ? ` to v${theme.availableVersion}` : ''}`}
|
||||
onclick={() => updateInstalledTheme(theme)}
|
||||
>
|
||||
<ThemeIcon name="download" set={iconSet} class="size-3.5" />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if (theme.status === 'installed' || theme.status === 'deleting') && !isActive && theme.name !== 'Default'}
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="icon"
|
||||
class="size-7 shrink-0"
|
||||
title="Uninstall theme"
|
||||
disabled={theme.status !== 'installed'}
|
||||
onclick={async () => {
|
||||
try {
|
||||
const deleteResult = await deleteTheme(theme);
|
||||
if (deleteResult) {
|
||||
sileo.success({
|
||||
title: 'Yaay!',
|
||||
description: 'Theme uninstalled successfully!',
|
||||
});
|
||||
} else {
|
||||
sileo.error({
|
||||
title: 'Uhhm..',
|
||||
description: 'Failed to uninstall theme.',
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
sileo.error({
|
||||
title: 'Uhhm..',
|
||||
description: 'Failed to uninstall theme.',
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#if theme.status === 'deleting'}
|
||||
<ThemeIcon
|
||||
name="loader"
|
||||
set={iconSet}
|
||||
class="size-3.5 animate-spin"
|
||||
<span
|
||||
class="relative z-10 flex items-center justify-center gap-2"
|
||||
>
|
||||
{#if theme.status === 'extracting'}
|
||||
<ThemeIcon
|
||||
name="loader"
|
||||
set={iconSet}
|
||||
class="size-4 animate-spin"
|
||||
/>
|
||||
{/if}
|
||||
<TextMorph
|
||||
text={themeButtonLabel(
|
||||
theme,
|
||||
$active_custom_theme?.folder_name
|
||||
)}
|
||||
duration={260}
|
||||
ease="cubic-bezier(0.19, 1, 0.22, 1)"
|
||||
disabled={$reduceAnimations}
|
||||
class="whitespace-nowrap"
|
||||
/>
|
||||
{:else}
|
||||
<ThemeIcon name="trash" set={iconSet} class="size-3.5" />
|
||||
{/if}
|
||||
</span>
|
||||
</Button>
|
||||
{/if}
|
||||
{#if $currentUser && ownedWorkshopLoaded && !isOwnInstalledTheme(theme) && theme.status === 'installed' && theme.name !== 'Default' && theme.folder_name !== 'default'}
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
class="size-7 shrink-0 text-muted-foreground hover:bg-amber-500/15 hover:text-amber-300"
|
||||
title="Report theme"
|
||||
aria-label={`Report ${theme.name}`}
|
||||
disabled={installedReportLoading}
|
||||
onclick={() => void openInstalledReport(theme)}
|
||||
>
|
||||
<Flag class="size-3.5" />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if hasThemeMenu}
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Trigger>
|
||||
{#snippet child({ props })}
|
||||
<Button
|
||||
{...props}
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
class="size-7 shrink-0 text-muted-foreground hover:text-white"
|
||||
title="More theme actions"
|
||||
aria-label={`More actions for ${theme.name}`}
|
||||
>
|
||||
<Ellipsis class="size-3.5" />
|
||||
</Button>
|
||||
{/snippet}
|
||||
</DropdownMenu.Trigger>
|
||||
<DropdownMenu.Content
|
||||
align="end"
|
||||
class="w-48 border-theme-700 bg-theme-950 text-theme-50"
|
||||
>
|
||||
{#if canEditTheme}
|
||||
<DropdownMenu.Item
|
||||
class="gap-2 text-[11px]"
|
||||
onclick={() => openThemeEditor(theme)}
|
||||
>
|
||||
<ThemeIcon name="edit" set={iconSet} class="size-3.5" />
|
||||
Edit theme
|
||||
</DropdownMenu.Item>
|
||||
{/if}
|
||||
{#if canRestoreTheme}
|
||||
<DropdownMenu.Item
|
||||
class="gap-2 text-[11px]"
|
||||
onclick={() =>
|
||||
requestThemeRestore(theme, theme.backups![0])}
|
||||
>
|
||||
<ThemeIcon
|
||||
name="history"
|
||||
set={iconSet}
|
||||
class="size-3.5"
|
||||
/>
|
||||
Restore previous version
|
||||
</DropdownMenu.Item>
|
||||
{/if}
|
||||
{#if canUpdateTheme}
|
||||
<DropdownMenu.Item
|
||||
class="gap-2 text-[11px]"
|
||||
onclick={() => updateInstalledTheme(theme)}
|
||||
>
|
||||
<ThemeIcon
|
||||
name="download"
|
||||
set={iconSet}
|
||||
class="size-3.5"
|
||||
/>
|
||||
Update theme
|
||||
</DropdownMenu.Item>
|
||||
{/if}
|
||||
{#if canReportTheme}
|
||||
<DropdownMenu.Item
|
||||
class="gap-2 text-[11px]"
|
||||
disabled={installedReportLoading}
|
||||
onclick={() => void openInstalledReport(theme)}
|
||||
>
|
||||
<Flag class="size-3.5" />
|
||||
Report theme
|
||||
</DropdownMenu.Item>
|
||||
{/if}
|
||||
{#if canUninstallTheme}
|
||||
<DropdownMenu.Separator class="my-1 bg-theme-800" />
|
||||
<DropdownMenu.Item
|
||||
class="gap-2 text-[11px] text-red-300 data-[highlighted]:bg-red-500/15 data-[highlighted]:text-red-200"
|
||||
disabled={theme.status !== 'installed'}
|
||||
onclick={() => void uninstallInstalledTheme(theme)}
|
||||
>
|
||||
{#if theme.status === 'deleting'}
|
||||
<ThemeIcon
|
||||
name="loader"
|
||||
set={iconSet}
|
||||
class="size-3.5 animate-spin"
|
||||
/>
|
||||
Uninstalling...
|
||||
{:else}
|
||||
<ThemeIcon
|
||||
name="trash"
|
||||
set={iconSet}
|
||||
class="size-3.5"
|
||||
/>
|
||||
Uninstall theme
|
||||
{/if}
|
||||
</DropdownMenu.Item>
|
||||
{/if}
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user