mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
feat: Theme Of The Month
This commit is contained in:
@@ -15,8 +15,34 @@
|
||||
import CloudHeader from "@/interface/components/store/CloudHeader.svelte"
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth"
|
||||
import { showPrivacyNotification } from "@/seqta/utils/Openers/OpenPrivacyNotification"
|
||||
import { showThemeOfTheMonthPopupNow } from "@/seqta/utils/Openers/OpenThemeOfTheMonthPopup"
|
||||
import { closeExtensionPopup } from "@/seqta/utils/Closers/closeExtensionPopup"
|
||||
import { getSnapshotForUpload } from "@/seqta/utils/cloudSettingsSync"
|
||||
import { getStoredOverride, setApiBase } from "@/seqta/utils/DevApiBase"
|
||||
|
||||
let devApiBaseInput = $state<string>(getStoredOverride() ?? "")
|
||||
let devApiBaseActive = $state<string | null>(getStoredOverride())
|
||||
|
||||
function applyDevApiBase() {
|
||||
const trimmed = devApiBaseInput.trim()
|
||||
if (trimmed === "") {
|
||||
setApiBase(null)
|
||||
devApiBaseActive = null
|
||||
return
|
||||
}
|
||||
if (!/^https?:\/\//.test(trimmed)) {
|
||||
alert("Please enter a full URL starting with http:// or https://")
|
||||
return
|
||||
}
|
||||
setApiBase(trimmed)
|
||||
devApiBaseActive = trimmed.replace(/\/$/, "")
|
||||
}
|
||||
|
||||
function clearDevApiBase() {
|
||||
devApiBaseInput = ""
|
||||
setApiBase(null)
|
||||
devApiBaseActive = null
|
||||
}
|
||||
|
||||
import { getAllPluginSettings } from "@/plugins"
|
||||
import type { BooleanSetting, StringSetting, NumberSetting, SelectSetting, ButtonSetting, HotkeySetting, ComponentSetting } from "@/plugins/core/types"
|
||||
@@ -483,6 +509,22 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Show Theme of the Month</h2>
|
||||
<p class="text-xs">Fetch and show the current month's popup now (ignores dismissed state)</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
closeExtensionPopup();
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
await showThemeOfTheMonthPopupNow();
|
||||
}}
|
||||
text="Show Now"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Export cloud settings JSON</h2>
|
||||
@@ -492,6 +534,31 @@
|
||||
<Button onClick={exportCloudSettingsJsonToFile} text="Export to file" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div class="flex justify-between items-start gap-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">API Base URL (session only)</h2>
|
||||
<p class="text-xs">Override the content API host for this browser session. Cleared on restart. Affects themes, theme of the month, and other server-driven content.</p>
|
||||
{#if devApiBaseActive}
|
||||
<p class="text-xs mt-1 text-amber-600 dark:text-amber-400">
|
||||
Override active: <span class="font-mono">{devApiBaseActive}</span>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="https://betterseqta.org"
|
||||
bind:value={devApiBaseInput}
|
||||
class="flex-1 px-2 py-1 text-xs rounded border bg-white dark:bg-zinc-800 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-zinc-100"
|
||||
/>
|
||||
<Button onClick={applyDevApiBase} text="Apply" />
|
||||
{#if devApiBaseActive}
|
||||
<Button onClick={clearDevApiBase} text="Clear" />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,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'
|
||||
|
||||
const themeManager = ThemeManager.getInstance();
|
||||
let cloudLoggedIn = $state(cloudAuth.state.isLoggedIn);
|
||||
@@ -122,13 +123,39 @@
|
||||
}
|
||||
};
|
||||
|
||||
function focusThemeById(themeId: string) {
|
||||
const match = themes.find((t) => t.id === themeId)
|
||||
?? themes.find((t) => t.flavours?.some((f) => f.id === themeId));
|
||||
if (match) {
|
||||
activeTab = 'themes';
|
||||
searchTerm = '';
|
||||
displayTheme = match;
|
||||
}
|
||||
}
|
||||
|
||||
function onHighlightThemeEvent(e: Event) {
|
||||
const detail = (e as CustomEvent).detail;
|
||||
if (detail?.themeId && typeof detail.themeId === 'string') {
|
||||
focusThemeById(detail.themeId);
|
||||
}
|
||||
}
|
||||
|
||||
// On mount
|
||||
onMount(async () => {
|
||||
window.addEventListener('bsplus:highlight-theme', onHighlightThemeEvent);
|
||||
|
||||
await fetchThemes();
|
||||
await fetchCurrentThemes();
|
||||
|
||||
darkMode = (await browser.storage.local.get('DarkMode')).DarkMode === 'true';
|
||||
darkMode = $settingsState.DarkMode;
|
||||
|
||||
const pending = consumePendingHighlightThemeId();
|
||||
if (pending) focusThemeById(pending);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('bsplus:highlight-theme', onHighlightThemeEvent);
|
||||
};
|
||||
});
|
||||
|
||||
// Filter themes (list is already featured-first, then newest; filter preserves order)
|
||||
|
||||
Reference in New Issue
Block a user