mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
Compare commits
57
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4943d441e1 | ||
|
|
fb80457bd3 | ||
|
|
4e6978d860 | ||
|
|
db69e902ca | ||
|
|
9e16eaa543 | ||
|
|
8165b431e5 | ||
|
|
e3581bc940 | ||
|
|
47077f77d7 | ||
|
|
e78a03c4ad | ||
|
|
776c1e98d9 | ||
|
|
bd29ab62c6 | ||
|
|
5928414a1e | ||
|
|
d97cc86ab3 | ||
|
|
4d9b17df37 | ||
|
|
eb2bdbec2f | ||
|
|
5623c12904 | ||
|
|
b3b3763fc8 | ||
|
|
7eac66b2b0 | ||
|
|
242e4f3ff8 | ||
|
|
1ba5f1ef49 | ||
|
|
56571b7597 | ||
|
|
80287caacb | ||
|
|
6f4728aa18 | ||
|
|
9d8f0613cb | ||
|
|
aaf03129a5 | ||
|
|
7bc4c55619 | ||
|
|
e11358d728 | ||
|
|
80a1f7a7ba | ||
|
|
ef781a78ff | ||
|
|
d4cd2affe2 | ||
|
|
c1151cf501 | ||
|
|
74bdf3b07d | ||
|
|
6d33ef88aa | ||
|
|
7a8a3cb70e | ||
|
|
2c0642f418 | ||
|
|
4fbb75ac3f | ||
|
|
c150e79e1c | ||
|
|
a19b43ef37 | ||
|
|
5dba4ba8b5 | ||
|
|
d9c0fee06d | ||
|
|
b8a9721f1f | ||
|
|
a760a152dc | ||
|
|
72cce2cc55 | ||
|
|
da6a0f2ad3 | ||
|
|
6523238eed | ||
|
|
1f0163b775 | ||
|
|
d35ee91d90 | ||
|
|
545069aa88 | ||
|
|
9dfe38a483 | ||
|
|
364db59d17 | ||
|
|
06777702fa | ||
|
|
8df7edcb75 | ||
|
|
b064f2df8f | ||
|
|
dc3b77f82b | ||
|
|
d980c01c81 | ||
|
|
1ce95f64e9 | ||
|
|
95acfc139d |
No files matched your search
@@ -11,9 +11,6 @@ on:
|
||||
schedule:
|
||||
# 13:30 UTC = 00:00 Adelaide during daylight saving (ACDT, UTC+10:30)
|
||||
- cron: "30 13 * * *"
|
||||
# 14:30 UTC = 00:00 Adelaide during standard time (ACST, UTC+9:30)
|
||||
- cron: "30 14 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -29,33 +26,15 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Check Adelaide midnight
|
||||
id: time_check
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
echo "proceed=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
export TZ=Australia/Adelaide
|
||||
NOW="$(date +'%Y-%m-%d %H:%M %Z')"
|
||||
if [ "$(date +%H%M)" = "0000" ]; then
|
||||
echo "proceed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "proceed=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Skipping: not midnight Australia/Adelaide ($NOW)"
|
||||
fi
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
if: steps.time_check.outputs.proceed == 'true'
|
||||
|
||||
- name: Set build date
|
||||
id: build_date
|
||||
if: steps.time_check.outputs.proceed == 'true'
|
||||
run: echo "date=$(TZ=Australia/Adelaide date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build extension
|
||||
id: build
|
||||
if: steps.time_check.outputs.proceed == 'true'
|
||||
uses: ./.github/actions/build-extension
|
||||
with:
|
||||
gh_release_update_check: "true"
|
||||
@@ -64,7 +43,6 @@ jobs:
|
||||
release_repo: ${{ github.repository }}
|
||||
|
||||
- name: Ensure nightly release exists
|
||||
if: steps.time_check.outputs.proceed == 'true'
|
||||
run: |
|
||||
TITLE="Nightly (${{ steps.build_date.outputs.date }})"
|
||||
if ! gh release view "${{ env.NIGHTLY_TAG }}" 2>/dev/null; then
|
||||
@@ -77,7 +55,6 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Upload nightly assets
|
||||
if: steps.time_check.outputs.proceed == 'true'
|
||||
run: |
|
||||
gh release upload "${{ env.NIGHTLY_TAG }}" \
|
||||
--clobber \
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -24,4 +24,4 @@ export default {
|
||||
'src/**/*.ts',
|
||||
'!src/**/*.d.ts',
|
||||
],
|
||||
};
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
// ref: https://stackoverflow.com/a/76920975
|
||||
import type { Plugin } from "vite";
|
||||
|
||||
/** Exit with code 1 on build failure; do not exit on success (multi-target builds). */
|
||||
export default function ClosePlugin(): Plugin {
|
||||
return {
|
||||
name: "ClosePlugin",
|
||||
buildEnd(error) {
|
||||
if (error) {
|
||||
console.error("Error bundling", error);
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log("Build ended");
|
||||
}
|
||||
},
|
||||
closeBundle() {
|
||||
console.log("Bundle closed");
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { dirname, relative } from "node:path/posix";
|
||||
import { globSync } from "glob";
|
||||
import type { Plugin } from "rollup";
|
||||
|
||||
const hash = (path: string) =>
|
||||
createHash("sha256").update(readFileSync(path)).digest("hex");
|
||||
|
||||
/** Reuse identical files already copied to stable extension paths. */
|
||||
export default (): Plugin => ({
|
||||
name: "dedupe-public-assets",
|
||||
writeBundle({ dir }) {
|
||||
if (!dir) return;
|
||||
const files = globSync("**/*", { cwd: dir, nodir: true });
|
||||
const stable = new Map<string, string>();
|
||||
const duplicates = new Map<string, string>();
|
||||
for (const file of files) {
|
||||
if (file.startsWith("resources/"))
|
||||
stable.set(hash(resolve(dir, file)), file);
|
||||
}
|
||||
for (const file of files) {
|
||||
const match = file.startsWith("assets/")
|
||||
? stable.get(hash(resolve(dir, file)))
|
||||
: undefined;
|
||||
if (match) duplicates.set(file, match);
|
||||
}
|
||||
for (const file of files.filter((file) =>
|
||||
/\.(?:css|html|js)$/.test(file),
|
||||
)) {
|
||||
const path = resolve(dir, file);
|
||||
let output = readFileSync(path, "utf8");
|
||||
for (const [asset, canonical] of duplicates) {
|
||||
output = output.replaceAll(
|
||||
relative(dirname(file), asset),
|
||||
relative(dirname(file), canonical),
|
||||
);
|
||||
}
|
||||
writeFileSync(path, output);
|
||||
}
|
||||
for (const file of duplicates.keys()) unlinkSync(resolve(dir, file));
|
||||
|
||||
const manifestPath = resolve(dir, "manifest.json");
|
||||
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
||||
for (const entry of manifest.web_accessible_resources ?? []) {
|
||||
entry.resources = entry.resources.filter(
|
||||
(file: string) => !duplicates.has(file),
|
||||
);
|
||||
}
|
||||
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Plugin } from "vite";
|
||||
import { build } from "esbuild";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
/** Bundle worker entry points imported with `?inlineWorker` as Blob-backed Workers in dev. */
|
||||
export default function InlineWorkerDevPlugin(): Plugin {
|
||||
@@ -16,6 +17,12 @@ export default function InlineWorkerDevPlugin(): Plugin {
|
||||
platform: "browser",
|
||||
format: "iife",
|
||||
target: "esnext",
|
||||
minify: true,
|
||||
alias: {
|
||||
"@huggingface/transformers": resolve(
|
||||
"node_modules/@huggingface/transformers/dist/transformers.web.js",
|
||||
),
|
||||
},
|
||||
external: ["webextension-polyfill"],
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
"browserslist": "> 0.5%, last 2 versions, not dead",
|
||||
"scripts": {
|
||||
"compile:layerchart": "node scripts/compile-layerchart-vendor.mjs",
|
||||
"postinstall": "node scripts/copy-pdfjs-assets.mjs && node scripts/copy-ort-wasm-assets.mjs && npm run compile:layerchart",
|
||||
"postinstall": "node scripts/copy-runtime-assets.mjs && npm run compile:layerchart",
|
||||
"autoaudit": "npm audit && npm audit fix && npm run build",
|
||||
"dev": "cross-env MODE=chrome vite dev",
|
||||
"dev:firefox": "cross-env MODE=firefox vite build --watch",
|
||||
@@ -25,7 +25,7 @@
|
||||
"test:ci": "npm run test:unit && npm run build && npm run test:smoke",
|
||||
"release": "gh release create $npm_package_version --repo BetterSEQTA/BetterSEQTA-Plus ./dist/*.zip --generate-notes",
|
||||
"publish": "bun lib/publish.js --b",
|
||||
"zip": "bedframe zip"
|
||||
"zip": "node scripts/package-extension-zips.mjs"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": {
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Chrome trace analyzer — aggregates hotspots for BetterSEQTA+ optimization.
|
||||
* Usage: node scripts/analyze-trace.mjs <path-to-trace.json>
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
|
||||
const path = process.argv[2];
|
||||
if (!path) {
|
||||
console.error("Usage: node scripts/analyze-trace.mjs <trace.json>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const raw = fs.readFileSync(path, "utf8");
|
||||
const { traceEvents } = JSON.parse(raw);
|
||||
|
||||
const DURATION_PHASES = new Set(["X", "b", "e"]);
|
||||
const openStacks = new Map(); // key -> { name, cat, args, ts }
|
||||
|
||||
const byName = new Map();
|
||||
const byCat = new Map();
|
||||
const byUrl = new Map();
|
||||
const byFunction = new Map();
|
||||
const layoutEvents = [];
|
||||
const paintEvents = [];
|
||||
const longTasks = [];
|
||||
const timers = [];
|
||||
const observers = [];
|
||||
const hitTests = [];
|
||||
const betterseqtaHits = new Map();
|
||||
const ipcMessages = new Map();
|
||||
const gcEvents = [];
|
||||
|
||||
let minTs = Infinity;
|
||||
let maxTs = -Infinity;
|
||||
|
||||
function add(map, key, dur, count = 1) {
|
||||
const e = map.get(key) ?? { dur: 0, count: 0 };
|
||||
e.dur += dur;
|
||||
e.count += count;
|
||||
map.set(key, e);
|
||||
}
|
||||
|
||||
function stackKey(ev) {
|
||||
return `${ev.pid}:${ev.tid}:${ev.name}:${ev.ts}`;
|
||||
}
|
||||
|
||||
for (const ev of traceEvents) {
|
||||
if (ev.ts != null) {
|
||||
minTs = Math.min(minTs, ev.ts);
|
||||
maxTs = Math.max(maxTs, ev.ts);
|
||||
}
|
||||
|
||||
const ph = ev.ph;
|
||||
const name = ev.name ?? "";
|
||||
const cat = ev.cat ?? "";
|
||||
const args = ev.args ?? {};
|
||||
|
||||
if (ph === "b") {
|
||||
openStacks.set(`${ev.pid}:${ev.tid}:${ev.id ?? name}`, ev);
|
||||
continue;
|
||||
}
|
||||
|
||||
let dur = ev.dur ?? 0;
|
||||
if (ph === "e" && ev.id != null) {
|
||||
const start = openStacks.get(`${ev.pid}:${ev.tid}:${ev.id}`);
|
||||
if (start) dur = ev.ts - start.ts;
|
||||
}
|
||||
if (dur <= 0 && ph !== "X") continue;
|
||||
|
||||
add(byName, name, dur);
|
||||
|
||||
const catParts = cat.split(",").filter(Boolean);
|
||||
for (const c of catParts.length ? catParts : [cat || "(none)"]) {
|
||||
add(byCat, c, dur);
|
||||
}
|
||||
|
||||
const url =
|
||||
args.data?.url ??
|
||||
args.url ??
|
||||
args.fileName ??
|
||||
args.data?.scriptName ??
|
||||
args.data?.frame ??
|
||||
"";
|
||||
if (url && typeof url === "string" && dur > 0) {
|
||||
add(byUrl, url.slice(0, 200), dur);
|
||||
}
|
||||
|
||||
const fn =
|
||||
args.data?.functionName ??
|
||||
args.functionName ??
|
||||
args.data?.columnNumber != null
|
||||
? `${args.data?.functionName ?? name}@${args.data?.url ?? ""}:${args.data?.lineNumber ?? "?"}`
|
||||
: "";
|
||||
if (fn && dur > 100) {
|
||||
add(byFunction, String(fn).slice(0, 250), dur);
|
||||
}
|
||||
|
||||
if (/Layout|UpdateLayoutTree|InvalidateLayout|LocalFrameView::performLayout/i.test(name)) {
|
||||
layoutEvents.push({ name, dur, ts: ev.ts, cat });
|
||||
}
|
||||
if (/Paint|Raster|DrawFrame|CompositeLayers|UpdateLayer/i.test(name)) {
|
||||
paintEvents.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (name === "RunTask" && dur > 50000) {
|
||||
longTasks.push({ dur, ts: ev.ts, cat, args: JSON.stringify(args).slice(0, 300) });
|
||||
}
|
||||
if (/Timer|setTimeout|setInterval|FireIdleCallback|requestAnimationFrame|RequestAnimationFrame/i.test(name)) {
|
||||
timers.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/MutationObserver|ResizeObserver|IntersectionObserver|DeliverObservations|NotifyMutation/i.test(name)) {
|
||||
observers.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/HitTest|FindElement|ElementAt/i.test(name)) {
|
||||
hitTests.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/V8\.GC|GC_|MajorGC|MinorGC|IncrementalMarking/i.test(name)) {
|
||||
gcEvents.push({ name, dur, ts: ev.ts });
|
||||
}
|
||||
if (/IPC|MessagePort|postMessage/i.test(name)) {
|
||||
add(ipcMessages, name, dur);
|
||||
}
|
||||
|
||||
const blob = JSON.stringify(args);
|
||||
if (/betterseqta|BetterSEQTA|bsplus|SEQTA\.ts|monofile|AddBetterSEQTA/i.test(blob + name + url)) {
|
||||
const key = `${name} | ${(url || blob).slice(0, 120)}`;
|
||||
add(betterseqtaHits, key, dur);
|
||||
}
|
||||
}
|
||||
|
||||
function top(map, n = 40, minCount = 1) {
|
||||
return [...map.entries()]
|
||||
.filter(([, v]) => v.count >= minCount)
|
||||
.sort((a, b) => b[1].dur - a[1].dur)
|
||||
.slice(0, n)
|
||||
.map(([k, v]) => ({
|
||||
key: k,
|
||||
totalMs: (v.dur / 1000).toFixed(1),
|
||||
count: v.count,
|
||||
avgMs: (v.dur / v.count / 1000).toFixed(2),
|
||||
}));
|
||||
}
|
||||
|
||||
const traceDurationMs = ((maxTs - minTs) / 1000).toFixed(0);
|
||||
|
||||
console.log(JSON.stringify({
|
||||
summary: {
|
||||
traceDurationMs,
|
||||
eventCount: traceEvents.length,
|
||||
layoutCount: layoutEvents.length,
|
||||
layoutTotalMs: (layoutEvents.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
paintCount: paintEvents.length,
|
||||
paintTotalMs: (paintEvents.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
longTaskCount: longTasks.length,
|
||||
longTaskTotalMs: (longTasks.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
timerCount: timers.length,
|
||||
timerTotalMs: (timers.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
observerCount: observers.length,
|
||||
observerTotalMs: (observers.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
hitTestCount: hitTests.length,
|
||||
hitTestTotalMs: (hitTests.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
gcCount: gcEvents.length,
|
||||
gcTotalMs: (gcEvents.reduce((s, e) => s + e.dur, 0) / 1000).toFixed(1),
|
||||
},
|
||||
topEventNames: top(byName, 50),
|
||||
topCategories: top(byCat, 30),
|
||||
topUrls: top(byUrl, 40),
|
||||
topFunctions: top(byFunction, 40, 1),
|
||||
topBetterseqta: top(betterseqtaHits, 50),
|
||||
topLongTasks: longTasks.sort((a, b) => b.dur - a.dur).slice(0, 20).map(e => ({
|
||||
ms: (e.dur / 1000).toFixed(1),
|
||||
cat: e.cat,
|
||||
args: e.args,
|
||||
})),
|
||||
topLayout: layoutEvents.sort((a, b) => b.dur - a.dur).slice(0, 15).map(e => ({
|
||||
name: e.name, ms: (e.dur / 1000).toFixed(2),
|
||||
})),
|
||||
topObservers: observers.sort((a, b) => b.dur - a.dur).slice(0, 15).map(e => ({
|
||||
name: e.name, ms: (e.dur / 1000).toFixed(2), count: 1,
|
||||
})),
|
||||
}, null, 2));
|
||||
@@ -1,28 +0,0 @@
|
||||
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const transformersDist = dirname(require.resolve("@huggingface/transformers"));
|
||||
const outDir = join(root, "src", "public", "resources", "ort");
|
||||
|
||||
mkdirSync(outDir, { recursive: true });
|
||||
|
||||
const ortFiles = [
|
||||
"ort-wasm-simd-threaded.jsep.mjs",
|
||||
"ort-wasm-simd-threaded.jsep.wasm",
|
||||
];
|
||||
|
||||
for (const file of ortFiles) {
|
||||
const src = join(transformersDist, file);
|
||||
if (!existsSync(src)) {
|
||||
throw new Error(
|
||||
`Missing ONNX Runtime WASM asset: ${src}\n` +
|
||||
"Ensure @huggingface/transformers is installed (direct dependency).",
|
||||
);
|
||||
}
|
||||
copyFileSync(src, join(outDir, file));
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { copyFileSync, mkdirSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const pdfjsRoot = join(root, "node_modules", "pdfjs-dist");
|
||||
const outDir = join(root, "src", "public", "resources", "pdfjs");
|
||||
|
||||
mkdirSync(outDir, { recursive: true });
|
||||
copyFileSync(
|
||||
join(pdfjsRoot, "build", "pdf.worker.min.mjs"),
|
||||
join(outDir, "pdf.worker.min.mjs"),
|
||||
);
|
||||
copyFileSync(
|
||||
join(pdfjsRoot, "legacy", "build", "pdf.min.mjs"),
|
||||
join(outDir, "pdf.legacy.min.mjs"),
|
||||
);
|
||||
@@ -0,0 +1,24 @@
|
||||
import { copyFileSync, mkdirSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const resources = join(root, "src", "public", "resources");
|
||||
const files = [
|
||||
["pdfjs-dist/build/pdf.worker.min.mjs", "pdfjs/pdf.worker.min.mjs"],
|
||||
["pdfjs-dist/legacy/build/pdf.min.mjs", "pdfjs/pdf.legacy.min.mjs"],
|
||||
[
|
||||
"@huggingface/transformers/dist/ort-wasm-simd-threaded.jsep.mjs",
|
||||
"ort/ort-wasm-simd-threaded.jsep.mjs",
|
||||
],
|
||||
[
|
||||
"@huggingface/transformers/dist/ort-wasm-simd-threaded.jsep.wasm",
|
||||
"ort/ort-wasm-simd-threaded.jsep.wasm",
|
||||
],
|
||||
];
|
||||
|
||||
for (const [source, target] of files) {
|
||||
const output = join(resources, target);
|
||||
mkdirSync(dirname(output), { recursive: true });
|
||||
copyFileSync(join(root, "node_modules", source), output);
|
||||
}
|
||||
@@ -42,7 +42,7 @@ const buildLabel = process.env.BUILD_LABEL || "";
|
||||
const base =
|
||||
updateChannel === "nightly" && buildLabel
|
||||
? `betterseqtaplus-nightly-${buildLabel}`
|
||||
: `betterseqtaplus-${version}`;
|
||||
: `${pkg.name}@${version}`;
|
||||
|
||||
const chromeZip = `dist/${base}-chrome.zip`;
|
||||
const firefoxZip = `dist/${base}-firefox.zip`;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/** @jest-environment jsdom */
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { runInNewContext } from "node:vm";
|
||||
|
||||
// Compile the actual Vite entry in Node (esbuild cannot run in jsdom's realm).
|
||||
const bootScript = execFileSync(
|
||||
process.execPath,
|
||||
[
|
||||
"--input-type=module",
|
||||
"-e",
|
||||
`
|
||||
import { readFileSync } from "node:fs";
|
||||
import { transformSync } from "esbuild";
|
||||
process.stdout.write(transformSync(readFileSync("src/SEQTA.ts", "utf8"), {
|
||||
loader: "ts", format: "cjs",
|
||||
supported: { "dynamic-import": false },
|
||||
define: { "import.meta.env.DEV": "false", "import.meta.hot": "undefined" },
|
||||
}).code);
|
||||
`,
|
||||
],
|
||||
{ encoding: "utf8" },
|
||||
);
|
||||
|
||||
test.each([
|
||||
{ onoff: false },
|
||||
{ "plugin.error-page-kitten.settings": { enabled: false } },
|
||||
])(
|
||||
"disabled 404 customization preserves the native error message: %j",
|
||||
async (stored) => {
|
||||
document.head.innerHTML = "";
|
||||
document.body.innerHTML = '<div class="message">Page not found</div>';
|
||||
const mount = jest.fn();
|
||||
runInNewContext(bootScript, {
|
||||
document,
|
||||
window,
|
||||
console,
|
||||
require: (module: string) => {
|
||||
if (module === "webextension-polyfill") {
|
||||
return { storage: { local: { get: async () => stored } } };
|
||||
}
|
||||
if (module.includes("errorPageKitten")) {
|
||||
return { isSeqta404Page: () => true, mountErrorPageKitten: mount };
|
||||
}
|
||||
return {};
|
||||
},
|
||||
});
|
||||
for (let i = 0; i < 10; i++) await Promise.resolve();
|
||||
|
||||
expect(mount).not.toHaveBeenCalled();
|
||||
expect(
|
||||
window.getComputedStyle(document.querySelector(".message")!).display,
|
||||
).not.toBe("none");
|
||||
},
|
||||
);
|
||||
+12
-12
@@ -178,24 +178,24 @@ async function bootErrorPage() {
|
||||
}
|
||||
document.removeEventListener("readystatechange", watchTitle);
|
||||
|
||||
if (!isSeqta404Page()) return;
|
||||
|
||||
const stored = await storagePromise;
|
||||
if ((stored.onoff ?? true) === false) return;
|
||||
const kittenSettings = stored["plugin.error-page-kitten.settings"] as
|
||||
| { enabled?: boolean }
|
||||
| undefined;
|
||||
if (kittenSettings?.enabled === false) return;
|
||||
|
||||
try {
|
||||
if (!isSeqta404Page()) return;
|
||||
|
||||
const stored = await storagePromise;
|
||||
if ((stored.onoff ?? true) === false) return;
|
||||
const kittenSettings = stored["plugin.error-page-kitten.settings"] as
|
||||
| { enabled?: boolean }
|
||||
| undefined;
|
||||
if (kittenSettings?.enabled === false) return;
|
||||
|
||||
mountErrorPageKitten();
|
||||
document.getElementById("bsplus-404-flash-hide")?.remove();
|
||||
} catch (error) {
|
||||
document.getElementById("bsplus-404-flash-hide")?.remove();
|
||||
document
|
||||
.querySelectorAll(".bsplus-kitten-404-hidden")
|
||||
.forEach((el) => el.classList.remove("bsplus-kitten-404-hidden"));
|
||||
console.error("[BetterSEQTA+] Failed to boot 404 page:", error);
|
||||
} finally {
|
||||
document.getElementById("bsplus-404-flash-hide")?.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,4 +230,4 @@ function recoverFromStaleDevModuleGraph(error: unknown) {
|
||||
console.error(
|
||||
"[BetterSEQTA+] Dev module graph is still stale after recovery. Restart `npm run dev`, then reload this page.",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,9 @@ import {
|
||||
registerGoogleCalendarMessageHandlers,
|
||||
registerOutlookCalendarMessageHandlers,
|
||||
} from "./background/calendarBackground";
|
||||
import { createCustomThemesHandlers } from "./background/customThemesHandlers";
|
||||
import { handleSearchThemeStockPhotos } from "./background/searchThemeStockPhotos";
|
||||
import { initTimetableClassmatesBackgroundSync } from "./background/timetableClassmatesSync";
|
||||
|
||||
/**
|
||||
* Session-only dev-mode override of the content API base.
|
||||
@@ -32,6 +35,8 @@ import {
|
||||
const DEFAULT_API_BASE = "https://betterseqta.org";
|
||||
let DEV_API_BASE: string | null = null;
|
||||
function apiBase(): string {
|
||||
// Extension dev builds always hit production (see DevApiBase.ts).
|
||||
if (import.meta.env.DEV) return DEFAULT_API_BASE;
|
||||
return DEV_API_BASE ?? DEFAULT_API_BASE;
|
||||
}
|
||||
|
||||
@@ -469,6 +474,10 @@ function handleSetDevApiBase(
|
||||
sender?: browser.Runtime.MessageSender,
|
||||
): boolean {
|
||||
if (!isTrustedSender(sender)) return false;
|
||||
if (import.meta.env.DEV) {
|
||||
DEV_API_BASE = null;
|
||||
return false;
|
||||
}
|
||||
const url = typeof request?.url === "string" ? request.url.trim() : null;
|
||||
if (url && /^https?:\/\//.test(url)) {
|
||||
DEV_API_BASE = url.replace(/\/$/, "");
|
||||
@@ -478,7 +487,14 @@ function handleSetDevApiBase(
|
||||
return false;
|
||||
}
|
||||
|
||||
const customThemesHandlers = createCustomThemesHandlers({
|
||||
apiBase,
|
||||
getAccessTokenFromStorage,
|
||||
});
|
||||
|
||||
const MESSAGE_HANDLERS: Record<string, MessageHandler> = {
|
||||
...customThemesHandlers,
|
||||
searchThemeStockPhotos: handleSearchThemeStockPhotos,
|
||||
reloadTabs: () => reloadSeqtaPages(),
|
||||
setDevApiBase: handleSetDevApiBase,
|
||||
extensionPages: (req) => {
|
||||
@@ -735,4 +751,5 @@ browser.runtime.onStartup.addListener(() => {
|
||||
});
|
||||
|
||||
initCloudSettingsAutoSync({ reloadSeqtaPages });
|
||||
initTimetableClassmatesBackgroundSync();
|
||||
void ensureSyncableStorageDefaults();
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
CALENDAR_WEEKLY_ALARM,
|
||||
clampSyncWeeks,
|
||||
getAutoSyncWeekly,
|
||||
getSyncAssessmentDueDates,
|
||||
getSyncWeeksAhead,
|
||||
isAnyCalendarConnected,
|
||||
markWeeklySyncPending,
|
||||
@@ -52,6 +53,7 @@ import {
|
||||
type OutlookCalendarStatus,
|
||||
} from "@/seqta/utils/calendarSync/providerStorage";
|
||||
import browser from "webextension-polyfill";
|
||||
import { isSeqtaTab } from "@/seqta/utils/seqtaTabMatch";
|
||||
|
||||
const WEEKLY_PERIOD_MINUTES = 7 * 24 * 60;
|
||||
|
||||
@@ -324,12 +326,14 @@ export function registerTrustedAsyncHandler(
|
||||
}
|
||||
|
||||
async function getGoogleCalendarStatus(): Promise<GoogleCalendarStatus> {
|
||||
const [state, shared, syncWeeksAhead, autoSyncWeekly] = await Promise.all([
|
||||
readGoogleCalendarState(),
|
||||
readSharedCalendarSyncSettings(),
|
||||
getSyncWeeksAhead(),
|
||||
getAutoSyncWeekly(),
|
||||
]);
|
||||
const [state, shared, syncWeeksAhead, autoSyncWeekly, syncAssessmentDueDates] =
|
||||
await Promise.all([
|
||||
readGoogleCalendarState(),
|
||||
readSharedCalendarSyncSettings(),
|
||||
getSyncWeeksAhead(),
|
||||
getAutoSyncWeekly(),
|
||||
getSyncAssessmentDueDates(),
|
||||
]);
|
||||
return {
|
||||
configured: isGoogleCalendarConfigured(),
|
||||
connected: !!(state.refreshToken || state.accessToken),
|
||||
@@ -338,6 +342,7 @@ async function getGoogleCalendarStatus(): Promise<GoogleCalendarStatus> {
|
||||
lastSyncOrigin: state.lastSyncOrigin,
|
||||
syncWeeksAhead,
|
||||
autoSyncWeekly,
|
||||
syncAssessmentDueDates,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -479,10 +484,17 @@ export function registerGoogleCalendarMessageHandlers(
|
||||
}));
|
||||
|
||||
registerTrustedAsyncHandler(handlers, isTrustedSender, "googleCalendarUpdateSyncSettings", async (request) => {
|
||||
const body = request as { syncWeeksAhead?: number; autoSyncWeekly?: boolean };
|
||||
const body = request as {
|
||||
syncWeeksAhead?: number;
|
||||
autoSyncWeekly?: boolean;
|
||||
syncAssessmentDueDates?: boolean;
|
||||
};
|
||||
const patch: Record<string, unknown> = {};
|
||||
if (body.syncWeeksAhead != null) patch.syncWeeksAhead = clampSyncWeeks(body.syncWeeksAhead);
|
||||
if (body.autoSyncWeekly != null) patch.autoSyncWeekly = !!body.autoSyncWeekly;
|
||||
if (body.syncAssessmentDueDates != null) {
|
||||
patch.syncAssessmentDueDates = !!body.syncAssessmentDueDates;
|
||||
}
|
||||
if (Object.keys(patch).length > 0) await writeSharedCalendarSyncSettings(patch);
|
||||
await ensureWeeklySyncAlarm();
|
||||
return { success: true, ...(await getGoogleCalendarStatus()) };
|
||||
@@ -499,11 +511,6 @@ export function registerOutlookCalendarMessageHandlers(
|
||||
registerProviderHandlers(handlers, isTrustedSender, OUTLOOK_BACKEND, getOutlookCalendarStatus);
|
||||
}
|
||||
|
||||
function isSeqtaTab(tab: browser.Tabs.Tab): boolean {
|
||||
const title = tab.title ?? "";
|
||||
return title.includes("SEQTA Learn") || title.includes("SEQTA Engage");
|
||||
}
|
||||
|
||||
export async function ensureWeeklySyncAlarm(): Promise<void> {
|
||||
const [connected, enabled] = await Promise.all([isAnyCalendarConnected(), getAutoSyncWeekly()]);
|
||||
if (!connected || !enabled) {
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
import { normalizeCustomThemeApiResponse } from "@/seqta/utils/customThemes/parseApiEnvelope";
|
||||
|
||||
type MessageSender = { (response?: unknown): void };
|
||||
|
||||
type UploadFilePart = {
|
||||
fieldName: string;
|
||||
filename: string;
|
||||
mimeType: string;
|
||||
dataBase64: string;
|
||||
};
|
||||
|
||||
type UploadPayload = {
|
||||
themeZip?: UploadFilePart;
|
||||
looseFiles?: UploadFilePart[];
|
||||
submissionNotes?: string;
|
||||
};
|
||||
|
||||
function base64ToBlob(base64: string, mimeType: string): Blob {
|
||||
const binary = atob(base64);
|
||||
const bytes = new Uint8Array(binary.length);
|
||||
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
||||
return new Blob([bytes], { type: mimeType });
|
||||
}
|
||||
|
||||
function buildFormDataFromPayload(payload: UploadPayload): FormData {
|
||||
const form = new FormData();
|
||||
if (payload.themeZip) {
|
||||
const part = payload.themeZip;
|
||||
form.append(
|
||||
part.fieldName,
|
||||
base64ToBlob(part.dataBase64, part.mimeType),
|
||||
part.filename,
|
||||
);
|
||||
}
|
||||
for (const part of payload.looseFiles ?? []) {
|
||||
form.append(
|
||||
part.fieldName,
|
||||
base64ToBlob(part.dataBase64, part.mimeType),
|
||||
part.filename,
|
||||
);
|
||||
}
|
||||
if (payload.submissionNotes?.trim()) {
|
||||
form.append("submission_notes", payload.submissionNotes.trim());
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
export function createCustomThemesHandlers(deps: {
|
||||
apiBase: () => string;
|
||||
getAccessTokenFromStorage: () => Promise<string | null>;
|
||||
}): Record<string, (request: any, sendResponse: MessageSender) => boolean> {
|
||||
async function readCustomThemesResponse(r: Response): Promise<Record<string, unknown>> {
|
||||
const text = await r.text();
|
||||
let body: unknown = {};
|
||||
try {
|
||||
body = text ? JSON.parse(text) : {};
|
||||
} catch {
|
||||
body = null;
|
||||
}
|
||||
const normalized = normalizeCustomThemeApiResponse(body, r.status, text);
|
||||
if (!r.ok || normalized.success === false) {
|
||||
console.error("[BetterSEQTA+ CustomThemes]", r.status, r.url, normalized);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
async function customThemesJsonFetch(
|
||||
path: string,
|
||||
init: RequestInit = {},
|
||||
requireAuth = false,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const headers: Record<string, string> = {
|
||||
Accept: "application/json",
|
||||
...(init.headers as Record<string, string> | undefined),
|
||||
};
|
||||
if (requireAuth) {
|
||||
const token = await deps.getAccessTokenFromStorage();
|
||||
if (!token) {
|
||||
return { success: false, error: "Not authenticated", httpStatus: 401 };
|
||||
}
|
||||
headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
const url = `${deps.apiBase()}${path}`;
|
||||
const r = await fetch(url, {
|
||||
...init,
|
||||
headers,
|
||||
cache: "no-store",
|
||||
});
|
||||
return await readCustomThemesResponse(r);
|
||||
}
|
||||
|
||||
async function customThemesMultipartPost(
|
||||
path: string,
|
||||
payload: UploadPayload,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const token = await deps.getAccessTokenFromStorage();
|
||||
if (!token) {
|
||||
return { success: false, error: "Not authenticated", httpStatus: 401 };
|
||||
}
|
||||
const form = buildFormDataFromPayload(payload);
|
||||
const url = `${deps.apiBase()}${path}`;
|
||||
const r = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: form,
|
||||
cache: "no-store",
|
||||
});
|
||||
return await readCustomThemesResponse(r);
|
||||
}
|
||||
|
||||
function handleFetchCustomThemes(request: any, sendResponse: MessageSender): boolean {
|
||||
void (async () => {
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
params.set("type", "betterseqta");
|
||||
params.set("page", String(request.page ?? 1));
|
||||
params.set("limit", String(request.limit ?? 20));
|
||||
if (request.sort) params.set("sort", String(request.sort));
|
||||
const search = request.search?.trim();
|
||||
const path = search
|
||||
? `/api/custom-themes/search?${params}&q=${encodeURIComponent(search)}`
|
||||
: `/api/custom-themes?${params}`;
|
||||
sendResponse(await customThemesJsonFetch(path));
|
||||
} catch (err) {
|
||||
console.error("[Background] fetchCustomThemes error:", err);
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: err instanceof Error ? err.message : "Fetch failed",
|
||||
});
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleFetchMyCustomThemes(request: any, sendResponse: MessageSender): boolean {
|
||||
void (async () => {
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
params.set("page", String(request.page ?? 1));
|
||||
params.set("limit", String(request.limit ?? 20));
|
||||
params.set("type", "betterseqta");
|
||||
if (request.status) params.set("status", String(request.status));
|
||||
sendResponse(
|
||||
await customThemesJsonFetch(`/api/custom-themes/mine?${params}`, {}, true),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("[Background] fetchMyCustomThemes error:", err);
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: err instanceof Error ? err.message : "Fetch failed",
|
||||
});
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleFetchMyCustomThemeDetail(request: any, sendResponse: MessageSender): boolean {
|
||||
const { themeId } = request;
|
||||
if (!themeId || typeof themeId !== "string") {
|
||||
sendResponse({ success: false, error: "Missing themeId" });
|
||||
return false;
|
||||
}
|
||||
void (async () => {
|
||||
try {
|
||||
sendResponse(
|
||||
await customThemesJsonFetch(
|
||||
`/api/custom-themes/mine/${encodeURIComponent(themeId)}`,
|
||||
{},
|
||||
true,
|
||||
),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("[Background] fetchMyCustomThemeDetail error:", err);
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: err instanceof Error ? err.message : "Fetch failed",
|
||||
});
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleSubmitCustomTheme(request: any, sendResponse: MessageSender): boolean {
|
||||
const payload = request.payload as UploadPayload | undefined;
|
||||
if (!payload?.themeZip && (!payload?.looseFiles || payload.looseFiles.length === 0)) {
|
||||
sendResponse({ success: false, error: "Missing upload files" });
|
||||
return false;
|
||||
}
|
||||
void (async () => {
|
||||
try {
|
||||
sendResponse(await customThemesMultipartPost("/api/custom-themes/mine", payload!));
|
||||
} catch (err) {
|
||||
console.error("[Background] submitCustomTheme error:", err);
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: { message: err instanceof Error ? err.message : "Upload failed" },
|
||||
httpStatus: 0,
|
||||
});
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleReplaceCustomThemeFiles(request: any, sendResponse: MessageSender): boolean {
|
||||
const { themeId, payload } = request;
|
||||
if (!themeId || typeof themeId !== "string") {
|
||||
sendResponse({ success: false, error: "Missing themeId" });
|
||||
return false;
|
||||
}
|
||||
if (!payload?.themeZip && (!payload?.looseFiles || payload.looseFiles.length === 0)) {
|
||||
sendResponse({ success: false, error: "Missing upload files" });
|
||||
return false;
|
||||
}
|
||||
void (async () => {
|
||||
try {
|
||||
sendResponse(
|
||||
await customThemesMultipartPost(
|
||||
`/api/custom-themes/mine/${encodeURIComponent(themeId)}/files`,
|
||||
payload,
|
||||
),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("[Background] replaceCustomThemeFiles error:", err);
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: err instanceof Error ? err.message : "Upload failed",
|
||||
});
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleUpdateCustomThemeMetadata(request: any, sendResponse: MessageSender): boolean {
|
||||
const { themeId, body } = request;
|
||||
if (!themeId || typeof themeId !== "string") {
|
||||
sendResponse({ success: false, error: "Missing themeId" });
|
||||
return false;
|
||||
}
|
||||
void (async () => {
|
||||
try {
|
||||
sendResponse(
|
||||
await customThemesJsonFetch(
|
||||
`/api/custom-themes/mine/${encodeURIComponent(themeId)}`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body ?? {}),
|
||||
},
|
||||
true,
|
||||
),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("[Background] updateCustomThemeMetadata error:", err);
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: err instanceof Error ? err.message : "Update failed",
|
||||
});
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleDeleteCustomTheme(request: any, sendResponse: MessageSender): boolean {
|
||||
const { themeId } = request;
|
||||
if (!themeId || typeof themeId !== "string") {
|
||||
sendResponse({ success: false, error: "Missing themeId" });
|
||||
return false;
|
||||
}
|
||||
void (async () => {
|
||||
try {
|
||||
sendResponse(
|
||||
await customThemesJsonFetch(
|
||||
`/api/custom-themes/mine/${encodeURIComponent(themeId)}`,
|
||||
{ method: "DELETE" },
|
||||
true,
|
||||
),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("[Background] deleteCustomTheme error:", err);
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: err instanceof Error ? err.message : "Delete failed",
|
||||
});
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
|
||||
return {
|
||||
fetchCustomThemes: handleFetchCustomThemes,
|
||||
fetchMyCustomThemes: handleFetchMyCustomThemes,
|
||||
fetchMyCustomThemeDetail: handleFetchMyCustomThemeDetail,
|
||||
submitCustomTheme: handleSubmitCustomTheme,
|
||||
replaceCustomThemeFiles: handleReplaceCustomThemeFiles,
|
||||
updateCustomThemeMetadata: handleUpdateCustomThemeMetadata,
|
||||
deleteCustomTheme: handleDeleteCustomTheme,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
type MessageSender = { (response?: unknown): void };
|
||||
|
||||
type StockPhotoResult = { title: string; thumbUrl: string; imageUrl: string };
|
||||
|
||||
export function handleSearchThemeStockPhotos(
|
||||
request: { query?: string; limit?: number },
|
||||
sendResponse: MessageSender,
|
||||
): boolean {
|
||||
const query = request.query?.trim();
|
||||
if (!query) {
|
||||
sendResponse({ success: false, error: "Missing query" });
|
||||
return false;
|
||||
}
|
||||
const limit = Math.min(Math.max(request.limit ?? 8, 1), 12);
|
||||
|
||||
void (async () => {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
action: "query",
|
||||
origin: "*",
|
||||
format: "json",
|
||||
generator: "search",
|
||||
gsrsearch: query,
|
||||
gsrnamespace: "6",
|
||||
gsrlimit: String(limit),
|
||||
prop: "imageinfo",
|
||||
iiprop: "url",
|
||||
iiurlwidth: "1400",
|
||||
});
|
||||
const res = await fetch(`https://commons.wikimedia.org/w/api.php?${params}`);
|
||||
const json = (await res.json()) as {
|
||||
query?: { pages?: Record<string, { title?: string; imageinfo?: { thumburl?: string; url?: string }[] }> };
|
||||
};
|
||||
const pages = json.query?.pages ?? {};
|
||||
const results: StockPhotoResult[] = Object.values(pages)
|
||||
.map((page) => {
|
||||
const info = page.imageinfo?.[0];
|
||||
if (!info?.url) return null;
|
||||
return {
|
||||
title: page.title?.replace(/^File:/, "") ?? "Photo",
|
||||
thumbUrl: info.thumburl ?? info.url,
|
||||
imageUrl: info.url,
|
||||
};
|
||||
})
|
||||
.filter((row): row is StockPhotoResult => row != null);
|
||||
|
||||
sendResponse({ success: true, results });
|
||||
} catch (err) {
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: err instanceof Error ? err.message : "Search failed",
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import browser from "webextension-polyfill";
|
||||
|
||||
import { hasAnySyncOptInScope } from "@/plugins/built-in/timetableClassmates/syncScopes";
|
||||
import { isSeqtaTab } from "@/seqta/utils/seqtaTabMatch";
|
||||
|
||||
const ALARM_NAME = "timetable-classmates-sync";
|
||||
const ALARM_PERIOD_MINUTES = 8 * 60;
|
||||
|
||||
let initialized = false;
|
||||
|
||||
async function pingSeqtaTabs(): Promise<void> {
|
||||
const tabs = await browser.tabs.query({});
|
||||
for (const tab of tabs) {
|
||||
if (!isSeqtaTab(tab) || tab.id == null) continue;
|
||||
try {
|
||||
await browser.tabs.sendMessage(tab.id, { type: "timetableClassmatesSync" });
|
||||
} catch {
|
||||
/* content script not ready */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function pingIfOptedIn(): Promise<void> {
|
||||
if (!(await hasAnySyncOptInScope())) return;
|
||||
await pingSeqtaTabs();
|
||||
}
|
||||
|
||||
export function initTimetableClassmatesBackgroundSync(): void {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
|
||||
void browser.alarms.create(ALARM_NAME, { periodInMinutes: ALARM_PERIOD_MINUTES });
|
||||
browser.alarms.onAlarm.addListener((alarm) => {
|
||||
if (alarm.name === ALARM_NAME) void pingIfOptedIn();
|
||||
});
|
||||
}
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
@layer override {
|
||||
.legacy-root,
|
||||
.legacy-root * {
|
||||
.legacy-root *:not(.iconFamily) {
|
||||
font-family: var(--betterseqta-font-family, Rubik), sans-serif !important;
|
||||
}
|
||||
|
||||
|
||||
+592
-263
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,51 @@
|
||||
html.performanceMode {
|
||||
--bs-settings-ease: 0.2s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
--bs-motion-duration: 0.2s;
|
||||
--bs-motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
|
||||
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
filter: none !important;
|
||||
|
||||
/* Inline page loaders only — boot overlay lives in #loading shadow DOM. */
|
||||
.bkloading-inline .big-circle,
|
||||
.bkloading-inline .small-circle,
|
||||
.bkloading-inline .outer-circle {
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
/* Custom title: cheaper hit-testing during mouse moves (trace showed many HitTests). */
|
||||
.bsplus-custom-title,
|
||||
#title.bsplus-custom-title {
|
||||
contain: layout style paint;
|
||||
}
|
||||
|
||||
/* Settings backdrop — skip expensive blur in performance mode. */
|
||||
#ExtensionPopup ~ *,
|
||||
.outside-container.hide {
|
||||
backdrop-filter: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
html.performanceModeSimpleUi {
|
||||
.bsplus-analytics-charts,
|
||||
.bsplus-analytics-chart-cell {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Boot loading spinner uses shadow DOM; custom properties inherit from the host. */
|
||||
#loading.bkloading {
|
||||
--bk-stage-duration: 0.85s !important;
|
||||
--bk-spin-outer: 1s !important;
|
||||
--bk-spin-inner: 3s !important;
|
||||
--bk-spin-small: 3s !important;
|
||||
}
|
||||
|
||||
html.performanceMode.transparencyEffects,
|
||||
html.performanceMode .backdrop-blur-xl,
|
||||
html.performanceMode .backdrop-blur-sm,
|
||||
html.performanceMode [class*="backdrop-blur"] {
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
}
|
||||
@@ -34,9 +34,21 @@
|
||||
#ExtensionPopup {
|
||||
border-radius: 0;
|
||||
filter: none;
|
||||
/* Avoid transform on the host — it makes shadow `position: fixed` children
|
||||
size to the host instead of the viewport on Engage stacking contexts. */
|
||||
transform-origin: center center;
|
||||
will-change: opacity;
|
||||
transition: opacity 0.05s;
|
||||
opacity: 0;
|
||||
transition: opacity var(--bs-motion-duration, 0.2s) cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
#ExtensionPopup.bsplus-settings-host--open {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#ExtensionPopup.bsplus-settings-host--closing {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Feedback modal scrollport — host overflow:hidden otherwise clips fixed overlays. */
|
||||
#ExtensionPopup.bsplus-feedback-open {
|
||||
overflow: auto !important;
|
||||
}
|
||||
@@ -1,36 +1,69 @@
|
||||
#menu ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
#menu
|
||||
ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
li.hasChildren:is(.active, .bsplus-active) {
|
||||
box-shadow: inset 0px 0 var(--item-colour, transparent) !important;
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
#menu ul:not(:has(li.hasChildren:is(.active, .bsplus-active))) {
|
||||
#menu ul:not(:has(> li.hasChildren:is(.active, .bsplus-active))) {
|
||||
overflow-y: scroll !important;
|
||||
}
|
||||
|
||||
#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::before,
|
||||
#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::after,
|
||||
#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::before,
|
||||
#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::after,
|
||||
#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > label,
|
||||
#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > svg,
|
||||
#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > label,
|
||||
#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > svg {
|
||||
/* !important beats theme animations (e.g. Beach palm-slide forwards). */
|
||||
transform: translateX(-320px) !important;
|
||||
/* Move the complete row, including hover fill, arrow and subject stripe.
|
||||
A transform on the folder itself would also move its absolute `.sub` panel.
|
||||
Resting margins are measured before drilling so auto margins interpolate. */
|
||||
#menu#menu ul.bsplus-drill-rows > :is(li, section) {
|
||||
margin-left: var(--bsplus-row-margin-left) !important;
|
||||
transition:
|
||||
margin-left 0.3s ease,
|
||||
background-color 0.2s ease,
|
||||
box-shadow 0.2s ease !important;
|
||||
animation: none !important;
|
||||
|
||||
> label,
|
||||
> svg,
|
||||
&::before,
|
||||
&::after {
|
||||
transform: none !important;
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
#menu ul > li > label,
|
||||
#menu ul > li > svg {
|
||||
transition: transform 0.3s ease;
|
||||
#menu#menu
|
||||
ul.bsplus-drill-rows:has(> .hasChildren:is(.active, .bsplus-active))
|
||||
> :is(li, section) {
|
||||
margin-left: calc(
|
||||
var(--bsplus-row-margin-left) + var(--bsplus-slide-off, -320px)
|
||||
) !important;
|
||||
}
|
||||
|
||||
/* Incoming rows travel only with their native panel. */
|
||||
#menu .sub > ul:not(.bsplus-drill-rows) > li {
|
||||
&,
|
||||
> label,
|
||||
> svg,
|
||||
&::before,
|
||||
&::after {
|
||||
animation: none !important;
|
||||
transform: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
#menu .sub {
|
||||
transition: transform 0.3s ease, left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition:
|
||||
transform 0.3s ease,
|
||||
left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
#menu > ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
#menu
|
||||
.sub
|
||||
ul:has(> li.hasChildren:is(.active, .bsplus-active))
|
||||
> li:not(:is(.active, .bsplus-active)) {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
|
||||
#menu
|
||||
> ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li:is(.active, .bsplus-active) {
|
||||
background: transparent !important;
|
||||
}
|
||||
@@ -48,127 +81,6 @@
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Icon-only collapsed: submenu slides over narrow icons */
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
> ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li::before,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
> ul
|
||||
ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li::before,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
> ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li
|
||||
> label,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
> ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li
|
||||
> svg,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
> ul
|
||||
ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li
|
||||
> label,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
> ul
|
||||
ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li
|
||||
> svg {
|
||||
transform: translateX(-70px);
|
||||
}
|
||||
|
||||
/*
|
||||
* Custom sidebar drill slides — use `.drilling` / `.drill-entering` / `.drill-returning`,
|
||||
* not `:has(.active)` (SEQTA strips `.active` on nested clicks).
|
||||
*/
|
||||
#menu.bsplus-custom-sidebar #bsplus-sidebar-root {
|
||||
#menu {
|
||||
--bsplus-slide-off: -320px;
|
||||
|
||||
.sub {
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
&.drilling {
|
||||
overflow: hidden !important;
|
||||
|
||||
&:not(.drill-returning) > li::before,
|
||||
&:not(.drill-returning) > li::after,
|
||||
&:not(.drill-returning) > li > label,
|
||||
&:not(.drill-returning) > li > svg,
|
||||
&:not(.drill-returning) .sub:has(.sub) > ul > li::before,
|
||||
&:not(.drill-returning) .sub:has(.sub) > ul > li::after,
|
||||
&:not(.drill-returning) .sub:has(.sub) > ul > li > label,
|
||||
&:not(.drill-returning) .sub:has(.sub) > ul > li > svg {
|
||||
transform: translateX(var(--bsplus-slide-off)) !important;
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
&:not(.drill-entering):not(.drill-returning) {
|
||||
> li::before,
|
||||
> li::after,
|
||||
> li > label,
|
||||
> li > svg,
|
||||
.sub:has(.sub) > ul > li::before,
|
||||
.sub:has(.sub) > ul > li::after,
|
||||
.sub:has(.sub) > ul > li > label,
|
||||
.sub:has(.sub) > ul > li > svg {
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
.sub {
|
||||
transform: translateX(0) !important;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.sub:has(.sub) > .nav > .back {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.drill-entering .sub.bsplus-sub-enter {
|
||||
animation: bsplus-submenu-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
&.drill-returning:not(.drilling) > li::before,
|
||||
&.drill-returning:not(.drilling) > li::after,
|
||||
&.drill-returning:not(.drilling) > li > label,
|
||||
&.drill-returning:not(.drilling) > li > svg,
|
||||
&.drilling.drill-returning > li.hasChildren > .sub > ul > li::before,
|
||||
&.drilling.drill-returning > li.hasChildren > .sub > ul > li::after,
|
||||
&.drilling.drill-returning > li.hasChildren > .sub > ul > li > label,
|
||||
&.drilling.drill-returning > li.hasChildren > .sub > ul > li > svg {
|
||||
transition: none !important;
|
||||
animation: bsplus-sidebar-return 0.32s cubic-bezier(0.22, 1, 0.36, 1) both !important;
|
||||
}
|
||||
}
|
||||
|
||||
body.icon-only-sidebar #menu.bsplus-custom-sidebar #bsplus-sidebar-root {
|
||||
--bsplus-slide-off: -70px;
|
||||
}
|
||||
|
||||
@keyframes bsplus-sidebar-return {
|
||||
from {
|
||||
transform: translateX(var(--bsplus-slide-off, -320px));
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bsplus-submenu-enter {
|
||||
from {
|
||||
opacity: 0.35;
|
||||
transform: translateX(28px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
/* Sidebar on the right edge — layout, drill direction, and mirrored accents. */
|
||||
|
||||
body.bsplus-sidebar-right {
|
||||
#menu {
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
width: var(--bsplus-sidebar-width, 270px) !important;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
#content {
|
||||
left: 0 !important;
|
||||
right: var(--bsplus-sidebar-width, 270px) !important;
|
||||
transition:
|
||||
right 0.4s cubic-bezier(0.4, 0, 0.2, 1),
|
||||
left 0.4s cubic-bezier(0.4, 0, 0.2, 1),
|
||||
transform 0.4s ease !important;
|
||||
}
|
||||
|
||||
/* Sub panels open to the left of the menu — anchor to menu edge, not viewport. */
|
||||
#menu .sub {
|
||||
left: auto !important;
|
||||
right: 100% !important;
|
||||
width: var(--bsplus-sidebar-width, 270px) !important;
|
||||
}
|
||||
|
||||
/* Title bar spans the full viewport; only page content respects sidebar inset. */
|
||||
#container #content #title,
|
||||
#title {
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
width: 100% !important;
|
||||
max-width: none !important;
|
||||
}
|
||||
|
||||
&.icon-only-sidebar {
|
||||
#menu {
|
||||
width: 70px !important;
|
||||
}
|
||||
|
||||
#content {
|
||||
right: var(--bsplus-icon-rail-space) !important;
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
#menu .sub {
|
||||
right: 100% !important;
|
||||
width: var(--bsplus-sidebar-width, 270px) !important;
|
||||
}
|
||||
}
|
||||
|
||||
&:has(#menu.bsplus-styled-sidebar) #container #content #title,
|
||||
&.menuShown:has(#menu.bsplus-styled-sidebar) #container #content #title {
|
||||
box-shadow: -6px 0 8px -4px rgb(0 0 0 / 0.25) !important;
|
||||
}
|
||||
|
||||
#menu.bsplus-styled-sidebar {
|
||||
&.bsplus-sidebar-indicator-bar:not(.bsplus-sidebar-style-strip) {
|
||||
> ul > li.item.active:not(.hasChildren)::after,
|
||||
.sub li.item.active:not(.hasChildren)::after {
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.bsplus-sidebar-style-strip {
|
||||
> ul > li.item.active:not(.hasChildren)::after,
|
||||
.sub li.item.active:not(.hasChildren)::after {
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#menu
|
||||
li:is(.active, .hasChildren.bsplus-active)
|
||||
> .sub
|
||||
> ul
|
||||
> .item:not(.hasChildren)::before {
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
border-radius: 0 8px 8px 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
body.bsplus-sidebar-right {
|
||||
#menu {
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
transform: translateX(var(--bsplus-sidebar-width, 270px)) !important;
|
||||
}
|
||||
|
||||
&.menuShown #menu {
|
||||
transform: translateX(0) !important;
|
||||
}
|
||||
|
||||
#content {
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
}
|
||||
|
||||
&.menuShown #content {
|
||||
transform: translateX(
|
||||
calc(-1 * var(--bsplus-sidebar-width, 270px))
|
||||
) !important;
|
||||
}
|
||||
|
||||
&.icon-only-sidebar {
|
||||
#menu {
|
||||
transform: translateX(70px) !important;
|
||||
}
|
||||
|
||||
&.menuShown #content {
|
||||
right: 0 !important;
|
||||
transform: translateX(
|
||||
calc(-1 * var(--bsplus-icon-rail-space))
|
||||
) !important;
|
||||
}
|
||||
}
|
||||
|
||||
#menuToggle {
|
||||
left: auto !important;
|
||||
right: 8px !important;
|
||||
}
|
||||
|
||||
#container #content #title,
|
||||
#title {
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* Counter `#content` slide so the fixed title stays viewport-wide. */
|
||||
&.menuShown #container #content #title {
|
||||
transform: translateX(var(--bsplus-sidebar-width, 270px)) !important;
|
||||
}
|
||||
|
||||
&.icon-only-sidebar.menuShown #container #content #title {
|
||||
transform: translateX(var(--bsplus-icon-rail-space)) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body.icon-only-sidebar.bsplus-sidebar-right {
|
||||
#menu#menu > ul > .hasChildren:is(.active, .bsplus-active) {
|
||||
margin-left: 0 !important;
|
||||
margin-right: 7.5% !important;
|
||||
border-radius: 0 var(--bsplus-sidebar-radius, 12px)
|
||||
var(--bsplus-sidebar-radius, 12px) 0 !important;
|
||||
> label {
|
||||
transform: translateX(2.625px) !important;
|
||||
}
|
||||
}
|
||||
#menu#menu > ul > .hasChildren:is(.active, .bsplus-active) > label::after {
|
||||
right: auto;
|
||||
left: calc((100% - 70px) / 2 - 1px);
|
||||
background:
|
||||
radial-gradient(
|
||||
circle at 100% 0,
|
||||
transparent calc(var(--bsplus-sidebar-radius, 12px) - 0.5px),
|
||||
var(--background-primary) var(--bsplus-sidebar-radius, 12px)
|
||||
)
|
||||
top / 100% var(--bsplus-sidebar-radius, 12px) no-repeat,
|
||||
radial-gradient(
|
||||
circle at 100% 100%,
|
||||
transparent calc(var(--bsplus-sidebar-radius, 12px) - 0.5px),
|
||||
var(--background-primary) var(--bsplus-sidebar-radius, 12px)
|
||||
)
|
||||
bottom / 100% var(--bsplus-sidebar-radius, 12px) no-repeat,
|
||||
linear-gradient(var(--background-primary), var(--background-primary))
|
||||
center / 100% calc(100% - 2 * var(--bsplus-sidebar-radius, 12px))
|
||||
no-repeat;
|
||||
}
|
||||
#menu > ul > .hasChildren > .sub {
|
||||
left: auto !important;
|
||||
right: 70px !important;
|
||||
border-right: none !important;
|
||||
border-left: 1px solid var(--border-color, rgba(128, 128, 128, 0.3)) !important;
|
||||
transform: translateX(100%);
|
||||
clip-path: inset(0 100% 0 0);
|
||||
}
|
||||
#menu > ul > .hasChildren:is(.active, .bsplus-active) > .sub {
|
||||
transform: none;
|
||||
clip-path: inset(0);
|
||||
}
|
||||
#menu > ul > .hasChildren > .sub .sub {
|
||||
left: 0 !important;
|
||||
right: auto !important;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Custom sidebar style presets + Look (density / radius / indicator). */
|
||||
/* Native sidebar style presets + Look (density / radius / indicator). */
|
||||
|
||||
$sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
@@ -18,25 +18,35 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
#menu.bsplus-custom-sidebar {
|
||||
$item: "> #bsplus-sidebar-root .bsplus-sidebar-item";
|
||||
$label: "> #bsplus-sidebar-root .bsplus-sidebar-item > label:not(.toggle)";
|
||||
$active: "> #bsplus-sidebar-root .bsplus-sidebar-item.bsplus-active:not(.hasChildren)";
|
||||
#menu.bsplus-styled-sidebar {
|
||||
$rootItem: "> ul > li.item";
|
||||
$subItem: ".sub li.item";
|
||||
$item: "#{$rootItem}, #{$subItem}";
|
||||
$rootLabel: "> ul > li.item > label:not(.toggle)";
|
||||
$subLabel: ".sub li.item > label:not(.toggle)";
|
||||
$label: "#{$rootLabel}, #{$subLabel}";
|
||||
$active: "> ul > li.item.active:not(.hasChildren), .sub li.item.active:not(.hasChildren)";
|
||||
|
||||
/* Look: base radius (pill / sharp / strip override).
|
||||
Density/radius animate with the same easing as sidebar width. */
|
||||
#{$item} {
|
||||
/* Look: base radius — layout transitions only on root rows (settings tweaks).
|
||||
Submenu rows must not animate margin/padding during folder drill slides. */
|
||||
#{$rootItem} {
|
||||
border-radius: var(--bsplus-sidebar-radius, 12px) !important;
|
||||
transition:
|
||||
padding $sidebar-motion,
|
||||
margin $sidebar-motion,
|
||||
border-radius $sidebar-motion,
|
||||
background-color 0.2s ease,
|
||||
box-shadow 0.2s ease,
|
||||
opacity 0.2s ease;
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
#{$label} {
|
||||
#{$subItem} {
|
||||
border-radius: var(--bsplus-sidebar-radius, 12px) !important;
|
||||
transition:
|
||||
background-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
#{$rootLabel} {
|
||||
min-height: 28px !important;
|
||||
transition:
|
||||
font-size $sidebar-motion,
|
||||
@@ -52,6 +62,11 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
#{$subLabel} {
|
||||
min-height: 28px !important;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
/* —— Style presets —— */
|
||||
&.bsplus-sidebar-style-soft {
|
||||
#{$item} {
|
||||
@@ -75,12 +90,24 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
&.bsplus-sidebar-style-glass {
|
||||
/* Never put backdrop-filter on an open folder — it becomes a clip
|
||||
containing-block and hides `.sub` labels on Chromium/Edge. */
|
||||
#{$item} {
|
||||
margin: 0 8px 8px !important;
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
|
||||
&:not(:has(> .sub)) {
|
||||
margin: 0 8px 8px !important;
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
|
||||
}
|
||||
&:has(> .sub) {
|
||||
background: transparent !important;
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
box-shadow: none !important;
|
||||
overflow: visible !important;
|
||||
contain: none !important;
|
||||
}
|
||||
}
|
||||
#{$active} {
|
||||
background: rgba(255, 255, 255, 0.2) !important;
|
||||
@@ -120,16 +147,17 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
&.bsplus-sidebar-style-neon #{$active} {
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
box-shadow:
|
||||
0 0 0 1px rgba(255, 255, 255, 0.55),
|
||||
0 0 14px rgba(255, 255, 255, 0.4),
|
||||
0 0 28px rgba(255, 255, 255, 0.22) !important;
|
||||
}
|
||||
|
||||
&.bsplus-sidebar-style-neon #{$item} {
|
||||
margin: 0 8px 8px !important;
|
||||
&.bsplus-sidebar-style-neon {
|
||||
#{$active} {
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
box-shadow:
|
||||
0 0 0 1px rgba(255, 255, 255, 0.55),
|
||||
0 0 14px rgba(255, 255, 255, 0.4),
|
||||
0 0 28px rgba(255, 255, 255, 0.22) !important;
|
||||
}
|
||||
#{$item} {
|
||||
margin: 0 8px 8px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* —— Density (comfortable = no class / no overrides) —— */
|
||||
@@ -181,42 +209,48 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
/* —— Active indicator (fill = default, no class) —— */
|
||||
&.bsplus-sidebar-indicator-bar:not(.bsplus-sidebar-style-strip) #{$active} {
|
||||
position: relative !important;
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
box-shadow: none !important;
|
||||
&::after {
|
||||
@include accent-bar(0.45);
|
||||
&.bsplus-sidebar-indicator-bar:not(.bsplus-sidebar-style-strip) {
|
||||
#{$active} {
|
||||
position: relative !important;
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
box-shadow: none !important;
|
||||
&::after {
|
||||
@include accent-bar(0.45);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.bsplus-sidebar-indicator-outline #{$active} {
|
||||
background: transparent !important;
|
||||
box-shadow:
|
||||
inset 0 0 0 2px rgba(255, 255, 255, 0.55),
|
||||
0 0 0 1px rgba(255, 255, 255, 0.12) !important;
|
||||
&.bsplus-sidebar-indicator-outline {
|
||||
#{$active} {
|
||||
background: transparent !important;
|
||||
box-shadow:
|
||||
inset 0 0 0 2px rgba(255, 255, 255, 0.55),
|
||||
0 0 0 1px rgba(255, 255, 255, 0.12) !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.bsplus-sidebar-indicator-underline:not(.bsplus-sidebar-style-strip) #{$active} {
|
||||
position: relative !important;
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
&::after {
|
||||
content: "" !important;
|
||||
position: absolute !important;
|
||||
left: 14px !important;
|
||||
right: 14px !important;
|
||||
bottom: 6px !important;
|
||||
top: auto !important;
|
||||
width: auto !important;
|
||||
height: 3px !important;
|
||||
border-radius: 999px !important;
|
||||
background: #fff !important;
|
||||
box-shadow: 0 0 8px rgba(255, 255, 255, 0.4) !important;
|
||||
pointer-events: none !important;
|
||||
z-index: 3 !important;
|
||||
opacity: 1 !important;
|
||||
display: block !important;
|
||||
&.bsplus-sidebar-indicator-underline:not(.bsplus-sidebar-style-strip) {
|
||||
#{$active} {
|
||||
position: relative !important;
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
&::after {
|
||||
content: "" !important;
|
||||
position: absolute !important;
|
||||
left: 14px !important;
|
||||
right: 14px !important;
|
||||
bottom: 6px !important;
|
||||
top: auto !important;
|
||||
width: auto !important;
|
||||
height: 3px !important;
|
||||
border-radius: 999px !important;
|
||||
background: #fff !important;
|
||||
box-shadow: 0 0 8px rgba(255, 255, 255, 0.4) !important;
|
||||
pointer-events: none !important;
|
||||
z-index: 3 !important;
|
||||
opacity: 1 !important;
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,8 +39,6 @@ html.transparencyEffects {
|
||||
[class*="LabelList__selected___"],
|
||||
.buttonChecklist,
|
||||
.pane,
|
||||
.legacy-root button,
|
||||
.legacy-root a,
|
||||
[class*="MessageList__MessageList___"] {
|
||||
backdrop-filter: blur(80px);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { animate } from "motion";
|
||||
import { delay } from "@/seqta/utils/delay.ts";
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import CloudPfpAvatar from "@/interface/components/CloudPfpAvatar.svelte";
|
||||
|
||||
const { hidePanel } = $props<{
|
||||
@@ -90,7 +91,7 @@
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
bind:this={background}
|
||||
class="flex absolute top-0 left-0 z-50 justify-center items-center w-full h-full cursor-pointer bg-black/50"
|
||||
class="flex absolute top-0 left-0 z-50 justify-center items-center w-full h-full cursor-pointer bg-black/50 {$settingsState.DarkMode ? 'dark' : ''}"
|
||||
onclick={handleBackgroundClick}
|
||||
onkeydown={(e) => { if (e.key === "Enter") handleBackgroundClick(e as unknown as MouseEvent) }}
|
||||
>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import browser from "webextension-polyfill";
|
||||
import QRCode from "qrcode";
|
||||
import { portal } from "../utils/portal";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
|
||||
let showQrModal = $state(false);
|
||||
let qrDataUrl = $state<string | null>(null);
|
||||
@@ -120,7 +121,7 @@
|
||||
{#if showQrModal && qrDataUrl}
|
||||
<div
|
||||
use:portal
|
||||
class="fixed cursor-auto inset-0 z-[10000] flex justify-center items-center bg-black/50 {isStandalone ? 'backdrop-blur-sm' : ''}"
|
||||
class="fixed cursor-auto inset-0 z-[10000] flex justify-center items-center bg-black/50 {isStandalone ? 'backdrop-blur-sm' : ''} {$settingsState.DarkMode ? 'dark' : ''}"
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
onclick={(e) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
import { animate } from 'motion';
|
||||
import { settingsState } from '@/seqta/utils/listeners/SettingsState';
|
||||
|
||||
let { onConfirm, onCancel, title, message } = $props<{
|
||||
onConfirm: () => void;
|
||||
@@ -27,7 +28,7 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex fixed inset-0 z-[10000] justify-center items-center bg-black/50"
|
||||
class="flex fixed inset-0 z-[10000] justify-center items-center bg-black/50 {$settingsState.DarkMode ? 'dark' : ''}"
|
||||
style="position: fixed; top: 0; left: 0; right: 0; bottom: 0;"
|
||||
onclick={(e) => {
|
||||
if (e.target === e.currentTarget) onCancel();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { fade, scale } from "svelte/transition";
|
||||
import { onMount, tick } from "svelte";
|
||||
import { onMount } from "svelte";
|
||||
import Switch from "./Switch.svelte";
|
||||
import {
|
||||
FEEDBACK_CATEGORIES,
|
||||
@@ -66,6 +66,11 @@
|
||||
const btnPrimary = $derived(
|
||||
`${btn} ${isDark ? "bg-zinc-200 text-zinc-900" : "bg-zinc-800 text-white"}`,
|
||||
);
|
||||
|
||||
function isStatusDetailKey(key: string): boolean {
|
||||
return key.startsWith("status-") && key !== "status-list";
|
||||
}
|
||||
|
||||
const panelKey = $derived(
|
||||
tab === "send"
|
||||
? successId
|
||||
@@ -76,54 +81,6 @@
|
||||
: "status-list",
|
||||
);
|
||||
|
||||
let panelBodyEl = $state<HTMLDivElement | null>(null);
|
||||
let panelHeightPx = $state<number | null>(null);
|
||||
|
||||
const panelHeightEase = "cubic-bezier(0.22, 1, 0.36, 1)";
|
||||
const panelHeightMotion = $derived(
|
||||
$settingsState.animations && panelHeightPx !== null
|
||||
? `height 280ms ${panelHeightEase}`
|
||||
: "none",
|
||||
);
|
||||
|
||||
function measurePanelHeight() {
|
||||
if (!panelBodyEl) return;
|
||||
panelHeightPx = panelBodyEl.scrollHeight;
|
||||
}
|
||||
|
||||
function panelMeasure(node: HTMLDivElement) {
|
||||
panelBodyEl = node;
|
||||
|
||||
const update = () => {
|
||||
panelHeightPx = node.scrollHeight;
|
||||
};
|
||||
|
||||
update();
|
||||
const ro = new ResizeObserver(() => update());
|
||||
ro.observe(node);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
ro.disconnect();
|
||||
if (panelBodyEl === node) panelBodyEl = null;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
panelKey;
|
||||
includeContact;
|
||||
errorMessage;
|
||||
statusLoading;
|
||||
statusItems.length;
|
||||
selectedItem;
|
||||
void tick().then(() => measurePanelHeight());
|
||||
});
|
||||
|
||||
function isStatusDetailKey(key: string): boolean {
|
||||
return key.startsWith("status-") && key !== "status-list";
|
||||
}
|
||||
|
||||
function errText(e: unknown): string {
|
||||
if (e instanceof FeedbackApiError) return e.message;
|
||||
return e instanceof Error ? e.message : "Something went wrong.";
|
||||
@@ -170,10 +127,24 @@
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
void tick().then(() => measurePanelHeight());
|
||||
const host = document.getElementById("ExtensionPopup");
|
||||
host?.classList.add("bsplus-feedback-open");
|
||||
// Remove leaked global styles from earlier builds that portaled to body.
|
||||
document.getElementById("betterseqta-feedback-modal-styles")?.remove();
|
||||
|
||||
const handleEscapeKey = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape" && !busy) onClose();
|
||||
};
|
||||
document.addEventListener("keydown", handleEscapeKey);
|
||||
|
||||
if (typeof initialFeedbackId === "string" && initialFeedbackId) {
|
||||
void openStatusItem(initialFeedbackId);
|
||||
}
|
||||
|
||||
return () => {
|
||||
host?.classList.remove("bsplus-feedback-open");
|
||||
document.removeEventListener("keydown", handleEscapeKey);
|
||||
};
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
@@ -200,236 +171,350 @@
|
||||
submitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
function tabClass(active: boolean): string {
|
||||
if (active) {
|
||||
return isDark
|
||||
? "bg-zinc-700 text-white font-semibold shadow-sm"
|
||||
: "bg-white text-zinc-900 font-semibold shadow-sm";
|
||||
}
|
||||
return isDark
|
||||
? "bg-transparent text-zinc-400 hover:text-zinc-200"
|
||||
: "bg-transparent text-zinc-500 hover:text-zinc-800";
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Backdrop click target — separate from dialog so inner clicks never bubble to a "close" handler. -->
|
||||
<div
|
||||
class="flex fixed inset-0 z-[99999] justify-center items-center bg-black/50 backdrop-blur-sm {isDark
|
||||
class="feedback-overlay fixed inset-0 z-[99999] overflow-y-auto overscroll-contain {isDark
|
||||
? 'dark'
|
||||
: ''}"
|
||||
onclick={(e) => {
|
||||
if (e.target === e.currentTarget && !busy) onClose();
|
||||
}}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === "Escape" && !busy) onClose();
|
||||
}}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
transition:fade={{ duration: $settingsState.animations ? 200 : 0 }}
|
||||
>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="feedback-dialog p-5 mx-4 w-full max-w-lg max-h-[90vh] overflow-y-auto rounded-2xl shadow-2xl border text-[18px] {isDark
|
||||
? 'bg-zinc-800 text-white border-zinc-700'
|
||||
: 'bg-white text-zinc-900 border-zinc-200'}"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
onkeydown={(e) => e.stopPropagation()}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="feedback-modal-title"
|
||||
tabindex="-1"
|
||||
in:scale={{
|
||||
duration: $settingsState.animations ? 280 : 0,
|
||||
start: 0.92,
|
||||
opacity: 0,
|
||||
easing: (t) => 1 - Math.pow(1 - t, 3),
|
||||
<button
|
||||
type="button"
|
||||
class="feedback-overlay__backdrop fixed inset-0 bg-black/50 backdrop-blur-sm border-0 p-0 cursor-default"
|
||||
aria-label="Close feedback"
|
||||
disabled={busy}
|
||||
onclick={() => {
|
||||
if (!busy) onClose();
|
||||
}}
|
||||
></button>
|
||||
|
||||
<div
|
||||
class="feedback-overlay__center relative z-[1] flex min-h-full items-center justify-center p-4 sm:p-6 pointer-events-none"
|
||||
>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="flex gap-1 p-1 mb-4 rounded-full {isDark ? 'bg-zinc-900' : 'bg-zinc-100'}"
|
||||
role="tablist"
|
||||
aria-label="Feedback views"
|
||||
class="feedback-dialog pointer-events-auto w-full max-w-lg max-h-[min(90dvh,100%)] rounded-2xl shadow-2xl border text-[18px] {isDark
|
||||
? 'bg-zinc-800 text-white border-zinc-700'
|
||||
: 'bg-white text-zinc-900 border-zinc-200'}"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
onkeydown={(e) => e.stopPropagation()}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="feedback-modal-title"
|
||||
tabindex="-1"
|
||||
in:scale={{
|
||||
duration: $settingsState.animations ? 280 : 0,
|
||||
start: 0.92,
|
||||
opacity: 0,
|
||||
easing: (t) => 1 - Math.pow(1 - t, 3),
|
||||
}}
|
||||
>
|
||||
<button type="button" role="tab" aria-selected={tab === "send"} onclick={() => selectTab("send")} class="flex-1 px-3 py-2.5 rounded-full transition-all duration-200 {tabClass(tab === 'send')}">
|
||||
Send
|
||||
</button>
|
||||
<button type="button" role="tab" aria-selected={tab === "status"} onclick={() => selectTab("status")} class="flex-1 px-3 py-2.5 rounded-full transition-all duration-200 {tabClass(tab === 'status')}">
|
||||
My feedback
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="feedback-tabs shrink-0 flex gap-1 p-1 m-5 mb-0 rounded-full {isDark
|
||||
? 'bg-zinc-900'
|
||||
: 'bg-zinc-100'}"
|
||||
role="tablist"
|
||||
aria-label="Feedback views"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={tab === "send"}
|
||||
onclick={() => selectTab("send")}
|
||||
class="feedback-tab flex-1 px-3 py-2.5 rounded-full text-[18px] font-medium transition-all duration-200 {tab ===
|
||||
'send'
|
||||
? isDark
|
||||
? 'bg-zinc-700 text-white font-semibold shadow-sm'
|
||||
: 'bg-white text-zinc-900 font-semibold shadow-sm'
|
||||
: isDark
|
||||
? 'bg-transparent text-zinc-400 hover:text-zinc-200'
|
||||
: 'bg-transparent text-zinc-500 hover:text-zinc-800'}"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={tab === "status"}
|
||||
onclick={() => selectTab("status")}
|
||||
class="feedback-tab flex-1 px-3 py-2.5 rounded-full text-[18px] font-medium transition-all duration-200 {tab ===
|
||||
'status'
|
||||
? isDark
|
||||
? 'bg-zinc-700 text-white font-semibold shadow-sm'
|
||||
: 'bg-white text-zinc-900 font-semibold shadow-sm'
|
||||
: isDark
|
||||
? 'bg-transparent text-zinc-400 hover:text-zinc-200'
|
||||
: 'bg-transparent text-zinc-500 hover:text-zinc-800'}"
|
||||
>
|
||||
My feedback
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="feedback-panel"
|
||||
style:height={panelHeightPx === null ? "auto" : `${panelHeightPx}px`}
|
||||
style:transition={panelHeightMotion}
|
||||
>
|
||||
<div class="feedback-panel__body" use:panelMeasure>
|
||||
{#if panelKey === "send-success" && successId}
|
||||
<h2 id="feedback-modal-title" class="mb-3 text-xl font-bold">Thanks for the feedback</h2>
|
||||
<p class="mb-2 text-zinc-600 dark:text-zinc-300">Reference ID:</p>
|
||||
<p class="mb-4 px-3 py-2 font-mono text-base rounded-lg {isDark ? 'bg-zinc-900' : 'bg-zinc-100'} break-all">{successId}</p>
|
||||
<div class="flex gap-3 justify-end">
|
||||
<button type="button" class={btnMuted} onclick={() => successId && openStatusItem(successId)}>Check status</button>
|
||||
<button type="button" class={btnPrimary} onclick={onClose}>Done</button>
|
||||
</div>
|
||||
{:else if panelKey === "send-form"}
|
||||
<h2 id="feedback-modal-title" class="mb-1 text-xl font-bold">Send feedback</h2>
|
||||
<p class="mb-4 text-zinc-600 dark:text-zinc-400">Anonymous by default. Contact and school details are optional.</p>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1.5 font-medium">
|
||||
Category
|
||||
<select id="feedback-category" bind:value={category} class={field} style={fieldStyle}>
|
||||
{#each FEEDBACK_CATEGORIES as value (value)}
|
||||
<option {value} style={fieldStyle}>{categoryLabel(value)}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1.5 font-medium">
|
||||
Subject <span class="font-normal text-zinc-500">(optional)</span>
|
||||
<input type="text" maxlength={120} bind:value={subject} placeholder="Short summary" class={field} style={fieldStyle} />
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1.5 font-medium">
|
||||
Message
|
||||
<textarea rows={5} maxlength={FEEDBACK_MESSAGE_MAX} bind:value={message} placeholder="What happened, or what would you like to see?" class="{field} resize-y min-h-[120px]" style={fieldStyle}></textarea>
|
||||
<span class="text-base font-normal text-zinc-500">{message.trim().length}/{FEEDBACK_MESSAGE_MAX} (min {FEEDBACK_MESSAGE_MIN})</span>
|
||||
</label>
|
||||
|
||||
<div class="flex justify-between items-center gap-3">
|
||||
<div>
|
||||
<p class="font-medium">Include contact details</p>
|
||||
<p class="text-base text-zinc-500">Name and email so we can reply</p>
|
||||
</div>
|
||||
<Switch state={includeContact} onChange={(v) => (includeContact = v)} />
|
||||
<div class="feedback-panel__body overflow-y-auto overscroll-contain px-5 pb-5 pt-4">
|
||||
{#if panelKey === "send-success" && successId}
|
||||
<h2 id="feedback-modal-title" class="mb-3 text-xl font-bold">Thanks for the feedback</h2>
|
||||
<p class="mb-2 text-zinc-600 dark:text-zinc-300">Reference ID:</p>
|
||||
<p
|
||||
class="mb-4 px-3 py-2 font-mono text-base rounded-lg {isDark
|
||||
? 'bg-zinc-900'
|
||||
: 'bg-zinc-100'} break-all"
|
||||
>
|
||||
{successId}
|
||||
</p>
|
||||
<div class="flex gap-3 justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class={btnMuted}
|
||||
onclick={() => successId && openStatusItem(successId)}>Check status</button
|
||||
>
|
||||
<button type="button" class={btnPrimary} onclick={onClose}>Done</button>
|
||||
</div>
|
||||
{#if includeContact}
|
||||
<input type="text" maxlength={80} bind:value={contactName} placeholder="Name" class={field} style={fieldStyle} />
|
||||
<input type="email" maxlength={254} bind:value={contactEmail} placeholder="Email" class={field} style={fieldStyle} />
|
||||
{/if}
|
||||
|
||||
<div class="flex justify-between items-center gap-3">
|
||||
<div>
|
||||
<p class="font-medium">Include SEQTA instance</p>
|
||||
<p class="text-base text-zinc-500">
|
||||
{#if instanceHostname}
|
||||
Hostname only: <span class="font-mono">{instanceHostname}</span>
|
||||
{:else}
|
||||
Open SEQTA first to detect hostname
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
state={includeInstance && !!instanceHostname}
|
||||
onChange={(v) => {
|
||||
if (instanceHostname) includeInstance = v;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#if errorMessage}
|
||||
<p class="text-red-600 dark:text-red-400" role="alert">{errorMessage}</p>
|
||||
{/if}
|
||||
|
||||
<p class="text-base text-zinc-500">
|
||||
Sent to betterseqta.org.
|
||||
<a href="https://betterseqta.org/privacy" target="_blank" rel="noopener noreferrer" class="underline">Privacy</a>
|
||||
{:else if panelKey === "send-form"}
|
||||
<h2 id="feedback-modal-title" class="mb-1 text-xl font-bold">Send feedback</h2>
|
||||
<p class="mb-4 text-zinc-600 dark:text-zinc-400">
|
||||
Anonymous by default. Contact and school details are optional.
|
||||
</p>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1.5 font-medium">
|
||||
Category
|
||||
<select id="feedback-category" bind:value={category} class={field} style={fieldStyle}>
|
||||
{#each FEEDBACK_CATEGORIES as value (value)}
|
||||
<option {value} style={fieldStyle}>{categoryLabel(value)}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1.5 font-medium">
|
||||
Subject <span class="font-normal text-zinc-500">(optional)</span>
|
||||
<input
|
||||
type="text"
|
||||
maxlength={120}
|
||||
bind:value={subject}
|
||||
placeholder="Short summary"
|
||||
class={field}
|
||||
style={fieldStyle}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1.5 font-medium">
|
||||
Message
|
||||
<textarea
|
||||
rows={5}
|
||||
maxlength={FEEDBACK_MESSAGE_MAX}
|
||||
bind:value={message}
|
||||
placeholder="What happened, or what would you like to see?"
|
||||
class="{field} resize-y min-h-[120px]"
|
||||
style={fieldStyle}
|
||||
></textarea>
|
||||
<span class="text-base font-normal text-zinc-500"
|
||||
>{message.trim().length}/{FEEDBACK_MESSAGE_MAX} (min {FEEDBACK_MESSAGE_MIN})</span
|
||||
>
|
||||
</label>
|
||||
|
||||
<div class="flex justify-between items-center gap-3">
|
||||
<div>
|
||||
<p class="font-medium">Include contact details</p>
|
||||
<p class="text-base text-zinc-500">Name and email so we can reply</p>
|
||||
</div>
|
||||
<Switch state={includeContact} onChange={(v) => (includeContact = v)} />
|
||||
</div>
|
||||
{#if includeContact}
|
||||
<input
|
||||
type="text"
|
||||
maxlength={80}
|
||||
bind:value={contactName}
|
||||
placeholder="Name"
|
||||
class={field}
|
||||
style={fieldStyle}
|
||||
/>
|
||||
<input
|
||||
type="email"
|
||||
maxlength={254}
|
||||
bind:value={contactEmail}
|
||||
placeholder="Email"
|
||||
class={field}
|
||||
style={fieldStyle}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<div class="flex justify-between items-center gap-3">
|
||||
<div>
|
||||
<p class="font-medium">Include SEQTA instance</p>
|
||||
<p class="text-base text-zinc-500">
|
||||
{#if instanceHostname}
|
||||
Hostname only: <span class="font-mono">{instanceHostname}</span>
|
||||
{:else}
|
||||
Open SEQTA first to detect hostname
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
state={includeInstance && !!instanceHostname}
|
||||
onChange={(v) => {
|
||||
if (instanceHostname) includeInstance = v;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#if errorMessage}
|
||||
<p class="text-red-600 dark:text-red-400" role="alert">{errorMessage}</p>
|
||||
{/if}
|
||||
|
||||
<p class="text-base text-zinc-500">
|
||||
Sent to betterseqta.org.
|
||||
<a
|
||||
href="https://betterseqta.org/privacy"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="underline">Privacy</a
|
||||
>
|
||||
</p>
|
||||
|
||||
<div class="flex gap-3 justify-end">
|
||||
<button type="button" class={btnMuted} onclick={onClose} disabled={submitting}
|
||||
>Cancel</button
|
||||
>
|
||||
<button type="button" class={btnPrimary} onclick={handleSubmit} disabled={submitting}>
|
||||
{submitting ? "Sending…" : "Send feedback"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{:else if isStatusDetailKey(panelKey) && selectedItem}
|
||||
<div class="flex items-start justify-between gap-3 mb-3">
|
||||
<h2 id="feedback-modal-title" class="text-xl font-bold">Feedback status</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="{btnMuted} !text-base !px-3 !py-1.5"
|
||||
onclick={() => {
|
||||
selectedItem = null;
|
||||
void loadStatusList();
|
||||
}}>Back</button
|
||||
>
|
||||
</div>
|
||||
<p class="mb-1 font-medium">
|
||||
{selectedItem.subject || "Untitled"} · {formatStatus(selectedItem.status)}
|
||||
</p>
|
||||
<p class="mb-4 font-mono text-base text-zinc-500 break-all">{selectedItem.id}</p>
|
||||
{#if hasReply(selectedItem)}
|
||||
<div
|
||||
class="p-3 mb-4 rounded-lg border {isDark
|
||||
? 'border-zinc-700 bg-zinc-900/50'
|
||||
: 'border-zinc-200 bg-zinc-50'}"
|
||||
>
|
||||
<p class="mb-1 text-base font-semibold uppercase tracking-wide text-zinc-500">
|
||||
Response
|
||||
</p>
|
||||
<p class="whitespace-pre-wrap">{selectedItem.response}</p>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="mb-4 text-zinc-500">No response yet.</p>
|
||||
{/if}
|
||||
{#if statusError}<p class="mb-3 text-red-600 dark:text-red-400" role="alert">{statusError}</p
|
||||
>{/if}
|
||||
<div class="flex gap-3 justify-end">
|
||||
<button type="button" class={btnMuted} onclick={onClose} disabled={submitting}>Cancel</button>
|
||||
<button type="button" class={btnPrimary} onclick={handleSubmit} disabled={submitting}>
|
||||
{submitting ? "Sending…" : "Send feedback"}
|
||||
<button
|
||||
type="button"
|
||||
class={btnMuted}
|
||||
onclick={() => openStatusItem(selectedItem!.id)}
|
||||
disabled={statusLoading}
|
||||
>
|
||||
{statusLoading ? "Refreshing…" : "Refresh"}
|
||||
</button>
|
||||
<button type="button" class={btnPrimary} onclick={onClose}>Close</button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex items-start justify-between gap-3 mb-3">
|
||||
<h2 id="feedback-modal-title" class="text-xl font-bold">My feedback</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="{btnMuted} !text-base !px-3 !py-1.5"
|
||||
onclick={() => void loadStatusList()}
|
||||
disabled={statusLoading}
|
||||
>
|
||||
{statusLoading ? "…" : "Refresh"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{:else if isStatusDetailKey(panelKey) && selectedItem}
|
||||
<div class="flex items-start justify-between gap-3 mb-3">
|
||||
<h2 id="feedback-modal-title" class="text-xl font-bold">Feedback status</h2>
|
||||
<button type="button" class="{btnMuted} !text-base !px-3 !py-1.5" onclick={() => { selectedItem = null; void loadStatusList(); }}>Back</button>
|
||||
</div>
|
||||
<p class="mb-1 font-medium">{selectedItem.subject || "Untitled"} · {formatStatus(selectedItem.status)}</p>
|
||||
<p class="mb-4 font-mono text-base text-zinc-500 break-all">{selectedItem.id}</p>
|
||||
{#if hasReply(selectedItem)}
|
||||
<div class="p-3 mb-4 rounded-lg border {isDark ? 'border-zinc-700 bg-zinc-900/50' : 'border-zinc-200 bg-zinc-50'}">
|
||||
<p class="mb-1 text-base font-semibold uppercase tracking-wide text-zinc-500">Response</p>
|
||||
<p class="whitespace-pre-wrap">{selectedItem.response}</p>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="mb-4 text-zinc-500">No response yet.</p>
|
||||
{/if}
|
||||
{#if statusError}<p class="mb-3 text-red-600 dark:text-red-400" role="alert">{statusError}</p>{/if}
|
||||
<div class="flex gap-3 justify-end">
|
||||
<button type="button" class={btnMuted} onclick={() => openStatusItem(selectedItem!.id)} disabled={statusLoading}>
|
||||
{statusLoading ? "Refreshing…" : "Refresh"}
|
||||
</button>
|
||||
<button type="button" class={btnPrimary} onclick={onClose}>Close</button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex items-start justify-between gap-3 mb-3">
|
||||
<h2 id="feedback-modal-title" class="text-xl font-bold">My feedback</h2>
|
||||
<button type="button" class="{btnMuted} !text-base !px-3 !py-1.5" onclick={() => void loadStatusList()} disabled={statusLoading}>
|
||||
{statusLoading ? "…" : "Refresh"}
|
||||
</button>
|
||||
</div>
|
||||
{#if statusError}<p class="mb-3 text-red-600 dark:text-red-400" role="alert">{statusError}</p>{/if}
|
||||
{#if statusLoading && !statusItems.length}
|
||||
<div class="feedback-loading" aria-busy="true" aria-live="polite">
|
||||
<Spinner size="md" />
|
||||
<p class="text-zinc-500">Checking your feedback…</p>
|
||||
<div class="feedback-loading__skeleton" aria-hidden="true">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
{#if statusError}<p class="mb-3 text-red-600 dark:text-red-400" role="alert">{statusError}</p
|
||||
>{/if}
|
||||
{#if statusLoading && !statusItems.length}
|
||||
<div class="feedback-loading" aria-busy="true" aria-live="polite">
|
||||
<Spinner size="md" />
|
||||
<p class="text-zinc-500">Checking your feedback…</p>
|
||||
<div class="feedback-loading__skeleton" aria-hidden="true">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
{:else if !statusItems.length}
|
||||
<p class="mb-4 text-zinc-500">No feedback yet.</p>
|
||||
<button type="button" class={btnPrimary} onclick={() => selectTab("send")}
|
||||
>Send feedback</button
|
||||
>
|
||||
{:else}
|
||||
<ul class="flex flex-col gap-2 mb-4">
|
||||
{#each statusItems as item (item.id)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => openStatusItem(item.id)}
|
||||
class="w-full p-3 text-left rounded-lg border transition-all duration-200 hover:scale-[1.01] focus:outline-none focus:ring-2 focus:ring-zinc-400 {isDark
|
||||
? 'border-zinc-700 bg-zinc-900/40'
|
||||
: 'border-zinc-200 bg-white'}"
|
||||
>
|
||||
<p class="text-base text-zinc-500 mb-0.5">
|
||||
{formatStatus(item.status)}{#if hasReply(item)} · Reply{/if} · {categoryLabel(
|
||||
item.category,
|
||||
)}
|
||||
</p>
|
||||
<p class="font-medium truncate">{item.subject || "Untitled"}</p>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
<div class="flex justify-end">
|
||||
<button type="button" class={btnMuted} onclick={onClose}>Close</button>
|
||||
</div>
|
||||
</div>
|
||||
{:else if !statusItems.length}
|
||||
<p class="mb-4 text-zinc-500">No feedback yet.</p>
|
||||
<button type="button" class={btnPrimary} onclick={() => selectTab("send")}>Send feedback</button>
|
||||
{:else}
|
||||
<ul class="flex flex-col gap-2 mb-4">
|
||||
{#each statusItems as item (item.id)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => openStatusItem(item.id)}
|
||||
class="w-full p-3 text-left rounded-lg border transition-all duration-200 hover:scale-[1.01] focus:outline-none focus:ring-2 focus:ring-zinc-400 {isDark
|
||||
? 'border-zinc-700 bg-zinc-900/40'
|
||||
: 'border-zinc-200 bg-white'}"
|
||||
>
|
||||
<p class="text-base text-zinc-500 mb-0.5">
|
||||
{formatStatus(item.status)}{#if hasReply(item)} · Reply{/if} · {categoryLabel(item.category)}
|
||||
</p>
|
||||
<p class="font-medium truncate">{item.subject || "Untitled"}</p>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
<div class="flex justify-end">
|
||||
<button type="button" class={btnMuted} onclick={onClose}>Close</button>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.feedback-overlay {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.feedback-overlay__backdrop:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.feedback-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.feedback-panel {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.feedback-panel__body {
|
||||
width: 100%;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.feedback-tabs {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.feedback-tab {
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.feedback-loading {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import type { Component } from "svelte";
|
||||
|
||||
let {
|
||||
loader,
|
||||
props = {},
|
||||
remountKey = "default",
|
||||
}: {
|
||||
loader: () => Promise<{ default: Component }>;
|
||||
props?: Record<string, unknown>;
|
||||
/** Change to force a fresh import (e.g. different panel). Props-only updates reuse the component. */
|
||||
remountKey?: string;
|
||||
} = $props();
|
||||
|
||||
let Comp = $state<Component | null>(null);
|
||||
let loadedKey = $state("");
|
||||
|
||||
$effect(() => {
|
||||
const key = remountKey;
|
||||
if (key === loadedKey && Comp) return;
|
||||
|
||||
loadedKey = key;
|
||||
Comp = null;
|
||||
void loader().then((mod) => {
|
||||
if (loadedKey === key) Comp = mod.default;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if Comp}
|
||||
<Comp {...props} />
|
||||
{:else}
|
||||
<div class="px-2 py-8 text-sm text-zinc-400 animate-pulse">Loading…</div>
|
||||
{/if}
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { animate as motionAnimate } from 'motion';
|
||||
import { fullMotionEffectsEnabled } from '@/seqta/utils/performanceMode';
|
||||
|
||||
let { initial, animate, exit, transition, children, class: className } = $props<{
|
||||
initial?: any,
|
||||
@@ -13,8 +14,27 @@
|
||||
|
||||
let divElement: HTMLElement;
|
||||
|
||||
const applyCssKeyframe = (keyframe: Record<string, unknown>) => {
|
||||
if (!divElement || !keyframe) return;
|
||||
if (keyframe.x != null) {
|
||||
divElement.style.transition =
|
||||
'transform var(--bs-motion-duration, 0.2s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))';
|
||||
const x = keyframe.x;
|
||||
divElement.style.transform =
|
||||
typeof x === 'number' ? `translateX(${x}px)` : `translateX(${String(x)})`;
|
||||
}
|
||||
if (typeof keyframe.opacity === 'number') {
|
||||
divElement.style.opacity = String(keyframe.opacity);
|
||||
}
|
||||
};
|
||||
|
||||
const playAnimation = (keyframe: any) => {
|
||||
if (divElement && keyframe) {
|
||||
if (!fullMotionEffectsEnabled()) {
|
||||
applyCssKeyframe(keyframe);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let finalKeyframe = { ...keyframe };
|
||||
|
||||
if (finalKeyframe.height === 'auto') {
|
||||
@@ -72,7 +92,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class={className} bind:this={divElement} style="will-change: transform, opacity;">
|
||||
<div class={className} bind:this={divElement} style={fullMotionEffectsEnabled() ? 'will-change: transform, opacity;' : undefined}>
|
||||
{#if children}
|
||||
{@render children()}
|
||||
{/if}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
normalizeSidebarRadius,
|
||||
normalizeSidebarStyleId,
|
||||
normalizeSidebarWidth,
|
||||
normalizeSidebarPosition,
|
||||
SIDEBAR_STYLES,
|
||||
type SidebarStyleId,
|
||||
} from "@/seqta/ui/sidebar/sidebarStyles";
|
||||
@@ -36,6 +37,9 @@
|
||||
normalizeSidebarIndicator($settingsState.sidebarActiveIndicator),
|
||||
);
|
||||
const width = $derived(normalizeSidebarWidth($settingsState.sidebarWidth));
|
||||
const position = $derived(
|
||||
normalizeSidebarPosition($settingsState.sidebarPosition),
|
||||
);
|
||||
const radius = $derived(
|
||||
normalizeSidebarRadius(
|
||||
$settingsState.sidebarCornerRadius ?? DEFAULT_SIDEBAR_RADIUS,
|
||||
@@ -51,6 +55,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="sidebar-appearance">
|
||||
<div class="card">
|
||||
<header class="card-header split">
|
||||
<div>
|
||||
@@ -90,7 +95,7 @@
|
||||
<button
|
||||
type="button"
|
||||
id={`sidebar-style-${style.id}`}
|
||||
class="option"
|
||||
class={`option style-${style.id}`}
|
||||
class:active
|
||||
role="option"
|
||||
aria-selected={active}
|
||||
@@ -170,6 +175,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="copy">
|
||||
<h3 class="row-title">Sidebar Position</h3>
|
||||
<p class="row-desc">Which edge of the screen the navigation sits on</p>
|
||||
</div>
|
||||
<div class="control">
|
||||
<Select
|
||||
value={position}
|
||||
onChange={(value) => (settingsState.sidebarPosition = value)}
|
||||
options={[
|
||||
{ value: "left", label: "Left" },
|
||||
{ value: "right", label: "Right" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="copy">
|
||||
<h3 class="row-title">Sidebar Width</h3>
|
||||
@@ -221,7 +243,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.sidebar-appearance {
|
||||
container: sidebar-appearance / inline-size;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin: 4px 0;
|
||||
padding: 4px;
|
||||
@@ -585,4 +613,78 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@container sidebar-appearance (max-width: 500px) {
|
||||
.preview-pane,
|
||||
.thumb {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.picker-body {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.options {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.option {
|
||||
min-height: 2.5rem;
|
||||
justify-content: center;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.option.style-soft {
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 3px 8px rgb(0 0 0 / 0.2);
|
||||
}
|
||||
|
||||
.option.style-pill {
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.option.style-glass {
|
||||
background: linear-gradient(135deg, rgb(148 163 184 / 0.24), rgb(148 163 184 / 0.08));
|
||||
box-shadow: inset 0 0 0 1px rgb(148 163 184 / 0.35);
|
||||
}
|
||||
|
||||
.option.style-sharp {
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.option.style-strip {
|
||||
border-radius: 0;
|
||||
border-left: 3px solid currentColor;
|
||||
}
|
||||
|
||||
.option.style-neon {
|
||||
box-shadow: 0 0 0 1px rgb(148 163 184 / 0.6), 0 0 12px rgb(148 163 184 / 0.4);
|
||||
}
|
||||
|
||||
.option.active {
|
||||
outline: 1px solid currentColor;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
font-size: 0.775rem;
|
||||
}
|
||||
|
||||
.card-header.split {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card-header.split .title {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.card-header.split .subtitle {
|
||||
font-size: 0.65rem;
|
||||
}
|
||||
|
||||
.selected-meta {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { animationsEnabled } from "@/seqta/utils/performanceMode";
|
||||
import { rafThrottle } from "@/seqta/utils/rafThrottle";
|
||||
import SidebarNavItem from "./SidebarNavItem.svelte";
|
||||
|
||||
type NavGroup = {
|
||||
@@ -39,11 +40,13 @@
|
||||
indicatorReady = true;
|
||||
};
|
||||
|
||||
const scheduleIndicator = rafThrottle(updateIndicator);
|
||||
|
||||
$effect(() => {
|
||||
selectedId;
|
||||
groups;
|
||||
trackEl;
|
||||
queueMicrotask(updateIndicator);
|
||||
scheduleIndicator();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -54,8 +57,8 @@
|
||||
{#if indicatorReady}
|
||||
<div
|
||||
class="pointer-events-none absolute left-0 top-0 z-0 rounded-lg bg-zinc-200/90 dark:bg-zinc-700/90"
|
||||
style="transform: translate({indicatorX}px, {indicatorY}px); width: {indicatorW}px; height: {indicatorH}px; transition: {$settingsState.animations
|
||||
? 'transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), width 0.28s cubic-bezier(0.22, 1, 0.36, 1), height 0.28s cubic-bezier(0.22, 1, 0.36, 1)'
|
||||
style="transform: translate({indicatorX}px, {indicatorY}px); width: {indicatorW}px; height: {indicatorH}px; transition: {animationsEnabled()
|
||||
? 'transform var(--bs-motion-duration, 0.28s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), width var(--bs-motion-duration, 0.28s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), height var(--bs-motion-duration, 0.28s) var(--bs-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))'
|
||||
: 'none'};"
|
||||
></div>
|
||||
{/if}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<script lang="ts">
|
||||
let { width, height} = $props<{width?: string, height?: string}>()
|
||||
let { width, height } = $props<{ width?: string; height?: string }>();
|
||||
</script>
|
||||
|
||||
<div style="width: {width ? width : '100%'}; height: {height ? height : '100%'}; background: #e0e0e0;" class="animate-pulse"></div>
|
||||
<div
|
||||
style="width: {width ? width : '100%'}; height: {height ? height : '100%'};"
|
||||
class="animate-pulse rounded-xl border border-zinc-200 bg-zinc-200 dark:border-zinc-700/80 dark:bg-zinc-800"
|
||||
></div>
|
||||
@@ -17,6 +17,7 @@
|
||||
step={step}
|
||||
bind:value={state}
|
||||
style={`background: linear-gradient(to right, #30d259ad 0%, #30D259 ${percentage}%, #dddddd ${percentage}%)`}
|
||||
oninput={(e) => onChange(Number(e.currentTarget.value))}
|
||||
onchange={(e) => onChange(Number(e.currentTarget.value))}
|
||||
class="w-full h-1 rounded-full appearance-none cursor-pointer slider"
|
||||
/>
|
||||
|
||||
@@ -1,44 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { animate } from 'motion';
|
||||
import { standalone } from '../utils/standalone.svelte'
|
||||
import { onMount } from "svelte";
|
||||
import { standalone } from '../utils/standalone.svelte';
|
||||
import { fullMotionEffectsEnabled } from '@/seqta/utils/performanceMode';
|
||||
|
||||
let { state, onChange } = $props<{ state: boolean, onChange: (newState: boolean) => void }>();
|
||||
let handle: HTMLElement | null = null;
|
||||
let { state: checked, onChange } = $props<{ state: boolean, onChange: (newState: boolean) => void }>();
|
||||
|
||||
const springParams = {
|
||||
stiffness: 600,
|
||||
damping: 30,
|
||||
};
|
||||
let motionReady = $state(false);
|
||||
onMount(() => {
|
||||
// Paint the hydrated position before enabling transitions for later toggles.
|
||||
let frame = requestAnimationFrame(() => {
|
||||
frame = requestAnimationFrame(() => { motionReady = true; });
|
||||
});
|
||||
return () => cancelAnimationFrame(frame);
|
||||
});
|
||||
|
||||
const animateSwitch = (enabled: boolean) => {
|
||||
if (!handle) return;
|
||||
animate(
|
||||
handle,
|
||||
{
|
||||
x: enabled ? (standalone.standalone ? 24 : 20) : 0,
|
||||
},
|
||||
{
|
||||
type: 'spring',
|
||||
stiffness: springParams.stiffness,
|
||||
damping: springParams.damping,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// Trigger animation whenever state changes
|
||||
$effect(() => animateSwitch(state));
|
||||
const knobX = $derived(checked ? (standalone.standalone ? 24 : 20) : 0);
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex w-14 p-1 cursor-pointer transition-all duration-150 rounded-full bg-gradient-to-tr select-none shadow-2xl ring-[1px] ring-[#DDDDDD]/30 dark:ring-[#38373D]/30 {state ? 'to-[#30D259]/80 from-[#30D259] dark:from-[#30D259]/40 dark:to-[#30D259]' : 'dark:from-[#38373D]/50 dark:to-[#38373D] to-[#DDDDDD]/50 from-[#DDDDDD]'}"
|
||||
onclick={() => onChange(!state)}
|
||||
onkeydown={(e) => e.key === "Enter" && onChange(!state)}
|
||||
class="flex w-14 p-1 cursor-pointer transition-all duration-150 rounded-full bg-gradient-to-tr select-none shadow-2xl ring-[1px] ring-[#DDDDDD]/30 dark:ring-[#38373D]/30 {checked ? 'to-[#30D259]/80 from-[#30D259] dark:from-[#30D259]/40 dark:to-[#30D259]' : 'dark:from-[#38373D]/50 dark:to-[#38373D] to-[#DDDDDD]/50 from-[#DDDDDD]'}"
|
||||
onclick={() => onChange(!checked)}
|
||||
onkeydown={(e) => e.key === "Enter" && onChange(!checked)}
|
||||
role="switch"
|
||||
aria-checked={state}
|
||||
aria-checked={checked}
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
bind:this={handle}
|
||||
class="w-6 h-6 bg-white dark:bg-[#FEFEFE] rounded-full drop-shadow-md"
|
||||
class="w-6 h-6 bg-white dark:bg-[#FEFEFE] rounded-full drop-shadow-md transition-transform duration-200"
|
||||
style={`transform: translateX(${knobX}px); transition-duration: ${motionReady && fullMotionEffectsEnabled() ? 200 : 0}ms`}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
[role="switch"] > div { transition: none !important; }
|
||||
}
|
||||
</style>
|
||||
@@ -1,76 +1,75 @@
|
||||
<script lang="ts">
|
||||
import MotionDiv from './MotionDiv.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import LazyPanel from "./LazyPanel.svelte";
|
||||
import type { Component } from "svelte";
|
||||
import { onMount } from "svelte";
|
||||
import { fullMotionEffectsEnabled } from "@/seqta/utils/performanceMode";
|
||||
|
||||
let { tabs, activeTab = $bindable(0) } = $props<{ tabs: { title: string, Content: any, props?: any }[]; activeTab?: number }>();
|
||||
let containerRef: HTMLElement | null = null;
|
||||
let tabWidth = $state(0);
|
||||
|
||||
const springTransition = { type: 'spring', stiffness: 250, damping: 25 };
|
||||
|
||||
const updateTabWidth = () => {
|
||||
tabWidth = tabs.length > 0 ? 100 / tabs.length : 0;
|
||||
if (!containerRef) return;
|
||||
containerRef.style.setProperty('--tab-width', `${tabWidth}%`);
|
||||
type TabDef = {
|
||||
title: string;
|
||||
Content?: Component;
|
||||
loader?: () => Promise<{ default: Component }>;
|
||||
props?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
const calcXPos = (index: number | null) => {
|
||||
if (containerRef) {
|
||||
return tabWidth * (index !== null ? index : activeTab) * containerRef.getBoundingClientRect().width / 100;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
let { tabs, activeTab = $bindable(0) } = $props<{
|
||||
tabs: TabDef[];
|
||||
activeTab?: number;
|
||||
}>();
|
||||
|
||||
onMount(() => {
|
||||
updateTabWidth();
|
||||
|
||||
const handleMessage = (event: MessageEvent) => {
|
||||
if (event.data === "popupClosed") {
|
||||
activeTab = 0;
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", handleMessage);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("message", handleMessage);
|
||||
};
|
||||
return () => window.removeEventListener("message", handleMessage);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col h-full min-h-0">
|
||||
<div class="top-0 z-10 shrink-0 text-[0.875rem] pb-0.5 mx-4 px-2 tab-width-container" role="tablist">
|
||||
<div bind:this={containerRef} class="flex relative">
|
||||
<MotionDiv
|
||||
<div class="flex relative">
|
||||
<div
|
||||
class="absolute top-0 left-0 z-0 h-full bg-gradient-to-tr dark:from-[#38373D]/80 dark:to-[#38373D] from-[#DDDDDD]/80 to-[#DDDDDD] rounded-full opacity-40 tab-width"
|
||||
animate={{ x: calcXPos(activeTab) }}
|
||||
transition={springTransition}
|
||||
/>
|
||||
style={`width: ${100 / Math.max(1, tabs.length)}%; transform: translateX(${activeTab * 100}%); transition: transform ${fullMotionEffectsEnabled() ? 250 : 0}ms cubic-bezier(0.22, 1, 0.36, 1)`}
|
||||
></div>
|
||||
{#each tabs as { title }, index}
|
||||
<button
|
||||
role="tab"
|
||||
aria-selected={activeTab === index}
|
||||
class="relative z-10 flex-1 px-4 py-2 focus-visible:outline-none"
|
||||
onclick={() => activeTab = index}
|
||||
onclick={() => (activeTab = index)}
|
||||
>
|
||||
{title}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow-hidden px-4 flex-1 min-h-0">
|
||||
{#each tabs as { Content, props }, index (index)}
|
||||
<div class="relative overflow-hidden px-4 flex-1 min-h-0">
|
||||
<div
|
||||
class="tab-scroll-fade absolute inset-x-4 top-0 h-3 bg-gradient-to-b from-white/80 dark:from-zinc-800/80 to-transparent pointer-events-none z-[1]"
|
||||
aria-hidden="true"
|
||||
></div>
|
||||
{#each tabs as tab, index (index)}
|
||||
{#if activeTab === index}
|
||||
<div
|
||||
role="tabpanel"
|
||||
class="focus:outline-none w-full h-full min-h-0 pt-2 overflow-y-auto no-scrollbar pb-6 tab active relative"
|
||||
>
|
||||
<div
|
||||
class="sticky top-0 w-full h-3 -mb-3 bg-gradient-to-b from-white/80 dark:from-zinc-800/80 to-transparent pointer-events-none z-[1]"
|
||||
aria-hidden="true"
|
||||
></div>
|
||||
<Content {...props} />
|
||||
{#if tab.loader}
|
||||
<LazyPanel loader={tab.loader} props={tab.props} />
|
||||
{:else if tab.Content}
|
||||
<tab.Content {...tab.props} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.tab-width { transition: none !important; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,57 @@
|
||||
<script lang="ts">
|
||||
import ThemeGrid from "@/interface/components/store/ThemeGrid.svelte";
|
||||
import ThemeModal from "@/interface/components/store/ThemeModal.svelte";
|
||||
import SkeletonLoader from "@/interface/components/SkeletonLoader.svelte";
|
||||
import type { CommunityThemesState } from "@/interface/hooks/communityThemesState.svelte";
|
||||
|
||||
let { communityState, searchTerm }: { communityState: CommunityThemesState; searchTerm: string } =
|
||||
$props();
|
||||
|
||||
</script>
|
||||
|
||||
{#if communityState.browseLoading}
|
||||
<div class="grid grid-cols-1 gap-4 py-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{#each Array(6) as _, i (i)}
|
||||
<SkeletonLoader width="100%" height="200px" />
|
||||
{/each}
|
||||
</div>
|
||||
{:else if communityState.browseError}
|
||||
<div class="flex flex-col items-center justify-center py-24 text-center">
|
||||
<h2 class="text-2xl font-bold">Couldn't load community themes</h2>
|
||||
<p class="mt-3 text-zinc-600 dark:text-zinc-300">{communityState.browseError}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-6 rounded-lg bg-zinc-900 px-4 py-2 font-medium text-white dark:bg-zinc-100 dark:text-zinc-900"
|
||||
onclick={() => void communityState.loadBrowseThemes()}
|
||||
>
|
||||
Try again
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<ThemeGrid
|
||||
themes={communityState.browseThemes}
|
||||
{searchTerm}
|
||||
setDisplayTheme={(theme) => (communityState.displayTheme = theme)}
|
||||
toggleFavorite={() => {}}
|
||||
isLoggedIn={false}
|
||||
installedThemeIds={communityState.currentThemes}
|
||||
variant="community"
|
||||
/>
|
||||
{#if communityState.displayTheme}
|
||||
<ThemeModal
|
||||
currentThemes={communityState.currentThemes}
|
||||
allThemes={communityState.browseThemes}
|
||||
theme={communityState.displayTheme}
|
||||
displayTheme={communityState.displayTheme}
|
||||
setDisplayTheme={(t) => (communityState.displayTheme = t)}
|
||||
selectedThemeId={communityState.selectedThemeId}
|
||||
installedThemeColors={communityState.installedThemeColors}
|
||||
variant="community"
|
||||
onInstall={async (themeId) => {
|
||||
if (communityState.displayTheme) await communityState.installCommunityTheme(themeId, communityState.displayTheme);
|
||||
}}
|
||||
onRemove={(id) => void communityState.removeInstalledTheme(id)}
|
||||
onApply={(id) => void communityState.applyInstalledTheme(id)}
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
|
||||
let {
|
||||
open = false,
|
||||
busy = false,
|
||||
maxWidthClass = "max-w-lg",
|
||||
labelledBy,
|
||||
onClose,
|
||||
children,
|
||||
}: {
|
||||
open?: boolean;
|
||||
busy?: boolean;
|
||||
maxWidthClass?: string;
|
||||
labelledBy?: string;
|
||||
onClose: () => void;
|
||||
children: Snippet;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
{#if open}
|
||||
<div
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm"
|
||||
role="presentation"
|
||||
onclick={(e) => {
|
||||
if (e.target === e.currentTarget && !busy) onClose();
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="max-h-[90dvh] w-full overflow-y-auto rounded-2xl border border-zinc-200 bg-white p-6 shadow-2xl dark:border-zinc-700 dark:bg-zinc-800 {maxWidthClass}"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby={labelledBy}
|
||||
>
|
||||
{@render children()}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,226 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import SkeletonLoader from "@/interface/components/SkeletonLoader.svelte";
|
||||
import SignInToFavoriteModal from "@/interface/components/SignInToFavoriteModal.svelte";
|
||||
import type { CommunityThemesState } from "@/interface/hooks/communityThemesState.svelte";
|
||||
import {
|
||||
formatCustomThemeStatus,
|
||||
formatThemeDate,
|
||||
statusBadgeClass,
|
||||
} from "@/seqta/utils/customThemes/client";
|
||||
import ThemePlaceholderCover from "@/interface/components/themes/ThemePlaceholderCover.svelte";
|
||||
import ThemeBlobImage from "@/interface/components/themes/ThemeBlobImage.svelte";
|
||||
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 { formatCustomThemeApiError } from "@/seqta/utils/customThemes/apiErrors";
|
||||
|
||||
let { communityState }: { communityState: CommunityThemesState } = $props();
|
||||
|
||||
const statusFilters = ["", "pending", "approved", "rejected"] as const;
|
||||
const themeManager = ThemeManager.getInstance();
|
||||
|
||||
let localThemes = $state<CustomTheme[]>([]);
|
||||
let localThemesLoading = $state(true);
|
||||
let submittingLocalId = $state<string | null>(null);
|
||||
let localSubmitError = $state<string | null>(null);
|
||||
|
||||
async function refreshLocalThemes() {
|
||||
localThemesLoading = true;
|
||||
try {
|
||||
const all = await themeManager.getAvailableThemes();
|
||||
localThemes = filterThemesByMode(all, "custom");
|
||||
} finally {
|
||||
localThemesLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitLocalTheme(theme: CustomTheme) {
|
||||
localSubmitError = null;
|
||||
if (!communityState.cloudLoggedIn) {
|
||||
communityState.showSignInOverlay = true;
|
||||
return;
|
||||
}
|
||||
submittingLocalId = theme.id;
|
||||
try {
|
||||
const { submitThemeById } = await import("@/seqta/utils/customThemes/submitLocalTheme");
|
||||
await submitThemeById(theme.id, theme.description?.trim() || undefined);
|
||||
await communityState.loadMyThemes();
|
||||
} catch (err) {
|
||||
localSubmitError = formatCustomThemeApiError(err);
|
||||
} finally {
|
||||
submittingLocalId = null;
|
||||
}
|
||||
}
|
||||
|
||||
function openInBuilder(themeId: string) {
|
||||
void import("@/seqta/utils/launchPageThemeBuilder").then(({ launchPageThemeBuilder }) =>
|
||||
launchPageThemeBuilder(themeId),
|
||||
);
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
void refreshLocalThemes();
|
||||
themeUpdates.addListener(refreshLocalThemes);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
themeUpdates.removeListener(refreshLocalThemes);
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if !communityState.cloudLoggedIn}
|
||||
<div class="mx-auto flex max-w-md flex-col items-center py-20 text-center">
|
||||
<h2 class="text-2xl font-bold">Sign in to manage your themes</h2>
|
||||
<p class="mt-3 text-zinc-600 dark:text-zinc-300">
|
||||
Submit themes for review and track pending, approved, or rejected submissions.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-6 rounded-lg bg-zinc-900 px-5 py-2.5 font-medium text-white dark:bg-zinc-100 dark:text-zinc-900"
|
||||
onclick={() => (communityState.showSignInOverlay = true)}
|
||||
>
|
||||
Sign in with BetterSEQTA Cloud
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<section class="mb-8">
|
||||
<h2 class="text-lg font-semibold text-zinc-900 dark:text-white">Themes on this device</h2>
|
||||
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">
|
||||
Submit a custom theme you created or imported without opening the theme builder.
|
||||
</p>
|
||||
{#if localSubmitError}
|
||||
<p class="mt-2 whitespace-pre-line text-sm text-red-600 dark:text-red-400">{localSubmitError}</p>
|
||||
{/if}
|
||||
{#if localThemesLoading}
|
||||
<div class="mt-3 grid grid-cols-1 gap-3">
|
||||
{#each Array(2) as _, i (i)}
|
||||
<SkeletonLoader width="100%" height="72px" />
|
||||
{/each}
|
||||
</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 & submit above or build one in Custom themes settings.
|
||||
</p>
|
||||
{:else}
|
||||
<ul class="mt-3 space-y-3">
|
||||
{#each localThemes as theme (theme.id)}
|
||||
<li
|
||||
class="flex flex-wrap items-center gap-4 rounded-xl border border-zinc-200 bg-white p-4 dark:border-zinc-700 dark:bg-zinc-800"
|
||||
>
|
||||
{#if theme.coverImage}
|
||||
<ThemeBlobImage
|
||||
source={theme.coverImage}
|
||||
alt=""
|
||||
class="h-14 w-20 shrink-0 rounded-lg object-cover"
|
||||
/>
|
||||
{:else}
|
||||
<ThemePlaceholderCover
|
||||
accentHint={theme.defaultColour}
|
||||
class="h-14 w-20 shrink-0 rounded-lg object-cover"
|
||||
/>
|
||||
{/if}
|
||||
<div class="min-w-0 flex-1">
|
||||
<span class="font-semibold text-zinc-900 dark:text-white">{theme.name || "Untitled theme"}</span>
|
||||
{#if theme.description}
|
||||
<p class="mt-1 truncate text-sm text-zinc-500 dark:text-zinc-400">{theme.description}</p>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex shrink-0 flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-200 px-3 py-2 text-sm font-medium text-zinc-900 transition hover:bg-zinc-300 dark:bg-zinc-700 dark:text-white dark:hover:bg-zinc-600"
|
||||
onclick={() => openInBuilder(theme.id)}
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-900 px-3 py-2 text-sm font-medium text-white transition hover:bg-zinc-700 disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white"
|
||||
disabled={submittingLocalId === theme.id}
|
||||
onclick={() => void submitLocalTheme(theme)}
|
||||
>
|
||||
{submittingLocalId === theme.id ? "Submitting…" : "Submit"}
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<h2 class="text-lg font-semibold text-zinc-900 dark:text-white">Community submissions</h2>
|
||||
<div class="mb-4 mt-3 flex flex-wrap gap-2">
|
||||
{#each statusFilters as status (status)}
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-sm font-medium transition {communityState.statusFilter === status
|
||||
? 'bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900'
|
||||
: 'bg-zinc-200 text-zinc-700 hover:bg-zinc-300 dark:bg-zinc-800 dark:text-zinc-300'}"
|
||||
onclick={() => (communityState.statusFilter = status)}
|
||||
>
|
||||
{status === "" ? "All" : formatCustomThemeStatus(status)}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
{#if communityState.myLoading}
|
||||
<div class="grid grid-cols-1 gap-3">
|
||||
{#each Array(4) as _, i (i)}
|
||||
<SkeletonLoader width="100%" height="72px" />
|
||||
{/each}
|
||||
</div>
|
||||
{:else if communityState.myError}
|
||||
<p class="text-red-600 dark:text-red-400">{communityState.myError}</p>
|
||||
{:else if communityState.myThemes.length === 0}
|
||||
<div class="py-10 text-center">
|
||||
<p class="text-lg text-zinc-600 dark:text-zinc-300">No community submissions yet.</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-4 rounded-lg bg-zinc-900 px-4 py-2 font-medium text-white dark:bg-zinc-100 dark:text-zinc-900"
|
||||
onclick={() =>
|
||||
void import("@/seqta/utils/launchPageThemeBuilder").then(({ launchPageThemeBuilder }) =>
|
||||
launchPageThemeBuilder(),
|
||||
)}
|
||||
>
|
||||
Create & submit a theme
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<ul class="space-y-3">
|
||||
{#each communityState.myThemes as theme (theme.id)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full items-center gap-4 rounded-xl border border-zinc-200 bg-white p-4 text-left transition hover:border-zinc-300 hover:shadow-sm dark:border-zinc-700 dark:bg-zinc-800 dark:hover:border-zinc-600"
|
||||
onclick={() => void communityState.openDetail(theme)}
|
||||
>
|
||||
{#if theme.coverImage}
|
||||
<img src={theme.coverImage} alt="" class="h-14 w-20 shrink-0 rounded-lg object-cover" />
|
||||
{:else}
|
||||
<ThemePlaceholderCover class="h-14 w-20 shrink-0 rounded-lg object-cover" />
|
||||
{/if}
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="font-semibold text-zinc-900 dark:text-white">{theme.name}</span>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-xs font-semibold {statusBadgeClass(theme.status)}"
|
||||
>
|
||||
{formatCustomThemeStatus(theme.status)}
|
||||
</span>
|
||||
</div>
|
||||
<p class="mt-1 truncate text-sm text-zinc-500 dark:text-zinc-400">
|
||||
Submitted {formatThemeDate(theme.created_at)}
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if communityState.showSignInOverlay}
|
||||
<SignInToFavoriteModal onClose={() => (communityState.showSignInOverlay = false)} />
|
||||
{/if}
|
||||
@@ -0,0 +1,190 @@
|
||||
<script lang="ts">
|
||||
import SkeletonLoader from "@/interface/components/SkeletonLoader.svelte";
|
||||
import ModalFrame from "./ModalFrame.svelte";
|
||||
import type { CommunityThemesState } from "@/interface/hooks/communityThemesState.svelte";
|
||||
import {
|
||||
canEditCustomTheme,
|
||||
formatCustomThemeStatus,
|
||||
formatThemeDate,
|
||||
statusBadgeClass,
|
||||
} from "@/seqta/utils/customThemes/client";
|
||||
|
||||
let { communityState }: { communityState: CommunityThemesState } = $props();
|
||||
|
||||
const theme = $derived(communityState.detailTheme);
|
||||
</script>
|
||||
|
||||
<ModalFrame
|
||||
open={theme != null}
|
||||
busy={communityState.detailBusy}
|
||||
maxWidthClass="max-w-2xl"
|
||||
onClose={() => communityState.closeDetail()}
|
||||
>
|
||||
{#if theme}
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold">{theme.name}</h2>
|
||||
<span
|
||||
class="mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-semibold {statusBadgeClass(theme.status)}"
|
||||
>
|
||||
{formatCustomThemeStatus(theme.status)}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg p-2 hover:bg-zinc-100 dark:hover:bg-zinc-700"
|
||||
aria-label="Close"
|
||||
onclick={() => communityState.closeDetail()}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if theme.status === "rejected" && theme.rejection_reason}
|
||||
<div
|
||||
class="mt-4 rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-900 dark:border-red-900 dark:bg-red-950 dark:text-red-100"
|
||||
>
|
||||
<p class="font-semibold">Rejection reason</p>
|
||||
<p class="mt-1 whitespace-pre-wrap">{theme.rejection_reason}</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if communityState.detailLoading}
|
||||
<div class="py-8"><SkeletonLoader width="100%" height="120px" /></div>
|
||||
{:else}
|
||||
<dl class="mt-4 grid grid-cols-2 gap-3 text-sm">
|
||||
<div>
|
||||
<dt class="text-zinc-500">Submitted</dt>
|
||||
<dd>{formatThemeDate(theme.created_at)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-zinc-500">Last updated</dt>
|
||||
<dd>{formatThemeDate(theme.updated_at)}</dd>
|
||||
</div>
|
||||
{#if theme.reviewed_at}
|
||||
<div>
|
||||
<dt class="text-zinc-500">Reviewed</dt>
|
||||
<dd>{formatThemeDate(theme.reviewed_at)}</dd>
|
||||
</div>
|
||||
{/if}
|
||||
{#if theme.slug}
|
||||
<div>
|
||||
<dt class="text-zinc-500">Slug</dt>
|
||||
<dd class="truncate">{theme.slug}</dd>
|
||||
</div>
|
||||
{/if}
|
||||
</dl>
|
||||
|
||||
{#if communityState.detailFiles.length > 0}
|
||||
<div class="mt-4">
|
||||
<h3 class="text-sm font-semibold">Files</h3>
|
||||
<ul class="mt-2 space-y-1 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
{#each communityState.detailFiles as file (file.id)}
|
||||
<li>{file.file_path} ({file.file_size.toLocaleString()} bytes)</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if canEditCustomTheme(theme)}
|
||||
<div class="mt-6 space-y-3 border-t border-zinc-200 pt-4 dark:border-zinc-700">
|
||||
<h3 class="font-semibold">Edit metadata</h3>
|
||||
<input
|
||||
class="w-full rounded-lg border border-zinc-300 px-3 py-2 text-sm dark:border-zinc-600 dark:bg-zinc-900"
|
||||
bind:value={communityState.editName}
|
||||
placeholder="Name"
|
||||
/>
|
||||
<textarea
|
||||
class="w-full rounded-lg border border-zinc-300 px-3 py-2 text-sm dark:border-zinc-600 dark:bg-zinc-900"
|
||||
rows="2"
|
||||
bind:value={communityState.editDescription}
|
||||
placeholder="Description"
|
||||
></textarea>
|
||||
<textarea
|
||||
class="w-full rounded-lg border border-zinc-300 px-3 py-2 text-sm dark:border-zinc-600 dark:bg-zinc-900"
|
||||
rows="2"
|
||||
bind:value={communityState.editNotes}
|
||||
placeholder="Submission notes"
|
||||
></textarea>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-200 px-4 py-2 text-sm font-medium dark:bg-zinc-700"
|
||||
disabled={communityState.detailBusy}
|
||||
onclick={() => void communityState.saveMetadata()}
|
||||
>
|
||||
Save metadata
|
||||
</button>
|
||||
|
||||
<h3 class="pt-2 font-semibold">Replace files</h3>
|
||||
<p class="text-sm text-zinc-500">Uploading new files resets review to pending.</p>
|
||||
<input
|
||||
type="file"
|
||||
accept=".zip,application/zip"
|
||||
class="block w-full text-sm"
|
||||
onchange={(e) => {
|
||||
communityState.replaceZipFile = (e.currentTarget as HTMLInputElement).files?.[0] ?? null;
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-900 px-4 py-2 text-sm font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900"
|
||||
disabled={communityState.detailBusy || !communityState.replaceZipFile}
|
||||
onclick={() => void communityState.runReplaceFiles()}
|
||||
>
|
||||
Upload revised files
|
||||
</button>
|
||||
</div>
|
||||
{:else if theme.status === "approved"}
|
||||
<p class="mt-4 text-sm text-zinc-500">
|
||||
Approved themes cannot be edited. Delete and re-submit if you need to publish an update.
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{#if communityState.detailError}
|
||||
<p class="mt-4 whitespace-pre-line text-sm text-red-600 dark:text-red-400">
|
||||
{communityState.detailError}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<div
|
||||
class="mt-6 flex flex-wrap justify-between gap-2 border-t border-zinc-200 pt-4 dark:border-zinc-700"
|
||||
>
|
||||
{#if communityState.showDeleteConfirm}
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-sm text-red-600 dark:text-red-400">Delete permanently?</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-red-600 px-3 py-1.5 text-sm font-medium text-white"
|
||||
disabled={communityState.detailBusy}
|
||||
onclick={() => void communityState.runDelete()}
|
||||
>
|
||||
Confirm delete
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-3 py-1.5 text-sm"
|
||||
onclick={() => (communityState.showDeleteConfirm = false)}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium text-red-600 hover:bg-red-50 dark:hover:bg-red-950"
|
||||
onclick={() => (communityState.showDeleteConfirm = true)}
|
||||
>
|
||||
Delete theme
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-200 px-4 py-2 text-sm font-medium dark:bg-zinc-700"
|
||||
onclick={() => communityState.closeDetail()}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</ModalFrame>
|
||||
@@ -4,9 +4,10 @@
|
||||
import CloudPfpAvatar from "@/interface/components/CloudPfpAvatar.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
|
||||
let { alwaysShowUserName = false, onClick = undefined } = $props<{
|
||||
let { alwaysShowUserName = false, onClick = undefined, compact = false } = $props<{
|
||||
alwaysShowUserName?: boolean;
|
||||
onClick?: () => void;
|
||||
compact?: boolean;
|
||||
}>();
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
@@ -71,7 +72,7 @@
|
||||
<button
|
||||
type="button"
|
||||
onclick={handleButtonClick}
|
||||
class="flex h-12 items-center gap-2 rounded-full bg-zinc-100/80 px-4 text-sm font-medium text-zinc-700 transition-colors duration-150 hover:bg-zinc-200 hover:text-zinc-950 focus:outline-none dark:bg-zinc-900/50 dark:text-zinc-200 dark:hover:bg-zinc-700 dark:hover:text-white"
|
||||
class="flex items-center gap-2 bg-zinc-100/80 font-medium text-zinc-700 transition-colors duration-150 hover:bg-zinc-200 hover:text-zinc-950 focus:outline-none dark:bg-zinc-900/50 dark:text-zinc-200 dark:hover:bg-zinc-700 dark:hover:text-white {compact ? 'h-8 rounded-lg px-3 text-[0.75rem]' : 'h-12 rounded-full px-4 text-sm'}"
|
||||
>
|
||||
{#if cloudState.isLoggedIn}
|
||||
{#if cloudState.user?.pfpUrl}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
showStoreTools,
|
||||
onLogoClick,
|
||||
onClose,
|
||||
onToggleSize,
|
||||
} = $props<{
|
||||
searchTerm: string;
|
||||
setSearchTerm: (term: string) => void;
|
||||
@@ -25,6 +26,7 @@
|
||||
showStoreTools: boolean;
|
||||
onLogoClick: () => void;
|
||||
onClose: () => void;
|
||||
onToggleSize?: () => void;
|
||||
}>();
|
||||
|
||||
const tabs: { id: SettingsPage; title: string }[] = [
|
||||
@@ -41,16 +43,16 @@
|
||||
class="flex shrink-0 items-center gap-4 border-b border-zinc-200/60 px-5 py-4 dark:border-zinc-700/50"
|
||||
style="--bs-settings-ease: 0.28s cubic-bezier(0.22, 1, 0.36, 1)"
|
||||
>
|
||||
<button type="button" class="hidden shrink-0 lg:block" onclick={onLogoClick}>
|
||||
<button type="button" class="shrink-0" onclick={onLogoClick} aria-label="BetterSEQTA+">
|
||||
<img
|
||||
src={resolveExtensionAssetUrl(darkLogo)}
|
||||
class="h-11 w-52 object-cover dark:hidden"
|
||||
alt="BetterSEQTA+"
|
||||
class="h-9 max-w-[10.5rem] object-contain object-left dark:hidden sm:h-10"
|
||||
alt=""
|
||||
/>
|
||||
<img
|
||||
src={resolveExtensionAssetUrl(lightLogo)}
|
||||
class="hidden h-11 w-52 object-cover dark:block"
|
||||
alt="BetterSEQTA+"
|
||||
class="hidden h-9 max-w-[10.5rem] object-contain object-left dark:block sm:h-10"
|
||||
alt=""
|
||||
/>
|
||||
</button>
|
||||
|
||||
@@ -71,7 +73,7 @@
|
||||
role="tab"
|
||||
aria-selected={activePage === tab.id}
|
||||
onclick={() => setActivePage(tab.id)}
|
||||
class="relative z-10 h-10 flex-1 whitespace-nowrap rounded-full px-4 text-base transition-colors duration-200
|
||||
class="relative z-10 h-10 flex-1 whitespace-nowrap rounded-full px-4 text-lg transition-colors duration-200
|
||||
{activePage === tab.id
|
||||
? 'font-semibold text-zinc-900 dark:text-white'
|
||||
: 'text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white'}"
|
||||
@@ -115,6 +117,13 @@
|
||||
<CloudHeader />
|
||||
{/if}
|
||||
|
||||
{#if onToggleSize}
|
||||
<button type="button" onclick={onToggleSize}
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center text-zinc-500 transition-[color,transform] duration-150 hover:text-zinc-950 active:scale-[0.96] focus:outline-none dark:text-zinc-400 dark:hover:text-white"
|
||||
aria-label="Collapse settings" title="Collapse settings" aria-expanded="true">
|
||||
<span class="font-IconFamily text-2xl" aria-hidden="true">{"\uec06"}</span>
|
||||
</button>
|
||||
{/if}
|
||||
<PlainCloseButton onclick={onClose} label="Close settings" />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
masterGridDisplayDownloadCount,
|
||||
gridCardPreviewImageUrls,
|
||||
} from '@/interface/utils/themeStoreFlavours'
|
||||
import { isStoreThemeInstalled } from '@/interface/utils/themeListFilters'
|
||||
import emblaCarouselSvelte from 'embla-carousel-svelte';
|
||||
import Autoplay from 'embla-carousel-autoplay';
|
||||
let { theme, onClick, toggleFavorite, isLoggedIn, onRequestSignIn, allStoreThemeRows } = $props<{
|
||||
let { theme, onClick, toggleFavorite, isLoggedIn, onRequestSignIn, allStoreThemeRows, installedThemeIds = [], variant = 'official' } = $props<{
|
||||
theme: Theme;
|
||||
onClick: () => void;
|
||||
toggleFavorite: (theme: Theme) => void;
|
||||
@@ -14,6 +15,8 @@
|
||||
onRequestSignIn?: () => void;
|
||||
/** Raw API themes (includes hidden slaves) for aggregated master download totals */
|
||||
allStoreThemeRows?: Theme[];
|
||||
installedThemeIds?: string[];
|
||||
variant?: 'official' | 'community';
|
||||
}>();
|
||||
|
||||
const displayDownloadCount = $derived(
|
||||
@@ -47,6 +50,10 @@
|
||||
];
|
||||
});
|
||||
|
||||
const isInstalled = $derived(isStoreThemeInstalled(theme, installedThemeIds));
|
||||
const isCommunity = $derived(variant === 'community');
|
||||
const showFavorites = $derived(!isCommunity);
|
||||
|
||||
function handleCardClick(e: MouseEvent) {
|
||||
if ((e.target as HTMLElement).closest('[data-theme-favorite]')) return;
|
||||
onClick();
|
||||
@@ -72,8 +79,18 @@
|
||||
<div
|
||||
class="theme-card isolate bg-gray-50 w-full transition-[transform,box-shadow,border-color] duration-300 ease-out relative group flex flex-col rounded-xl overflow-clip border hover:scale-[1.02] hover:shadow-xl dark:hover:shadow-black/60 dark:bg-zinc-800 dark:border-white/[0.1] h-auto"
|
||||
>
|
||||
{#if theme.featured === true}
|
||||
{#if isCommunity}
|
||||
<div class="absolute top-2 left-2 z-20 pointer-events-none">
|
||||
<span
|
||||
class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-sky-100 text-sky-900 dark:bg-sky-950 dark:text-sky-100 shadow-sm"
|
||||
aria-label="Community theme"
|
||||
>
|
||||
Community
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if theme.featured === true}
|
||||
<div class="absolute top-2 z-20 pointer-events-none {isCommunity ? 'left-[5.75rem]' : 'left-2'}">
|
||||
<span
|
||||
class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100 shadow-sm"
|
||||
aria-label="Featured theme"
|
||||
@@ -85,6 +102,20 @@
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if isInstalled}
|
||||
<div class="absolute top-2 z-20 pointer-events-none {theme.featured === true ? (isCommunity ? 'left-[11rem]' : 'left-[5.5rem]') : isCommunity ? 'left-[5.75rem]' : 'left-2'}">
|
||||
<span
|
||||
class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-900 dark:bg-emerald-950 dark:text-emerald-100 shadow-sm"
|
||||
aria-label="Installed"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-3.5 h-3.5">
|
||||
<path fill-rule="evenodd" d="M19.916 4.626a.75.75 0 01.208 1.04l-9 13.5a.75.75 0 01-1.154.114l-6-6a.75.75 0 011.06-1.06l5.353 5.353 8.493-12.739a.75.75 0 011.04-.208z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Installed
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if showFavorites}
|
||||
<button
|
||||
type="button"
|
||||
data-theme-favorite
|
||||
@@ -113,6 +144,7 @@
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.318 6.318a4.5 4.5 0 0 1 6.364 0L12 7.636l1.318-1.318a4.5 4.5 0 0 1 6.364 6.364L12 20.364l-7.682-7.682a4.5 4.5 0 0 1 0-6.364Z" />
|
||||
</svg>
|
||||
</button>
|
||||
{/if}
|
||||
<div class="absolute bottom-1 left-3 right-3 z-10 mb-1 flex flex-col gap-0.5">
|
||||
<span class="text-xl font-bold text-white drop-shadow-md">{theme.name}</span>
|
||||
{#if theme.author}
|
||||
@@ -125,12 +157,14 @@
|
||||
</svg>
|
||||
{displayDownloadCount.toLocaleString()}
|
||||
</span>
|
||||
{#if showFavorites}
|
||||
<span class="flex items-center gap-1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill={theme.is_favorited ? 'currentColor' : 'none'} stroke="currentColor" stroke-width="1.5" class="w-3.5 h-3.5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
|
||||
</svg>
|
||||
{(theme.favorite_count ?? 0).toLocaleString()}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if gridRotatorUrls.length === 0}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
isLoggedIn,
|
||||
onRequestSignIn,
|
||||
allStoreThemeRows,
|
||||
installedThemeIds = [],
|
||||
variant = 'official',
|
||||
} = $props<{
|
||||
themes: Theme[];
|
||||
searchTerm: string;
|
||||
@@ -19,6 +21,8 @@
|
||||
onRequestSignIn?: () => void;
|
||||
/** Raw API list (includes `slave` rows) for master download aggregation */
|
||||
allStoreThemeRows?: Theme[];
|
||||
installedThemeIds?: string[];
|
||||
variant?: 'official' | 'community';
|
||||
}>();
|
||||
|
||||
let filteredThemes = $derived(themes.filter((theme: Theme) => {
|
||||
@@ -27,39 +31,49 @@
|
||||
const description = (theme.description ?? '').toLowerCase();
|
||||
return name.includes(q) || description.includes(q);
|
||||
}));
|
||||
|
||||
const isCommunity = $derived(variant === 'community');
|
||||
</script>
|
||||
|
||||
<div class="relative" >
|
||||
<div class="grid grid-cols-1 gap-4 py-6 mx-auto sm:grid-cols-2 lg:grid-cols-3">
|
||||
{#each filteredThemes as theme (theme.id)}
|
||||
<ThemeCard
|
||||
{theme}
|
||||
onClick={() => setDisplayTheme(theme)}
|
||||
{toggleFavorite}
|
||||
{isLoggedIn}
|
||||
{onRequestSignIn}
|
||||
{allStoreThemeRows}
|
||||
/>
|
||||
{/each}
|
||||
|
||||
{#if filteredThemes.length !== 0}
|
||||
<a href="https://docs.betterseqta.org/theme-creation/" class="block relative z-0 hover:z-20 w-full cursor-pointer">
|
||||
<div class="bg-zinc-50 h-48 w-full transition-[transform,box-shadow,border-color] duration-300 ease-out relative overflow-clip rounded-xl border group group/card flex flex-col justify-center items-center hover:scale-[1.02] hover:shadow-xl dark:hover:shadow-black/60 dark:bg-zinc-800 dark:border-white/[0.1]">
|
||||
<div class="text-2xl font-IconFamily">{'\uecb3'}</div>
|
||||
<div class="text-xl font-bold text-center transition-all duration-500 dark:text-white">
|
||||
Got a Theme Idea?
|
||||
<p class="text-lg font-light subtitle">Transform it into a stunning theme!</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
{#if filteredThemes.length === 0}
|
||||
<div class="absolute top-0 flex flex-col items-center justify-center w-full text-center h-96">
|
||||
<h1 class="mt-4 text-3xl font-bold tracking-tight text-zinc-900 dark:text-zinc-100 sm:text-5xl">That doesn't exist! 😭😭😭</h1>
|
||||
<p class="mt-6 text-lg leading-7 text-zinc-600 dark:text-zinc-300">Sorry, we couldn't find the theme you're looking for. Maybe... you could create it?</p>
|
||||
<a href="https://docs.betterseqta.org/theme-creation/" class='p-2 px-3 mt-4 transition rounded-md cursor-pointer dark:text-white bg-zinc-500/10 hover:scale-105'>
|
||||
<div class="relative">
|
||||
{#if filteredThemes.length > 0}
|
||||
<div class="mx-auto grid grid-cols-1 gap-4 py-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{#each filteredThemes as theme (theme.id)}
|
||||
<ThemeCard
|
||||
{theme}
|
||||
onClick={() => setDisplayTheme(theme)}
|
||||
{toggleFavorite}
|
||||
{isLoggedIn}
|
||||
{onRequestSignIn}
|
||||
{allStoreThemeRows}
|
||||
{installedThemeIds}
|
||||
{variant}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
{:else if isCommunity}
|
||||
<div class="mx-auto max-w-md py-24 text-center text-zinc-500 dark:text-zinc-400">
|
||||
<p class="text-lg font-medium text-zinc-900 dark:text-white">
|
||||
{searchTerm.trim() ? "No themes match your search" : "No community themes yet"}
|
||||
</p>
|
||||
<p class="mt-2 text-sm">
|
||||
{searchTerm.trim()
|
||||
? "Try a different search or clear the box."
|
||||
: "Approved submissions show up here. Use Create & submit above to share yours."}
|
||||
</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="absolute top-0 flex h-96 w-full flex-col items-center justify-center text-center">
|
||||
<h1 class="mt-4 text-3xl font-bold tracking-tight text-zinc-900 dark:text-zinc-100 sm:text-5xl">
|
||||
That doesn't exist! 😭😭😭
|
||||
</h1>
|
||||
<p class="mt-6 text-lg leading-7 text-zinc-600 dark:text-zinc-300">
|
||||
Sorry, we couldn't find the theme you're looking for. Maybe... you could create it?
|
||||
</p>
|
||||
<a
|
||||
href="https://docs.betterseqta.org/theme-creation/"
|
||||
class="mt-4 cursor-pointer rounded-md bg-zinc-500/10 p-2 px-3 transition hover:scale-105 dark:text-white"
|
||||
>
|
||||
Show me how!
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -9,24 +9,33 @@ flavourCarouselImageUrl,
|
||||
masterCarouselImageUrl,
|
||||
masterGridDisplayDownloadCount,
|
||||
} from '@/interface/utils/themeStoreFlavours'
|
||||
import {
|
||||
getThemeApplyButtonStyles,
|
||||
resolveStoreVariantAccentColor,
|
||||
} from '@/interface/utils/themeListFilters'
|
||||
let {
|
||||
theme,
|
||||
currentThemes,
|
||||
setDisplayTheme,
|
||||
onInstall,
|
||||
onRemove,
|
||||
onApply,
|
||||
allThemes,
|
||||
allStoreThemeRows,
|
||||
displayTheme,
|
||||
toggleFavorite,
|
||||
isLoggedIn,
|
||||
onRequestSignIn,
|
||||
selectedThemeId = '',
|
||||
installedThemeColors = {},
|
||||
variant = 'official',
|
||||
} = $props<{
|
||||
theme: Theme | null
|
||||
currentThemes: string[]
|
||||
setDisplayTheme: (theme: Theme | null) => void
|
||||
onInstall: (themeId: string) => void | Promise<void>
|
||||
onRemove: (themeId: string) => void | Promise<void>
|
||||
onApply: (themeId: string) => void | Promise<void>
|
||||
allThemes: Theme[]
|
||||
/** Raw API themes (includes slaves) — same aggregation as grid download count */
|
||||
allStoreThemeRows?: Theme[]
|
||||
@@ -34,7 +43,20 @@ displayTheme: Theme | null
|
||||
toggleFavorite?: (theme: Theme) => void
|
||||
isLoggedIn?: boolean
|
||||
onRequestSignIn?: () => void
|
||||
selectedThemeId?: string
|
||||
installedThemeColors?: Record<string, string>
|
||||
variant?: 'official' | 'community'
|
||||
}>()
|
||||
const isCommunity = $derived(variant === 'community')
|
||||
const showFavorites = $derived(!isCommunity)
|
||||
function variantApplyStyles(variantId: string) {
|
||||
if (!theme) {
|
||||
return getThemeApplyButtonStyles(undefined)
|
||||
}
|
||||
return getThemeApplyButtonStyles(
|
||||
resolveStoreVariantAccentColor(theme, variantId, installedThemeColors),
|
||||
)
|
||||
}
|
||||
const modalDisplayDownloadCount = $derived.by(() => {
|
||||
const t = theme
|
||||
if (!t) return 0
|
||||
@@ -106,7 +128,7 @@ $effect(() => {
|
||||
if (displayTheme && modalElement) {
|
||||
animate(
|
||||
modalElement,
|
||||
{ y: [500, 0], opacity: [0, 1] },
|
||||
{ y: [16, 0], opacity: [0, 1], scale: [0.98, 1] },
|
||||
{
|
||||
type: 'spring',
|
||||
stiffness: 150,
|
||||
@@ -118,7 +140,7 @@ damping: 20,
|
||||
const hideModal = (relatedTheme = null) => {
|
||||
animate(
|
||||
modalElement,
|
||||
{ y: [10, 500], opacity: [1, 0] },
|
||||
{ y: [0, 16], opacity: [1, 0], scale: [1, 0.98] },
|
||||
{
|
||||
type: 'spring',
|
||||
stiffness: 150,
|
||||
@@ -145,6 +167,14 @@ await onRemove(id)
|
||||
installingId = null
|
||||
}
|
||||
}
|
||||
async function runApply(id: string) {
|
||||
installingId = id
|
||||
try {
|
||||
await onApply(id)
|
||||
} finally {
|
||||
installingId = null
|
||||
}
|
||||
}
|
||||
async function onFlavourClick(flIdx: number, themeId: string, action: 'install' | 'remove') {
|
||||
scrollHeroToFlavourIndex(flIdx)
|
||||
if (action === 'install') await runInstall(themeId)
|
||||
@@ -158,7 +188,7 @@ else await runRemove(theme.id)
|
||||
}
|
||||
</script>
|
||||
<div
|
||||
class="flex fixed inset-0 z-50 justify-center items-end bg-black/70 backdrop-blur-sm"
|
||||
class="flex fixed inset-0 z-50 items-center justify-center bg-black/70 backdrop-blur-sm p-4 sm:p-6"
|
||||
onclick={(e) => {
|
||||
if (e.target === e.currentTarget) hideModal()
|
||||
}}
|
||||
@@ -171,7 +201,7 @@ transition:fade
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
bind:this={modalElement}
|
||||
class="w-full max-w-[600px] h-[95%] p-4 bg-white rounded-t-2xl dark:bg-zinc-800 overflow-y-auto overflow-x-hidden rounded-xl border border-zinc-200 dark:border-zinc-700 cursor-auto transition-colors duration-200"
|
||||
class="flex w-full max-w-[600px] h-fit max-h-[calc(100dvh-3rem)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl shadow-black/30 dark:border-zinc-700 dark:bg-zinc-800 cursor-auto transition-colors duration-200"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
onkeydown={(e) => e.stopPropagation()}
|
||||
role="dialog"
|
||||
@@ -179,7 +209,7 @@ aria-modal="true"
|
||||
tabindex="-1"
|
||||
>
|
||||
{#if theme}
|
||||
<div class="relative h-auto">
|
||||
<div class="relative flex max-h-[calc(100dvh-3rem)] flex-col overflow-y-auto overflow-x-hidden p-5 pb-8">
|
||||
<div class="absolute top-0 right-0 flex gap-1 items-center">
|
||||
<button
|
||||
type="button"
|
||||
@@ -194,6 +224,14 @@ aria-label="Close"
|
||||
<h2 class="text-2xl font-bold text-zinc-900 dark:text-white">
|
||||
{theme.name}
|
||||
</h2>
|
||||
{#if isCommunity}
|
||||
<span
|
||||
class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-sky-100 text-sky-900 dark:bg-sky-950 dark:text-sky-100"
|
||||
aria-label="Community theme"
|
||||
>
|
||||
Community
|
||||
</span>
|
||||
{/if}
|
||||
{#if theme.featured === true}
|
||||
<span
|
||||
class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100"
|
||||
@@ -222,12 +260,14 @@ By {theme.author}
|
||||
</svg>
|
||||
{modalDisplayDownloadCount.toLocaleString()} downloads
|
||||
</span>
|
||||
{#if showFavorites}
|
||||
<span class="flex items-center gap-1.5">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill={theme.is_favorited ? 'currentColor' : 'none'} stroke="currentColor" stroke-width="1.5" class="w-4 h-4">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
|
||||
</svg>
|
||||
{(theme.favorite_count ?? 0).toLocaleString()} favorites
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if heroSlides.length > 0}
|
||||
{#key theme?.id}
|
||||
@@ -277,12 +317,8 @@ aria-label="Next hero slide"
|
||||
<p class="mb-2 text-sm font-semibold text-zinc-800 dark:text-zinc-100">Variants</p>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mb-6 w-full">
|
||||
{#if currentThemes.includes(theme.id)}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => onMasterVariantClick('remove')}
|
||||
disabled={installingId !== null}
|
||||
class="relative w-full overflow-hidden rounded-2xl min-h-[9.5rem] sm:min-h-[11rem] text-left shadow-md border border-zinc-400/70 dark:border-zinc-500 transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2 dark:focus:ring-offset-zinc-800 disabled:opacity-70 group ring-1 ring-black/10 dark:ring-white/10"
|
||||
title="Remove {theme.name} (master)"
|
||||
<div
|
||||
class="relative w-full overflow-hidden rounded-2xl min-h-[9.5rem] sm:min-h-[11rem] text-left shadow-md border border-zinc-400/70 dark:border-zinc-500 group ring-1 ring-black/10 dark:ring-white/10"
|
||||
>
|
||||
{#if masterThumb}
|
||||
<img src={masterThumb} alt="" class="absolute inset-0 w-full h-full object-cover transition-transform duration-200 group-hover:scale-[1.03]" draggable="false" />
|
||||
@@ -297,11 +333,32 @@ title="Remove {theme.name} (master)"
|
||||
</span>
|
||||
{/if}
|
||||
<span class="text-lg sm:text-xl font-bold text-white drop-shadow-md tracking-tight leading-snug">
|
||||
Remove · {theme.name}
|
||||
{theme.id === selectedThemeId ? 'Applied · ' : ''}{theme.name}
|
||||
</span>
|
||||
<span class="mt-1 text-sm font-medium text-white/85">Master</span>
|
||||
</div>
|
||||
<span class="mt-1 text-sm font-medium text-white/85">Master · Installed</span>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
{#if theme.id !== selectedThemeId}
|
||||
<button
|
||||
type="button"
|
||||
onclick={(e) => { e.stopPropagation(); void runApply(theme.id) }}
|
||||
disabled={installingId !== null}
|
||||
style={variantApplyStyles(theme.id).apply}
|
||||
class="px-3 py-1.5 text-sm font-semibold rounded-lg hover:brightness-90 disabled:opacity-70"
|
||||
>
|
||||
Apply
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
onclick={(e) => { e.stopPropagation(); void onMasterVariantClick('remove') }}
|
||||
disabled={installingId !== null}
|
||||
class="px-3 py-1.5 text-sm font-semibold rounded-lg bg-white/20 text-white hover:bg-white/30 disabled:opacity-70"
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
@@ -330,12 +387,8 @@ title="Install {theme.name} (master)"
|
||||
{#each theme.flavours ?? [] as f, flavourIdx (f.id)}
|
||||
{@const thumb = flavourCarouselImageUrl(f)}
|
||||
{#if currentThemes.includes(f.id)}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => onFlavourClick(flavourIdx, f.id, 'remove')}
|
||||
disabled={installingId !== null}
|
||||
class="relative w-full overflow-hidden rounded-2xl min-h-[9.5rem] sm:min-h-[11rem] text-left shadow-md border border-zinc-400/70 dark:border-zinc-500 transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2 dark:focus:ring-offset-zinc-800 disabled:opacity-70 group ring-1 ring-black/10 dark:ring-white/10"
|
||||
title="Remove {f.name}"
|
||||
<div
|
||||
class="relative w-full overflow-hidden rounded-2xl min-h-[9.5rem] sm:min-h-[11rem] text-left shadow-md border border-zinc-400/70 dark:border-zinc-500 group ring-1 ring-black/10 dark:ring-white/10"
|
||||
>
|
||||
{#if thumb}
|
||||
<img src={thumb} alt="" class="absolute inset-0 w-full h-full object-cover transition-transform duration-200 group-hover:scale-[1.03]" draggable="false" />
|
||||
@@ -350,10 +403,32 @@ title="Remove {f.name}"
|
||||
</span>
|
||||
{/if}
|
||||
<span class="text-lg sm:text-xl font-bold text-white drop-shadow-md tracking-tight leading-snug">
|
||||
Remove · {f.name}
|
||||
{f.id === selectedThemeId ? 'Applied · ' : ''}{f.name}
|
||||
</span>
|
||||
</div>
|
||||
<span class="mt-1 text-sm font-medium text-white/85">Installed</span>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
{#if f.id !== selectedThemeId}
|
||||
<button
|
||||
type="button"
|
||||
onclick={(e) => { e.stopPropagation(); scrollHeroToFlavourIndex(flavourIdx); void runApply(f.id) }}
|
||||
disabled={installingId !== null}
|
||||
style={variantApplyStyles(f.id).apply}
|
||||
class="px-3 py-1.5 text-sm font-semibold rounded-lg hover:brightness-90 disabled:opacity-70"
|
||||
>
|
||||
Apply
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
onclick={(e) => { e.stopPropagation(); void onFlavourClick(flavourIdx, f.id, 'remove') }}
|
||||
disabled={installingId !== null}
|
||||
class="px-3 py-1.5 text-sm font-semibold rounded-lg bg-white/20 text-white hover:bg-white/30 disabled:opacity-70"
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
@@ -385,7 +460,7 @@ title="Install {f.name}"
|
||||
{theme.description}
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2 mt-4 justify-start sm:justify-end items-center">
|
||||
{#if toggleFavorite && theme}
|
||||
{#if showFavorites && toggleFavorite && theme}
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 rounded-full transition-all duration-200 hover:scale-105 active:scale-95 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2 dark:focus:ring-offset-zinc-800 {theme.is_favorited ? 'text-red-500 bg-red-500/10 dark:bg-red-500/20' : 'bg-zinc-200 dark:bg-zinc-700 dark:text-white hover:bg-zinc-300 dark:hover:bg-zinc-600'}"
|
||||
@@ -401,6 +476,31 @@ aria-label={theme.is_favorited ? 'Unfavorite' : 'Favorite'}
|
||||
{/if}
|
||||
{#if !hasFlavours}
|
||||
{#if currentThemes.includes(theme.id)}
|
||||
{#if theme.id === selectedThemeId}
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
style={variantApplyStyles(theme.id).applied}
|
||||
class="relative flex justify-center items-center px-4 py-2 min-w-[8rem] rounded-lg opacity-90"
|
||||
>
|
||||
Applied
|
||||
</button>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => runApply(theme.id)}
|
||||
disabled={installingId !== null}
|
||||
style={variantApplyStyles(theme.id).apply}
|
||||
class="relative flex justify-center items-center px-4 py-2 min-w-[8rem] rounded-lg transition-all duration-200 hover:brightness-90 active:scale-95 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-70"
|
||||
>
|
||||
{#if installingId === theme.id}
|
||||
<svg class="absolute w-4 h-4 animate-spin" width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke="currentColor" fill="currentColor" class="origin-center animate-spin-fast" d="M2,12A11.2,11.2,0,0,1,13,1.05C12.67,1,12.34,1,12,1a11,11,0,0,0,0,22c.34,0,.67,0,1-.05C6,23,2,17.74,2,12Z"/>
|
||||
</svg>
|
||||
{/if}
|
||||
<span class="{installingId === theme.id ? 'opacity-0' : 'opacity-100'}">Apply</span>
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => runRemove(theme.id)}
|
||||
@@ -432,11 +532,11 @@ class="relative flex justify-center items-center px-4 py-2 min-w-[8rem] text-bla
|
||||
{/if}
|
||||
</div>
|
||||
{#if relatedThemes.length > 0}
|
||||
<div class="my-8 border-b border-zinc-200 dark:border-zinc-700"></div>
|
||||
<div class="pt-6 mt-6 border-t border-zinc-200 dark:border-zinc-700"></div>
|
||||
<h3 class="mb-4 text-lg font-bold text-zinc-900 dark:text-white">
|
||||
Related themes
|
||||
</h3>
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div class="grid grid-cols-1 gap-4 pb-2 sm:grid-cols-2">
|
||||
{#each relatedThemes as relatedTheme (relatedTheme.id)}
|
||||
<button
|
||||
type="button"
|
||||
@@ -458,7 +558,7 @@ class="relative z-0 hover:z-20 w-full cursor-pointer rounded-xl overflow-hidden
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex justify-center items-center h-full text-zinc-600 dark:text-zinc-300">
|
||||
<div class="flex justify-center items-center p-8 text-zinc-600 dark:text-zinc-300">
|
||||
<button
|
||||
type="button"
|
||||
class="px-4 py-2 rounded-lg bg-zinc-200 dark:bg-zinc-700 transition-all duration-200 hover:scale-105 active:scale-95 dark:text-white focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2 dark:focus:ring-offset-zinc-800"
|
||||
|
||||
@@ -8,25 +8,22 @@
|
||||
|
||||
let { isEditMode, selectNoBackground = $bindable(), selectedBackground = $bindable() } = $props<{ isEditMode: boolean, selectNoBackground: () => void, selectedBackground: string | null }>();
|
||||
let backgrounds = $state<{ id: string; type: string; blob: Blob | null; url?: string }[]>([]);
|
||||
let error = $state<string | null>(null);
|
||||
let feedback = $state<{ kind: 'error' | 'warn'; text: string } | null>(null);
|
||||
|
||||
let imageBackgrounds = $derived(backgrounds.filter(bg => bg.type === 'image'));
|
||||
let videoBackgrounds = $derived(backgrounds.filter(bg => bg.type === 'video'));
|
||||
|
||||
function setError(e: unknown) {
|
||||
error = e instanceof Error ? e.message : 'An unknown error occurred';
|
||||
}
|
||||
|
||||
async function getTheme() {
|
||||
return localStorage.getItem('selectedBackground');
|
||||
}
|
||||
|
||||
async function setTheme(theme: string) {
|
||||
localStorage.setItem('selectedBackground', theme);
|
||||
function inferBackgroundType(file: File): 'image' | 'video' {
|
||||
const mime = file.type.toLowerCase();
|
||||
if (mime.startsWith('video/')) return 'video';
|
||||
if (mime.startsWith('image/')) return 'image';
|
||||
const ext = file.name.split('.').pop()?.toLowerCase() ?? '';
|
||||
return ['mp4', 'mov', 'webm', 'm4v', 'mkv'].includes(ext) ? 'video' : 'image';
|
||||
}
|
||||
|
||||
async function handleFileChange(file: File): Promise<void> {
|
||||
if (!file) return;
|
||||
feedback = null;
|
||||
|
||||
try {
|
||||
if (!isIndexedDBSupported()) {
|
||||
@@ -38,34 +35,47 @@
|
||||
throw new Error("Not enough storage space to save this background.");
|
||||
}
|
||||
|
||||
const fileId = `${Date.now()}-${file.name}`;
|
||||
const fileType = file.type.split('/')[0];
|
||||
const blob = new Blob([file], { type: file.type });
|
||||
const fileId = `${Date.now()}-${file.name.replace(/[^\w.-]+/g, '_')}`;
|
||||
const fileType = inferBackgroundType(file);
|
||||
const blob = file.slice(0, file.size, file.type || (fileType === 'video' ? 'video/mp4' : 'image/jpeg'));
|
||||
|
||||
await writeData(fileId, fileType, blob);
|
||||
backgrounds = [...backgrounds, { id: fileId, type: fileType, blob, url: URL.createObjectURL(blob) }];
|
||||
backgrounds = [
|
||||
...backgrounds,
|
||||
{ id: fileId, type: fileType, blob, url: URL.createObjectURL(blob) },
|
||||
];
|
||||
backgroundUpdates.triggerUpdate();
|
||||
|
||||
const ext = file.name.split('.').pop()?.toLowerCase() ?? '';
|
||||
if (['heic', 'heif'].includes(ext) || file.type.toLowerCase().includes('hei')) {
|
||||
feedback = {
|
||||
kind: 'warn',
|
||||
text: 'HEIC saved, but Chrome and Edge often cannot preview it. Export as JPEG or PNG if the thumbnail stays blank.',
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e);
|
||||
feedback = {
|
||||
kind: 'error',
|
||||
text: e instanceof Error ? e.message : 'An unknown error occurred',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function syncBackgrounds(): Promise<void> {
|
||||
try {
|
||||
error = null;
|
||||
feedback = null;
|
||||
|
||||
if (!isIndexedDBSupported()) {
|
||||
throw new Error("Your browser doesn't support IndexedDB. Unable to load backgrounds.");
|
||||
}
|
||||
|
||||
selectedBackground = await getTheme();
|
||||
selectedBackground = localStorage.getItem('selectedBackground');
|
||||
const dbData = await readAllData();
|
||||
|
||||
// Release existing object URLs to prevent memory leaks
|
||||
backgrounds.forEach(bg => {
|
||||
if (bg.url) URL.revokeObjectURL(bg.url);
|
||||
});
|
||||
|
||||
// Create fresh background objects with new object URLs
|
||||
backgrounds = dbData.map(bg => ({
|
||||
id: bg.id,
|
||||
type: bg.type,
|
||||
@@ -73,12 +83,14 @@
|
||||
url: URL.createObjectURL(bg.blob)
|
||||
}));
|
||||
|
||||
// Check if selected background still exists
|
||||
if (selectedBackground && !backgrounds.some(bg => bg.id === selectedBackground)) {
|
||||
selectNoBackground();
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e);
|
||||
feedback = {
|
||||
kind: 'error',
|
||||
text: e instanceof Error ? e.message : 'An unknown error occurred',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +101,7 @@
|
||||
}
|
||||
|
||||
selectedBackground = fileId;
|
||||
setTheme(fileId);
|
||||
localStorage.setItem('selectedBackground', fileId);
|
||||
}
|
||||
|
||||
async function deleteBackground(fileId: string): Promise<void> {
|
||||
@@ -100,14 +112,18 @@
|
||||
if (selectedBackground === fileId) {
|
||||
selectNoBackground();
|
||||
}
|
||||
backgroundUpdates.triggerUpdate();
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? `Failed to delete background: ${e.message}` : 'An unknown error occurred';
|
||||
feedback = {
|
||||
kind: 'error',
|
||||
text: e instanceof Error ? e.message : 'An unknown error occurred',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
selectNoBackground = () => {
|
||||
selectedBackground = null;
|
||||
setTheme('');
|
||||
localStorage.setItem('selectedBackground', '');
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
@@ -115,12 +131,6 @@
|
||||
selectedBackground
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
syncBackgrounds();
|
||||
backgroundUpdates.addListener(syncBackgrounds);
|
||||
@@ -138,11 +148,22 @@
|
||||
</script>
|
||||
|
||||
<div class="relative px-1 { !( isEditMode && imageBackgrounds.length === 0 && videoBackgrounds.length === 0 ) && 'pt-2' }">
|
||||
{#if feedback}
|
||||
<div
|
||||
class="mx-1 mb-3 rounded-lg border px-3 py-2 text-sm {feedback.kind === 'warn'
|
||||
? 'border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-100'
|
||||
: 'border-red-300/60 bg-red-50 text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200'}"
|
||||
role={feedback.kind === 'warn' ? 'status' : 'alert'}
|
||||
>
|
||||
{feedback.text}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !(imageBackgrounds.length === 0 && isEditMode)}
|
||||
<h2 class="pb-2 text-lg font-bold">Background Images</h2>
|
||||
<div class="flex flex-wrap gap-4 mb-4">
|
||||
{#if !isEditMode}
|
||||
<BackgroundUploader on:fileChange={e => handleFileChange(e.detail)} />
|
||||
<BackgroundUploader onFileChange={handleFileChange} />
|
||||
{/if}
|
||||
{#each imageBackgrounds as bg (bg.id)}
|
||||
{#if bg.url}
|
||||
@@ -163,7 +184,7 @@
|
||||
<h2 class="py-2 text-lg font-bold">Background Videos</h2>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
{#if !isEditMode}
|
||||
<BackgroundUploader on:fileChange={e => handleFileChange(e.detail)} />
|
||||
<BackgroundUploader onFileChange={handleFileChange} />
|
||||
{/if}
|
||||
{#each videoBackgrounds as bg (bg.id)}
|
||||
{#if bg.url}
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let { onFileChange }: { onFileChange?: (file: File) => void } = $props();
|
||||
|
||||
function handleFileChange(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const input = event.currentTarget as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
if (file) {
|
||||
dispatch('fileChange', file);
|
||||
onFileChange?.(file);
|
||||
}
|
||||
// Allow re-selecting the same file.
|
||||
input.value = "";
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="relative w-16 h-16 overflow-hidden transition rounded-xl bg-zinc-100 dark:bg-zinc-900">
|
||||
<div class="flex items-center justify-center w-full h-full text-3xl font-bold text-gray-400 transition font-IconFamily hover:text-gray-500">
|
||||
<!-- Plus icon -->
|
||||
<div
|
||||
class="flex items-center justify-center w-full h-full text-3xl font-bold text-gray-400 transition font-IconFamily hover:text-gray-500 pointer-events-none"
|
||||
>
|
||||
<!-- Plus icon -->
|
||||
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*, video/mp4"
|
||||
on:change={handleFileChange}
|
||||
accept="image/*,video/*,.mp4,.mov,.webm,.m4v,.heic,.heif"
|
||||
onchange={handleFileChange}
|
||||
class="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
|
||||
aria-label="Upload background image or video"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { defaultThemeCoverDataUrl } from "@/interface/utils/themePlaceholderCover";
|
||||
|
||||
let {
|
||||
accentHint = "#52525b",
|
||||
class: className = "",
|
||||
}: {
|
||||
accentHint?: string;
|
||||
class?: string;
|
||||
} = $props();
|
||||
|
||||
const src = $derived(defaultThemeCoverDataUrl(accentHint));
|
||||
</script>
|
||||
|
||||
<img src={src} alt="" class={className} draggable="false" />
|
||||
@@ -3,25 +3,29 @@
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import browser from 'webextension-polyfill'
|
||||
import { themeUpdates } from '@/interface/hooks/ThemeUpdates'
|
||||
import { closeExtensionPopup } from '@/seqta/utils/Closers/closeExtensionPopup'
|
||||
import { ThemeManager } from '@/plugins/built-in/themes/theme-manager'
|
||||
import { cloudAuth } from '@/seqta/utils/CloudAuth'
|
||||
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 { 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 } = $props<{
|
||||
let { isEditMode, showNavigation = true, listMode = 'all' } = $props<{
|
||||
isEditMode: boolean;
|
||||
showNavigation?: boolean;
|
||||
listMode?: ThemeListMode;
|
||||
}>();
|
||||
let isDragging = $state(false);
|
||||
let tempTheme = $state(null);
|
||||
let favoriteStatus = $state<Record<string, boolean>>({});
|
||||
let cloudLoggedIn = $state(cloudAuth.state.isLoggedIn);
|
||||
let prevLoggedIn = $state(false);
|
||||
let showSignInModal = $state(false);
|
||||
let submittingThemeId = $state<string | null>(null);
|
||||
let submitError = $state<string | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => {
|
||||
@@ -70,37 +74,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
const handleDragOver = (e: DragEvent) => {
|
||||
e.preventDefault();
|
||||
isDragging = true;
|
||||
}
|
||||
|
||||
const handleDragLeave = () => {
|
||||
isDragging = false;
|
||||
}
|
||||
|
||||
const handleDrop = async (e: DragEvent) => {
|
||||
e.preventDefault();
|
||||
isDragging = false;
|
||||
const file = e.dataTransfer?.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = async (event: ProgressEvent<FileReader>) => {
|
||||
try {
|
||||
const result = JSON.parse(event.target?.result as string);
|
||||
tempTheme = result;
|
||||
await themeManager.installTheme(result, { fromStore: false });
|
||||
await fetchThemes();
|
||||
} catch (error) {
|
||||
console.error('Error parsing file:', error);
|
||||
alert('Error parsing file. Please upload a valid JSON theme file.');
|
||||
}
|
||||
tempTheme = null;
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
||||
const fetchThemes = async () => {
|
||||
themes = {
|
||||
themes: await themeManager.getAvailableThemes(),
|
||||
@@ -135,11 +108,38 @@
|
||||
}
|
||||
|
||||
const openThemeCreator = async (themeId?: string) => {
|
||||
const { OpenThemeCreator } = await import('@/plugins/built-in/themes/ThemeCreator')
|
||||
OpenThemeCreator(themeId)
|
||||
closeExtensionPopup()
|
||||
const { launchPageThemeBuilder } = await import('@/seqta/utils/launchPageThemeBuilder')
|
||||
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;
|
||||
if (!cloudLoggedIn) {
|
||||
showSignInModal = true;
|
||||
return;
|
||||
}
|
||||
submittingThemeId = theme.id;
|
||||
try {
|
||||
const { submitThemeById } = await import('@/seqta/utils/customThemes/submitLocalTheme');
|
||||
await submitThemeById(theme.id, theme.description?.trim() || undefined);
|
||||
} catch (err) {
|
||||
submitError = formatCustomThemeApiError(err);
|
||||
} finally {
|
||||
submittingThemeId = null;
|
||||
}
|
||||
}
|
||||
|
||||
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 customThemeActionCompactClass = customThemeActionClass
|
||||
|
||||
const handleToggleFavorite = async (theme: CustomTheme, e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
if (!cloudLoggedIn) {
|
||||
@@ -165,34 +165,22 @@
|
||||
onDestroy(() => {
|
||||
themeUpdates.removeListener(fetchThemes);
|
||||
})
|
||||
|
||||
const visibleThemes = $derived(
|
||||
themes ? filterThemesByMode(themes.themes, listMode) : [],
|
||||
);
|
||||
|
||||
const useTwoColumnLayout = $derived(listMode === 'downloaded' || listMode === 'custom');
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="pt-5 mb-1 w-full max-w-lg mx-auto"
|
||||
class="relative mb-1 w-full {useTwoColumnLayout ? '' : 'max-w-lg mx-auto'}"
|
||||
role="list"
|
||||
tabindex="-1"
|
||||
ondragover={handleDragOver}
|
||||
ondragleave={handleDragLeave}
|
||||
ondrop={handleDrop}
|
||||
>
|
||||
<div class="{isDragging ? 'opacity-100' : 'opacity-0'} transition pointer-events-none absolute w-full p-2 z-50">
|
||||
<div class="sticky top-5 w-full h-64 bg-white rounded-xl shadow-xl dark:bg-zinc-900 dark:text-white outline-dashed outline-4 outline-zinc-200 dark:outline-zinc-700">
|
||||
<div class="flex justify-center items-center h-full">
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<svg height="48" width="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<g fill="currentColor">
|
||||
<path d="M44,31a1,1,0,0,0-1,1v8a3,3,0,0,1-3,3H8a3,3,0,0,1-3-3V32a1,1,0,0,0-2,0v8a5.006,5.006,0,0,0,5,5H40a5.006,5.006,0,0,0,5-5V32A1,1,0,0,0,44,31Z" fill="currentColor"/>
|
||||
<path d="M23.2,33.6a1,1,0,0,0,1.6,0l9-12A1,1,0,0,0,33,20H26V5a2,2,0,0,0-4,0V20H15a1,1,0,0,0-.8,1.6Z" fill="currentColor"/>
|
||||
</g>
|
||||
</svg>
|
||||
<span class="text-lg">Import Theme</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-2">
|
||||
<div class="{useTwoColumnLayout ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-2 px-2'}">
|
||||
{#if themes}
|
||||
{#each themes.themes as theme (theme.id)}
|
||||
{#each visibleThemes 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)}
|
||||
@@ -210,36 +198,57 @@
|
||||
{/if}
|
||||
|
||||
{#if !isEditMode}
|
||||
<div
|
||||
class="flex absolute right-24 top-1/4 z-20 place-items-center p-2 w-8 h-8 text-center rounded-full opacity-0 transition-all -translate-y-1/2 group-hover:opacity-100 group-hover:top-1/2 {(favoriteStatus[theme.id] ?? false) ? 'text-red-400' : 'text-white/80'} bg-black/50"
|
||||
onclick={(event) => handleToggleFavorite(theme, event)}
|
||||
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') handleToggleFavorite(theme, event as any) }}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
title={cloudLoggedIn ? ((favoriteStatus[theme.id] ?? false) ? 'Remove from favorites' : 'Add to favorites') : 'Sign in to favorite themes'}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill={(favoriteStatus[theme.id] ?? false) ? 'currentColor' : 'none'} stroke="currentColor" stroke-width="2" class="w-5 h-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div
|
||||
class="absolute z-20 flex w-8 h-8 p-2 text-white transition-all rounded-full delay-[20ms] opacity-0 top-1/4 right-2 bg-black/50 place-items-center group-hover:opacity-100 group-hover:top-1/2 -translate-y-1/2"
|
||||
onclick={(event) => { event.stopPropagation(); void openThemeCreator(theme.id) }}
|
||||
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') void openThemeCreator(theme.id) }}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
>
|
||||
<span class="text-lg font-IconFamily"></span>
|
||||
</div>
|
||||
<div class="absolute inset-y-0 right-3 z-20 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100">
|
||||
{#if !isLocalCustomTheme(theme)}
|
||||
<div
|
||||
class="flex h-8 w-8 place-items-center rounded-full bg-black/50 p-2 text-center {(favoriteStatus[theme.id] ?? false) ? 'text-red-400' : 'text-white/80'}"
|
||||
onclick={(event) => handleToggleFavorite(theme, event)}
|
||||
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') handleToggleFavorite(theme, event as any) }}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
title={cloudLoggedIn ? ((favoriteStatus[theme.id] ?? false) ? 'Remove from favorites' : 'Add to favorites') : 'Sign in to favorite themes'}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill={(favoriteStatus[theme.id] ?? false) ? 'currentColor' : 'none'} stroke="currentColor" stroke-width="2" class="h-5 w-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div
|
||||
class="flex absolute right-12 top-1/4 z-20 place-items-center p-2 w-8 h-8 text-center rounded-full opacity-0 transition-all -translate-y-1/2 text-white/80 bg-black/50 group-hover:opacity-100 group-hover:top-1/2"
|
||||
onclick={(event) => { event.stopPropagation(); handleShareTheme(theme) }}
|
||||
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') handleShareTheme(theme) }}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
>
|
||||
<span class="text-lg font-IconFamily"></span>
|
||||
<div
|
||||
class="flex h-8 w-8 place-items-center rounded-full bg-black/50 p-2 text-white/80"
|
||||
onclick={(event) => { event.stopPropagation(); handleShareTheme(theme) }}
|
||||
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') handleShareTheme(theme) }}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
title="Export theme"
|
||||
>
|
||||
<span class="text-lg font-IconFamily"></span>
|
||||
</div>
|
||||
|
||||
{#if isLocalCustomTheme(theme)}
|
||||
<div
|
||||
class="flex h-8 w-8 place-items-center rounded-full bg-black/50 p-2 text-white"
|
||||
onclick={(event) => { event.stopPropagation(); void openThemeCreator(theme.id) }}
|
||||
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') void openThemeCreator(theme.id) }}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
title="Edit theme"
|
||||
>
|
||||
<span class="text-lg font-IconFamily"></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"></span>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -250,6 +259,11 @@
|
||||
alt={theme.name}
|
||||
class="object-cover absolute inset-0 z-0 w-full h-full pointer-events-none"
|
||||
/>
|
||||
{:else}
|
||||
<ThemePlaceholderCover
|
||||
accentHint={theme.defaultColour}
|
||||
class="pointer-events-none absolute inset-0 z-0 h-full w-full object-cover"
|
||||
/>
|
||||
{/if}
|
||||
{#if !theme.hideThemeName}
|
||||
<div class="z-10 {theme.coverImage ? 'text-white' : ''}">{theme.name}</div>
|
||||
@@ -259,62 +273,142 @@
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if tempTheme}
|
||||
<div class="flex justify-center place-items-center w-full bg-gray-200 rounded-xl animate-pulse dark:bg-zinc-700/50 aspect-theme">
|
||||
<svg class="w-5 h-5 text-white animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
{#if themes && visibleThemes.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">
|
||||
Create a theme with the builder, or follow our guide to get started.
|
||||
</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 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"></span>
|
||||
Create a theme
|
||||
</button>
|
||||
<a
|
||||
href="https://docs.betterseqta.org/theme-creation/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
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">{'\uecb3'}</span>
|
||||
View docs
|
||||
</a>
|
||||
</div>
|
||||
{: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"></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"></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"></span>
|
||||
Create a theme
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if themes && themes.themes.length === 0 && !tempTheme}
|
||||
<div class="flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center">
|
||||
<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"></span>
|
||||
Install a theme
|
||||
</button>
|
||||
{#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 listMode === 'custom' && submitError}
|
||||
<p class="col-span-2 whitespace-pre-line text-sm text-red-600 dark:text-red-400">{submitError}</p>
|
||||
{/if}
|
||||
|
||||
{#if listMode === 'custom'}
|
||||
<div class="grid grid-cols-2 gap-2 {useTwoColumnLayout ? 'col-span-2' : ''}">
|
||||
<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"
|
||||
class={customThemeActionCompactClass}
|
||||
>
|
||||
<span class="font-IconFamily text-lg" aria-hidden="true"></span>
|
||||
Create a theme
|
||||
<span class="text-2xl font-IconFamily" aria-hidden="true"></span>
|
||||
<span>Create theme</span>
|
||||
</button>
|
||||
|
||||
<a
|
||||
href="https://docs.betterseqta.org/theme-creation/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class={customThemeActionCompactClass}
|
||||
>
|
||||
<span class="text-2xl font-IconFamily" aria-hidden="true">{'\uecb3'}</span>
|
||||
<span>View docs</span>
|
||||
</a>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => void openCommunitySubmit()}
|
||||
class="{customThemeActionClass} col-span-2"
|
||||
>
|
||||
<span class="text-2xl font-IconFamily" aria-hidden="true"></span>
|
||||
<span>Create & submit</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{: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"></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"></span>
|
||||
<span class="ml-2">Theme Store</span>
|
||||
</button>
|
||||
|
||||
{#if showNavigation && themes && themes.themes.length > 0}
|
||||
<div id="divider" class="w-full h-[1px] my-2 bg-zinc-100 dark:bg-zinc-600"></div>
|
||||
|
||||
<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"></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"></span>
|
||||
<span class="ml-2">Create your own</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"></span>
|
||||
<span class="ml-2">Create your own</span>
|
||||
</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,23 +1,48 @@
|
||||
import localforage from "localforage";
|
||||
|
||||
type BackgroundRecord = { id: string; type: string; blob: Blob };
|
||||
|
||||
const store = localforage.createInstance({
|
||||
name: "BackgroundDB",
|
||||
storeName: "backgrounds",
|
||||
});
|
||||
const DB_NAME = "BackgroundDB";
|
||||
const STORE = "backgrounds";
|
||||
|
||||
export async function openDatabase(): Promise<typeof store> {
|
||||
await store.ready();
|
||||
return store;
|
||||
let dbPromise: Promise<IDBDatabase> | null = null;
|
||||
|
||||
function req<T>(request: IDBRequest<T>): Promise<T> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onerror = () => reject(request.error);
|
||||
});
|
||||
}
|
||||
|
||||
function txDone(tx: IDBTransaction): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
tx.oncomplete = () => resolve();
|
||||
tx.onerror = () => reject(tx.error);
|
||||
});
|
||||
}
|
||||
|
||||
export function openDatabase(): Promise<IDBDatabase> {
|
||||
if (!dbPromise) {
|
||||
dbPromise = new Promise((resolve, reject) => {
|
||||
const open = indexedDB.open(DB_NAME, 1);
|
||||
open.onerror = () => {
|
||||
dbPromise = null;
|
||||
reject(open.error);
|
||||
};
|
||||
open.onupgradeneeded = () => {
|
||||
if (!open.result.objectStoreNames.contains(STORE)) {
|
||||
open.result.createObjectStore(STORE, { keyPath: "id" });
|
||||
}
|
||||
};
|
||||
open.onsuccess = () => resolve(open.result);
|
||||
});
|
||||
}
|
||||
return dbPromise;
|
||||
}
|
||||
|
||||
export async function readAllData(): Promise<BackgroundRecord[]> {
|
||||
await store.ready();
|
||||
const items: BackgroundRecord[] = [];
|
||||
await store.iterate<BackgroundRecord, void>((value) => {
|
||||
if (value?.id && value.blob) items.push(value);
|
||||
});
|
||||
const db = await openDatabase();
|
||||
const tx = db.transaction(STORE, "readonly");
|
||||
const items = await req(tx.objectStore(STORE).getAll());
|
||||
await txDone(tx);
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -26,25 +51,50 @@ export async function writeData(
|
||||
type: string,
|
||||
blob: Blob,
|
||||
): Promise<void> {
|
||||
await store.setItem(id, { id, type, blob });
|
||||
const record = { id, type, blob };
|
||||
const db = await openDatabase();
|
||||
const tx = db.transaction(STORE, "readwrite");
|
||||
const store = tx.objectStore(STORE);
|
||||
|
||||
try {
|
||||
await req(store.keyPath ? store.put(record) : store.put(record, id));
|
||||
await txDone(tx);
|
||||
} catch (e) {
|
||||
const detail = e instanceof Error ? e.message : String(e);
|
||||
throw new Error(`Failed to save background: ${detail}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteData(id: string): Promise<void> {
|
||||
await store.removeItem(id);
|
||||
const db = await openDatabase();
|
||||
const tx = db.transaction(STORE, "readwrite");
|
||||
await req(tx.objectStore(STORE).delete(id));
|
||||
await txDone(tx);
|
||||
}
|
||||
|
||||
export async function clearAllData(): Promise<void> {
|
||||
await store.clear();
|
||||
const db = await openDatabase();
|
||||
const tx = db.transaction(STORE, "readwrite");
|
||||
await req(tx.objectStore(STORE).clear());
|
||||
await txDone(tx);
|
||||
}
|
||||
|
||||
export async function getDataById(
|
||||
id: string,
|
||||
): Promise<BackgroundRecord | undefined> {
|
||||
const item = await store.getItem<BackgroundRecord>(id);
|
||||
return item ?? undefined;
|
||||
const db = await openDatabase();
|
||||
const tx = db.transaction(STORE, "readonly");
|
||||
const item = await req(tx.objectStore(STORE).get(id));
|
||||
await txDone(tx);
|
||||
return item?.blob instanceof Blob ? item : undefined;
|
||||
}
|
||||
|
||||
export function closeDatabase(): void {}
|
||||
export function closeDatabase(): void {
|
||||
if (dbPromise) {
|
||||
void dbPromise.then((db) => db.close());
|
||||
dbPromise = null;
|
||||
}
|
||||
}
|
||||
|
||||
export function isIndexedDBSupported(): boolean {
|
||||
return "indexedDB" in window;
|
||||
@@ -53,11 +103,7 @@ export function isIndexedDBSupported(): boolean {
|
||||
export async function hasEnoughStorageSpace(
|
||||
requiredSpace: number,
|
||||
): Promise<boolean> {
|
||||
if ("storage" in navigator && "estimate" in navigator.storage) {
|
||||
const { quota, usage } = await navigator.storage.estimate();
|
||||
if (quota !== undefined && usage !== undefined) {
|
||||
return quota - usage > requiredSpace;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (!("storage" in navigator) || !navigator.storage.estimate) return true;
|
||||
const { quota, usage } = await navigator.storage.estimate();
|
||||
return quota == null || usage == null || quota - usage > requiredSpace;
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
import browser from "webextension-polyfill";
|
||||
import type { Theme } from "@/interface/types/Theme";
|
||||
import { getCommunityInstalledThemeIds } from "@/interface/utils/themeListFilters";
|
||||
import { themeUpdates } from "@/interface/hooks/ThemeUpdates";
|
||||
import { ThemeManager } from "@/plugins/built-in/themes/theme-manager";
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import {
|
||||
deleteCustomTheme,
|
||||
fetchCommunityThemes,
|
||||
fetchMyCustomThemeDetail,
|
||||
fetchMyCustomThemes,
|
||||
replaceCustomThemeFiles,
|
||||
updateCustomThemeMetadata,
|
||||
} from "@/seqta/utils/customThemes/client";
|
||||
import {
|
||||
buildUploadPartsFromZipFile,
|
||||
mergeUploadPayload,
|
||||
} from "@/seqta/utils/customThemes/buildThemeUploadFormData";
|
||||
import { formatCustomThemeApiError } from "@/seqta/utils/customThemes/apiErrors";
|
||||
import type { CustomThemeFile, CustomThemeOwner } from "@/seqta/utils/customThemes/types";
|
||||
import {
|
||||
consumeOpenCommunityThemeSubmit,
|
||||
consumePendingCommunitySubmitThemeId,
|
||||
OPEN_COMMUNITY_SUBMIT_EVENT,
|
||||
} from "@/seqta/utils/openCommunityThemeSubmit";
|
||||
export type CommunityThemesTab = "browse" | "mine";
|
||||
|
||||
export class CommunityThemesState {
|
||||
innerTab = $state<CommunityThemesTab>("browse");
|
||||
cloudLoggedIn = $state(cloudAuth.state.isLoggedIn);
|
||||
|
||||
browseThemes = $state<Theme[]>([]);
|
||||
browseLoading = $state(true);
|
||||
browseError = $state<string | null>(null);
|
||||
|
||||
myThemes = $state<CustomThemeOwner[]>([]);
|
||||
myLoading = $state(false);
|
||||
myError = $state<string | null>(null);
|
||||
statusFilter = $state<"" | "pending" | "approved" | "rejected">("");
|
||||
|
||||
displayTheme = $state<Theme | null>(null);
|
||||
currentThemes = $state<string[]>([]);
|
||||
selectedThemeId = $state("");
|
||||
installedThemeColors = $state<Record<string, string>>({});
|
||||
|
||||
showSignInOverlay = $state(false);
|
||||
|
||||
detailTheme = $state<CustomThemeOwner | null>(null);
|
||||
detailFiles = $state<CustomThemeFile[]>([]);
|
||||
detailLoading = $state(false);
|
||||
detailError = $state<string | null>(null);
|
||||
editName = $state("");
|
||||
editDescription = $state("");
|
||||
editNotes = $state("");
|
||||
detailBusy = $state(false);
|
||||
replaceZipFile = $state<File | null>(null);
|
||||
showDeleteConfirm = $state(false);
|
||||
|
||||
private readonly themeManager = ThemeManager.getInstance();
|
||||
|
||||
constructor(private readonly getSearchTerm: () => string) {}
|
||||
|
||||
async refreshInstalledThemes() {
|
||||
const themes = await this.themeManager.getAvailableThemes();
|
||||
this.currentThemes = getCommunityInstalledThemeIds(themes);
|
||||
this.selectedThemeId = this.themeManager.getSelectedThemeId() || "";
|
||||
this.installedThemeColors = Object.fromEntries(
|
||||
themes
|
||||
.filter((t) => t != null && t.installedFromCommunity === true)
|
||||
.map((t) => [t.id, t.defaultColour]),
|
||||
);
|
||||
}
|
||||
|
||||
async loadBrowseThemes() {
|
||||
this.browseLoading = true;
|
||||
this.browseError = null;
|
||||
try {
|
||||
const q = this.getSearchTerm().trim();
|
||||
const res = await fetchCommunityThemes({
|
||||
sort: "popular",
|
||||
limit: 50,
|
||||
search: q.length > 0 ? q : undefined,
|
||||
});
|
||||
this.browseThemes = res.themes as Theme[];
|
||||
} catch (err) {
|
||||
this.browseError = err instanceof Error ? err.message : "Could not load community themes";
|
||||
} finally {
|
||||
this.browseLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async loadMyThemes() {
|
||||
if (!this.cloudLoggedIn) return;
|
||||
this.myLoading = true;
|
||||
this.myError = null;
|
||||
try {
|
||||
const res = await fetchMyCustomThemes({
|
||||
limit: 50,
|
||||
status: this.statusFilter || undefined,
|
||||
});
|
||||
this.myThemes = res.themes;
|
||||
} catch (err) {
|
||||
this.myError = err instanceof Error ? err.message : "Could not load your themes";
|
||||
} finally {
|
||||
this.myLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async openDetail(theme: CustomThemeOwner) {
|
||||
this.detailTheme = theme;
|
||||
this.detailFiles = [];
|
||||
this.detailError = null;
|
||||
this.editName = theme.name;
|
||||
this.editDescription = theme.description ?? "";
|
||||
this.editNotes = theme.submission_notes ?? "";
|
||||
this.replaceZipFile = null;
|
||||
this.showDeleteConfirm = false;
|
||||
this.detailLoading = true;
|
||||
try {
|
||||
const res = await fetchMyCustomThemeDetail(theme.id);
|
||||
this.detailTheme = res.theme;
|
||||
this.detailFiles = res.files;
|
||||
this.editName = res.theme.name;
|
||||
this.editDescription = res.theme.description ?? "";
|
||||
this.editNotes = res.theme.submission_notes ?? "";
|
||||
} catch (err) {
|
||||
this.detailError = err instanceof Error ? err.message : "Could not load theme details";
|
||||
} finally {
|
||||
this.detailLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
closeDetail() {
|
||||
this.detailTheme = null;
|
||||
this.detailFiles = [];
|
||||
this.detailError = null;
|
||||
this.showDeleteConfirm = false;
|
||||
}
|
||||
|
||||
async installCommunityTheme(themeId: string, meta: Theme) {
|
||||
const row = this.browseThemes.find((x) => x.id === themeId) ?? meta;
|
||||
const installedId = await this.themeManager.downloadCommunityTheme({
|
||||
id: themeId,
|
||||
theme_json_url: row.theme_json_url,
|
||||
updated_at: row.updated_at,
|
||||
});
|
||||
await this.themeManager.setTheme(installedId);
|
||||
themeUpdates.triggerUpdate();
|
||||
await this.refreshInstalledThemes();
|
||||
void browser.runtime.sendMessage({ type: "cloudSettingsRequestDebouncedUpload" }).catch(() => {});
|
||||
}
|
||||
|
||||
async removeInstalledTheme(themeId: string) {
|
||||
await this.themeManager.deleteTheme(themeId);
|
||||
themeUpdates.triggerUpdate();
|
||||
await this.refreshInstalledThemes();
|
||||
}
|
||||
|
||||
async applyInstalledTheme(themeId: string) {
|
||||
await this.themeManager.setTheme(themeId);
|
||||
this.selectedThemeId = themeId;
|
||||
themeUpdates.triggerUpdate();
|
||||
void browser.runtime.sendMessage({ type: "cloudSettingsRequestDebouncedUpload" }).catch(() => {});
|
||||
}
|
||||
|
||||
async saveMetadata() {
|
||||
if (!this.detailTheme) return;
|
||||
this.detailBusy = true;
|
||||
this.detailError = null;
|
||||
try {
|
||||
const updated = await updateCustomThemeMetadata(this.detailTheme.id, {
|
||||
name: this.editName.trim() || undefined,
|
||||
description: this.editDescription.trim() || undefined,
|
||||
submission_notes: this.editNotes.trim() || undefined,
|
||||
});
|
||||
this.detailTheme = updated;
|
||||
await this.loadMyThemes();
|
||||
} catch (err) {
|
||||
this.detailError = formatCustomThemeApiError(err);
|
||||
} finally {
|
||||
this.detailBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
async runReplaceFiles() {
|
||||
if (!this.detailTheme || !this.replaceZipFile) return;
|
||||
this.detailBusy = true;
|
||||
this.detailError = null;
|
||||
try {
|
||||
const payload = mergeUploadPayload(await buildUploadPartsFromZipFile(this.replaceZipFile));
|
||||
const res = await replaceCustomThemeFiles(this.detailTheme.id, payload);
|
||||
this.detailTheme = res.theme;
|
||||
this.replaceZipFile = null;
|
||||
await this.loadMyThemes();
|
||||
} catch (err) {
|
||||
this.detailError = formatCustomThemeApiError(err);
|
||||
} finally {
|
||||
this.detailBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
async runDelete() {
|
||||
if (!this.detailTheme) return;
|
||||
this.detailBusy = true;
|
||||
this.detailError = null;
|
||||
try {
|
||||
await deleteCustomTheme(this.detailTheme.id);
|
||||
this.closeDetail();
|
||||
await this.loadMyThemes();
|
||||
} catch (err) {
|
||||
this.detailError = formatCustomThemeApiError(err);
|
||||
} finally {
|
||||
this.detailBusy = false;
|
||||
this.showDeleteConfirm = false;
|
||||
}
|
||||
}
|
||||
|
||||
bindReactiveLoads() {
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => {
|
||||
this.cloudLoggedIn = s.isLoggedIn;
|
||||
});
|
||||
return unsub;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (this.innerTab === "browse") void this.loadBrowseThemes();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
this.getSearchTerm();
|
||||
if (this.innerTab === "browse") void this.loadBrowseThemes();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (this.innerTab === "mine" && this.cloudLoggedIn) void this.loadMyThemes();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
this.statusFilter;
|
||||
if (this.innerTab === "mine" && this.cloudLoggedIn) void this.loadMyThemes();
|
||||
});
|
||||
}
|
||||
|
||||
mount() {
|
||||
const onThemesUpdated = () => void this.refreshInstalledThemes();
|
||||
themeUpdates.addListener(onThemesUpdated);
|
||||
void this.refreshInstalledThemes();
|
||||
|
||||
const openPageBuilderForSubmit = () => {
|
||||
const themeId = consumePendingCommunitySubmitThemeId() ?? undefined;
|
||||
void import("@/seqta/utils/launchPageThemeBuilder").then(({ launchPageThemeBuilder }) =>
|
||||
launchPageThemeBuilder(themeId),
|
||||
);
|
||||
};
|
||||
|
||||
if (consumeOpenCommunityThemeSubmit()) {
|
||||
openPageBuilderForSubmit();
|
||||
}
|
||||
|
||||
const onOpenCommunitySubmit = () => {
|
||||
if (consumeOpenCommunityThemeSubmit()) openPageBuilderForSubmit();
|
||||
};
|
||||
window.addEventListener(OPEN_COMMUNITY_SUBMIT_EVENT, onOpenCommunitySubmit);
|
||||
|
||||
return () => {
|
||||
themeUpdates.removeListener(onThemesUpdated);
|
||||
window.removeEventListener(OPEN_COMMUNITY_SUBMIT_EVENT, onOpenCommunitySubmit);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function createCommunityThemesState(getSearchTerm: () => string) {
|
||||
return new CommunityThemesState(getSearchTerm);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class ThemeBuilderPanelStore {
|
||||
editingThemeId = $state<string | null>(null);
|
||||
|
||||
open(themeId?: string | null) {
|
||||
this.editingThemeId = themeId ?? null;
|
||||
}
|
||||
|
||||
close() {
|
||||
this.editingThemeId = null;
|
||||
}
|
||||
}
|
||||
|
||||
export const themeBuilderPanel = new ThemeBuilderPanelStore();
|
||||
@@ -39,6 +39,21 @@ input {
|
||||
scrollbar-width: none !important;
|
||||
}
|
||||
|
||||
[data-settings-panel] {
|
||||
transform: scale(0.94);
|
||||
opacity: 0;
|
||||
transform-origin: center center;
|
||||
transition:
|
||||
transform var(--bs-motion-duration, 0.22s) cubic-bezier(0.22, 1, 0.36, 1),
|
||||
opacity var(--bs-motion-duration, 0.22s) cubic-bezier(0.22, 1, 0.36, 1);
|
||||
will-change: transform, opacity;
|
||||
}
|
||||
|
||||
[data-settings-panel].bsplus-settings-panel--open {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.cm-editor {
|
||||
width: 100%;
|
||||
min-height: 100px;
|
||||
|
||||
@@ -34,6 +34,8 @@ if (!mountPoint) {
|
||||
void (async () => {
|
||||
await initializeSettingsState();
|
||||
initVerboseLogging();
|
||||
const { syncApiBaseToBackground } = await import("@/seqta/utils/DevApiBase");
|
||||
syncApiBaseToBackground();
|
||||
renderSvelte(Settings, mountPoint, { standalone: true });
|
||||
})();
|
||||
}
|
||||
@@ -4,8 +4,10 @@ import settingsStyle from "./index.css?inline";
|
||||
import contentShadowStyle from "./contentShadow.css?inline";
|
||||
|
||||
const shadowStyles = {
|
||||
settings: settingsStyle,
|
||||
content: contentShadowStyle,
|
||||
// Registered properties are document-wide, including inside shadow roots.
|
||||
// Keep Tailwind 3 gradients separate from a host's typed Tailwind 4 properties.
|
||||
settings: settingsStyle.replaceAll("--tw-gradient", "--bs-gradient"),
|
||||
content: contentShadowStyle.replaceAll("--tw-gradient", "--bs-gradient"),
|
||||
} as const;
|
||||
|
||||
export type ShadowStyleVariant = keyof typeof shadowStyles;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import BrowsePanel from "@/interface/components/communityThemes/BrowsePanel.svelte";
|
||||
import MyThemesPanel from "@/interface/components/communityThemes/MyThemesPanel.svelte";
|
||||
import OwnerThemeDetailModal from "@/interface/components/communityThemes/OwnerThemeDetailModal.svelte";
|
||||
import { createCommunityThemesState } from "@/interface/hooks/communityThemesState.svelte";
|
||||
|
||||
let { searchTerm }: { searchTerm: string; setSearchTerm?: (term: string) => void } = $props();
|
||||
|
||||
const communityState = createCommunityThemesState(() => searchTerm);
|
||||
communityState.bindReactiveLoads();
|
||||
|
||||
onMount(() => communityState.mount());
|
||||
</script>
|
||||
|
||||
<div class="relative flex h-full min-h-0 flex-col overflow-hidden text-zinc-900 dark:text-white">
|
||||
<div class="shrink-0 border-b border-zinc-200/60 px-6 py-4 dark:border-zinc-700/50">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="inline-flex rounded-xl bg-zinc-200/80 p-1 dark:bg-zinc-800/80">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium transition-colors {communityState.innerTab === 'browse'
|
||||
? 'bg-white text-zinc-900 shadow dark:bg-zinc-700 dark:text-white'
|
||||
: 'text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white'}"
|
||||
onclick={() => (communityState.innerTab = "browse")}
|
||||
>
|
||||
Browse
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium transition-colors {communityState.innerTab === 'mine'
|
||||
? 'bg-white text-zinc-900 shadow dark:bg-zinc-700 dark:text-white'
|
||||
: 'text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white'}"
|
||||
onclick={() => (communityState.innerTab = "mine")}
|
||||
>
|
||||
My themes
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-900 px-4 py-2 text-sm font-medium text-white transition hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white"
|
||||
onclick={() =>
|
||||
void import("@/seqta/utils/launchPageThemeBuilder").then(({ launchPageThemeBuilder }) =>
|
||||
launchPageThemeBuilder(),
|
||||
)}
|
||||
>
|
||||
Create & submit
|
||||
</button>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-zinc-500 dark:text-zinc-400">
|
||||
Community themes are user-submitted and moderated separately from the official theme store.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<main class="min-h-0 flex-1 overflow-y-auto bg-zinc-50/80 px-6 py-6 dark:bg-zinc-900/40 md:px-8 lg:px-10">
|
||||
{#if communityState.innerTab === "browse"}
|
||||
<BrowsePanel {communityState} {searchTerm} />
|
||||
{:else}
|
||||
<MyThemesPanel {communityState} />
|
||||
{/if}
|
||||
</main>
|
||||
|
||||
<OwnerThemeDetailModal {communityState} />
|
||||
</div>
|
||||
+411
-127
@@ -1,29 +1,25 @@
|
||||
<script lang="ts">
|
||||
import Settings from "./settings/general.svelte";
|
||||
import Shortcuts from "./settings/shortcuts.svelte";
|
||||
import Theme from "./settings/theme.svelte";
|
||||
import Store from "./store.svelte";
|
||||
import TabbedContainer from "../components/TabbedContainer.svelte";
|
||||
import LazyPanel from "../components/LazyPanel.svelte";
|
||||
import darkLogo from "@/resources/icons/betterseqta-dark-full.png";
|
||||
import lightLogo from "@/resources/icons/betterseqta-light-full.png";
|
||||
import { resolveExtensionAssetUrl } from "@/lib/extensionAssetUrl";
|
||||
|
||||
import { standalone as StandaloneStore } from "../utils/standalone.svelte";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import { onMount, onDestroy, tick } from "svelte";
|
||||
import { animate } from "motion";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
import { closeExtensionPopup } from "@/seqta/utils/Closers/closeExtensionPopup";
|
||||
import { OpenAboutPage } from "@/seqta/utils/Openers/OpenAboutPage";
|
||||
import { OpenWhatsNewPopup } from "@/seqta/utils/Openers/OpenWhatsNewPopup";
|
||||
|
||||
import type { Component } from "svelte";
|
||||
import FontPickerModal from "../components/FontPickerModal.svelte";
|
||||
import CloudPanel from "../components/CloudPanel.svelte";
|
||||
import DisclaimerModal from "../components/DisclaimerModal.svelte";
|
||||
import FeedbackModal from "../components/FeedbackModal.svelte";
|
||||
import SidebarNav from "../components/SidebarNav.svelte";
|
||||
import StoreHeader from "../components/store/Header.svelte";
|
||||
import { settingsPopup } from "@/seqta/utils/settingsPopup";
|
||||
import { armDevModeUnlock } from "@/seqta/utils/devModeUnlock";
|
||||
import { consumeOpenFeedbackRequest } from "@/seqta/utils/feedback/client";
|
||||
import {
|
||||
consumeSettingsDestination,
|
||||
@@ -39,9 +35,15 @@
|
||||
} from "@/utils/githubReleaseUpdate";
|
||||
type PageId = "settings" | "themes" | "backgrounds";
|
||||
type StoreTab = "themes" | "backgrounds";
|
||||
type ThemeView = "theme-settings" | "theme-store";
|
||||
type ThemeView = "theme-settings" | "theme-store" | "community-themes" | "create-theme";
|
||||
type BackgroundView = "background-settings" | "background-store";
|
||||
|
||||
const loadSettingsBody = () => import("./settings/SettingsBody.svelte");
|
||||
const loadShortcuts = () => import("./settings/shortcuts.svelte");
|
||||
const loadThemeSettings = () => import("./settings/theme.svelte");
|
||||
const loadStore = () => import("./store.svelte");
|
||||
const loadCommunityThemes = () => import("./communityThemes.svelte");
|
||||
|
||||
type NavItem = {
|
||||
id: string;
|
||||
label: string;
|
||||
@@ -52,8 +54,9 @@
|
||||
|
||||
const BACKGROUND_CATEGORY_PREFIX = "background-category:";
|
||||
|
||||
let devModeSequence = "";
|
||||
let compactActiveTab = $state(0);
|
||||
let expanded = $state(settingsState.settingsPopupExpanded === true);
|
||||
let lastExpandedTab: number | null = null;
|
||||
let activePage = $state<PageId>("settings");
|
||||
let activeSection = $state("general");
|
||||
let activeThemeView = $state<ThemeView>("theme-store");
|
||||
@@ -62,6 +65,18 @@
|
||||
let backgroundCategories = $state<string[]>([]);
|
||||
let storeSearchTerm = $state("");
|
||||
let settingsSearch = $state("");
|
||||
let debouncedSettingsSearch = $state("");
|
||||
let settingsSearchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
$effect(() => {
|
||||
const query = settingsSearch;
|
||||
if (settingsSearchTimer) clearTimeout(settingsSearchTimer);
|
||||
const delay = isPerformanceMode() ? 250 : 150;
|
||||
settingsSearchTimer = setTimeout(() => {
|
||||
debouncedSettingsSearch = query;
|
||||
settingsSearchTimer = null;
|
||||
}, delay);
|
||||
});
|
||||
|
||||
let showDisclaimerModal = $state(false);
|
||||
let disclaimerCallbacks = $state<{ onConfirm: () => void; onCancel: () => void } | null>(null);
|
||||
@@ -77,26 +92,31 @@
|
||||
{ id: "appearance", label: "Appearance" },
|
||||
];
|
||||
|
||||
const appNav: NavItem[] = [
|
||||
$effect(() => {
|
||||
if (!$settingsState.devMode && activeSection === "advanced") activeSection = "general";
|
||||
});
|
||||
|
||||
const appNav = $derived<NavItem[]>([
|
||||
{ id: "timetable", label: "Timetable" },
|
||||
{ id: "assessments", label: "Assessments" },
|
||||
{ id: "features", label: "Features" },
|
||||
{ id: "advanced", label: "Advanced" },
|
||||
...($settingsState.devMode ? [{ id: "advanced", label: "Advanced" }] : []),
|
||||
{ id: "shortcuts", label: "Shortcuts" },
|
||||
];
|
||||
]);
|
||||
|
||||
const settingsNavGroups = [
|
||||
const settingsNavGroups = $derived([
|
||||
{ label: "User Settings", items: userNav },
|
||||
{ label: "App Settings", items: appNav },
|
||||
];
|
||||
]);
|
||||
|
||||
const themeNavGroups = [
|
||||
{
|
||||
label: "Themes",
|
||||
items: [
|
||||
{ id: "theme-store", label: "Store" },
|
||||
{ id: "theme-settings", label: "Theme settings" },
|
||||
{ id: "create-theme", label: "Create theme" },
|
||||
{ id: "theme-store", label: "Theme store" },
|
||||
{ id: "community-themes", label: "Community themes" },
|
||||
{ id: "theme-settings", label: "Downloaded themes" },
|
||||
{ id: "create-theme", label: "Custom themes" },
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -143,17 +163,34 @@
|
||||
);
|
||||
|
||||
const sectionTitle = $derived.by(() => {
|
||||
if (activePage === "settings" && settingsSearch.trim()) return "Search results";
|
||||
if (activePage === "themes") return "Themes";
|
||||
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 === "community-themes") return "Community themes";
|
||||
if (activeThemeView === "theme-store") return "Theme store";
|
||||
return "Themes";
|
||||
}
|
||||
if (activePage === "backgrounds") return "Backgrounds";
|
||||
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") ||
|
||||
(activePage === "themes" &&
|
||||
(activeThemeView === "theme-store" || activeThemeView === "community-themes")) ||
|
||||
(activePage === "backgrounds" && activeBackgroundView === "background-store"),
|
||||
);
|
||||
|
||||
const isOfficialStoreView = $derived(
|
||||
activePage === "themes" && activeThemeView === "theme-store",
|
||||
);
|
||||
|
||||
const openGhRelease = () => {
|
||||
const url =
|
||||
ghReleaseUpdate?.url ?? "https://github.com/BetterSEQTA/BetterSEQTA-Plus/releases";
|
||||
@@ -164,24 +201,13 @@
|
||||
closeExtensionPopup();
|
||||
};
|
||||
|
||||
const handleDevModeToggle = () => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
devModeSequence += event.key.toLowerCase();
|
||||
if (devModeSequence.includes("dev")) {
|
||||
document.removeEventListener("keydown", handleKeyDown);
|
||||
settingsState.devMode = true;
|
||||
alert("Dev mode is now enabled");
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("keydown", handleKeyDown);
|
||||
setTimeout(() => {
|
||||
document.removeEventListener("keydown", handleKeyDown);
|
||||
devModeSequence = "";
|
||||
}, 10000);
|
||||
};
|
||||
const handleDevModeToggle = () => armDevModeUnlock();
|
||||
|
||||
let ColourPickerComponent = $state<Component | null>(null);
|
||||
let FontPickerComponent = $state<Component | null>(null);
|
||||
let CloudPanelComponent = $state<Component | null>(null);
|
||||
let DisclaimerModalComponent = $state<Component | null>(null);
|
||||
let FeedbackModalComponent = $state<Component | null>(null);
|
||||
|
||||
const openColourPicker = async () => {
|
||||
if (!ColourPickerComponent) {
|
||||
@@ -190,7 +216,10 @@
|
||||
showColourPicker = true;
|
||||
};
|
||||
|
||||
const openFontPicker = () => {
|
||||
const openFontPicker = async () => {
|
||||
if (!FontPickerComponent) {
|
||||
FontPickerComponent = (await import("../components/FontPickerModal.svelte")).default;
|
||||
}
|
||||
showFontPicker = true;
|
||||
};
|
||||
|
||||
@@ -216,28 +245,146 @@
|
||||
let showFeedbackModal = $state<boolean>(false);
|
||||
let feedbackFocusId = $state<string | null>(null);
|
||||
|
||||
const openCloudPanel = () => {
|
||||
const openCloudPanel = async () => {
|
||||
if (!CloudPanelComponent) {
|
||||
CloudPanelComponent = (await import("../components/CloudPanel.svelte")).default;
|
||||
}
|
||||
showCloudPanel = true;
|
||||
};
|
||||
|
||||
const openFeedback = (feedbackId?: string | null) => {
|
||||
const openFeedback = async (feedbackId?: string | null) => {
|
||||
if (!FeedbackModalComponent) {
|
||||
FeedbackModalComponent = (await import("../components/FeedbackModal.svelte")).default;
|
||||
}
|
||||
feedbackFocusId = typeof feedbackId === "string" && feedbackId ? feedbackId : null;
|
||||
showFeedbackModal = true;
|
||||
};
|
||||
|
||||
const showDisclaimer = (
|
||||
const showDisclaimer = async (
|
||||
onConfirm: () => void,
|
||||
onCancel: () => void,
|
||||
title = "Confirm",
|
||||
message = "",
|
||||
) => {
|
||||
if (!DisclaimerModalComponent) {
|
||||
DisclaimerModalComponent = (await import("../components/DisclaimerModal.svelte")).default;
|
||||
}
|
||||
disclaimerCallbacks = { onConfirm, onCancel };
|
||||
disclaimerTitle = title;
|
||||
disclaimerMessage = message;
|
||||
showDisclaimerModal = true;
|
||||
};
|
||||
|
||||
const settingsSharedProps = {
|
||||
showColourPicker: openColourPicker,
|
||||
showFontPicker: openFontPicker,
|
||||
showDisclaimer,
|
||||
showCloudPanel: openCloudPanel,
|
||||
};
|
||||
|
||||
let settingsPanel = $state<HTMLElement>();
|
||||
let settingsContent = $state<HTMLElement>();
|
||||
let resizeSnapshot: HTMLElement | undefined;
|
||||
let resizeAnimation: ReturnType<typeof animate> | undefined;
|
||||
let resizeGeneration = 0;
|
||||
const bounds = ["width", "height", "top", "right"] as const;
|
||||
const clearMorphContent = () => {
|
||||
resizeSnapshot?.remove();
|
||||
resizeSnapshot = undefined;
|
||||
if (settingsContent) {
|
||||
settingsContent.style.removeProperty("width");
|
||||
settingsContent.style.removeProperty("height");
|
||||
settingsContent.style.removeProperty("opacity");
|
||||
}
|
||||
};
|
||||
const clearResize = () => {
|
||||
resizeGeneration++;
|
||||
resizeAnimation?.stop();
|
||||
resizeAnimation = undefined;
|
||||
if (settingsPanel) for (const key of bounds) settingsPanel.style.removeProperty(key);
|
||||
clearMorphContent();
|
||||
};
|
||||
|
||||
const resizePanel = async (nextExpanded: boolean) => {
|
||||
const panel = settingsPanel;
|
||||
const content = settingsContent;
|
||||
const generation = ++resizeGeneration;
|
||||
const from = panel ? getComputedStyle(panel) : null;
|
||||
const start = bounds.map((key) => parseFloat(from?.[key] ?? "0"));
|
||||
resizeAnimation?.stop();
|
||||
const motionEnabled = $settingsState.animations !== false && !$settingsState.performanceMode &&
|
||||
!window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
const root = panel?.getRootNode() as ShadowRoot | Document | undefined;
|
||||
const restoreFocus = !!content?.contains(root?.activeElement ?? null);
|
||||
|
||||
// A visual snapshot has no live component listeners or accessible controls.
|
||||
// Include the current crossfade when a second click reverses the morph.
|
||||
if (panel && content && motionEnabled) {
|
||||
const snapshot = document.createElement("div");
|
||||
snapshot.inert = true;
|
||||
snapshot.setAttribute("aria-hidden", "true");
|
||||
snapshot.setAttribute("data-settings-snapshot", "");
|
||||
snapshot.style.cssText = `position:absolute;top:0;right:0;width:${panel.clientWidth}px;height:${panel.clientHeight}px;overflow:hidden;pointer-events:none;z-index:20;`;
|
||||
snapshot.append(content.cloneNode(true));
|
||||
if (resizeSnapshot) snapshot.append(resizeSnapshot.cloneNode(true));
|
||||
snapshot.querySelectorAll("[id]").forEach((element) => element.removeAttribute("id"));
|
||||
resizeSnapshot?.remove();
|
||||
resizeSnapshot = snapshot;
|
||||
panel.append(snapshot);
|
||||
content.style.opacity = "0";
|
||||
} else {
|
||||
clearMorphContent();
|
||||
}
|
||||
|
||||
expanded = nextExpanded;
|
||||
await tick();
|
||||
if (!panel || !content || generation !== resizeGeneration) return;
|
||||
for (const key of bounds) panel.style.removeProperty(key);
|
||||
if (restoreFocus) content.querySelector<HTMLButtonElement>(
|
||||
`[aria-label="${nextExpanded ? "Collapse" : "Expand"} settings"]`,
|
||||
)?.focus({ preventScroll: true });
|
||||
if (!motionEnabled) return;
|
||||
const targetStyle = getComputedStyle(panel);
|
||||
const target = bounds.map((key) => parseFloat(targetStyle[key]));
|
||||
// The incoming layout stays at its destination size while the outer bounds
|
||||
// move, so compact text and images never stretch across the expanded panel.
|
||||
content.style.width = `${panel.clientWidth}px`;
|
||||
content.style.height = `${panel.clientHeight}px`;
|
||||
bounds.forEach((key, index) => { panel.style[key] = `${start[index]}px`; });
|
||||
resizeAnimation = animate(0, 1, {
|
||||
type: "spring", stiffness: 420, damping: 36,
|
||||
onUpdate: (progress) => {
|
||||
if (generation !== resizeGeneration) return;
|
||||
const opacity = Math.max(0, Math.min(1, progress));
|
||||
content.style.opacity = String(opacity);
|
||||
if (resizeSnapshot) resizeSnapshot.style.opacity = String(1 - opacity);
|
||||
bounds.forEach((key, index) => {
|
||||
panel.style[key] = `${start[index] + (target[index] - start[index]) * progress}px`;
|
||||
});
|
||||
},
|
||||
onComplete: () => {
|
||||
if (generation !== resizeGeneration) return;
|
||||
for (const key of bounds) panel.style.removeProperty(key);
|
||||
clearMorphContent();
|
||||
resizeAnimation = undefined;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
let restoreSizeAfterClose = false;
|
||||
const resetClosedLayout = () => {
|
||||
if (!restoreSizeAfterClose) return;
|
||||
clearResize();
|
||||
expanded = settingsState.settingsPopupExpanded === true;
|
||||
restoreSizeAfterClose = false;
|
||||
};
|
||||
const closePopupsOnSettingsClose = () => {
|
||||
resizeGeneration++;
|
||||
resizeAnimation?.stop();
|
||||
resizeAnimation = undefined;
|
||||
if (expanded) syncCompactTab();
|
||||
restoreSizeAfterClose = true;
|
||||
if (document.getElementById("ExtensionPopup")?.style.opacity === "0") resetClosedLayout();
|
||||
showColourPicker = false;
|
||||
showFontPicker = false;
|
||||
showCloudPanel = false;
|
||||
@@ -251,6 +398,33 @@
|
||||
}
|
||||
};
|
||||
|
||||
const syncCompactTab = () => {
|
||||
compactActiveTab = activePage === "settings"
|
||||
? activeSection === "shortcuts" ? 1 : 0
|
||||
: 2;
|
||||
lastExpandedTab = compactActiveTab;
|
||||
};
|
||||
|
||||
const toggleExpanded = () => {
|
||||
settingsState.settingsPopupExpanded = !expanded;
|
||||
if (expanded) {
|
||||
syncCompactTab();
|
||||
} else if (compactActiveTab === lastExpandedTab) {
|
||||
void resizePanel(true);
|
||||
return;
|
||||
} else if (compactActiveTab === 1) {
|
||||
activePage = "settings";
|
||||
activeSection = "shortcuts";
|
||||
} else if (compactActiveTab === 2) {
|
||||
activePage = "themes";
|
||||
activeThemeView = "theme-settings";
|
||||
} else {
|
||||
activePage = "settings";
|
||||
if (activeSection === "shortcuts") activeSection = "general";
|
||||
}
|
||||
void resizePanel(!expanded);
|
||||
};
|
||||
|
||||
const selectNavItem = (id: string) => {
|
||||
if (activePage === "settings") {
|
||||
settingsSearch = "";
|
||||
@@ -259,11 +433,7 @@
|
||||
}
|
||||
|
||||
if (activePage === "themes") {
|
||||
if (id === "create-theme") {
|
||||
void openThemeCreator();
|
||||
} else {
|
||||
activeThemeView = id as ThemeView;
|
||||
}
|
||||
activeThemeView = id as ThemeView;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -275,19 +445,28 @@
|
||||
}
|
||||
};
|
||||
|
||||
const openThemeCreator = async () => {
|
||||
const { OpenThemeCreator } = await import("@/plugins/built-in/themes/ThemeCreator");
|
||||
OpenThemeCreator();
|
||||
closeExtensionPopup();
|
||||
};
|
||||
|
||||
const applyDestination = (destination: SettingsDestination) => {
|
||||
clearResize();
|
||||
restoreSizeAfterClose = false;
|
||||
expanded = true;
|
||||
activePage = destination.page;
|
||||
if (destination.page === "settings" && destination.section) {
|
||||
settingsSearch = "";
|
||||
activeSection = destination.section;
|
||||
if (destination.page === "settings") {
|
||||
if (destination.section) {
|
||||
settingsSearch = "";
|
||||
activeSection = destination.section;
|
||||
}
|
||||
if (destination.search) {
|
||||
settingsSearch = destination.search;
|
||||
}
|
||||
} else if (destination.page === "themes" && destination.view) {
|
||||
activeThemeView = destination.view === "store" ? "theme-store" : "theme-settings";
|
||||
activeThemeView =
|
||||
destination.view === "store"
|
||||
? "theme-store"
|
||||
: destination.view === "community"
|
||||
? "community-themes"
|
||||
: destination.view === "custom"
|
||||
? "create-theme"
|
||||
: "theme-settings";
|
||||
} else if (destination.page === "backgrounds" && destination.view) {
|
||||
activeBackgroundView = destination.view === "store" ? "background-store" : "background-settings";
|
||||
}
|
||||
@@ -301,15 +480,24 @@
|
||||
|
||||
onMount(() => {
|
||||
settingsPopup.addListener(closePopupsOnSettingsClose);
|
||||
window.addEventListener("bsplus:settings-hidden", resetClosedLayout);
|
||||
window.addEventListener("bsplus:settings-opening", resetClosedLayout);
|
||||
|
||||
if (standalone) {
|
||||
StandaloneStore.setStandalone(true);
|
||||
}
|
||||
|
||||
if (ghReleaseUpdateEnabled) {
|
||||
void checkGithubReleaseUpdate().then((info) => {
|
||||
ghReleaseUpdate = info;
|
||||
});
|
||||
const runCheck = () => {
|
||||
void checkGithubReleaseUpdate().then((info) => {
|
||||
ghReleaseUpdate = info;
|
||||
});
|
||||
};
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(runCheck, { timeout: 4000 });
|
||||
} else {
|
||||
setTimeout(runCheck, 500);
|
||||
}
|
||||
}
|
||||
|
||||
const pendingFeedbackId = consumeOpenFeedbackRequest();
|
||||
@@ -339,6 +527,8 @@
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("bsplus:settings-hidden", resetClosedLayout);
|
||||
window.removeEventListener("bsplus:settings-opening", resetClosedLayout);
|
||||
window.removeEventListener("keydown", onKeyDown);
|
||||
window.removeEventListener("bsplus:open-feedback", onOpenFeedback);
|
||||
window.removeEventListener(SETTINGS_NAVIGATION_EVENT, onNavigateSettings);
|
||||
@@ -346,6 +536,7 @@
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
clearResize();
|
||||
settingsPopup.removeListener(closePopupsOnSettingsClose);
|
||||
});
|
||||
</script>
|
||||
@@ -364,9 +555,10 @@
|
||||
activePage = page;
|
||||
if (page === "themes") activeThemeView = "theme-store";
|
||||
}}
|
||||
showStoreTools={isStoreView}
|
||||
showStoreTools={isOfficialStoreView || activeThemeView === "community-themes"}
|
||||
onLogoClick={handleDevModeToggle}
|
||||
onClose={handleClose}
|
||||
onToggleSize={standalone ? undefined : toggleExpanded}
|
||||
/>
|
||||
|
||||
<!-- Body: left nav + content -->
|
||||
@@ -461,53 +653,85 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{#if isStoreView}
|
||||
<div class="min-w-0 min-h-0 flex-1">
|
||||
<Store
|
||||
activeTab={activePage as StoreTab}
|
||||
searchTerm={storeSearchTerm}
|
||||
{selectedBackgroundCategory}
|
||||
setActiveTab={(tab) => {
|
||||
activePage = tab;
|
||||
if (tab === "themes") activeThemeView = "theme-store";
|
||||
else activeBackgroundView = "background-store";
|
||||
}}
|
||||
setSearchTerm={(term) => (storeSearchTerm = term)}
|
||||
setBackgroundCategories={(categories) => (backgroundCategories = categories)}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex flex-col flex-1 min-w-0 min-h-0">
|
||||
<div class="shrink-0 px-6 pt-5 pb-3">
|
||||
<h1 class="text-3xl font-semibold tracking-tight text-zinc-900 dark:text-white">
|
||||
{sectionTitle}
|
||||
</h1>
|
||||
</div>
|
||||
<div class="flex-1 min-h-0 px-4 pb-8 overflow-y-auto no-scrollbar">
|
||||
{#if activePage === "settings"}
|
||||
{#if activeSection === "shortcuts" && !settingsSearch.trim()}
|
||||
<Shortcuts />
|
||||
{:else}
|
||||
<Settings
|
||||
showColourPicker={openColourPicker}
|
||||
showFontPicker={openFontPicker}
|
||||
{showDisclaimer}
|
||||
showCloudPanel={openCloudPanel}
|
||||
activeSection={settingsSearch.trim() ? "all" : activeSection}
|
||||
searchQuery={settingsSearch}
|
||||
/>
|
||||
{#if settingsSearch.trim()}
|
||||
<Shortcuts searchQuery={settingsSearch} />
|
||||
{/if}
|
||||
{/if}
|
||||
{:else if activePage === "themes"}
|
||||
<Theme section="themes" />
|
||||
<div class="flex min-h-0 min-w-0 flex-1 overflow-hidden">
|
||||
{#if isStoreView}
|
||||
<div class="min-h-0 min-w-0 flex-1 overflow-hidden">
|
||||
{#if activePage === "themes" && activeThemeView === "community-themes"}
|
||||
<LazyPanel
|
||||
loader={loadCommunityThemes}
|
||||
remountKey="community-themes"
|
||||
props={{
|
||||
searchTerm: storeSearchTerm,
|
||||
setSearchTerm: (term: string) => (storeSearchTerm = term),
|
||||
}}
|
||||
/>
|
||||
{:else}
|
||||
<Theme section="backgrounds" />
|
||||
<LazyPanel
|
||||
loader={loadStore}
|
||||
remountKey="store"
|
||||
props={{
|
||||
activeTab: activePage as StoreTab,
|
||||
searchTerm: storeSearchTerm,
|
||||
selectedBackgroundCategory,
|
||||
setActiveTab: (tab: StoreTab) => {
|
||||
activePage = tab;
|
||||
if (tab === "themes") activeThemeView = "theme-store";
|
||||
else activeBackgroundView = "background-store";
|
||||
},
|
||||
setSearchTerm: (term: string) => (storeSearchTerm = term),
|
||||
setBackgroundCategories: (categories: string[]) =>
|
||||
(backgroundCategories = categories),
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<div class="shrink-0 px-6 pt-5 pb-3">
|
||||
<h1 class="text-3xl font-semibold tracking-tight text-zinc-900 dark:text-white">
|
||||
{sectionTitle}
|
||||
</h1>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 overflow-y-auto px-4 pb-8 no-scrollbar">
|
||||
{#if activePage === "settings"}
|
||||
{#if activeSection === "shortcuts" && !debouncedSettingsSearch.trim()}
|
||||
<LazyPanel loader={loadShortcuts} remountKey="shortcuts-page" />
|
||||
{:else}
|
||||
<LazyPanel
|
||||
loader={loadSettingsBody}
|
||||
remountKey="settings-body"
|
||||
props={{
|
||||
...settingsSharedProps,
|
||||
activeSection: debouncedSettingsSearch.trim() ? "all" : activeSection,
|
||||
searchQuery: debouncedSettingsSearch,
|
||||
}}
|
||||
/>
|
||||
{#if debouncedSettingsSearch.trim()}
|
||||
<LazyPanel
|
||||
loader={loadShortcuts}
|
||||
remountKey="shortcuts-search"
|
||||
props={{ searchQuery: debouncedSettingsSearch }}
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
{:else if activePage === "themes"}
|
||||
<LazyPanel
|
||||
loader={loadThemeSettings}
|
||||
remountKey={`theme-settings-${activeThemeListMode}`}
|
||||
props={{ section: "themes", listMode: activeThemeListMode }}
|
||||
/>
|
||||
{:else}
|
||||
<LazyPanel
|
||||
loader={loadThemeSettings}
|
||||
remountKey="background-settings"
|
||||
props={{ section: "backgrounds" }}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
@@ -517,13 +741,13 @@
|
||||
class="flex h-full min-h-0 flex-col gap-2 overflow-hidden bg-white dark:bg-zinc-800 dark:text-white"
|
||||
>
|
||||
<div
|
||||
class="grid shrink-0 place-items-center border-b border-zinc-200/40 dark:border-zinc-700/40"
|
||||
class="grid shrink-0 items-center border-b border-zinc-200/40 dark:border-zinc-700/40 {standalone ? 'grid-cols-1' : 'grid-cols-[minmax(0,1fr)_44px] gap-2 px-2'}"
|
||||
>
|
||||
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<img
|
||||
src={resolveExtensionAssetUrl(darkLogo)}
|
||||
class="w-4/5 dark:hidden"
|
||||
class="min-w-0 dark:hidden {standalone ? 'mx-auto w-4/5' : 'h-auto w-full max-w-[296px] justify-self-center object-contain'}"
|
||||
alt="BetterSEQTA+"
|
||||
onclick={handleDevModeToggle}
|
||||
/>
|
||||
@@ -531,10 +755,17 @@
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<img
|
||||
src={resolveExtensionAssetUrl(lightLogo)}
|
||||
class="hidden w-4/5 dark:block"
|
||||
class="hidden min-w-0 dark:block {standalone ? 'mx-auto w-4/5' : 'h-auto w-full max-w-[296px] justify-self-center object-contain'}"
|
||||
alt="BetterSEQTA+"
|
||||
onclick={handleDevModeToggle}
|
||||
/>
|
||||
{#if !standalone}
|
||||
<button type="button" onclick={toggleExpanded}
|
||||
class="mt-2 flex h-11 w-11 shrink-0 self-start items-center justify-center text-zinc-500 transition-[color,transform] duration-150 hover:text-zinc-950 active:scale-[0.96] focus:outline-none dark:text-zinc-400 dark:hover:text-white"
|
||||
aria-label="Expand settings" title="Expand settings" aria-expanded="false">
|
||||
<span class="font-IconFamily text-2xl" aria-hidden="true">{"\uebdb"}</span>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-hidden">
|
||||
@@ -543,17 +774,21 @@
|
||||
tabs={[
|
||||
{
|
||||
title: "Settings",
|
||||
Content: Settings,
|
||||
loader: loadSettingsBody,
|
||||
props: {
|
||||
showColourPicker: openColourPicker,
|
||||
showFontPicker: openFontPicker,
|
||||
showDisclaimer,
|
||||
showCloudPanel: openCloudPanel,
|
||||
...settingsSharedProps,
|
||||
activeSection: "all",
|
||||
},
|
||||
},
|
||||
{ title: "Shortcuts", Content: Shortcuts },
|
||||
{ title: "Themes", Content: Theme },
|
||||
{
|
||||
title: "Shortcuts",
|
||||
loader: loadShortcuts,
|
||||
},
|
||||
{
|
||||
title: "Themes",
|
||||
loader: loadThemeSettings,
|
||||
props: { section: "all" },
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
@@ -570,7 +805,7 @@
|
||||
</div>
|
||||
{:else}
|
||||
<div
|
||||
class="absolute inset-0 z-50 flex items-center justify-center p-4 sm:p-6 {$settingsState.DarkMode
|
||||
class="absolute inset-0 z-50 {$settingsState.DarkMode
|
||||
? 'dark'
|
||||
: ''}"
|
||||
role="dialog"
|
||||
@@ -579,20 +814,69 @@
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 bg-black/60 backdrop-blur-sm transition-colors duration-200"
|
||||
class="settings-backdrop absolute inset-0 {expanded ? 'bg-black/60' : 'bg-transparent'} {expanded && !$settingsState.performanceMode
|
||||
? 'backdrop-blur-sm'
|
||||
: 'backdrop-blur-none'}"
|
||||
class:settings-backdrop--motion={$settingsState.animations !== false && !$settingsState.performanceMode}
|
||||
aria-label="Close settings"
|
||||
onclick={handleClose}
|
||||
></button>
|
||||
|
||||
<div
|
||||
class="relative z-10 w-[min(1180px,96vw)] h-[min(860px,92vh)] no-scrollbar overflow-clip"
|
||||
class="settings-panel absolute z-10 no-scrollbar overflow-clip bg-white dark:bg-zinc-800 shadow-2xl border border-zinc-200/60 dark:border-zinc-700/60"
|
||||
class:settings-panel--expanded={expanded}
|
||||
bind:this={settingsPanel}
|
||||
data-settings-panel
|
||||
>
|
||||
{@render settingsShell()}
|
||||
<div class="settings-content" bind:this={settingsContent}>
|
||||
{#if expanded}
|
||||
{@render settingsShell()}
|
||||
{:else}
|
||||
{@render compactSettings()}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.settings-content {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.settings-panel {
|
||||
width: min(384px, calc(100vw - 20px));
|
||||
height: min(600px, calc(100vh - 95px));
|
||||
top: min(80px, 10vh);
|
||||
right: 10px;
|
||||
border-radius: 1rem;
|
||||
transform-origin: 70% 0;
|
||||
}
|
||||
|
||||
.settings-panel--expanded {
|
||||
border-radius: 0.75rem;
|
||||
transform-origin: center;
|
||||
width: min(1180px, 96vw);
|
||||
height: min(860px, 92vh);
|
||||
top: calc((100% - min(860px, 92vh)) / 2);
|
||||
right: calc((100% - min(1180px, 96vw)) / 2);
|
||||
}
|
||||
|
||||
.settings-backdrop--motion {
|
||||
transition: background-color 200ms ease;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.settings-backdrop--motion {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if showColourPicker && ColourPickerComponent}
|
||||
<ColourPickerComponent
|
||||
hidePicker={() => {
|
||||
@@ -601,24 +885,24 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showCloudPanel}
|
||||
<CloudPanel
|
||||
{#if showCloudPanel && CloudPanelComponent}
|
||||
<CloudPanelComponent
|
||||
hidePanel={() => {
|
||||
showCloudPanel = false;
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showFontPicker}
|
||||
<FontPickerModal
|
||||
{#if showFontPicker && FontPickerComponent}
|
||||
<FontPickerComponent
|
||||
hidePicker={() => {
|
||||
showFontPicker = false;
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showDisclaimerModal && disclaimerCallbacks}
|
||||
<DisclaimerModal
|
||||
{#if showDisclaimerModal && disclaimerCallbacks && DisclaimerModalComponent}
|
||||
<DisclaimerModalComponent
|
||||
title={disclaimerTitle}
|
||||
message={disclaimerMessage}
|
||||
onConfirm={() => {
|
||||
@@ -634,8 +918,8 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if showFeedbackModal}
|
||||
<FeedbackModal
|
||||
{#if showFeedbackModal && FeedbackModalComponent}
|
||||
<FeedbackModalComponent
|
||||
initialFeedbackId={feedbackFocusId}
|
||||
onClose={() => {
|
||||
showFeedbackModal = false;
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import Slider from "@/interface/components/Slider.svelte";
|
||||
import Select from "@/interface/components/Select.svelte";
|
||||
import HotkeyInput from "@/interface/components/HotkeyInput.svelte";
|
||||
import SettingRow from "./SettingRow.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import {
|
||||
setPerformanceModePluginOverride,
|
||||
} from "@/seqta/utils/performanceMode";
|
||||
import { PERFORMANCE_HEAVY_PLUGIN_IDS } from "@/seqta/utils/performanceModeConfig";
|
||||
import { onMount } from "svelte";
|
||||
import {
|
||||
matchesSearch,
|
||||
PLUGIN_SECTION_BY_ID,
|
||||
type SettingsSectionId,
|
||||
type SettingsSectionSharedProps,
|
||||
} from "./shared";
|
||||
import {
|
||||
pluginSettingsStore,
|
||||
type PluginSettingsEntry,
|
||||
} from "./pluginSettingsState.svelte";
|
||||
|
||||
let {
|
||||
section,
|
||||
showDisclaimer,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps & { section: SettingsSectionId } = $props();
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => {
|
||||
cloudState = s;
|
||||
});
|
||||
return unsub;
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
void pluginSettingsStore.ensureLoaded();
|
||||
});
|
||||
|
||||
const pluginHit = (plugin: PluginSettingsEntry) =>
|
||||
matchesSearch(
|
||||
searchQuery,
|
||||
plugin.name,
|
||||
plugin.description,
|
||||
...Object.values(plugin.settings).flatMap((s) => [s.title, s.description]),
|
||||
);
|
||||
|
||||
const visiblePlugins = $derived(
|
||||
pluginSettingsStore.plugins.filter(
|
||||
(plugin) =>
|
||||
(PLUGIN_SECTION_BY_ID[plugin.pluginId] ?? "features") === section &&
|
||||
pluginHit(plugin),
|
||||
),
|
||||
);
|
||||
|
||||
const pluginPerfPaused = (pluginId: string) =>
|
||||
($settingsState.performanceMode ?? false) &&
|
||||
$settingsState.performanceModePluginOverrides?.[pluginId] !== true &&
|
||||
PERFORMANCE_HEAVY_PLUGIN_IDS.has(pluginId);
|
||||
</script>
|
||||
|
||||
{#if pluginSettingsStore.loading && visiblePlugins.length === 0}
|
||||
<div class="px-5 py-6 text-sm text-zinc-400">Loading plugin settings…</div>
|
||||
{/if}
|
||||
|
||||
{#each visiblePlugins as plugin (plugin.pluginId)}
|
||||
{@const perfPaused = pluginPerfPaused(plugin.pluginId)}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40 {!(plugin as PluginSettingsEntry & { disableToggle?: boolean }).disableToggle && Object.keys(plugin.settings).length === 0 ? 'hidden' : ''} {perfPaused ? 'opacity-60' : ''}"
|
||||
>
|
||||
{#if perfPaused}
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-3 border-b border-amber-200/60 dark:border-amber-900/40 bg-amber-50/80 dark:bg-amber-950/20"
|
||||
>
|
||||
<p class="text-sm text-amber-800 dark:text-amber-200">
|
||||
Paused by Performance Mode — enable anyway
|
||||
</p>
|
||||
<Switch
|
||||
state={$settingsState.performanceModePluginOverrides?.[plugin.pluginId] === true}
|
||||
onChange={(forceOn: boolean) =>
|
||||
setPerformanceModePluginOverride(plugin.pluginId, forceOn)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if plugin.disableToggle}
|
||||
<div class="flex justify-between items-center px-4 py-3 {perfPaused ? 'pointer-events-none' : ''}">
|
||||
<div class="pr-4">
|
||||
<h2 class="flex gap-2 items-center text-sm font-bold">
|
||||
Enable {plugin.name}
|
||||
{#if plugin.beta}
|
||||
<span
|
||||
class="px-2 py-0.5 text-xs font-medium text-orange-800 bg-orange-100 rounded-full border border-orange-300/30 dark:bg-orange-900/30 dark:text-orange-300 dark:border-orange-900/30"
|
||||
>
|
||||
Beta
|
||||
</span>
|
||||
{/if}
|
||||
</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">{plugin.description}</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={(pluginSettingsStore.values[plugin.pluginId]?.enabled as boolean | undefined) ?? true}
|
||||
onChange={async (value) => {
|
||||
if (plugin.pluginId === "assessments-average" && value === true) {
|
||||
showDisclaimer(
|
||||
async () => {
|
||||
await pluginSettingsStore.update(plugin.pluginId, "enabled", true);
|
||||
},
|
||||
() => {},
|
||||
"Assessment Averages Disclaimer",
|
||||
"This feature calculates a simple average of your assessment grades. It does not take into account:\n• Assessment weightings\n• Different grading scales\n• Other factors used in official reports\n\nThe displayed average may be inaccurate compared to your actual marks found in reports.\n\nDo you want to enable this feature?",
|
||||
);
|
||||
return;
|
||||
}
|
||||
await pluginSettingsStore.update(plugin.pluginId, "enabled", value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !perfPaused && (!plugin.disableToggle || ((pluginSettingsStore.values[plugin.pluginId]?.enabled as boolean | undefined) ?? true))}
|
||||
{#each Object.entries(plugin.settings) as [key, setting] (key)}
|
||||
{#if key !== "enabled" && !(key === "useCloudPfp" && !cloudState.isLoggedIn)}
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">{setting.title || key}</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">{setting.description || ""}</p>
|
||||
</div>
|
||||
<div>
|
||||
{#if setting.type === "boolean"}
|
||||
<Switch
|
||||
state={(pluginSettingsStore.values[plugin.pluginId]?.[key] as boolean | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === "number"}
|
||||
<div class="w-28 shrink-0">
|
||||
<Slider
|
||||
state={(pluginSettingsStore.values[plugin.pluginId]?.[key] as number | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
min={setting.min}
|
||||
max={setting.max}
|
||||
step={setting.step}
|
||||
/>
|
||||
</div>
|
||||
{:else if setting.type === "string"}
|
||||
<input
|
||||
type="text"
|
||||
class="px-2 py-1 text-sm rounded-md dark:bg-[#38373D]/50 bg-[#DDDDDD] dark:text-white border-none"
|
||||
value={(pluginSettingsStore.values[plugin.pluginId]?.[key] as string | undefined) ?? setting.default}
|
||||
oninput={(e) =>
|
||||
pluginSettingsStore.update(plugin.pluginId, key, e.currentTarget.value)}
|
||||
/>
|
||||
{:else if setting.type === "select"}
|
||||
<Select
|
||||
value={(pluginSettingsStore.values[plugin.pluginId]?.[key] as string | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
options={(setting.options as string[]).map((opt) => ({
|
||||
value: opt,
|
||||
label: opt.charAt(0).toUpperCase() + opt.slice(1),
|
||||
}))}
|
||||
/>
|
||||
{:else if setting.type === "button"}
|
||||
<Button onClick={() => setting.trigger?.()} text={setting.title} />
|
||||
{:else if setting.type === "hotkey"}
|
||||
<HotkeyInput
|
||||
value={(pluginSettingsStore.values[plugin.pluginId]?.[key] as string | undefined) ?? setting.default}
|
||||
onChange={(value) => pluginSettingsStore.update(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === "component" && setting.component}
|
||||
{@const Component = setting.component as import("svelte").Component}
|
||||
<Component />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if plugin.pluginId === "global-search"}
|
||||
<SettingRow
|
||||
title="Theme of the Month"
|
||||
description="Show the monthly featured theme popup when a new entry is available"
|
||||
id={15}
|
||||
Component={Switch}
|
||||
{searchQuery}
|
||||
props={{
|
||||
state: !($settingsState.themeOfTheMonthDisabled ?? false),
|
||||
onChange: (isOn: boolean) => (settingsState.themeOfTheMonthDisabled = !isOn),
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
@@ -0,0 +1,26 @@
|
||||
<script lang="ts">
|
||||
import type { SettingsList } from "@/interface/types/SettingsProps";
|
||||
import { matchesSearch } from "./shared";
|
||||
|
||||
let {
|
||||
title,
|
||||
description,
|
||||
Component,
|
||||
props = {},
|
||||
searchQuery = "",
|
||||
}: SettingsList & { searchQuery?: string } = $props();
|
||||
|
||||
const visible = $derived(matchesSearch(searchQuery, title, description));
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">{title}</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">{description}</p>
|
||||
</div>
|
||||
<div class="shrink-0">
|
||||
<Component {...props} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import LazyPanel from "../../components/LazyPanel.svelte";
|
||||
import {
|
||||
ALL_SETTINGS_SECTIONS,
|
||||
type SettingsSectionId,
|
||||
type SettingsSectionSharedProps,
|
||||
} from "./shared";
|
||||
import { SECTION_LOADERS } from "./sectionLoaders";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
let {
|
||||
activeSection = "general",
|
||||
...rest
|
||||
}: SettingsSectionSharedProps & { activeSection?: string } = $props();
|
||||
|
||||
let mountedSectionCount = $state(1);
|
||||
|
||||
function scheduleIdle(step: () => void) {
|
||||
const delay = isPerformanceMode() ? 64 : 32;
|
||||
const timeout = isPerformanceMode() ? 800 : 500;
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(step, { timeout });
|
||||
} else {
|
||||
setTimeout(step, delay);
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
mountedSectionCount = 1;
|
||||
if (activeSection !== "all") return;
|
||||
|
||||
let idx = 1;
|
||||
const step = () => {
|
||||
if (idx >= ALL_SETTINGS_SECTIONS.length) return;
|
||||
mountedSectionCount = ++idx;
|
||||
scheduleIdle(step);
|
||||
};
|
||||
scheduleIdle(step);
|
||||
});
|
||||
|
||||
const sectionsToShow = $derived.by((): SettingsSectionId[] => {
|
||||
if (activeSection === "all") {
|
||||
return ALL_SETTINGS_SECTIONS.slice(0, mountedSectionCount);
|
||||
}
|
||||
if (ALL_SETTINGS_SECTIONS.includes(activeSection as SettingsSectionId)) {
|
||||
return [activeSection as SettingsSectionId];
|
||||
}
|
||||
return ["general"];
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col divide-y divide-zinc-100 dark:divide-zinc-700">
|
||||
{#each sectionsToShow as section (section)}
|
||||
<LazyPanel
|
||||
loader={SECTION_LOADERS[section]}
|
||||
remountKey={section}
|
||||
props={{ section, ...rest }}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -1,772 +1,8 @@
|
||||
<script lang="ts">
|
||||
import Switch from "../../components/Switch.svelte"
|
||||
import Button from "../../components/Button.svelte"
|
||||
import Slider from "../../components/Slider.svelte"
|
||||
import Select from "@/interface/components/Select.svelte"
|
||||
import HotkeyInput from "@/interface/components/HotkeyInput.svelte"
|
||||
import SettingsBody from "./SettingsBody.svelte";
|
||||
import type { SettingsSectionSharedProps } from "./shared";
|
||||
|
||||
import browser from "webextension-polyfill"
|
||||
|
||||
import type { SettingsList } from "@/interface/types/SettingsProps"
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState.ts"
|
||||
import PickerSwatch from "@/interface/components/PickerSwatch.svelte"
|
||||
import SidebarAppearance from "@/interface/components/SidebarAppearance.svelte"
|
||||
import ConnectMobileApp from "@/interface/components/ConnectMobileApp.svelte"
|
||||
import CloudSettingsSync from "@/interface/components/CloudSettingsSync.svelte"
|
||||
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"
|
||||
import { onMount } from "svelte"
|
||||
|
||||
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 { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage"
|
||||
|
||||
const isEngage = isSeqtaEngageExperience();
|
||||
import type { BooleanSetting, StringSetting, NumberSetting, SelectSetting, ButtonSetting, HotkeySetting, ComponentSetting } from "@/plugins/core/types"
|
||||
|
||||
// Union type representing all possible settings
|
||||
type SettingType =
|
||||
(Omit<BooleanSetting, 'type'> & { type: 'boolean', id: string }) |
|
||||
(Omit<StringSetting, 'type'> & { type: 'string', id: string }) |
|
||||
(Omit<NumberSetting, 'type'> & { type: 'number', id: string }) |
|
||||
(Omit<SelectSetting<string>, 'type'> & {
|
||||
type: 'select',
|
||||
id: string,
|
||||
options: string[]
|
||||
}) |
|
||||
(Omit<ButtonSetting, 'type'> & {
|
||||
type: 'button',
|
||||
id: string
|
||||
}) |
|
||||
(Omit<HotkeySetting, 'type'> & {
|
||||
type: 'hotkey',
|
||||
id: string
|
||||
}) |
|
||||
(Omit<ComponentSetting, 'type'> & {
|
||||
type: 'component',
|
||||
id: string,
|
||||
component: any
|
||||
});
|
||||
|
||||
interface Plugin {
|
||||
pluginId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
beta?: boolean;
|
||||
settings: Record<string, SettingType>;
|
||||
}
|
||||
|
||||
const pluginSettings = getAllPluginSettings().filter(
|
||||
(plugin) => !(isSeqtaEngageExperience() && plugin.pluginId === "global-search"),
|
||||
) as Plugin[];
|
||||
const pluginSettingsValues = $state<Record<string, Record<string, any>>>({});
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => { cloudState = s; });
|
||||
return unsub;
|
||||
});
|
||||
|
||||
async function loadPluginSettings() {
|
||||
for (const plugin of pluginSettings) {
|
||||
if (Object.keys(plugin.settings).length === 0) continue;
|
||||
|
||||
const storageKey = `plugin.${plugin.pluginId}.settings`;
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
|
||||
pluginSettingsValues[plugin.pluginId] = stored[storageKey] || {};
|
||||
|
||||
for (const [key, setting] of Object.entries(plugin.settings)) {
|
||||
if (
|
||||
pluginSettingsValues[plugin.pluginId][key] === undefined &&
|
||||
setting.type !== 'button' &&
|
||||
setting.type !== 'component'
|
||||
) {
|
||||
pluginSettingsValues[plugin.pluginId][key] = setting.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function updatePluginSetting(pluginId: string, key: string, value: any) {
|
||||
const storageKey = `plugin.${pluginId}.settings`;
|
||||
|
||||
if (!pluginSettingsValues[pluginId]) {
|
||||
pluginSettingsValues[pluginId] = {};
|
||||
}
|
||||
pluginSettingsValues[pluginId][key] = value;
|
||||
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
const currentSettings = (stored[storageKey] || {}) as Record<string, any>;
|
||||
|
||||
currentSettings[key] = value;
|
||||
|
||||
await browser.storage.local.set({ [storageKey]: currentSettings });
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
void loadPluginSettings();
|
||||
});
|
||||
|
||||
const { showColourPicker, showFontPicker, showDisclaimer, showCloudPanel, activeSection = "general", searchQuery = "" } = $props<{
|
||||
showColourPicker: () => void;
|
||||
showFontPicker: () => void;
|
||||
showDisclaimer: (onConfirm: () => void, onCancel: () => void, title?: string, message?: string) => void;
|
||||
showCloudPanel: () => void;
|
||||
activeSection?: string;
|
||||
searchQuery?: string;
|
||||
}>();
|
||||
|
||||
/** Map each plugin into the settings sidebar category that fits its purpose. */
|
||||
const pluginSectionById: Record<string, string> = {
|
||||
"profile-picture": "account",
|
||||
"animated-background": "appearance",
|
||||
"background-music": "appearance",
|
||||
timetable: "timetable",
|
||||
timetableEdit: "timetable",
|
||||
"assessments-overview": "assessments",
|
||||
"assessments-average": "assessments",
|
||||
"grade-analytics": "assessments",
|
||||
"global-search": "features",
|
||||
"enhanced-navigation": "features",
|
||||
messageFolders: "features",
|
||||
notificationCollector: "features",
|
||||
};
|
||||
|
||||
const showsSection = (section: string) =>
|
||||
activeSection === "all" || activeSection === section;
|
||||
|
||||
const pluginBelongsInSection = (pluginId: string) =>
|
||||
activeSection === "all" ||
|
||||
(pluginSectionById[pluginId] ?? "features") === activeSection;
|
||||
|
||||
const matchesSearch = (...parts: Array<string | undefined>) => {
|
||||
const q = searchQuery.trim().toLowerCase();
|
||||
return !q || parts.some((part) => part?.toLowerCase().includes(q));
|
||||
};
|
||||
|
||||
const pluginHit = (plugin: Plugin) =>
|
||||
matchesSearch(plugin.name, plugin.description, ...Object.values(plugin.settings).flatMap((s) => [s.title, s.description]));
|
||||
|
||||
async function exportCloudSettingsJsonToFile() {
|
||||
const payload = await getSnapshotForUpload();
|
||||
const blob = new Blob([JSON.stringify(payload, null, 2)], {
|
||||
type: "application/json",
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `betterseqta-plus-settings-export-${new Date().toISOString().replace(/[:.]/g, "-")}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
let props: SettingsSectionSharedProps & { activeSection?: string } = $props();
|
||||
</script>
|
||||
|
||||
{#snippet Setting({ title, description, Component, props }: SettingsList) }
|
||||
{#if matchesSearch(title, description)}
|
||||
<div class="flex justify-between items-center px-5 py-5">
|
||||
<div class="pr-5">
|
||||
<h2 class="text-xl font-bold">{title}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{description}</p>
|
||||
</div>
|
||||
<div class="shrink-0">
|
||||
<Component {...props} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
<div class="flex flex-col divide-y divide-zinc-100 dark:divide-zinc-700">
|
||||
{#if showsSection("account")}
|
||||
{@render Setting({
|
||||
title: "Connect Mobile App",
|
||||
description: "Link your SEQTA session to DesQTA — the modern desktop and mobile app for SEQTA Learn",
|
||||
id: 0,
|
||||
Component: ConnectMobileApp,
|
||||
props: {}
|
||||
})}
|
||||
|
||||
{#if matchesSearch("BetterSEQTA Cloud", "Account & sync")}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">BetterSEQTA Cloud</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Account & sync</p>
|
||||
</div>
|
||||
<div>
|
||||
<CloudHeader alwaysShowUserName onClick={showCloudPanel} />
|
||||
</div>
|
||||
</div>
|
||||
{#if cloudState.isLoggedIn}
|
||||
<div class="px-3 pb-3">
|
||||
<CloudSettingsSync showDisclaimer={(onConfirm, onCancel) => showDisclaimer(onConfirm, onCancel, "Restore from cloud?", "This will replace your local settings with the cloud backup. Continue?")} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if showsSection("general")}
|
||||
{#each [
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "Edit Sidebar Layout",
|
||||
description: "Reorder pages on the sidebar",
|
||||
id: 5,
|
||||
Component: Button,
|
||||
props: {
|
||||
onClick: () => browser.runtime.sendMessage({ type: 'currentTab', info: 'EditSidebar' }),
|
||||
text: "Edit"
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Icon Only Sidebar",
|
||||
description: "Show only icons in the sidebar for a compact layout",
|
||||
id: 14,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.iconOnlySidebar ?? false,
|
||||
onChange: (isOn: boolean) => settingsState.iconOnlySidebar = isOn
|
||||
}
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: "Animations",
|
||||
description: "Enable animations on certain pages",
|
||||
id: 6,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.animations,
|
||||
onChange: (isOn: boolean) => settingsState.animations = isOn
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "12 Hour Time",
|
||||
description: "Prefer 12 hour time format for SEQTA",
|
||||
id: 9,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.timeFormat === "12",
|
||||
onChange: (isOn: boolean) => settingsState.timeFormat = isOn ? "12" : "24"
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Default Page",
|
||||
description: "Choose which page loads first when you open SEQTA",
|
||||
id: 10,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.defaultPage ?? "home",
|
||||
onChange: (value: string) => (settingsState.defaultPage = value),
|
||||
options: isEngage
|
||||
? [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
]
|
||||
: [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "welcome", label: "Welcome" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
],
|
||||
},
|
||||
},
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "News Feed Source",
|
||||
description: "Choose the sources for your news feed",
|
||||
id: 11,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.newsSource,
|
||||
onChange: (value: string) => settingsState.newsSource = value,
|
||||
options: [
|
||||
{ value: "australia", label: "Australia" },
|
||||
{ value: "usa", label: "USA" },
|
||||
{ value: "uk", label: "UK" },
|
||||
{ value: "taiwan", label: "Taiwan" },
|
||||
{ value: "hong_kong", label: "Hong Kong" },
|
||||
{ value: "panama", label: "Panama" },
|
||||
{ value: "canada", label: "Canada" },
|
||||
{ value: "singapore", label: "Singapore" },
|
||||
{ value: "japan", label: "Japan" },
|
||||
{ value: "netherlands", label: "Netherlands" },
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
] as option (option.id)}
|
||||
{@render Setting(option)}
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if showsSection("appearance")}
|
||||
{#each [
|
||||
{
|
||||
title: "Custom Theme Colour",
|
||||
description: "Customise the overall theme colour of SEQTA Learn",
|
||||
id: 4,
|
||||
Component: PickerSwatch,
|
||||
props: {
|
||||
onClick: showColourPicker
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Interface Font",
|
||||
description: "Choose the typeface used across SEQTA Learn",
|
||||
id: 16,
|
||||
Component: Button,
|
||||
props: {
|
||||
onClick: showFontPicker,
|
||||
text: "Change"
|
||||
}
|
||||
},
|
||||
] as option (option.id)}
|
||||
{@render Setting(option)}
|
||||
{/each}
|
||||
|
||||
{#if !isEngage && matchesSearch("Sidebar Style", "Item Size", "Corner Radius", "Active Indicator", "Sidebar Width", "Transparency Effects", "Blur Strength")}
|
||||
<div class="border-none">
|
||||
<SidebarAppearance />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if matchesSearch("Adaptive Theme Colour", "Soft Gradient", "Smooth colour transition")}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Adaptive Theme Colour</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Change the theme colour based on the current class (e.g. when viewing a course or assessments page)</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColour ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.adaptiveThemeColour = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#if $settingsState.adaptiveThemeColour}
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Soft Gradient</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Use a soft gradient instead of a solid colour when viewing a class</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeGradient ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.adaptiveThemeGradient = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Smooth colour transition</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Ease between class/subject colours when navigating instead of switching instantly</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColourTransition ?? true}
|
||||
onChange={(isOn: boolean) => settingsState.adaptiveThemeColourTransition = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if showsSection("general")}
|
||||
{#if matchesSearch("Home Page Assessments", "Include Past Assessments", "Maximum Subjects", "Maximum Assessments per Subject")}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Home Page Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Limit upcoming assessments shown on the home page by subject</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Include Past Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Show past-due assessments from the upcoming list, matching the Assessments page</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.homeUpcomingIncludePast ?? true}
|
||||
onChange={(isOn: boolean) => (settingsState.homeUpcomingIncludePast = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Subjects</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Number of subjects to include, ordered by soonest due date</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingSubjectsMax ?? 5)}
|
||||
onChange={(value: string) => (settingsState.homeUpcomingSubjectsMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "7", label: "7" },
|
||||
{ value: "10", label: "10" },
|
||||
{ value: "15", label: "15" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Assessments per Subject</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Assessments shown for each included subject</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingAssessmentsPerSubjectMax ?? 0)}
|
||||
onChange={(value: string) => (settingsState.homeUpcomingAssessmentsPerSubjectMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "1", label: "1" },
|
||||
{ value: "2", label: "2" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "10", label: "10" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#each pluginSettings as plugin (plugin.pluginId)}
|
||||
{#if pluginBelongsInSection(plugin.pluginId) && pluginHit(plugin)}
|
||||
<div class="border-none">
|
||||
<div class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40 {!(plugin as any).disableToggle && Object.keys(plugin.settings).length === 0 ? 'hidden' : ''}">
|
||||
<!-- Always show enable toggle if disableToggle is true -->
|
||||
{#if (plugin as any).disableToggle}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="flex gap-2 items-center text-xl font-bold">
|
||||
Enable {plugin.name}
|
||||
{#if plugin.beta}
|
||||
<span class="px-2 py-0.5 text-xs font-medium text-orange-800 bg-orange-100 rounded-full border border-orange-300/30 dark:bg-orange-900/30 dark:text-orange-300 dark:border-orange-900/30">
|
||||
Beta
|
||||
</span>
|
||||
{/if}
|
||||
</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{plugin.description}</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={pluginSettingsValues[plugin.pluginId]?.enabled ?? true}
|
||||
onChange={async (value) => {
|
||||
if (plugin.pluginId === 'assessments-average' && value === true) {
|
||||
showDisclaimer(
|
||||
async () => {
|
||||
await updatePluginSetting(plugin.pluginId, 'enabled', true);
|
||||
},
|
||||
() => {},
|
||||
"Assessment Averages Disclaimer",
|
||||
"This feature calculates a simple average of your assessment grades. It does not take into account:\n• Assessment weightings\n• Different grading scales\n• Other factors used in official reports\n\nThe displayed average may be inaccurate compared to your actual marks found in reports.\n\nDo you want to enable this feature?"
|
||||
);
|
||||
return;
|
||||
}
|
||||
await updatePluginSetting(plugin.pluginId, 'enabled', value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !((plugin as any).disableToggle) || (pluginSettingsValues[plugin.pluginId]?.enabled ?? true)}
|
||||
{#each Object.entries(plugin.settings) as [key, setting] (key)}
|
||||
<!-- Skip the 'enabled' setting and hide cloud-only settings when not signed in -->
|
||||
{#if key !== 'enabled' && !(key === 'useCloudPfp' && !cloudState.isLoggedIn)}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">{setting.title || key}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{setting.description || ''}</p>
|
||||
</div>
|
||||
<div>
|
||||
{#if setting.type === 'boolean'}
|
||||
<Switch
|
||||
state={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === 'number'}
|
||||
<div class="w-28 shrink-0">
|
||||
<Slider
|
||||
state={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
min={setting.min}
|
||||
max={setting.max}
|
||||
step={setting.step}
|
||||
/>
|
||||
</div>
|
||||
{:else if setting.type === 'string'}
|
||||
<input
|
||||
type="text"
|
||||
class="px-2 py-1 text-sm rounded-md dark:bg-[#38373D]/50 bg-[#DDDDDD] dark:text-white border-none"
|
||||
value={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
oninput={(e) => updatePluginSetting(plugin.pluginId, key, e.currentTarget.value)}
|
||||
/>
|
||||
{:else if setting.type === 'select'}
|
||||
<Select
|
||||
value={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
options={(setting.options as string[]).map(opt => ({
|
||||
value: opt,
|
||||
label: opt.charAt(0).toUpperCase() + opt.slice(1)
|
||||
}))}
|
||||
/>
|
||||
{:else if setting.type === 'button'}
|
||||
<Button
|
||||
onClick={() => setting.trigger?.()}
|
||||
text={setting.title}
|
||||
/>
|
||||
{:else if setting.type === 'hotkey'}
|
||||
<HotkeyInput
|
||||
value={pluginSettingsValues[plugin.pluginId]?.[key] ?? setting.default}
|
||||
onChange={(value) => updatePluginSetting(plugin.pluginId, key, value)}
|
||||
/>
|
||||
{:else if setting.type === 'component'}
|
||||
{#if setting.component}
|
||||
{@const Component = setting.component}
|
||||
<Component />
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{#if plugin.pluginId === 'global-search'}
|
||||
{@render Setting({
|
||||
title: "Theme of the Month",
|
||||
description: "Show the monthly featured theme popup when a new entry is available",
|
||||
id: 15,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: !($settingsState.themeOfTheMonthDisabled ?? false),
|
||||
onChange: (isOn: boolean) => settingsState.themeOfTheMonthDisabled = !isOn
|
||||
}
|
||||
})}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
{#if showsSection("advanced")}
|
||||
{@render Setting({
|
||||
title: "BetterSEQTA+",
|
||||
description: "Enables BetterSEQTA+ features",
|
||||
id: 12,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.onoff,
|
||||
onChange: (isOn: boolean) => settingsState.onoff = isOn
|
||||
}
|
||||
})}
|
||||
|
||||
{#if $settingsState.devMode && matchesSearch(
|
||||
"Developer Mode",
|
||||
"Verbose logging",
|
||||
"Delay loading screen",
|
||||
"Sensitive Hider",
|
||||
"Mock Notices",
|
||||
"Show Privacy Notification",
|
||||
"Show Theme of the Month",
|
||||
"Export cloud settings JSON",
|
||||
"API Base URL",
|
||||
"GitHub latest version override",
|
||||
)}
|
||||
<div class="flex-col p-1 my-1 bg-gradient-to-br from-white rounded-xl border shadow-sm to-zinc-100 border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40">
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Developer Mode</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Enables developer mode, allowing you to test new features and changes.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch state={$settingsState.devMode} onChange={(isOn: boolean) => settingsState.devMode = isOn} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Verbose logging</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Show diagnostic console output (indexer, theme manager, timetable colour patch, etc.)</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.verboseLogging ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.verboseLogging = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Delay loading screen</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Keep the loading overlay visible for 5 extra seconds so you can preview canvas variants.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.devDelayLoadingScreen ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.devDelayLoadingScreen = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Sensitive Hider</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Replace sensitive content with mock data</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.hideSensitiveContent ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.hideSensitiveContent = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Mock Notices</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Use fake notice data on homepage instead of real data</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.mockNotices ?? false}
|
||||
onChange={(isOn: boolean) => settingsState.mockNotices = isOn}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Privacy Notification</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Show the privacy notification popup on next page load</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
settingsState.privacyStatementShown = false;
|
||||
settingsState.privacyStatementLastUpdated = undefined;
|
||||
closeExtensionPopup();
|
||||
// Small delay to ensure popup is closed before showing notification
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
await showPrivacyNotification();
|
||||
}}
|
||||
text="Show Now"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Theme of the Month</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">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-5 py-4">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Export cloud settings JSON</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Download the same payload as cloud sync (OAuth tokens stripped). For debugging and server testing.</p>
|
||||
</div>
|
||||
<div>
|
||||
<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-xl font-bold">API Base URL (session only)</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">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 class="flex flex-col gap-2 px-4 py-3">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold">GitHub latest version override</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Pretend a newer GitHub release exists to test the update badge. Only applies when dev mode is on.</p>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="e.g. 9.9.9"
|
||||
value={$settingsState.devGhReleaseVersionOverride ?? ""}
|
||||
oninput={(e) => {
|
||||
settingsState.devGhReleaseVersionOverride = e.currentTarget.value;
|
||||
}}
|
||||
class="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"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
<SettingsBody {...props} />
|
||||
@@ -0,0 +1,101 @@
|
||||
import browser from "webextension-polyfill";
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage";
|
||||
import type {
|
||||
BooleanSetting,
|
||||
ButtonSetting,
|
||||
ComponentSetting,
|
||||
HotkeySetting,
|
||||
NumberSetting,
|
||||
SelectSetting,
|
||||
StringSetting,
|
||||
} from "@/plugins/core/types";
|
||||
|
||||
type SettingType =
|
||||
| (Omit<BooleanSetting, "type"> & { type: "boolean"; id: string })
|
||||
| (Omit<StringSetting, "type"> & { type: "string"; id: string })
|
||||
| (Omit<NumberSetting, "type"> & { type: "number"; id: string })
|
||||
| (Omit<SelectSetting<string>, "type"> & {
|
||||
type: "select";
|
||||
id: string;
|
||||
options: string[];
|
||||
})
|
||||
| (Omit<ButtonSetting, "type"> & { type: "button"; id: string })
|
||||
| (Omit<HotkeySetting, "type"> & { type: "hotkey"; id: string })
|
||||
| (Omit<ComponentSetting, "type"> & {
|
||||
type: "component";
|
||||
id: string;
|
||||
component: unknown;
|
||||
});
|
||||
|
||||
export type PluginSettingsEntry = {
|
||||
pluginId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
beta?: boolean;
|
||||
settings: Record<string, SettingType>;
|
||||
disableToggle?: boolean;
|
||||
};
|
||||
|
||||
let loadPromise: Promise<void> | null = null;
|
||||
|
||||
class PluginSettingsStore {
|
||||
loaded = $state(false);
|
||||
loading = $state(false);
|
||||
plugins = $state<PluginSettingsEntry[]>([]);
|
||||
values = $state<Record<string, Record<string, unknown>>>({});
|
||||
|
||||
ensureLoaded(): Promise<void> {
|
||||
if (this.loaded) return Promise.resolve();
|
||||
if (loadPromise) return loadPromise;
|
||||
|
||||
this.loading = true;
|
||||
loadPromise = this.load().finally(() => {
|
||||
this.loading = false;
|
||||
this.loaded = true;
|
||||
});
|
||||
return loadPromise;
|
||||
}
|
||||
|
||||
private async load(): Promise<void> {
|
||||
const { getAllPluginSettings } = await import("@/plugins");
|
||||
this.plugins = getAllPluginSettings().filter(
|
||||
(plugin) =>
|
||||
!(isSeqtaEngageExperience() && plugin.pluginId === "global-search"),
|
||||
) as PluginSettingsEntry[];
|
||||
|
||||
for (const plugin of this.plugins) {
|
||||
if (Object.keys(plugin.settings).length === 0) continue;
|
||||
|
||||
const storageKey = `plugin.${plugin.pluginId}.settings`;
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
this.values[plugin.pluginId] = (stored[storageKey] as Record<string, unknown>) || {};
|
||||
|
||||
for (const [key, setting] of Object.entries(plugin.settings)) {
|
||||
if (
|
||||
this.values[plugin.pluginId][key] === undefined &&
|
||||
setting.type !== "button" &&
|
||||
setting.type !== "component"
|
||||
) {
|
||||
this.values[plugin.pluginId][key] = setting.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async update(pluginId: string, key: string, value: unknown): Promise<void> {
|
||||
await this.ensureLoaded();
|
||||
|
||||
if (!this.values[pluginId]) {
|
||||
this.values[pluginId] = {};
|
||||
}
|
||||
this.values[pluginId][key] = value;
|
||||
|
||||
const storageKey = `plugin.${pluginId}.settings`;
|
||||
const stored = await browser.storage.local.get(storageKey);
|
||||
const currentSettings = (stored[storageKey] || {}) as Record<string, unknown>;
|
||||
currentSettings[key] = value;
|
||||
await browser.storage.local.set({ [storageKey]: currentSettings });
|
||||
}
|
||||
}
|
||||
|
||||
export const pluginSettingsStore = new PluginSettingsStore();
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Component } from "svelte";
|
||||
import type { SettingsSectionId } from "./shared";
|
||||
|
||||
export const SECTION_LOADERS: Record<
|
||||
SettingsSectionId,
|
||||
() => Promise<{ default: Component }>
|
||||
> = {
|
||||
account: () => import("./sections/account.svelte"),
|
||||
general: () => import("./sections/generalOptions.svelte"),
|
||||
appearance: () => import("./sections/appearance.svelte"),
|
||||
timetable: () => import("./sections/plugins.svelte"),
|
||||
assessments: () => import("./sections/plugins.svelte"),
|
||||
features: () => import("./sections/plugins.svelte"),
|
||||
advanced: () => import("./sections/advanced.svelte"),
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import ConnectMobileApp from "@/interface/components/ConnectMobileApp.svelte";
|
||||
import CloudSettingsSync from "@/interface/components/CloudSettingsSync.svelte";
|
||||
import CloudHeader from "@/interface/components/store/CloudHeader.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import PluginSettingsBlocks from "../PluginSettingsBlocks.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let {
|
||||
showDisclaimer,
|
||||
showCloudPanel,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps = $props();
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
$effect(() => {
|
||||
const unsub = cloudAuth.subscribe((s) => {
|
||||
cloudState = s;
|
||||
});
|
||||
return unsub;
|
||||
});
|
||||
|
||||
const founderBadgeSetting = {
|
||||
title: "Titlebar founder badge",
|
||||
description: "Show your Cloud founder badge in the SEQTA titlebar",
|
||||
} as const;
|
||||
|
||||
const showCloudCardHeader = $derived(
|
||||
matchesSearch(searchQuery, "BetterSEQTA Cloud", "Account & sync"),
|
||||
);
|
||||
|
||||
const showFounderBadgeSetting = $derived(
|
||||
matchesSearch(
|
||||
searchQuery,
|
||||
founderBadgeSetting.title,
|
||||
founderBadgeSetting.description,
|
||||
"founder badge",
|
||||
"titlebar",
|
||||
"founder",
|
||||
),
|
||||
);
|
||||
|
||||
const showCloudAccountCard = $derived(showCloudCardHeader || showFounderBadgeSetting);
|
||||
</script>
|
||||
|
||||
<SettingRow
|
||||
title="Connect Mobile App"
|
||||
description="Link your SEQTA session to DesQTA — the modern desktop and mobile app for SEQTA Learn"
|
||||
id={0}
|
||||
Component={ConnectMobileApp}
|
||||
{searchQuery}
|
||||
props={{}}
|
||||
/>
|
||||
|
||||
{#if showCloudAccountCard}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
{#if showCloudCardHeader}
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">BetterSEQTA Cloud</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">Account & sync</p>
|
||||
</div>
|
||||
<div>
|
||||
<CloudHeader compact alwaysShowUserName onClick={showCloudPanel} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if cloudState.isLoggedIn}
|
||||
<div class="px-3 pb-3" class:pt-3={!showCloudCardHeader}>
|
||||
{#if showCloudCardHeader}
|
||||
<CloudSettingsSync
|
||||
showDisclaimer={(onConfirm, onCancel) =>
|
||||
showDisclaimer(
|
||||
onConfirm,
|
||||
onCancel,
|
||||
"Restore from cloud?",
|
||||
"This will replace your local settings with the cloud backup. Continue?",
|
||||
)}
|
||||
/>
|
||||
{/if}
|
||||
{#if showFounderBadgeSetting}
|
||||
<SettingRow
|
||||
title={founderBadgeSetting.title}
|
||||
description={founderBadgeSetting.description}
|
||||
id={17}
|
||||
Component={Switch}
|
||||
{searchQuery}
|
||||
props={{
|
||||
state: $settingsState.showTitlebarFounderBadge !== false,
|
||||
onChange: (isOn: boolean) => (settingsState.showTitlebarFounderBadge = isOn),
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if showFounderBadgeSetting}
|
||||
<div class="px-5 pb-4 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
Sign in to Cloud first.
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<PluginSettingsBlocks section="account" {showDisclaimer} {searchQuery} />
|
||||
@@ -0,0 +1,246 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
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, PRODUCTION_API_BASE, setApiBase } from "@/seqta/utils/DevApiBase";
|
||||
|
||||
const isExtensionDevBuild = import.meta.env.DEV;
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let { searchQuery = "" }: SettingsSectionSharedProps = $props();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
async function exportCloudSettingsJsonToFile() {
|
||||
const payload = await getSnapshotForUpload();
|
||||
const blob = new Blob([JSON.stringify(payload, null, 2)], {
|
||||
type: "application/json",
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `betterseqta-plus-settings-export-${new Date().toISOString().replace(/[:.]/g, "-")}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $settingsState.devMode && matchesSearch(
|
||||
searchQuery,
|
||||
"Developer Mode",
|
||||
"Verbose logging",
|
||||
"Delay loading screen",
|
||||
"Sensitive Hider",
|
||||
"Mock Notices",
|
||||
"Show Privacy Notification",
|
||||
"Show Theme of the Month",
|
||||
"Export cloud settings JSON",
|
||||
"API Base URL",
|
||||
"GitHub latest version override",
|
||||
)}
|
||||
<div
|
||||
class="flex-col p-1 my-1 bg-gradient-to-br from-white rounded-xl border shadow-sm to-zinc-100 border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Developer Mode</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Enables developer mode, allowing you to test new features and changes.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.devMode}
|
||||
onChange={(isOn: boolean) => (settingsState.devMode = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Verbose logging</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Show diagnostic console output (indexer, theme manager, timetable colour patch, etc.)
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.verboseLogging ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.verboseLogging = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Delay loading screen</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Keep the loading overlay visible for 5 extra seconds so you can preview canvas variants.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.devDelayLoadingScreen ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.devDelayLoadingScreen = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Sensitive Hider</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Replace sensitive content with mock data
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.hideSensitiveContent ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.hideSensitiveContent = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Mock Notices</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Use fake notice data on homepage instead of real data
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.mockNotices ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.mockNotices = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Show Privacy Notification</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Show the privacy notification popup on next page load
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
settingsState.privacyStatementShown = false;
|
||||
settingsState.privacyStatementLastUpdated = undefined;
|
||||
closeExtensionPopup();
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
await showPrivacyNotification();
|
||||
}}
|
||||
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">Show Theme of the Month</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
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>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Download the same payload as cloud sync (OAuth tokens stripped). For debugging and server
|
||||
testing.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<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>
|
||||
{#if isExtensionDevBuild}
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Extension dev builds always use production ({PRODUCTION_API_BASE}) for the theme store,
|
||||
community submit, and related APIs. Build a release package to test a staging host override.
|
||||
</p>
|
||||
{:else}
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
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}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if !isExtensionDevBuild}
|
||||
<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>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div>
|
||||
<h2 class="text-sm font-bold">GitHub latest version override</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Pretend a newer GitHub release exists to test the update badge. Only applies when dev mode
|
||||
is on.
|
||||
</p>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="e.g. 9.9.9"
|
||||
value={$settingsState.devGhReleaseVersionOverride ?? ""}
|
||||
oninput={(e) => {
|
||||
settingsState.devGhReleaseVersionOverride = e.currentTarget.value;
|
||||
}}
|
||||
class="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"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,105 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import PickerSwatch from "@/interface/components/PickerSwatch.svelte";
|
||||
import SidebarAppearance from "@/interface/components/SidebarAppearance.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import PluginSettingsBlocks from "../PluginSettingsBlocks.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage";
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let {
|
||||
showColourPicker,
|
||||
showFontPicker,
|
||||
showDisclaimer,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps = $props();
|
||||
|
||||
const isEngage = isSeqtaEngageExperience();
|
||||
</script>
|
||||
|
||||
{#each [
|
||||
{
|
||||
title: "Custom Theme Colour",
|
||||
description: "Customise the overall theme colour of SEQTA Learn",
|
||||
id: 4,
|
||||
Component: PickerSwatch,
|
||||
props: { onClick: showColourPicker },
|
||||
},
|
||||
{
|
||||
title: "Interface Font",
|
||||
description: "Choose the typeface used across SEQTA Learn",
|
||||
id: 16,
|
||||
Component: Button,
|
||||
props: { onClick: showFontPicker, text: "Change" },
|
||||
},
|
||||
] as option (option.id)}
|
||||
<SettingRow {...option} {searchQuery} />
|
||||
{/each}
|
||||
|
||||
{#if !isEngage && matchesSearch(searchQuery, "Sidebar Style", "Item Size", "Corner Radius", "Active Indicator", "Sidebar Position", "Sidebar Width", "Transparency Effects", "Blur Strength")}
|
||||
<div class="border-none">
|
||||
<SidebarAppearance />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if matchesSearch(searchQuery, "Adaptive Theme Colour", "Soft Gradient", "Smooth colour transition")}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Adaptive Theme Colour</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Change the theme colour based on the current class (e.g. when viewing a course or
|
||||
assessments page)
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColour ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.adaptiveThemeColour = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#if $settingsState.adaptiveThemeColour}
|
||||
<div
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Soft Gradient</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Use a soft gradient instead of a solid colour when viewing a class
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeGradient ?? false}
|
||||
onChange={(isOn: boolean) => (settingsState.adaptiveThemeGradient = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Smooth colour transition</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Ease between class/subject colours when navigating instead of switching instantly
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.adaptiveThemeColourTransition ?? true}
|
||||
onChange={(isOn: boolean) => (settingsState.adaptiveThemeColourTransition = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<PluginSettingsBlocks section="appearance" {showDisclaimer} {searchQuery} />
|
||||
@@ -0,0 +1,254 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import Select from "@/interface/components/Select.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isSeqtaEngageExperience } from "@/seqta/utils/isSeqtaEngage";
|
||||
import {
|
||||
PERFORMANCE_HEAVY_PLUGINS,
|
||||
setPerformanceModePluginOverride,
|
||||
} from "@/seqta/utils/performanceMode";
|
||||
import browser from "webextension-polyfill";
|
||||
import { matchesSearch, type SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let { searchQuery = "" }: SettingsSectionSharedProps = $props();
|
||||
|
||||
const isEngage = isSeqtaEngageExperience();
|
||||
|
||||
const generalOptions = $derived([
|
||||
{
|
||||
title: "BetterSEQTA+",
|
||||
description: "Enables BetterSEQTA+ features",
|
||||
id: 12,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.onoff,
|
||||
onChange: (isOn: boolean) => (settingsState.onoff = isOn),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Performance Mode",
|
||||
description:
|
||||
"Pauses heavy plugins, disables blur, and uses shorter smooth animations while SEQTA is open",
|
||||
id: 0,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.performanceMode ?? false,
|
||||
onChange: (isOn: boolean) => (settingsState.performanceMode = isOn),
|
||||
},
|
||||
},
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "Edit Sidebar Layout",
|
||||
description: "Reorder pages on the sidebar",
|
||||
id: 5,
|
||||
Component: Button,
|
||||
props: {
|
||||
onClick: () =>
|
||||
browser.runtime.sendMessage({ type: "currentTab", info: "EditSidebar" }),
|
||||
text: "Edit",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Icon Only Sidebar",
|
||||
description: "Show only icons in the sidebar for a compact layout",
|
||||
id: 14,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.iconOnlySidebar ?? false,
|
||||
onChange: (isOn: boolean) => (settingsState.iconOnlySidebar = isOn),
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: "Animations",
|
||||
description: "Enable animations on certain pages",
|
||||
id: 6,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.animations,
|
||||
onChange: (isOn: boolean) => (settingsState.animations = isOn),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "12 Hour Time",
|
||||
description: "Prefer 12 hour time format for SEQTA",
|
||||
id: 9,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.timeFormat === "12",
|
||||
onChange: (isOn: boolean) => (settingsState.timeFormat = isOn ? "12" : "24"),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Default Page",
|
||||
description: "Choose which page loads first when you open SEQTA",
|
||||
id: 10,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.defaultPage ?? "home",
|
||||
onChange: (value: string) => (settingsState.defaultPage = value),
|
||||
options: isEngage
|
||||
? [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
]
|
||||
: [
|
||||
{ value: "home", label: "Home" },
|
||||
{ value: "dashboard", label: "Dashboard" },
|
||||
{ value: "timetable", label: "Timetable" },
|
||||
{ value: "welcome", label: "Welcome" },
|
||||
{ value: "messages", label: "Messages" },
|
||||
{ value: "documents", label: "Documents" },
|
||||
{ value: "reports", label: "Reports" },
|
||||
],
|
||||
},
|
||||
},
|
||||
...(!isEngage
|
||||
? [
|
||||
{
|
||||
title: "News Feed Source",
|
||||
description: "Choose the sources for your news feed",
|
||||
id: 11,
|
||||
Component: Select,
|
||||
props: {
|
||||
value: $settingsState.newsSource,
|
||||
onChange: (value: string) => (settingsState.newsSource = value),
|
||||
options: [
|
||||
{ value: "australia", label: "Australia" },
|
||||
{ value: "usa", label: "USA" },
|
||||
{ value: "uk", label: "UK" },
|
||||
{ value: "taiwan", label: "Taiwan" },
|
||||
{ value: "hong_kong", label: "Hong Kong" },
|
||||
{ value: "panama", label: "Panama" },
|
||||
{ value: "canada", label: "Canada" },
|
||||
{ value: "singapore", label: "Singapore" },
|
||||
{ value: "japan", label: "Japan" },
|
||||
{ value: "netherlands", label: "Netherlands" },
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]);
|
||||
</script>
|
||||
|
||||
{#each generalOptions as option (option.id)}
|
||||
<SettingRow {...option} {searchQuery} />
|
||||
{#if option.id === 0 && $settingsState.performanceMode && matchesSearch(searchQuery, "Performance Mode", "Global Search", "Assessment Averages", "enable anyway", "paused")}
|
||||
<div class="border-none -mt-px">
|
||||
<div
|
||||
class="mx-5 mb-4 rounded-xl border border-zinc-200/80 bg-zinc-50/80 px-4 py-3 dark:border-zinc-700/60 dark:bg-zinc-900/40"
|
||||
>
|
||||
<p class="mb-3 text-sm font-medium text-zinc-500 dark:text-zinc-400">
|
||||
Paused for performance — enable anyway:
|
||||
</p>
|
||||
<div class="space-y-3">
|
||||
{#each PERFORMANCE_HEAVY_PLUGINS as heavy (heavy.id)}
|
||||
<div class="flex justify-between items-center gap-4">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-zinc-800 dark:text-zinc-100">{heavy.name}</p>
|
||||
<p class="text-xs text-zinc-500 dark:text-zinc-400">{heavy.description}</p>
|
||||
</div>
|
||||
<Switch
|
||||
state={$settingsState.performanceModePluginOverrides?.[heavy.id] === true}
|
||||
onChange={(forceOn: boolean) => setPerformanceModePluginOverride(heavy.id, forceOn)}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
{#if matchesSearch(
|
||||
searchQuery,
|
||||
"Home Page Assessments",
|
||||
"Include Past Assessments",
|
||||
"Maximum Subjects",
|
||||
"Maximum Assessments per Subject",
|
||||
)}
|
||||
<div class="border-none">
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Home Page Assessments</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Limit upcoming assessments shown on the home page by subject
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Include Past Assessments</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Show past-due assessments from the upcoming list, matching the Assessments page
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
state={$settingsState.homeUpcomingIncludePast ?? true}
|
||||
onChange={(isOn: boolean) => (settingsState.homeUpcomingIncludePast = isOn)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Maximum Subjects</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Number of subjects to include, ordered by soonest due date
|
||||
</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingSubjectsMax ?? 5)}
|
||||
onChange={(value: string) => (settingsState.homeUpcomingSubjectsMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "7", label: "7" },
|
||||
{ value: "10", label: "10" },
|
||||
{ value: "15", label: "15" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">Maximum Assessments per Subject</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Assessments shown for each included subject
|
||||
</p>
|
||||
</div>
|
||||
<Select
|
||||
value={String($settingsState.homeUpcomingAssessmentsPerSubjectMax ?? 0)}
|
||||
onChange={(value: string) =>
|
||||
(settingsState.homeUpcomingAssessmentsPerSubjectMax = Number(value))}
|
||||
options={[
|
||||
{ value: "0", label: "All" },
|
||||
{ value: "1", label: "1" },
|
||||
{ value: "2", label: "2" },
|
||||
{ value: "3", label: "3" },
|
||||
{ value: "5", label: "5" },
|
||||
{ value: "10", label: "10" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,12 @@
|
||||
<script lang="ts">
|
||||
import PluginSettingsBlocks from "../PluginSettingsBlocks.svelte";
|
||||
import type { SettingsSectionId, SettingsSectionSharedProps } from "../shared";
|
||||
|
||||
let {
|
||||
section,
|
||||
showDisclaimer,
|
||||
searchQuery = "",
|
||||
}: SettingsSectionSharedProps & { section: SettingsSectionId } = $props();
|
||||
</script>
|
||||
|
||||
<PluginSettingsBlocks {section} {showDisclaimer} {searchQuery} />
|
||||
@@ -0,0 +1,47 @@
|
||||
export const ALL_SETTINGS_SECTIONS = [
|
||||
"account",
|
||||
"general",
|
||||
"appearance",
|
||||
"timetable",
|
||||
"assessments",
|
||||
"features",
|
||||
"advanced",
|
||||
] as const;
|
||||
|
||||
export type SettingsSectionId = (typeof ALL_SETTINGS_SECTIONS)[number];
|
||||
|
||||
export type SettingsSectionSharedProps = {
|
||||
showColourPicker: () => void;
|
||||
showFontPicker: () => void;
|
||||
showDisclaimer: (
|
||||
onConfirm: () => void,
|
||||
onCancel: () => void,
|
||||
title?: string,
|
||||
message?: string,
|
||||
) => void;
|
||||
showCloudPanel: () => void;
|
||||
searchQuery?: string;
|
||||
};
|
||||
|
||||
export function matchesSearch(
|
||||
searchQuery: string,
|
||||
...parts: Array<string | undefined>
|
||||
): boolean {
|
||||
const q = searchQuery.trim().toLowerCase();
|
||||
return !q || parts.some((part) => part?.toLowerCase().includes(q));
|
||||
}
|
||||
|
||||
export const PLUGIN_SECTION_BY_ID: Record<string, SettingsSectionId> = {
|
||||
"profile-picture": "account",
|
||||
"animated-background": "appearance",
|
||||
"background-music": "appearance",
|
||||
timetable: "timetable",
|
||||
timetableEdit: "timetable",
|
||||
"assessments-overview": "assessments",
|
||||
"assessments-average": "assessments",
|
||||
"grade-analytics": "assessments",
|
||||
"global-search": "features",
|
||||
"enhanced-navigation": "features",
|
||||
messageFolders: "features",
|
||||
notificationCollector: "features",
|
||||
};
|
||||
@@ -2,9 +2,11 @@
|
||||
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" } = $props<{
|
||||
let { section = "all", listMode = "all" } = $props<{
|
||||
section?: "all" | "themes" | "backgrounds";
|
||||
listMode?: ThemeListMode;
|
||||
}>();
|
||||
|
||||
// backgrounds
|
||||
@@ -29,19 +31,36 @@
|
||||
: clearTheme ? 'Clear Background' : 'No Background Selected'}
|
||||
</button>
|
||||
{/if}
|
||||
<div class="relative w-full">
|
||||
<button
|
||||
onclick={() => editMode = !editMode}
|
||||
class="absolute top-0 right-0 z-10 px-2 h-8 text-lg rounded-xl bg-zinc-100 dark:bg-zinc-700">
|
||||
<span class="mr-2">{editMode ? 'Done' : 'Edit'}</span>
|
||||
<span class="font-IconFamily">{editMode ? '\ue9e4' : '\uec38'}</span>
|
||||
</button>
|
||||
<div class="w-full">
|
||||
{#if showThemes || showBackgrounds}
|
||||
<div class="mb-3 flex justify-end">
|
||||
<button
|
||||
onclick={() => editMode = !editMode}
|
||||
class="inline-flex h-8 items-center rounded-xl bg-zinc-100 px-3 text-lg dark:bg-zinc-700">
|
||||
<span class="mr-2">{editMode ? 'Done' : 'Remove'}</span>
|
||||
<span class="font-IconFamily">{editMode ? '\ue9e4' : '\uec38'}</span>
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if showBackgrounds}
|
||||
<BackgroundSelector isEditMode={editMode} bind:selectedBackground={selectedBackground} bind:selectNoBackground={selectNoBackground} />
|
||||
{/if}
|
||||
{#if showThemes}
|
||||
<ThemeSelector isEditMode={editMode} showNavigation={section === "all"} />
|
||||
{#if listMode === "custom"}
|
||||
<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"
|
||||
onclick={() =>
|
||||
void import("@/seqta/utils/launchPageThemeBuilder").then(({ launchPageThemeBuilder }) =>
|
||||
launchPageThemeBuilder(),
|
||||
)}
|
||||
>
|
||||
<span class="font-IconFamily text-lg" aria-hidden="true"></span>
|
||||
Open theme builder
|
||||
</button>
|
||||
{/if}
|
||||
<ThemeSelector isEditMode={editMode} showNavigation={section === "all"} {listMode} />
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import Backgrounds from '../components/store/Backgrounds.svelte'
|
||||
import { cloudAuth } from '@/seqta/utils/CloudAuth'
|
||||
import SignInToFavoriteModal from '../components/SignInToFavoriteModal.svelte'
|
||||
import { getStoreInstalledThemeIds } from '@/interface/utils/themeListFilters'
|
||||
import { consumePendingHighlightThemeId } from '@/seqta/utils/openThemeStoreWithHighlight'
|
||||
|
||||
const themeManager = ThemeManager.getInstance();
|
||||
@@ -53,6 +54,8 @@
|
||||
let loading = $state(true);
|
||||
let displayTheme = $state<Theme | null>(null);
|
||||
let currentThemes = $state<string[]>([]);
|
||||
let selectedThemeId = $state('');
|
||||
let installedThemeColors = $state<Record<string, string>>({});
|
||||
|
||||
let error = $state<string | null>(null);
|
||||
let fetchAttempt = $state(0);
|
||||
@@ -73,7 +76,13 @@
|
||||
|
||||
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 && theme.installedFromStore === true)
|
||||
.map((theme) => [theme.id, theme.defaultColour]),
|
||||
);
|
||||
};
|
||||
|
||||
const setDisplayTheme = (theme: Theme | null) => {
|
||||
@@ -174,15 +183,24 @@
|
||||
// On mount
|
||||
onMount(async () => {
|
||||
window.addEventListener('bsplus:highlight-theme', onHighlightThemeEvent);
|
||||
themeUpdates.addListener(fetchCurrentThemes);
|
||||
|
||||
await fetchThemes();
|
||||
await fetchCurrentThemes();
|
||||
|
||||
const pending = consumePendingHighlightThemeId();
|
||||
if (pending) focusThemeById(pending);
|
||||
const load = async () => {
|
||||
await fetchThemes();
|
||||
await fetchCurrentThemes();
|
||||
const pending = consumePendingHighlightThemeId();
|
||||
if (pending) focusThemeById(pending);
|
||||
};
|
||||
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
requestIdleCallback(() => void load(), { timeout: 2500 });
|
||||
} else {
|
||||
void load();
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('bsplus:highlight-theme', onHighlightThemeEvent);
|
||||
themeUpdates.removeListener(fetchCurrentThemes);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -219,6 +237,13 @@
|
||||
await fetchCurrentThemes();
|
||||
}
|
||||
|
||||
async function applyThemeFromStore(themeId: string) {
|
||||
await themeManager.setTheme(themeId);
|
||||
selectedThemeId = themeId;
|
||||
themeUpdates.triggerUpdate();
|
||||
void browser.runtime.sendMessage({ type: 'cloudSettingsRequestDebouncedUpload' }).catch(() => {});
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
loadBackground();
|
||||
selectedBackground
|
||||
@@ -287,6 +312,7 @@
|
||||
{toggleFavorite}
|
||||
isLoggedIn={cloudLoggedIn}
|
||||
onRequestSignIn={() => (showSignInOverlay = true)}
|
||||
installedThemeIds={currentThemes}
|
||||
/>
|
||||
|
||||
{#if displayTheme}
|
||||
@@ -300,6 +326,8 @@
|
||||
{toggleFavorite}
|
||||
isLoggedIn={cloudLoggedIn}
|
||||
onRequestSignIn={() => (showSignInOverlay = true)}
|
||||
{selectedThemeId}
|
||||
{installedThemeColors}
|
||||
onInstall={async (themeId: string) => {
|
||||
if (displayTheme) await installThemeFromStore(themeId, displayTheme);
|
||||
}}
|
||||
@@ -307,6 +335,9 @@
|
||||
console.debug('deleting theme', themeId);
|
||||
await removeThemeFromStore(themeId);
|
||||
}}
|
||||
onApply={async (themeId: string) => {
|
||||
await applyThemeFromStore(themeId);
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
{:else if activeTab === 'backgrounds'}
|
||||
|
||||
@@ -21,14 +21,28 @@
|
||||
handleImageUpload,
|
||||
handleRemoveImage,
|
||||
handleImageVariableChange,
|
||||
handleCoverImageUpload
|
||||
} from '../utils/themeImageHandlers';
|
||||
import { ThemeManager } from '@/plugins/built-in/themes/theme-manager'
|
||||
import { themeUpdates } from '../hooks/ThemeUpdates'
|
||||
import { CloseThemeCreator } from '@/plugins/built-in/themes/ThemeCreator'
|
||||
import ThemeBlobImage from '@/interface/components/themes/ThemeBlobImage.svelte'
|
||||
import { submitLocalThemeToCommunity } from '@/seqta/utils/customThemes/submitLocalTheme'
|
||||
import { formatCustomThemeApiError } from '@/seqta/utils/customThemes/apiErrors'
|
||||
import { cloudAuth } from '@/seqta/utils/CloudAuth'
|
||||
import LucideMoon from '@/interface/components/icons/LucideMoon.svelte'
|
||||
import LucideSun from '@/interface/components/icons/LucideSun.svelte'
|
||||
import SidebarAppearance from '@/interface/components/SidebarAppearance.svelte'
|
||||
import { FONT_PRESETS, DEFAULT_FONT_ID } from '@/seqta/ui/fonts/presets'
|
||||
import { applySelectedFont, ensureFontPickerFontsLoaded } from '@/seqta/ui/fonts/Manager'
|
||||
import {
|
||||
applySidebarSettings,
|
||||
defaultThemeCreatorMeta,
|
||||
mergeThemeWithCreatorMeta,
|
||||
snapshotSidebarSettings,
|
||||
type ThemeCreatorSidebarMeta,
|
||||
} from '@/interface/utils/themeCreatorMeta'
|
||||
import { ensureThemeCoverImage } from '@/interface/utils/themePlaceholderCover'
|
||||
import ThemeBlobImage from '@/interface/components/themes/ThemeBlobImage.svelte'
|
||||
import type { ThemeCreatorMeta } from '@/types/CustomThemes'
|
||||
|
||||
const { themeID } = $props<{ themeID: string }>()
|
||||
const themeManager = ThemeManager.getInstance();
|
||||
@@ -52,7 +66,73 @@
|
||||
let closedAccordions = $state<string[]>([])
|
||||
let themeLoaded = $state(false);
|
||||
let codeEditorFullscreen = $state(false);
|
||||
|
||||
let communityBusy = $state(false);
|
||||
let communityError = $state<string | null>(null);
|
||||
let cloudLoggedIn = $state(cloudAuth.state.isLoggedIn);
|
||||
let panelDark = $state(Boolean(settingsState.DarkMode));
|
||||
let creatorMeta = $state<ThemeCreatorMeta>(defaultThemeCreatorMeta());
|
||||
let originalSidebar = $state<ThemeCreatorSidebarMeta | null>(null);
|
||||
let originalFontId = $state<string | null>(null);
|
||||
/** When true, generated font/background CSS is merged for live preview and save. */
|
||||
let composeVisuals = $state(false);
|
||||
|
||||
const previewTheme = $derived.by(() => {
|
||||
if (!themeLoaded) return null;
|
||||
if (composeVisuals || theme.creatorMeta || creatorMeta.pageBackgroundImageId) {
|
||||
return mergeThemeWithCreatorMeta(theme, creatorMeta);
|
||||
}
|
||||
return { ...theme, creatorMeta };
|
||||
});
|
||||
|
||||
function touchVisuals() {
|
||||
if (!composeVisuals && !theme.creatorMeta && !creatorMeta.userCustomCss.trim()) {
|
||||
creatorMeta = { ...creatorMeta, userCustomCss: theme.CustomCSS };
|
||||
}
|
||||
composeVisuals = true;
|
||||
}
|
||||
|
||||
function imageUsage(imageId: string): 'decorative' | 'page-background' | 'cover' {
|
||||
if (creatorMeta.pageBackgroundImageId === imageId) return 'page-background';
|
||||
const image = theme.CustomImages.find((item) => item.id === imageId);
|
||||
if (image && theme.coverImage === image.blob) return 'cover';
|
||||
return 'decorative';
|
||||
}
|
||||
|
||||
function setImageUsage(imageId: string, usage: 'decorative' | 'page-background' | 'cover') {
|
||||
const image = theme.CustomImages.find((item) => item.id === imageId);
|
||||
if (!image) return;
|
||||
|
||||
let nextMeta = { ...creatorMeta };
|
||||
let coverImage = theme.coverImage;
|
||||
|
||||
if (usage === 'page-background') {
|
||||
nextMeta = { ...nextMeta, pageBackgroundImageId: imageId };
|
||||
} else if (nextMeta.pageBackgroundImageId === imageId) {
|
||||
nextMeta = { ...nextMeta, pageBackgroundImageId: null };
|
||||
}
|
||||
|
||||
if (usage === 'cover') {
|
||||
coverImage = image.blob;
|
||||
} else if (coverImage === image.blob) {
|
||||
coverImage = null;
|
||||
}
|
||||
|
||||
creatorMeta = nextMeta;
|
||||
theme = { ...theme, coverImage };
|
||||
touchVisuals();
|
||||
}
|
||||
|
||||
function onFontIdChange(fontId: string) {
|
||||
creatorMeta = { ...creatorMeta, fontId };
|
||||
applySelectedFont(fontId);
|
||||
touchVisuals();
|
||||
}
|
||||
|
||||
function patchCreatorMeta(patch: Partial<ThemeCreatorMeta>) {
|
||||
creatorMeta = { ...creatorMeta, ...patch };
|
||||
touchVisuals();
|
||||
}
|
||||
|
||||
function toggleCodeEditorFullscreen(e: MouseEvent) {
|
||||
e.preventDefault();
|
||||
codeEditorFullscreen = !codeEditorFullscreen;
|
||||
@@ -71,8 +151,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function prepareThemeClone() {
|
||||
const themeClone = JSON.parse(JSON.stringify(theme)) as LoadedCustomTheme;
|
||||
|
||||
themeClone.CustomImages = theme.CustomImages.map((image) => ({
|
||||
...image,
|
||||
blob: image.blob,
|
||||
}));
|
||||
themeClone.coverImage = theme.coverImage;
|
||||
themeClone.userEdited = true;
|
||||
|
||||
if (shouldForceThemeAppearance(themeClone)) {
|
||||
themeClone.forceTheme = true;
|
||||
} else {
|
||||
themeClone.forceTheme = false;
|
||||
themeClone.forceDark = undefined;
|
||||
}
|
||||
|
||||
const merged = mergeThemeWithCreatorMeta(themeClone, {
|
||||
...creatorMeta,
|
||||
sidebar: snapshotSidebarSettings(),
|
||||
});
|
||||
return await ensureThemeCoverImage(merged);
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
await themeManager.disableTheme();
|
||||
const unsubCloud = cloudAuth.subscribe((s) => {
|
||||
cloudLoggedIn = s.isLoggedIn;
|
||||
});
|
||||
const unsubSettings = settingsState.subscribe((s) => {
|
||||
panelDark = s.DarkMode;
|
||||
});
|
||||
|
||||
void ensureFontPickerFontsLoaded();
|
||||
originalSidebar = snapshotSidebarSettings();
|
||||
originalFontId = settingsState.selectedFont ?? DEFAULT_FONT_ID;
|
||||
|
||||
if (themeID) {
|
||||
const tempTheme = await themeManager.getTheme(themeID);
|
||||
@@ -85,59 +198,93 @@
|
||||
tempTheme.forceTheme ??
|
||||
(tempTheme.forceDark !== undefined ? true : undefined),
|
||||
};
|
||||
themeLoaded = true;
|
||||
} else {
|
||||
themeLoaded = true
|
||||
}
|
||||
|
||||
if (theme.creatorMeta) {
|
||||
creatorMeta = { ...defaultThemeCreatorMeta(), ...theme.creatorMeta };
|
||||
applySidebarSettings(theme.creatorMeta.sidebar);
|
||||
composeVisuals = true;
|
||||
} else {
|
||||
creatorMeta = defaultThemeCreatorMeta({
|
||||
userCustomCss: theme.CustomCSS,
|
||||
fontId: settingsState.selectedFont ?? DEFAULT_FONT_ID,
|
||||
});
|
||||
}
|
||||
|
||||
applySelectedFont(creatorMeta.fontId);
|
||||
themeLoaded = true;
|
||||
themeUpdates.triggerUpdate();
|
||||
|
||||
return () => {
|
||||
unsubCloud();
|
||||
unsubSettings();
|
||||
if (originalSidebar) applySidebarSettings(originalSidebar);
|
||||
if (originalFontId) applySelectedFont(originalFontId);
|
||||
};
|
||||
});
|
||||
|
||||
async function onImageUpload(event: Event) {
|
||||
theme = await handleImageUpload(event, theme);
|
||||
const updated = await handleImageUpload(event, theme);
|
||||
if (updated === theme) return;
|
||||
theme = updated as LoadedCustomTheme;
|
||||
if (!creatorMeta.pageBackgroundImageId && theme.CustomImages.length === 1) {
|
||||
creatorMeta = { ...creatorMeta, pageBackgroundImageId: theme.CustomImages[0].id };
|
||||
}
|
||||
touchVisuals();
|
||||
}
|
||||
|
||||
function onRemoveImage(imageId: string) {
|
||||
if (creatorMeta.pageBackgroundImageId === imageId) {
|
||||
creatorMeta = { ...creatorMeta, pageBackgroundImageId: null };
|
||||
}
|
||||
theme = handleRemoveImage(imageId, theme);
|
||||
touchVisuals();
|
||||
}
|
||||
|
||||
function onImageVariableChange(imageId: string, variableName: string) {
|
||||
theme = handleImageVariableChange(imageId, variableName, theme);
|
||||
}
|
||||
|
||||
async function onCoverImageUpload(event: Event) {
|
||||
theme = await handleCoverImageUpload(event, theme);
|
||||
touchVisuals();
|
||||
}
|
||||
|
||||
async function submitTheme() {
|
||||
const themeClone = JSON.parse(JSON.stringify(theme));
|
||||
const themeClone = await prepareThemeClone();
|
||||
|
||||
// re-insert blobs into themeClone
|
||||
themeClone.CustomImages = theme.CustomImages.map((image) => ({
|
||||
...image,
|
||||
blob: image.blob
|
||||
}))
|
||||
themeClone.coverImage = theme.coverImage
|
||||
themeClone.userEdited = true
|
||||
|
||||
if (shouldForceThemeAppearance(themeClone)) {
|
||||
themeClone.forceTheme = true;
|
||||
} else {
|
||||
themeClone.forceTheme = false;
|
||||
themeClone.forceDark = undefined;
|
||||
}
|
||||
|
||||
themeManager.clearPreview();
|
||||
await themeManager.saveTheme(themeClone);
|
||||
await themeManager.setTheme(themeClone.id);
|
||||
themeUpdates.triggerUpdate();
|
||||
CloseThemeCreator();
|
||||
await CloseThemeCreator({ restoreTheme: false });
|
||||
}
|
||||
|
||||
async function submitThemeToCommunity() {
|
||||
communityError = null;
|
||||
if (!cloudLoggedIn) {
|
||||
communityError = "Sign in with BetterSEQTA Cloud to submit themes.";
|
||||
return;
|
||||
}
|
||||
if (!theme.name.trim()) {
|
||||
communityError = "Add a theme name before submitting.";
|
||||
return;
|
||||
}
|
||||
|
||||
communityBusy = true;
|
||||
try {
|
||||
const themeClone = await prepareThemeClone();
|
||||
await themeManager.saveTheme(themeClone);
|
||||
await themeManager.setTheme(themeClone.id);
|
||||
await submitLocalThemeToCommunity(themeClone, theme.description?.trim() || undefined);
|
||||
themeUpdates.triggerUpdate();
|
||||
await CloseThemeCreator({ restoreTheme: false });
|
||||
} catch (err) {
|
||||
communityError = formatCustomThemeApiError(err);
|
||||
} finally {
|
||||
communityBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (themeLoaded) {
|
||||
void themeManager.updatePreviewDebounced(theme);
|
||||
}
|
||||
const snapshot = previewTheme;
|
||||
if (!snapshot) return;
|
||||
void themeManager.updatePreviewDebounced(snapshot);
|
||||
});
|
||||
|
||||
type SettingType = 'switch' | 'button' | 'slider' | 'colourPicker' | 'select' | 'codeEditor' | 'imageUpload' | 'conditional' | 'lightDarkToggle';
|
||||
@@ -221,20 +368,35 @@
|
||||
{/if}
|
||||
{:else if item.type === 'imageUpload'}
|
||||
{#each theme.CustomImages as image (image.id)}
|
||||
<div class="flex gap-2 items-center px-2 py-2 mb-4 h-16 bg-white rounded-lg shadow-lg dark:bg-zinc-700">
|
||||
<div class="h-full">
|
||||
<ThemeBlobImage source={image.blob} alt={image.variableName} class="object-contain h-full rounded" />
|
||||
<div class="mb-4 space-y-2 rounded-lg bg-white px-2 py-2 shadow-lg dark:bg-zinc-700">
|
||||
<div class="flex h-16 items-center gap-2">
|
||||
<div class="h-full">
|
||||
<ThemeBlobImage source={image.blob} alt={image.variableName} class="object-contain h-full rounded" />
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
value={image.variableName}
|
||||
oninput={(e) => onImageVariableChange(image.id, e.currentTarget.value)}
|
||||
placeholder="CSS variable name"
|
||||
class="grow flex-3 rounded-lg border-0 bg-zinc-200 p-2 transition dark:bg-zinc-600/50 dark:placeholder-zinc-300 focus:bg-zinc-300/50 dark:focus:bg-zinc-600"
|
||||
/>
|
||||
<button onclick={() => onRemoveImage(image.id)} class="p-2 transition dark:text-white" type="button">
|
||||
<span class='text-xl font-IconFamily'>{'\ued8c'}</span>
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
bind:value={image.variableName}
|
||||
oninput={(e) => onImageVariableChange(image.id, e.currentTarget.value)}
|
||||
placeholder="CSS Variable Name"
|
||||
class="p-2 w-full rounded-lg border-0 transition grow flex-3 dark:placeholder-zinc-300 bg-zinc-200 dark:bg-zinc-600/50 focus:bg-zinc-300/50 dark:focus:bg-zinc-600"
|
||||
/>
|
||||
<button onclick={() => onRemoveImage(image.id)} class="p-2 transition dark:text-white">
|
||||
<span class='text-xl font-IconFamily'>{'\ued8c'}</span>
|
||||
</button>
|
||||
<label class="block text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Use as
|
||||
<select
|
||||
class="mt-1 w-full rounded-lg border-0 bg-zinc-200 px-2 py-1.5 text-sm dark:bg-zinc-600"
|
||||
value={imageUsage(image.id)}
|
||||
onchange={(e) =>
|
||||
setImageUsage(image.id, e.currentTarget.value as 'decorative' | 'page-background' | 'cover')}
|
||||
>
|
||||
<option value="decorative">Decorative (CSS variable only)</option>
|
||||
<option value="page-background">SEQTA page background</option>
|
||||
<option value="cover">Theme store cover image</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
@@ -270,7 +432,7 @@
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
<div class='h-screen overflow-y-scroll {$settingsState.DarkMode && "dark"} no-scrollbar'>
|
||||
<div class:dark={panelDark} class="h-full min-h-0 overflow-y-scroll no-scrollbar">
|
||||
{#if codeEditorFullscreen}
|
||||
<div class="absolute inset-0 bg-white z-[10000] dark:bg-zinc-900 dark:text-white">
|
||||
<div class="sticky top-0 px-2 h-screen">
|
||||
@@ -278,14 +440,27 @@
|
||||
<h2 class="text-xl font-bold">Custom CSS</h2>
|
||||
<button onclick={toggleCodeEditorFullscreen} class="pr-14 text-xl font-IconFamily">{'\uec06'}</button>
|
||||
</div>
|
||||
<CodeEditor className="editorHeight" value={theme.CustomCSS} onChange={(value: string) => { theme = { ...theme, CustomCSS: value } }} />
|
||||
<CodeEditor
|
||||
className="editorHeight"
|
||||
value={creatorMeta.userCustomCss}
|
||||
onChange={(value: string) => patchCreatorMeta({ userCustomCss: value })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class='flex relative flex-col p-2 w-full min-h-screen bg-zinc-100 dark:bg-zinc-800 dark:text-white'>
|
||||
<div class="relative flex min-h-full w-full flex-col bg-zinc-100 p-2 text-zinc-900 dark:bg-zinc-800 dark:text-white">
|
||||
|
||||
|
||||
<h1 class='text-xl font-semibold'>Theme Creator</h1>
|
||||
<div class="mb-2 flex items-start justify-between gap-2">
|
||||
<h1 class="text-xl font-semibold">Theme Creator</h1>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg p-2 text-zinc-500 transition hover:bg-zinc-200 dark:hover:bg-zinc-700"
|
||||
aria-label="Close theme creator"
|
||||
onclick={() => void CloseThemeCreator()}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<a href='https://docs.betterseqta.org/theme-creation/' target='_blank' rel='noopener noreferrer' class='text-sm font-light text-zinc-500 dark:text-zinc-400'>
|
||||
<span class='pr-0.5 no-underline font-IconFamily'>{'\ueb44'}</span>
|
||||
<span class='underline'>
|
||||
@@ -316,19 +491,122 @@
|
||||
|
||||
<Divider />
|
||||
|
||||
<div class="flex overflow-hidden relative gap-1 justify-center place-items-center w-full rounded-lg transition aspect-theme group bg-zinc-200 dark:bg-zinc-700">
|
||||
<div class={`transition pointer-events-none z-30 font-IconFamily ${ theme.coverImage ? 'opacity-0 group-hover:opacity-100' : ''}`}>
|
||||
{'\uec60'}
|
||||
<div class="py-3">
|
||||
<h2 class="text-sm font-bold">Accent colour</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-400">Default accent and gradient start colour.</p>
|
||||
<div class="mt-2">
|
||||
<ColourPicker
|
||||
savePresets={false}
|
||||
standalone={true}
|
||||
customState={theme.defaultColour}
|
||||
customOnChange={(color: string) => {
|
||||
theme = { ...theme, defaultColour: color };
|
||||
touchVisuals();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<span class={`dark:text-white pointer-events-none z-30 transition ${ theme.coverImage ? 'opacity-0 group-hover:opacity-100' : ''}`}>{theme.coverImage ? 'Change' : 'Add'} cover image</span>
|
||||
<input type="file" accept='image/*' onchange={onCoverImageUpload} class="absolute inset-0 z-10 w-full h-full opacity-0 cursor-pointer" />
|
||||
{#if !theme.hideThemeName && theme.coverImage}
|
||||
<div class="absolute z-30 opacity-100 transition-opacity pointer-events-none group-hover:opacity-0">{theme.name}</div>
|
||||
{/if}
|
||||
{#if theme.coverImage}
|
||||
<div class="absolute z-20 w-full h-full opacity-0 transition-opacity pointer-events-none group-hover:opacity-100 bg-black/20"></div>
|
||||
<ThemeBlobImage source={theme.coverImage} alt="Cover" class="object-cover absolute z-0 w-full h-full rounded" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div class="py-3">
|
||||
<h2 class="text-sm font-bold">Interface font</h2>
|
||||
<select
|
||||
class="mt-2 w-full rounded-lg border-0 bg-zinc-200 p-2 text-sm dark:bg-zinc-700"
|
||||
value={creatorMeta.fontId}
|
||||
onchange={(e) => onFontIdChange(e.currentTarget.value)}
|
||||
>
|
||||
{#each FONT_PRESETS as preset (preset.id)}
|
||||
<option value={preset.id}>{preset.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div class="py-3 space-y-3">
|
||||
<div>
|
||||
<h2 class="text-sm font-bold">Images & page background</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-400">
|
||||
Upload images, then choose how each one is used. Set one as the live SEQTA page background to preview it on the main page.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{#each theme.CustomImages as image (image.id)}
|
||||
<div class="space-y-2 rounded-lg bg-zinc-200/80 px-2 py-2 dark:bg-zinc-700/80">
|
||||
<div class="flex h-16 items-center gap-2">
|
||||
<ThemeBlobImage source={image.blob} alt="" class="h-full rounded object-contain" />
|
||||
<input
|
||||
type="text"
|
||||
value={image.variableName}
|
||||
oninput={(e) => onImageVariableChange(image.id, e.currentTarget.value)}
|
||||
placeholder="CSS variable"
|
||||
class="min-w-0 flex-1 rounded-lg border-0 bg-zinc-100 p-2 text-sm dark:bg-zinc-600 dark:text-white"
|
||||
/>
|
||||
<button type="button" class="p-2 dark:text-white" onclick={() => onRemoveImage(image.id)}>
|
||||
<span class="text-xl font-IconFamily">{'\ued8c'}</span>
|
||||
</button>
|
||||
</div>
|
||||
<select
|
||||
class="w-full rounded-lg border-0 bg-zinc-100 px-2 py-1.5 text-sm dark:bg-zinc-600"
|
||||
value={imageUsage(image.id)}
|
||||
onchange={(e) =>
|
||||
setImageUsage(image.id, e.currentTarget.value as 'decorative' | 'page-background' | 'cover')}
|
||||
>
|
||||
<option value="decorative">Decorative only (CSS variable)</option>
|
||||
<option value="page-background">SEQTA page background</option>
|
||||
<option value="cover">Theme store cover</option>
|
||||
</select>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<label class="flex h-10 cursor-pointer items-center justify-center gap-2 rounded-lg bg-zinc-200 dark:bg-zinc-700">
|
||||
<span class="font-IconFamily">{'\uec60'}</span>
|
||||
<span class="text-sm dark:text-white">Add image</span>
|
||||
<input type="file" accept="image/*" class="hidden" onchange={onImageUpload} />
|
||||
</label>
|
||||
|
||||
<label class="block text-sm">
|
||||
Gradient end
|
||||
<div class="mt-1">
|
||||
<ColourPicker
|
||||
savePresets={false}
|
||||
standalone={true}
|
||||
customState={creatorMeta.gradientEnd || theme.defaultColour}
|
||||
customOnChange={(color: string) => patchCreatorMeta({ gradientEnd: color })}
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
<label class="block text-sm">
|
||||
Gradient angle ({creatorMeta.gradientAngle}°)
|
||||
<Slider
|
||||
state={creatorMeta.gradientAngle}
|
||||
min={0}
|
||||
max={360}
|
||||
step={1}
|
||||
onChange={(value) => patchCreatorMeta({ gradientAngle: value })}
|
||||
/>
|
||||
</label>
|
||||
<label class="block text-sm">
|
||||
Colour overlay ({Math.round(creatorMeta.overlayOpacity * 100)}%)
|
||||
<Slider
|
||||
state={creatorMeta.overlayOpacity}
|
||||
min={0}
|
||||
max={0.85}
|
||||
step={0.05}
|
||||
onChange={(value) => patchCreatorMeta({ overlayOpacity: value })}
|
||||
/>
|
||||
</label>
|
||||
<label class="block text-sm">
|
||||
Background blur ({creatorMeta.backgroundBlurPx}px)
|
||||
<Slider
|
||||
state={creatorMeta.backgroundBlurPx}
|
||||
min={0}
|
||||
max={24}
|
||||
step={1}
|
||||
onChange={(value) => patchCreatorMeta({ backgroundBlurPx: value })}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
@@ -354,6 +632,12 @@
|
||||
|
||||
<Divider />
|
||||
|
||||
<div class="theme-creator-sidebar -mx-2">
|
||||
<SidebarAppearance />
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
{#each [
|
||||
{
|
||||
type: 'switch',
|
||||
@@ -395,40 +679,55 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'colourPicker',
|
||||
title: 'Default Theme Colour',
|
||||
description: 'Set the default color for your theme',
|
||||
direction: 'vertical',
|
||||
props: {
|
||||
customState: theme.defaultColour,
|
||||
customOnChange: (color: string) => theme = { ...theme, defaultColour: color }
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'imageUpload',
|
||||
title: 'Custom Images',
|
||||
description: 'Add custom images to your theme',
|
||||
direction: 'vertical',
|
||||
},
|
||||
{
|
||||
type: 'codeEditor',
|
||||
title: 'Custom CSS',
|
||||
description: 'Add custom CSS to your theme',
|
||||
description: 'Extra CSS appended after generated theme rules',
|
||||
direction: 'vertical',
|
||||
props: {
|
||||
value: theme.CustomCSS,
|
||||
onChange: (value: string) => { theme = { ...theme, CustomCSS: value } }
|
||||
value: creatorMeta.userCustomCss,
|
||||
onChange: (value: string) => patchCreatorMeta({ userCustomCss: value })
|
||||
}
|
||||
}
|
||||
] as SettingItem[] as setting}
|
||||
{@render settingItem(setting)}
|
||||
{/each}
|
||||
|
||||
<button
|
||||
onclick={submitTheme}
|
||||
class="w-full px-4 py-2 mt-3 text-[13px] dark:text-white transition rounded-xl bg-zinc-200 dark:bg-zinc-700/50">
|
||||
Save Theme
|
||||
</button>
|
||||
|
||||
<div
|
||||
class="sticky bottom-0 z-10 -mx-2 mt-4 space-y-2 border-t border-zinc-200/80 bg-zinc-100 p-3 pb-4 dark:border-zinc-700/60 dark:bg-zinc-800"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onclick={submitTheme}
|
||||
class="w-full rounded-xl bg-zinc-900 px-4 py-3 text-[13px] font-medium text-white transition hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white"
|
||||
>
|
||||
Save & apply
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={communityBusy || !theme.name.trim() || !cloudLoggedIn}
|
||||
onclick={() => void submitThemeToCommunity()}
|
||||
class="w-full rounded-xl bg-zinc-200 px-4 py-3 text-[13px] font-medium text-zinc-900 transition hover:bg-zinc-300 disabled:opacity-50 dark:bg-zinc-700 dark:text-white dark:hover:bg-zinc-600"
|
||||
>
|
||||
{communityBusy ? "Submitting…" : "Save & submit to community"}
|
||||
</button>
|
||||
{#if !cloudLoggedIn}
|
||||
<p class="text-xs text-zinc-500 dark:text-zinc-400">
|
||||
Sign in with BetterSEQTA Cloud to submit themes to the community library.
|
||||
</p>
|
||||
{/if}
|
||||
{#if communityError}
|
||||
<p class="whitespace-pre-line text-sm text-red-600 dark:text-red-400">{communityError}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.theme-creator-sidebar :global(.preview-pane) {
|
||||
display: none;
|
||||
}
|
||||
.theme-creator-sidebar :global(.picker-body) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,47 @@
|
||||
import { buildSimpleTheme } from "./buildSimpleTheme";
|
||||
import { buildThemeBuilderCss } from "./themeBuilderDraft";
|
||||
import { getFontPreset } from "@/seqta/ui/fonts/presets";
|
||||
|
||||
describe("buildSimpleTheme", () => {
|
||||
it("paints the tint above an opaque photo when blur is disabled", () => {
|
||||
const css = buildThemeBuilderCss(
|
||||
getFontPreset("inter"),
|
||||
["theme-bg-0"],
|
||||
{ accentColor: "#00f", overlayOpacity: 0.5, backgroundBlurPx: 0 },
|
||||
);
|
||||
const backgroundLayers = css.match(/background-image: (.*) !important;/)?.[1];
|
||||
expect(backgroundLayers).toMatch(/^linear-gradient\(.*\), var\(--theme-bg-0\)$/);
|
||||
});
|
||||
|
||||
it("builds CSS with font import and image variables", () => {
|
||||
const css = buildThemeBuilderCss(
|
||||
getFontPreset("inter"),
|
||||
["theme-bg-0"],
|
||||
{ accentColor: "#00f", gradientEnd: "#f0f" },
|
||||
);
|
||||
expect(css).toContain("Inter");
|
||||
expect(css).toContain("var(--theme-bg-0)");
|
||||
expect(css).toContain("#title");
|
||||
});
|
||||
|
||||
it("creates a theme with photos as custom image variables", () => {
|
||||
const theme = buildSimpleTheme({
|
||||
name: "Sunset",
|
||||
accentColor: "#ff6600",
|
||||
fontId: "rubik",
|
||||
photoBlobs: [new Blob(["x"], { type: "image/png" })],
|
||||
});
|
||||
expect(theme.name).toBe("Sunset");
|
||||
expect(theme.defaultColour).toBe("#ff6600");
|
||||
expect(theme.CustomImages).toHaveLength(1);
|
||||
expect(theme.CustomImages[0].variableName).toBe("theme-bg-0");
|
||||
expect(theme.coverImage).toBeTruthy();
|
||||
expect(theme.hideThemeName).toBe(true);
|
||||
});
|
||||
|
||||
it("requires a name", () => {
|
||||
expect(() =>
|
||||
buildSimpleTheme({ name: " ", accentColor: "#000", photoBlobs: [] }),
|
||||
).toThrow("Theme name is required");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { LoadedCustomTheme } from "@/types/CustomThemes";
|
||||
import { buildThemeFromDraft, type ThemeBuilderDraft } from "./themeBuilderDraft";
|
||||
|
||||
export type SimpleThemeInput = ThemeBuilderDraft;
|
||||
|
||||
export { buildThemeBuilderCss as buildSimpleThemeCss } from "./themeBuilderDraft";
|
||||
|
||||
/** @deprecated Use buildThemeFromDraft */
|
||||
export function buildSimpleTheme(input: SimpleThemeInput): LoadedCustomTheme {
|
||||
return buildThemeFromDraft(input);
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import { generateImageId } from "@/interface/utils/themeImageHandlers";
|
||||
import { DEFAULT_FONT_ID, getFontPreset, type FontPreset } from "@/seqta/ui/fonts/presets";
|
||||
import type { LoadedCustomTheme } from "@/types/CustomThemes";
|
||||
|
||||
export type ThemeBuilderDraft = {
|
||||
name: string;
|
||||
description?: string;
|
||||
accentColor: string;
|
||||
gradientEnd?: string;
|
||||
gradientAngle?: number;
|
||||
backgroundBlurPx?: number;
|
||||
overlayOpacity?: number;
|
||||
fontId?: string;
|
||||
photoBlobs: Blob[];
|
||||
customCssExtra?: string;
|
||||
themeId?: string;
|
||||
};
|
||||
|
||||
/** Keep the BetterSEQTA title bar opaque (generated themes must not use the old transparent #title hack). */
|
||||
const TITLEBAR_SOLID = `#title {
|
||||
background: var(--background-primary) !important;
|
||||
}`;
|
||||
|
||||
function clamp(n: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, n));
|
||||
}
|
||||
|
||||
export function buildThemeBuilderCss(
|
||||
font: FontPreset,
|
||||
imageVariables: string[],
|
||||
draft: Pick<
|
||||
ThemeBuilderDraft,
|
||||
"accentColor" | "gradientEnd" | "gradientAngle" | "backgroundBlurPx" | "overlayOpacity" | "customCssExtra"
|
||||
>,
|
||||
): string {
|
||||
const importLine = font.googleUrl ? `@import url("${font.googleUrl}");\n` : "";
|
||||
const angle = draft.gradientAngle ?? 135;
|
||||
const overlay = clamp(draft.overlayOpacity ?? 0.35, 0, 0.85);
|
||||
const blurPx = clamp(draft.backgroundBlurPx ?? 0, 0, 24);
|
||||
const endColor = (draft.gradientEnd ?? draft.accentColor).trim();
|
||||
|
||||
const rules: string[] = [
|
||||
`${importLine}body, #container, .dashboard {
|
||||
font-family: ${font.stack} !important;
|
||||
}`,
|
||||
];
|
||||
|
||||
const imageLayer =
|
||||
imageVariables.length > 0
|
||||
? imageVariables.map((name) => `var(--${name})`).join(", ")
|
||||
: "";
|
||||
const gradientLayer = `linear-gradient(${angle}deg, color-mix(in srgb, ${draft.accentColor} ${Math.round(overlay * 100)}%, transparent), color-mix(in srgb, ${endColor} ${Math.round(overlay * 100)}%, transparent))`;
|
||||
|
||||
rules.push(`#container {
|
||||
isolation: isolate;
|
||||
position: relative;
|
||||
}`);
|
||||
|
||||
if (imageLayer && blurPx > 0) {
|
||||
rules.push(`#container::after {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: -2;
|
||||
pointer-events: none;
|
||||
background-image: ${imageLayer};
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-attachment: fixed;
|
||||
filter: blur(${blurPx}px);
|
||||
transform: scale(1.04);
|
||||
}`);
|
||||
rules.push(`#container {
|
||||
background-image: ${gradientLayer} !important;
|
||||
background-size: cover !important;
|
||||
background-position: center !important;
|
||||
background-attachment: fixed !important;
|
||||
}`);
|
||||
} else {
|
||||
const bgLayers: string[] = [gradientLayer];
|
||||
if (imageLayer) bgLayers.push(imageLayer);
|
||||
rules.push(`#container {
|
||||
background-image: ${bgLayers.join(", ")} !important;
|
||||
background-size: cover !important;
|
||||
background-position: center !important;
|
||||
background-attachment: fixed !important;
|
||||
}`);
|
||||
}
|
||||
|
||||
rules.push(`#container::before {
|
||||
display: none !important;
|
||||
content: none !important;
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
}`);
|
||||
|
||||
if (!imageLayer || blurPx === 0) {
|
||||
rules.push(`#container::after {
|
||||
display: none !important;
|
||||
content: none !important;
|
||||
filter: none !important;
|
||||
}`);
|
||||
}
|
||||
|
||||
rules.push(TITLEBAR_SOLID);
|
||||
const extra = draft.customCssExtra?.trim();
|
||||
if (extra) rules.push(extra);
|
||||
return rules.join("\n\n");
|
||||
}
|
||||
|
||||
export function buildThemeFromDraft(draft: ThemeBuilderDraft): LoadedCustomTheme {
|
||||
const name = draft.name.trim();
|
||||
if (!name) throw new Error("Theme name is required");
|
||||
|
||||
const font = getFontPreset(draft.fontId ?? DEFAULT_FONT_ID);
|
||||
const photoBlobs = draft.photoBlobs.filter((blob) => blob.size > 0);
|
||||
const CustomImages = photoBlobs.map((blob, index) => ({
|
||||
id: generateImageId(),
|
||||
blob,
|
||||
variableName: `theme-bg-${index}`,
|
||||
}));
|
||||
|
||||
return {
|
||||
id: draft.themeId ?? crypto.randomUUID(),
|
||||
name,
|
||||
description: (draft.description ?? "").trim(),
|
||||
defaultColour: draft.accentColor.trim() || "rgba(0, 123, 255, 1)",
|
||||
CanChangeColour: true,
|
||||
allowBackgrounds: true,
|
||||
CustomCSS: buildThemeBuilderCss(font, CustomImages.map((i) => i.variableName), draft),
|
||||
CustomImages,
|
||||
coverImage: photoBlobs[0] ?? null,
|
||||
isEditable: true,
|
||||
hideThemeName: Boolean(photoBlobs[0]),
|
||||
adaptiveCssVariables: [],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { buildThemeBuilderCss } from "@/interface/utils/themeBuilderDraft";
|
||||
import { applySelectedFont } from "@/seqta/ui/fonts/Manager";
|
||||
import { DEFAULT_FONT_ID, getFontPreset } from "@/seqta/ui/fonts/presets";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import type { LoadedCustomTheme, ThemeCreatorMeta } from "@/types/CustomThemes";
|
||||
|
||||
export type ThemeCreatorSidebarMeta = {
|
||||
sidebarStyle?: string;
|
||||
sidebarDensity?: string;
|
||||
sidebarCornerRadius?: number;
|
||||
sidebarActiveIndicator?: string;
|
||||
sidebarWidth?: string;
|
||||
sidebarPosition?: string;
|
||||
sidebarBlur?: number;
|
||||
transparencyEffects?: boolean;
|
||||
};
|
||||
|
||||
export function defaultThemeCreatorMeta(
|
||||
overrides: Partial<ThemeCreatorMeta> = {},
|
||||
): ThemeCreatorMeta {
|
||||
return {
|
||||
fontId: settingsState.selectedFont ?? DEFAULT_FONT_ID,
|
||||
pageBackgroundImageId: null,
|
||||
backgroundBlurPx: 0,
|
||||
overlayOpacity: 0.35,
|
||||
gradientAngle: 135,
|
||||
gradientEnd: "",
|
||||
userCustomCss: "",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export function snapshotSidebarSettings(): ThemeCreatorSidebarMeta {
|
||||
return {
|
||||
sidebarStyle: settingsState.sidebarStyle,
|
||||
sidebarDensity: settingsState.sidebarDensity,
|
||||
sidebarCornerRadius: settingsState.sidebarCornerRadius,
|
||||
sidebarActiveIndicator: settingsState.sidebarActiveIndicator,
|
||||
sidebarWidth: settingsState.sidebarWidth,
|
||||
sidebarPosition: settingsState.sidebarPosition,
|
||||
sidebarBlur: settingsState.sidebarBlur,
|
||||
transparencyEffects: settingsState.transparencyEffects,
|
||||
};
|
||||
}
|
||||
|
||||
export function applySidebarSettings(meta: ThemeCreatorSidebarMeta | undefined): void {
|
||||
if (!meta) return;
|
||||
if (meta.sidebarStyle !== undefined) settingsState.sidebarStyle = meta.sidebarStyle;
|
||||
if (meta.sidebarDensity !== undefined) settingsState.sidebarDensity = meta.sidebarDensity;
|
||||
if (meta.sidebarCornerRadius !== undefined) {
|
||||
settingsState.sidebarCornerRadius = meta.sidebarCornerRadius;
|
||||
}
|
||||
if (meta.sidebarActiveIndicator !== undefined) {
|
||||
settingsState.sidebarActiveIndicator = meta.sidebarActiveIndicator;
|
||||
}
|
||||
if (meta.sidebarWidth !== undefined) settingsState.sidebarWidth = meta.sidebarWidth;
|
||||
if (meta.sidebarPosition !== undefined) settingsState.sidebarPosition = meta.sidebarPosition;
|
||||
if (meta.sidebarBlur !== undefined) settingsState.sidebarBlur = meta.sidebarBlur;
|
||||
if (meta.transparencyEffects !== undefined) {
|
||||
settingsState.transparencyEffects = meta.transparencyEffects;
|
||||
}
|
||||
}
|
||||
|
||||
export function composeThemeCustomCss(
|
||||
theme: Pick<LoadedCustomTheme, "defaultColour" | "CustomImages">,
|
||||
meta: ThemeCreatorMeta,
|
||||
): string {
|
||||
const font = getFontPreset(meta.fontId ?? DEFAULT_FONT_ID);
|
||||
const backgroundVariables: string[] = [];
|
||||
if (meta.pageBackgroundImageId) {
|
||||
const image = theme.CustomImages.find((item) => item.id === meta.pageBackgroundImageId);
|
||||
if (image?.variableName) backgroundVariables.push(image.variableName);
|
||||
}
|
||||
|
||||
const gradientEnd = (meta.gradientEnd || theme.defaultColour).trim();
|
||||
|
||||
return buildThemeBuilderCss(font, backgroundVariables, {
|
||||
accentColor: theme.defaultColour,
|
||||
gradientEnd,
|
||||
gradientAngle: meta.gradientAngle ?? 135,
|
||||
backgroundBlurPx: meta.backgroundBlurPx ?? 0,
|
||||
overlayOpacity: meta.overlayOpacity ?? 0.35,
|
||||
customCssExtra: meta.userCustomCss ?? "",
|
||||
});
|
||||
}
|
||||
|
||||
export function applyThemeCreatorMetaToSettings(meta: ThemeCreatorMeta | undefined): void {
|
||||
if (!meta) return;
|
||||
if (meta.fontId) {
|
||||
settingsState.selectedFont = meta.fontId;
|
||||
applySelectedFont(meta.fontId);
|
||||
}
|
||||
applySidebarSettings(meta.sidebar);
|
||||
}
|
||||
|
||||
export function mergeThemeWithCreatorMeta(
|
||||
theme: LoadedCustomTheme,
|
||||
meta: ThemeCreatorMeta,
|
||||
): LoadedCustomTheme {
|
||||
const sidebar = meta.sidebar ?? theme.creatorMeta?.sidebar;
|
||||
const mergedMeta: ThemeCreatorMeta = { ...meta };
|
||||
if (sidebar) {
|
||||
mergedMeta.sidebar = sidebar;
|
||||
} else {
|
||||
delete mergedMeta.sidebar;
|
||||
}
|
||||
const CustomCSS = composeThemeCustomCss(theme, mergedMeta);
|
||||
return { ...theme, creatorMeta: mergedMeta, CustomCSS };
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import type { CustomTheme } from '@/types/CustomThemes';
|
||||
import type { Theme } from '@/interface/types/Theme';
|
||||
import {
|
||||
filterThemesByMode,
|
||||
getThemeApplyButtonStyles,
|
||||
getCommunityInstalledThemeIds,
|
||||
getStoreInstalledThemeIds,
|
||||
isStoreThemeInstalled,
|
||||
resolveLocalThemeInstallId,
|
||||
resolveStoreVariantAccentColor,
|
||||
} from './themeListFilters';
|
||||
|
||||
function makeCustomTheme(overrides: Partial<CustomTheme> & Pick<CustomTheme, 'id' | 'name'>): CustomTheme {
|
||||
return {
|
||||
description: '',
|
||||
defaultColour: '#000000',
|
||||
CanChangeColour: true,
|
||||
allowBackgrounds: true,
|
||||
CustomCSS: '',
|
||||
CustomImages: [],
|
||||
coverImage: null,
|
||||
isEditable: false,
|
||||
hideThemeName: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function makeStoreTheme(overrides: Partial<Theme> & Pick<Theme, 'id' | 'name'>): Theme {
|
||||
return {
|
||||
description: '',
|
||||
coverImage: '',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('resolveLocalThemeInstallId', () => {
|
||||
it('keeps store ids and forks local imports that collide with store copies', () => {
|
||||
expect(resolveLocalThemeInstallId('theme-1', null, true, false)).toBe('theme-1');
|
||||
const forked = resolveLocalThemeInstallId(
|
||||
'theme-1',
|
||||
makeCustomTheme({ id: 'theme-1', name: 'Store', installedFromStore: true }),
|
||||
false,
|
||||
false,
|
||||
);
|
||||
expect(forked).not.toBe('theme-1');
|
||||
expect(
|
||||
resolveLocalThemeInstallId(
|
||||
'theme-1',
|
||||
makeCustomTheme({ id: 'theme-1', name: 'Local' }),
|
||||
false,
|
||||
false,
|
||||
),
|
||||
).toBe('theme-1');
|
||||
});
|
||||
});
|
||||
|
||||
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 = [
|
||||
makeCustomTheme({ id: 'store-1', name: 'Store', installedFromStore: true }),
|
||||
makeCustomTheme({ id: 'community-1', name: 'Community', installedFromCommunity: true }),
|
||||
makeCustomTheme({ id: 'local-1', name: 'Local' }),
|
||||
];
|
||||
expect(getStoreInstalledThemeIds(themes)).toEqual(['store-1']);
|
||||
expect(getCommunityInstalledThemeIds(themes)).toEqual(['community-1']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isStoreThemeInstalled', () => {
|
||||
it('matches master or flavour ids', () => {
|
||||
const theme = makeStoreTheme({
|
||||
id: 'master-1',
|
||||
name: 'Master',
|
||||
flavours: [{ id: 'flavour-1', name: 'Dark', accent_color: '#000', cover_image: '' }],
|
||||
});
|
||||
expect(isStoreThemeInstalled(theme, ['master-1'])).toBe(true);
|
||||
expect(isStoreThemeInstalled(theme, ['flavour-1'])).toBe(true);
|
||||
expect(isStoreThemeInstalled(theme, ['other'])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveStoreVariantAccentColor', () => {
|
||||
it('prefers installed colours then flavour accents', () => {
|
||||
const theme = makeStoreTheme({
|
||||
id: 'master-1',
|
||||
name: 'Master',
|
||||
flavours: [{ id: 'flavour-1', name: 'Dark', accent_color: '#112233', cover_image: '' }],
|
||||
});
|
||||
expect(resolveStoreVariantAccentColor(theme, 'flavour-1', { 'flavour-1': '#ff0000' })).toBe(
|
||||
'#ff0000',
|
||||
);
|
||||
expect(resolveStoreVariantAccentColor(theme, 'flavour-1')).toBe('#112233');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getThemeApplyButtonStyles', () => {
|
||||
it('derives apply and applied styles from the accent colour', () => {
|
||||
const styles = getThemeApplyButtonStyles('#ff0000');
|
||||
expect(styles.apply).toContain('background-color: #FF0000');
|
||||
expect(styles.applied).toContain('color: #FF0000');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
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). */
|
||||
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.
|
||||
*/
|
||||
export function resolveLocalThemeInstallId(
|
||||
themeId: string,
|
||||
existing: Pick<CustomTheme, 'installedFromStore' | 'installedFromCommunity'> | null,
|
||||
fromStore: boolean,
|
||||
fromCommunity: boolean,
|
||||
): string {
|
||||
if (fromStore || fromCommunity) return themeId;
|
||||
if (
|
||||
existing &&
|
||||
(existing.installedFromStore === true || existing.installedFromCommunity === true)
|
||||
) {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
/** 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;
|
||||
return (theme.flavours ?? []).some((flavour) => installed.has(flavour.id));
|
||||
}
|
||||
|
||||
export function resolveStoreVariantAccentColor(
|
||||
theme: Theme,
|
||||
variantId: string,
|
||||
installedThemeColors: Record<string, string> = {},
|
||||
): string {
|
||||
const installed = installedThemeColors[variantId]?.trim();
|
||||
if (installed) return installed;
|
||||
|
||||
const flavour = theme.flavours?.find((entry) => entry.id === variantId);
|
||||
if (flavour?.accent_color?.trim()) return flavour.accent_color.trim();
|
||||
|
||||
if (variantId === theme.id) {
|
||||
const firstFlavourAccent = theme.flavours?.find((entry) => entry.accent_color?.trim())?.accent_color?.trim();
|
||||
if (firstFlavourAccent) return firstFlavourAccent;
|
||||
}
|
||||
|
||||
return DEFAULT_THEME_ACCENT;
|
||||
}
|
||||
|
||||
export type ThemeApplyButtonStyles = {
|
||||
apply: string;
|
||||
applied: string;
|
||||
};
|
||||
|
||||
export function getThemeApplyButtonStyles(accentColor: string | undefined): ThemeApplyButtonStyles {
|
||||
const parsed = parseCssColor(accentColor?.trim() || DEFAULT_THEME_ACCENT, DEFAULT_THEME_ACCENT);
|
||||
const onAccent = parsed.lightness() >= 60 ? '#18181b' : '#ffffff';
|
||||
|
||||
return {
|
||||
apply: `background-color: ${parsed.hex()}; color: ${onAccent};`,
|
||||
applied: `background-color: ${parsed.alpha(0.18).string()}; color: ${parsed.hex()};`,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
createDefaultThemeCoverSvg,
|
||||
defaultThemeCoverDataUrl,
|
||||
} from "./themePlaceholderCover";
|
||||
|
||||
describe("themePlaceholderCover", () => {
|
||||
it("builds an svg cover placeholder", () => {
|
||||
const svg = createDefaultThemeCoverSvg("#3366ff");
|
||||
expect(svg).toContain("<svg");
|
||||
expect(svg).toContain("No cover image");
|
||||
expect(svg).toContain("#3366ff");
|
||||
});
|
||||
|
||||
it("builds a data url", () => {
|
||||
expect(defaultThemeCoverDataUrl()).toMatch(/^data:image\/svg\+xml/);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { LoadedCustomTheme } from "@/types/CustomThemes";
|
||||
|
||||
/** SVG cover used when a theme has no store/community cover image. */
|
||||
export function createDefaultThemeCoverSvg(accentHint = "#52525b"): string {
|
||||
const accent = accentHint.startsWith("#") ? accentHint : "#52525b";
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" width="800" height="450" viewBox="0 0 800 450" role="img" aria-label="Theme cover placeholder">
|
||||
<defs>
|
||||
<linearGradient id="bsplus-theme-cover-grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="${accent}" stop-opacity="0.45"/>
|
||||
<stop offset="55%" stop-color="#27272a" stop-opacity="0.95"/>
|
||||
<stop offset="100%" stop-color="#09090b"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="800" height="450" fill="url(#bsplus-theme-cover-grad)"/>
|
||||
<g fill="none" stroke="#fafafa" stroke-opacity="0.35" stroke-width="2">
|
||||
<rect x="280" y="130" width="240" height="160" rx="16"/>
|
||||
<path d="M310 250 L350 190 L390 230 L430 170 L490 250 Z" fill="#fafafa" fill-opacity="0.12" stroke="none"/>
|
||||
<circle cx="430" cy="175" r="14" fill="#fafafa" fill-opacity="0.2" stroke="none"/>
|
||||
</g>
|
||||
<text x="400" y="330" text-anchor="middle" fill="#fafafa" fill-opacity="0.85" font-family="system-ui,Segoe UI,sans-serif" font-size="22" font-weight="600">No cover image</text>
|
||||
<text x="400" y="360" text-anchor="middle" fill="#fafafa" fill-opacity="0.5" font-family="system-ui,Segoe UI,sans-serif" font-size="14">Add one in Theme Creator</text>
|
||||
</svg>`;
|
||||
}
|
||||
|
||||
export function defaultThemeCoverDataUrl(accentHint?: string): string {
|
||||
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
|
||||
createDefaultThemeCoverSvg(accentHint),
|
||||
)}`;
|
||||
}
|
||||
|
||||
let cachedCoverBlob: Blob | null = null;
|
||||
|
||||
export async function getDefaultThemeCoverBlob(accentHint?: string): Promise<Blob> {
|
||||
if (!cachedCoverBlob) {
|
||||
cachedCoverBlob = new Blob([createDefaultThemeCoverSvg(accentHint)], {
|
||||
type: "image/svg+xml",
|
||||
});
|
||||
}
|
||||
return cachedCoverBlob;
|
||||
}
|
||||
|
||||
export async function ensureThemeCoverImage(theme: LoadedCustomTheme): Promise<LoadedCustomTheme> {
|
||||
if (theme.coverImage && theme.coverImage.size > 0) return theme;
|
||||
const coverImage = await getDefaultThemeCoverBlob(theme.defaultColour);
|
||||
return { ...theme, coverImage };
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as pdfjs from "pdfjs-dist";
|
||||
import browser from "webextension-polyfill";
|
||||
|
||||
/** Static copies in `src/public` (see `scripts/copy-pdfjs-assets.mjs`, manifest web_accessible_resources). */
|
||||
/** Static copies in `src/public` (see `scripts/copy-runtime-assets.mjs`, manifest web_accessible_resources). */
|
||||
const PDF_WORKER_RESOURCE = "resources/pdfjs/pdf.worker.min.mjs";
|
||||
const PDF_LEGACY_RESOURCE = "resources/pdfjs/pdf.legacy.min.mjs";
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"64": "resources/icons/icon-64.png"
|
||||
}
|
||||
},
|
||||
"permissions": ["tabs", "notifications", "storage", "identity", "alarms"],
|
||||
"permissions": ["tabs", "notifications", "storage", "alarms", "cookies"],
|
||||
"host_permissions": [
|
||||
"https://newsapi.org/",
|
||||
"https://betterseqta.org/",
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
syncAnimatedBackground,
|
||||
updateAnimationSpeed,
|
||||
} from "./backgroundLayers";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const settings = defineSettings({
|
||||
speed: numberSetting({
|
||||
@@ -40,6 +41,11 @@ const animatedBackgroundPlugin: Plugin<typeof settings> = {
|
||||
settings: instance.settings,
|
||||
|
||||
run: async (api) => {
|
||||
if (isPerformanceMode()) {
|
||||
removeAnimatedBackgroundLayers();
|
||||
return () => removeAnimatedBackgroundLayers();
|
||||
}
|
||||
|
||||
await syncAnimatedBackground(api);
|
||||
const resync = () => void syncAnimatedBackground(api);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import styles from "./styles.css?inline";
|
||||
import BackgroundMusicSetting from "./BackgroundMusicSetting.svelte";
|
||||
import localforage from "localforage";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const settings = defineSettings({
|
||||
uploader: componentSetting({
|
||||
@@ -187,6 +188,10 @@ const backgroundMusicPlugin: Plugin<typeof settings> = {
|
||||
defaultEnabled: false,
|
||||
|
||||
run: async (api) => {
|
||||
if (isPerformanceMode()) {
|
||||
return () => stopAudio();
|
||||
}
|
||||
|
||||
await api.storage.loaded;
|
||||
|
||||
type BgSettings = { volume?: number; pauseOnHidden?: boolean };
|
||||
|
||||
@@ -24,6 +24,8 @@ const REBRANDED_404_BODY = `
|
||||
<div class="message">
|
||||
<h1>Page not found</h1>
|
||||
<p>We can't find the page you're looking for.</p>
|
||||
<p>It may have been moved, deleted or the link might be out of date.</p>
|
||||
<p>Ref: 404</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -63,6 +65,23 @@ describe("errorPageKitten", () => {
|
||||
expect(isSeqta404Page()).toBe(false);
|
||||
});
|
||||
|
||||
it("does not detect generic 404 pages on other sites", () => {
|
||||
document.title = "404 - Not Found";
|
||||
document.body.innerHTML = `
|
||||
<div class="message">
|
||||
<h1>Page not found</h1>
|
||||
<p>Sorry, this page does not exist.</p>
|
||||
</div>
|
||||
`;
|
||||
expect(isSeqta404Page()).toBe(false);
|
||||
});
|
||||
|
||||
it("does not treat a 404 title alone as SEQTA", () => {
|
||||
document.title = "Error 404";
|
||||
document.body.innerHTML = "<p>Not found</p>";
|
||||
expect(isSeqta404Page()).toBe(false);
|
||||
});
|
||||
|
||||
it("plugin run is a no-op outside a 404 page", async () => {
|
||||
document.title = "SEQTA Learn";
|
||||
document.body.innerHTML = '<div id="container"></div>';
|
||||
|
||||
@@ -16,12 +16,36 @@ const CARD_HTML = `<h1>404 Not Found</h1>
|
||||
</div>
|
||||
<a href="http://www.seqta.com.au">SEQTA</a>`;
|
||||
|
||||
function normalizePageText(text: string): string {
|
||||
return text
|
||||
.replace(/[\u2018\u2019]/g, "'")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
/** Fingerprints SEQTA's rebranded standalone 404 — not generic site 404s. */
|
||||
function isSeqtaRebranded404Message(message: Element): boolean {
|
||||
const heading = message.querySelector("h1");
|
||||
if (normalizePageText(heading?.textContent ?? "").toLowerCase() !== "page not found") {
|
||||
return false;
|
||||
}
|
||||
|
||||
const body = normalizePageText(message.textContent ?? "");
|
||||
return (
|
||||
body.includes("We can't find the page you're looking for") &&
|
||||
body.includes(
|
||||
"It may have been moved, deleted or the link might be out of date.",
|
||||
) &&
|
||||
body.includes("Ref: 404")
|
||||
);
|
||||
}
|
||||
|
||||
/** Standalone SEQTA 404 document — not the SPA (#container). */
|
||||
export function isSeqta404Page(): boolean {
|
||||
if (document.getElementById("container")) return false;
|
||||
const heading = document.querySelector(".message > h1");
|
||||
const text = heading?.textContent ?? document.title;
|
||||
return /not found/i.test(text) || /404/.test(document.title);
|
||||
const message = document.querySelector(".message");
|
||||
if (!message) return false;
|
||||
return isSeqtaRebranded404Message(message);
|
||||
}
|
||||
|
||||
export function mountErrorPageKitten(): () => void {
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
isValidHotkey,
|
||||
} from "./src/utils/hotkeyUtils";
|
||||
import { titleBarState } from "@/seqta/ui/titlebar/titleBarState.svelte";
|
||||
import { isPluginAllowedInPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
const settings = defineSettings({
|
||||
searchHotkey: hotkeySetting({
|
||||
@@ -91,6 +92,7 @@ const runGlobalSearch = globalSearchPlugin.run!;
|
||||
|
||||
globalSearchPlugin.run = async (api) => {
|
||||
if (isSeqtaEngageExperience() || isSeqtaLoginPage()) return () => {};
|
||||
if (!isPluginAllowedInPerformanceMode("global-search")) return () => {};
|
||||
|
||||
// Eager chrome (like Analytics menu injection) — heavy chunk loads behind it.
|
||||
const hotkey = isValidHotkey(api.settings.searchHotkey ?? "")
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
getStoredPassiveItems,
|
||||
installPassiveObserver,
|
||||
} from "../indexing/passiveObserver";
|
||||
import { globalSearchIndexingEnabled } from "@/seqta/utils/performanceMode";
|
||||
|
||||
function scheduleIdleIndexing(run: () => void): void {
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
@@ -83,7 +84,7 @@ const globalSearchPlugin: Plugin<{}> = {
|
||||
(await import("../indexing/selfTests")).runGlobalSearchSelfTests(),
|
||||
};
|
||||
|
||||
if (api.settings.passiveIndexing) {
|
||||
if (globalSearchIndexingEnabled(!!api.settings.passiveIndexing)) {
|
||||
try {
|
||||
installPassiveObserver();
|
||||
} catch (error) {
|
||||
@@ -91,7 +92,10 @@ const globalSearchPlugin: Plugin<{}> = {
|
||||
}
|
||||
}
|
||||
|
||||
if (api.settings.runIndexingOnLoad && !isIndexingPaused()) {
|
||||
if (
|
||||
globalSearchIndexingEnabled(!!api.settings.runIndexingOnLoad) &&
|
||||
!isIndexingPaused()
|
||||
) {
|
||||
scheduleIdleIndexing(() => {
|
||||
if (!isIndexingPaused()) void runIndexing();
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { unmount } from "svelte";
|
||||
import { warmUpVectorSearchOnInteraction } from "../search/vector/vectorSearch";
|
||||
import { formatHotkeyForDisplay, isValidHotkey } from "../utils/hotkeyUtils";
|
||||
import { waitForElm } from "@/seqta/utils/waitForElm";
|
||||
import { transparencyEnabled } from "@/seqta/utils/performanceMode";
|
||||
import browser from "webextension-polyfill";
|
||||
|
||||
type AppRef = {
|
||||
@@ -295,7 +296,7 @@ export async function mountSearchBar(
|
||||
SearchBar,
|
||||
searchRoot.attachShadow({ mode: "open" }),
|
||||
{
|
||||
transparencyEffects: api.settings.transparencyEffects,
|
||||
transparencyEffects: transparencyEnabled(),
|
||||
showRecentFirst: api.settings.showRecentFirst,
|
||||
searchHotkey: currentHotkey,
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@ const VERSION_KEY = "betterseqta-index-version";
|
||||
|
||||
let dbPromise: Promise<IDBDatabase> | null = null;
|
||||
let cachedDb: IDBDatabase | null = null;
|
||||
let upgradeChain: Promise<void> = Promise.resolve();
|
||||
|
||||
function getCurrentVersion(): number {
|
||||
const storedVersion = localStorage.getItem(VERSION_KEY);
|
||||
@@ -180,48 +181,161 @@ function idbRequest<T>(request: IDBRequest<T>): Promise<T> {
|
||||
});
|
||||
}
|
||||
|
||||
async function objectStore(
|
||||
function runStoreTransaction(
|
||||
db: IDBDatabase,
|
||||
store: string,
|
||||
mode: IDBTransactionMode = "readonly",
|
||||
): Promise<IDBObjectStore> {
|
||||
const db = await openDB();
|
||||
mode: IDBTransactionMode,
|
||||
run: (objectStore: IDBObjectStore) => void | Promise<void>,
|
||||
): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = db.transaction(store, mode);
|
||||
const objectStoreRef = tx.objectStore(store);
|
||||
|
||||
if (!db.objectStoreNames.contains(store)) {
|
||||
await upgradeDB(store);
|
||||
const upgradedDb = await openDB();
|
||||
return upgradedDb.transaction(store, mode).objectStore(store);
|
||||
Promise.resolve(run(objectStoreRef)).catch(reject);
|
||||
|
||||
tx.oncomplete = () => resolve();
|
||||
tx.onerror = () => reject(tx.error ?? new Error(`IndexedDB transaction failed for ${store}`));
|
||||
tx.onabort = () => reject(tx.error ?? new Error(`IndexedDB transaction aborted for ${store}`));
|
||||
});
|
||||
}
|
||||
|
||||
async function withUpgradeLock<T>(fn: () => Promise<T>): Promise<T> {
|
||||
const previous = upgradeChain;
|
||||
let release!: () => void;
|
||||
upgradeChain = new Promise<void>((resolve) => {
|
||||
release = resolve;
|
||||
});
|
||||
await previous;
|
||||
try {
|
||||
return await fn();
|
||||
} finally {
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
return db.transaction(store, mode).objectStore(store);
|
||||
async function openDatabaseWithStores(
|
||||
version: number,
|
||||
storesToCreate: string[],
|
||||
): Promise<IDBDatabase> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let request: IDBOpenDBRequest;
|
||||
try {
|
||||
request = indexedDB.open(DB_NAME, version);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
request.onupgradeneeded = () => {
|
||||
const db = request.result;
|
||||
if (!db.objectStoreNames.contains(META_STORE)) {
|
||||
db.createObjectStore(META_STORE);
|
||||
}
|
||||
for (const store of storesToCreate) {
|
||||
if (!db.objectStoreNames.contains(store)) {
|
||||
db.createObjectStore(store);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
request.onsuccess = () => {
|
||||
attachConnection(request.result);
|
||||
resolve(request.result);
|
||||
};
|
||||
request.onerror = () => reject(request.error);
|
||||
});
|
||||
}
|
||||
|
||||
async function upgradeDB(newStore: string): Promise<void> {
|
||||
invalidateConnection();
|
||||
await withUpgradeLock(async () => {
|
||||
invalidateConnection();
|
||||
|
||||
let baseVersion = 0;
|
||||
let baseVersion = 0;
|
||||
|
||||
try {
|
||||
const db = await openDatabase();
|
||||
baseVersion = db.version;
|
||||
try {
|
||||
const db = await openDatabase();
|
||||
if (db.objectStoreNames.contains(newStore)) {
|
||||
attachConnection(db);
|
||||
return;
|
||||
}
|
||||
baseVersion = db.version;
|
||||
db.close();
|
||||
cachedDb = null;
|
||||
dbPromise = null;
|
||||
} catch (error) {
|
||||
console.warn("[DB] Could not probe database version before upgrade:", error);
|
||||
}
|
||||
|
||||
try {
|
||||
await openDatabaseWithStores(baseVersion + 1, [newStore]);
|
||||
} catch (error) {
|
||||
console.error("Error upgrading database:", error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates any missing object stores in a single version bump so later job
|
||||
* writes do not race passive observer traffic on a mid-run upgrade.
|
||||
*/
|
||||
export async function ensureStoresExist(stores: string[]): Promise<void> {
|
||||
const uniqueStores = [...new Set(stores.filter(Boolean))];
|
||||
if (uniqueStores.length === 0) return;
|
||||
|
||||
await withUpgradeLock(async () => {
|
||||
let db: IDBDatabase;
|
||||
try {
|
||||
db = await openDB();
|
||||
} catch (error) {
|
||||
console.warn("[DB] ensureStoresExist: could not open database:", error);
|
||||
return;
|
||||
}
|
||||
|
||||
const missing = uniqueStores.filter(
|
||||
(store) => !db.objectStoreNames.contains(store),
|
||||
);
|
||||
if (missing.length === 0) return;
|
||||
|
||||
invalidateConnection();
|
||||
const baseVersion = db.version;
|
||||
db.close();
|
||||
cachedDb = null;
|
||||
dbPromise = null;
|
||||
} catch (error) {
|
||||
console.warn("[DB] Could not probe database version before upgrade:", error);
|
||||
|
||||
try {
|
||||
await openDatabaseWithStores(baseVersion + 1, missing);
|
||||
} catch (error) {
|
||||
console.error("[DB] ensureStoresExist failed:", error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function withObjectStore<T>(
|
||||
store: string,
|
||||
mode: IDBTransactionMode,
|
||||
run: (objectStore: IDBObjectStore) => Promise<T>,
|
||||
): Promise<T> {
|
||||
let db = await openDB();
|
||||
|
||||
if (!db.objectStoreNames.contains(store)) {
|
||||
await upgradeDB(store);
|
||||
db = await openDB();
|
||||
}
|
||||
|
||||
try {
|
||||
await openDatabase(baseVersion + 1, newStore);
|
||||
} catch (error) {
|
||||
console.error("Error upgrading database:", error);
|
||||
throw error;
|
||||
}
|
||||
let result!: T;
|
||||
await runStoreTransaction(db, store, mode, async (objectStoreRef) => {
|
||||
result = await run(objectStoreRef);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getAll(store: string): Promise<any[]> {
|
||||
try {
|
||||
const s = await objectStore(store);
|
||||
return await idbRequest(s.getAll());
|
||||
return await withObjectStore(store, "readonly", async (s) =>
|
||||
idbRequest(s.getAll()),
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(`Error in getAll for store ${store}:`, error);
|
||||
return [];
|
||||
@@ -230,8 +344,9 @@ export async function getAll(store: string): Promise<any[]> {
|
||||
|
||||
export async function get(store: string, key: string): Promise<any> {
|
||||
try {
|
||||
const s = await objectStore(store);
|
||||
return await idbRequest(s.get(key));
|
||||
return await withObjectStore(store, "readonly", async (s) =>
|
||||
idbRequest(s.get(key)),
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(`Error in get for store ${store}, key ${key}:`, error);
|
||||
return null;
|
||||
@@ -244,8 +359,9 @@ export async function put(
|
||||
key?: string,
|
||||
): Promise<void> {
|
||||
try {
|
||||
const s = await objectStore(store, "readwrite");
|
||||
await idbRequest(key ? s.put(value, key) : s.put(value));
|
||||
await withObjectStore(store, "readwrite", async (s) => {
|
||||
await idbRequest(key ? s.put(value, key) : s.put(value));
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error in put for store ${store}:`, error);
|
||||
throw error;
|
||||
@@ -297,8 +413,9 @@ function runStoreDiffTransaction(
|
||||
|
||||
export async function remove(store: string, key: string): Promise<void> {
|
||||
try {
|
||||
const s = await objectStore(store, "readwrite");
|
||||
await idbRequest(s.delete(key));
|
||||
await withObjectStore(store, "readwrite", async (s) => {
|
||||
await idbRequest(s.delete(key));
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error in remove for store ${store}, key ${key}:`, error);
|
||||
throw error;
|
||||
@@ -307,8 +424,9 @@ export async function remove(store: string, key: string): Promise<void> {
|
||||
|
||||
export async function clear(store: string): Promise<void> {
|
||||
try {
|
||||
const s = await objectStore(store, "readwrite");
|
||||
await idbRequest(s.clear());
|
||||
await withObjectStore(store, "readwrite", async (s) => {
|
||||
await idbRequest(s.clear());
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error in clear for store ${store}:`, error);
|
||||
throw error;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { applyStoreDiff, get, getAll, put, remove } from "./db";
|
||||
import { applyStoreDiff, ensureStoresExist, get, getAll, put, remove } from "./db";
|
||||
import { jobs } from "./jobs";
|
||||
import { decorateIndexItems } from "./renderComponents";
|
||||
import type { IndexItem, Job, JobContext } from "./types";
|
||||
@@ -8,6 +8,8 @@ import { getVectorizedItemIds, pruneOrphanVectorEmbeddings } from "./utils";
|
||||
import { INDEX_SCHEMA_VERSION, SCHEMA_VERSION_KEY } from "./schemaVersion";
|
||||
import { resetSearchIndexes } from "./resetIndexes";
|
||||
import { isIndexingPaused } from "./indexingPause";
|
||||
import { setIndexingActive } from "./indexingState";
|
||||
import { isPluginBlockedByPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
import { verboseDebug } from '@/utils/verboseLog';
|
||||
const META_STORE = "meta";
|
||||
@@ -285,6 +287,11 @@ function dispatchVectorProgress(
|
||||
}
|
||||
|
||||
export async function runIndexing(): Promise<void> {
|
||||
if (isPluginBlockedByPerformanceMode("global-search")) {
|
||||
verboseDebug("[Indexer] Skipping indexing — performance mode blocks Global Search.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isIndexingPaused()) {
|
||||
verboseDebug(
|
||||
"[Indexer] Skipping indexing — index was reset; reload the page to rebuild.",
|
||||
@@ -304,10 +311,13 @@ export async function runIndexing(): Promise<void> {
|
||||
}
|
||||
|
||||
startHeartbeat();
|
||||
setIndexingActive(true);
|
||||
verboseDebug("%c[Indexer] Starting indexing...", "color: green");
|
||||
|
||||
try {
|
||||
const jobIds = Object.keys(jobs);
|
||||
await ensureStoresExist([META_STORE, ...jobIds]);
|
||||
|
||||
let completedJobs = 0;
|
||||
const totalSteps = jobIds.length + 1;
|
||||
dispatchProgress(completedJobs, totalSteps, true, "Starting jobs");
|
||||
@@ -379,6 +389,15 @@ export async function runIndexing(): Promise<void> {
|
||||
removeItem,
|
||||
getProgress: () => loadProgress(jobId),
|
||||
setProgress: (p) => saveProgress(jobId, p),
|
||||
reportJobProgress: ({ processed, total, status }) => {
|
||||
const stepProgress = total > 0 ? processed / total : 0;
|
||||
dispatchProgress(
|
||||
completedJobs + stepProgress,
|
||||
totalSteps,
|
||||
true,
|
||||
status ?? `Running job: ${job.label}`,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
verboseDebug(`%c[Indexer] Running job "${jobId}"...`, "color: #4ea1ff");
|
||||
@@ -500,6 +519,7 @@ export async function runIndexing(): Promise<void> {
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
setIndexingActive(false);
|
||||
stopHeartbeat();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import {
|
||||
isIndexingActive,
|
||||
setIndexingActive,
|
||||
} from "./indexingState";
|
||||
|
||||
describe("indexingState", () => {
|
||||
afterEach(() => {
|
||||
setIndexingActive(false);
|
||||
});
|
||||
|
||||
it("tracks whether structured indexing is running", () => {
|
||||
expect(isIndexingActive()).toBe(false);
|
||||
setIndexingActive(true);
|
||||
expect(isIndexingActive()).toBe(true);
|
||||
setIndexingActive(false);
|
||||
expect(isIndexingActive()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
/** True while `runIndexing()` holds the indexer lock in this tab. */
|
||||
let indexingActive = false;
|
||||
|
||||
export function setIndexingActive(active: boolean): void {
|
||||
indexingActive = active;
|
||||
}
|
||||
|
||||
export function isIndexingActive(): boolean {
|
||||
return indexingActive;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ export const coursesJob: Job = {
|
||||
return score;
|
||||
},
|
||||
|
||||
run: async (_ctx) => {
|
||||
run: async (ctx) => {
|
||||
const subjects = await fetchActiveSubjects();
|
||||
if (subjects.length === 0) {
|
||||
verboseDebug("[Courses job] No active subjects discovered.");
|
||||
@@ -113,6 +113,8 @@ export const coursesJob: Job = {
|
||||
|
||||
const items: IndexItem[] = [];
|
||||
const seenIds = new Set<string>();
|
||||
const totalSubjects = subjects.length;
|
||||
let processedSubjects = 0;
|
||||
|
||||
// Sequential per-subject fetch keeps load on SEQTA bounded; the shared
|
||||
// API layer also limits concurrency per route as a defense in depth.
|
||||
@@ -121,6 +123,12 @@ export const coursesJob: Job = {
|
||||
if (seenIds.has(id)) continue;
|
||||
seenIds.add(id);
|
||||
|
||||
ctx.reportJobProgress?.({
|
||||
processed: processedSubjects,
|
||||
total: totalSubjects,
|
||||
status: `Running job: Courses (${processedSubjects + 1}/${totalSubjects})`,
|
||||
});
|
||||
|
||||
const payload = await seqtaFetchPayload<CoursePayload>(
|
||||
"/seqta/student/load/courses",
|
||||
{
|
||||
@@ -129,7 +137,10 @@ export const coursesJob: Job = {
|
||||
},
|
||||
);
|
||||
|
||||
if (!payload) continue;
|
||||
if (!payload) {
|
||||
processedSubjects++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const title =
|
||||
(typeof payload.t === "string" && payload.t.trim()) ||
|
||||
@@ -168,8 +179,15 @@ export const coursesJob: Job = {
|
||||
renderComponentId: "course",
|
||||
}),
|
||||
);
|
||||
processedSubjects++;
|
||||
}
|
||||
|
||||
ctx.reportJobProgress?.({
|
||||
processed: totalSubjects,
|
||||
total: totalSubjects,
|
||||
status: "Running job: Courses (saving)",
|
||||
});
|
||||
|
||||
verboseDebug(
|
||||
`[Courses job] Indexed ${items.length} courses across ${subjects.length} subjects.`,
|
||||
);
|
||||
|
||||
@@ -11,7 +11,9 @@ import { isSensitiveSeqtaPath, normalizeSeqtaPath } from "./api";
|
||||
import { mergeDynamicItems } from "../utils/dynamicItems";
|
||||
import { decorateIndexItems } from "./renderComponents";
|
||||
import { isIndexingPaused } from "./indexingPause";
|
||||
import { isIndexingActive } from "./indexingState";
|
||||
import { isAssessmentListRoute } from "./routeFilters";
|
||||
import { isPluginBlockedByPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
/**
|
||||
* Passive network observer.
|
||||
@@ -295,6 +297,73 @@ function titleFromEndpoint(
|
||||
return (firstLine || fallback).slice(0, 200);
|
||||
}
|
||||
|
||||
function shouldSkipPassiveEntity(
|
||||
ctx: CapturedContext,
|
||||
entity: unknown,
|
||||
isPeopleSupport: boolean,
|
||||
): boolean {
|
||||
if (!entity || (typeof entity !== "object" && typeof entity !== "string")) {
|
||||
return true;
|
||||
}
|
||||
if (ctx.route.includes("/load/message") && typeof entity === "object") {
|
||||
const subject = (entity as Record<string, unknown>).subject;
|
||||
if (typeof subject === "string" && subject.startsWith("BQ+TIMETABLE:")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return isPeopleSupport && !isPeopleEntityWorthIndexing(entity);
|
||||
}
|
||||
|
||||
function passiveEntityToIndexItem(
|
||||
ctx: CapturedContext,
|
||||
entity: unknown,
|
||||
index: number,
|
||||
category: ReturnType<typeof categoryFromRoute>,
|
||||
isPeopleSupport: boolean,
|
||||
): IndexItem | null {
|
||||
const fallbackId = `${ctx.route}#${index}`;
|
||||
const entityId = pickId(entity, fallbackId);
|
||||
const stableId = `passive-${ctx.route.replace(/\//g, "_")}-${entityId}`;
|
||||
|
||||
const content = extractTextFromValue(entity, {
|
||||
maxChars: MAX_PER_RESPONSE_TEXT_CHARS,
|
||||
});
|
||||
const title = titleFromEndpoint(ctx.route, entity, content, fallbackId);
|
||||
if (!content && (!title || title === fallbackId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const deepLinkHints = pickDeepLinkHints(entity);
|
||||
const sourcePage = sourcePageForRoute(ctx.route);
|
||||
const coursePm = ctx.route.includes("/load/courses")
|
||||
? extractProgrammeMetaclass(ctx.requestBody, entity)
|
||||
: null;
|
||||
|
||||
return buildIndexItem({
|
||||
id: stableId,
|
||||
text: title,
|
||||
category,
|
||||
contentOverride: content,
|
||||
metadata: {
|
||||
route: ctx.route,
|
||||
source: "passive",
|
||||
observedAt: new Date(ctx.observedAt).toISOString(),
|
||||
entityType: category,
|
||||
entityId,
|
||||
icon: "\ueb71",
|
||||
sourcePage,
|
||||
...(isPeopleSupport ? { supportRecord: true, priority: "low" } : {}),
|
||||
...deepLinkHints,
|
||||
...(coursePm
|
||||
? { programme: coursePm.programme, metaclass: coursePm.metaclass }
|
||||
: {}),
|
||||
},
|
||||
actionId: "passive",
|
||||
renderComponentId: "passive",
|
||||
dateAdded: ctx.observedAt,
|
||||
});
|
||||
}
|
||||
|
||||
function synthesizeItems(
|
||||
ctx: CapturedContext,
|
||||
payload: unknown,
|
||||
@@ -305,75 +374,16 @@ function synthesizeItems(
|
||||
if (entities.length === 0) return [];
|
||||
|
||||
const category = categoryFromRoute(ctx.route);
|
||||
const now = ctx.observedAt;
|
||||
const out: IndexItem[] = [];
|
||||
|
||||
const isPeopleSupport = ctx.route.includes("/load/message/people");
|
||||
|
||||
const out: IndexItem[] = [];
|
||||
const limit = Math.min(entities.length, MAX_ITEMS_PER_RESPONSE);
|
||||
|
||||
for (let i = 0; i < limit; i++) {
|
||||
const entity = entities[i];
|
||||
if (!entity || (typeof entity !== "object" && typeof entity !== "string")) {
|
||||
continue;
|
||||
}
|
||||
if (shouldSkipPassiveEntity(ctx, entity, isPeopleSupport)) continue;
|
||||
|
||||
// For the messages compose-people endpoint, skip records that don't
|
||||
// carry a real human name. We never want raw entries like
|
||||
// `/seqta/student/load/message/people#20` becoming titles, and we
|
||||
// explicitly route the rest to /messages so they're treated as support
|
||||
// records, not standalone "people" results.
|
||||
if (isPeopleSupport && !isPeopleEntityWorthIndexing(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const fallbackId = `${ctx.route}#${i}`;
|
||||
const entityId = pickId(entity, fallbackId);
|
||||
const stableId = `passive-${ctx.route.replace(/\//g, "_")}-${entityId}`;
|
||||
|
||||
const content = extractTextFromValue(entity, {
|
||||
maxChars: MAX_PER_RESPONSE_TEXT_CHARS,
|
||||
});
|
||||
const title = titleFromEndpoint(ctx.route, entity, content, fallbackId);
|
||||
if (!content && (!title || title === fallbackId)) {
|
||||
// Skip records that produced neither title nor content; they are
|
||||
// structurally noise (e.g. tiny acknowledgement payloads).
|
||||
continue;
|
||||
}
|
||||
|
||||
const deepLinkHints = pickDeepLinkHints(entity);
|
||||
const sourcePage = sourcePageForRoute(ctx.route);
|
||||
const coursePm = ctx.route.includes("/load/courses")
|
||||
? extractProgrammeMetaclass(ctx.requestBody, entity)
|
||||
: null;
|
||||
|
||||
out.push(
|
||||
buildIndexItem({
|
||||
id: stableId,
|
||||
text: title,
|
||||
category,
|
||||
contentOverride: content,
|
||||
metadata: {
|
||||
route: ctx.route,
|
||||
source: "passive",
|
||||
observedAt: new Date(now).toISOString(),
|
||||
entityType: category,
|
||||
entityId,
|
||||
icon: "\ueb71",
|
||||
sourcePage,
|
||||
// Mark message/people as a low-priority support record so the
|
||||
// search ranker can deprioritize it relative to real messages,
|
||||
// assessments, courses, etc.
|
||||
...(isPeopleSupport ? { supportRecord: true, priority: "low" } : {}),
|
||||
...deepLinkHints,
|
||||
...(coursePm
|
||||
? { programme: coursePm.programme, metaclass: coursePm.metaclass }
|
||||
: {}),
|
||||
},
|
||||
actionId: "passive",
|
||||
renderComponentId: "passive",
|
||||
dateAdded: now,
|
||||
}),
|
||||
);
|
||||
const item = passiveEntityToIndexItem(ctx, entity, i, category, isPeopleSupport);
|
||||
if (item) out.push(item);
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -384,7 +394,7 @@ function synthesizeItems(
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
async function persistItems(items: IndexItem[]): Promise<void> {
|
||||
if (items.length === 0 || isIndexingPaused()) return;
|
||||
if (items.length === 0 || isIndexingPaused() || isIndexingActive()) return;
|
||||
|
||||
// Dedupe against existing entries. We replace on collision so the latest
|
||||
// observation wins (e.g. if a message changes title).
|
||||
@@ -405,10 +415,10 @@ async function persistItems(items: IndexItem[]): Promise<void> {
|
||||
}
|
||||
|
||||
function scheduleFlush() {
|
||||
if (pendingFlush || isIndexingPaused()) return;
|
||||
if (pendingFlush || isIndexingPaused() || isIndexingActive()) return;
|
||||
pendingFlush = setTimeout(() => {
|
||||
pendingFlush = null;
|
||||
if (!pendingDirty || isIndexingPaused()) return;
|
||||
if (!pendingDirty || isIndexingPaused() || isIndexingActive()) return;
|
||||
pendingDirty = false;
|
||||
void flushDynamicItems();
|
||||
}, FLUSH_DEBOUNCE_MS);
|
||||
@@ -425,7 +435,7 @@ export function pausePassiveObserver(): void {
|
||||
}
|
||||
|
||||
async function flushDynamicItems(): Promise<void> {
|
||||
if (isIndexingPaused()) return;
|
||||
if (isIndexingPaused() || isIndexingActive()) return;
|
||||
if (pendingChangedItems.size === 0) return;
|
||||
|
||||
const rawChanged = Array.from(pendingChangedItems.values());
|
||||
@@ -480,6 +490,7 @@ async function consumeResponse(
|
||||
url: string,
|
||||
requestBody: unknown,
|
||||
): Promise<void> {
|
||||
if (isPluginBlockedByPerformanceMode("global-search")) return;
|
||||
if (!response.ok) return;
|
||||
|
||||
const route = normalizeSeqtaPath(url);
|
||||
|
||||
@@ -24,6 +24,12 @@ export interface JobContext {
|
||||
removeItem: (id: string, storeId?: string) => Promise<void>;
|
||||
getProgress: <T = any>() => Promise<T | undefined>;
|
||||
setProgress: <T = any>(progress: T) => Promise<void>;
|
||||
/** Optional live status/progress while a long-running job is in flight. */
|
||||
reportJobProgress?: (detail: {
|
||||
processed: number;
|
||||
total: number;
|
||||
status?: string;
|
||||
}) => void;
|
||||
}
|
||||
|
||||
export interface Job {
|
||||
|
||||
Loaded 100 of 264 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user