Compare commits

...
22 changed files with 967 additions and 71 deletions

No files matched your search

-1
View File
@@ -1,2 +1 @@
legacy-peer-deps=true
+1 -1
View File
@@ -1,6 +1,6 @@
export default {
preset: 'ts-jest',
testEnvironment: 'node',
testEnvironment: 'jsdom',
roots: ['<rootDir>/src'],
testMatch: [
'**/__tests__/**/*.ts',
+304 -1
View File
@@ -3844,18 +3844,320 @@ div.day-empty {
.userInfo {
display: flex;
align-items: center;
padding-top: 4px;
padding: 4px 0;
}
.userInfoText {
text-align: end;
padding: 2px 0;
}
.userInfoName {
margin: 0 !important;
font-size: 20px;
font-weight: 700;
line-height: 1.2;
}
.userInfoCode {
margin: 0 !important;
line-height: 1.2;
}
.userInfoNameRow {
display: inline-flex;
align-items: center;
justify-content: flex-end;
gap: 6px;
}
.userInfoDetails {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 2px;
}
.userInfoHouseWrap {
display: inline-block;
margin: 0 8px;
text-align: center;
}
.userInfoHouseWrap .userInfohouse {
display: block;
margin: 0 !important;
padding: 0 6px !important;
box-sizing: border-box;
}
.userInfoHouseWrap .bsplus-founder-badge-slot {
width: 100%;
margin-top: 4px;
}
.userInfoHouseWrap .bsplus-founder-badge-slot[hidden],
.bsplus-founder-badge-slot[hidden] {
display: none;
}
.bsplus-founder-badge--titlebar {
display: block;
width: 100%;
border-radius: 5px;
}
.bsplus-founder-badge--titlebar .bsplus-founder-badge__glass,
.bsplus-founder-badge--titlebar .bsplus-founder-badge__content {
width: 100%;
border-radius: 5px;
box-sizing: border-box;
}
.bsplus-founder-badge--titlebar .bsplus-founder-badge__content {
justify-content: center;
padding: 0 6px;
gap: 0;
min-height: 0;
height: auto;
font-size: 15px;
line-height: normal;
backdrop-filter: none;
-webkit-backdrop-filter: none;
background: rgba(255, 255, 255, 0.12);
box-shadow:
inset 0 0 0 1px rgba(255, 255, 255, 0.28),
inset 0 1px 0 rgba(255, 255, 255, 0.16),
inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}
.bsplus-founder-badge--titlebar .bsplus-founder-badge__label {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
}
.bsplus-founder-badge--titlebar:focus-visible .bsplus-founder-badge__content {
box-shadow:
inset 0 0 0 1px rgba(255, 255, 255, 0.28),
inset 0 1px 0 rgba(255, 255, 255, 0.16),
inset 0 -1px 0 rgba(0, 0, 0, 0.12),
0 0 0 2px var(--theme-primary, #f97316),
0 0 0 4px rgba(249, 115, 22, 0.35);
}
.legacy-root .bsplus-founder-badge,
.legacy-root .bsplus-founder-badge-actions .bsplus-cal-btn {
background: transparent !important;
}
.legacy-root .bsplus-founder-badge::after,
.legacy-root .bsplus-founder-badge-actions .bsplus-cal-btn::after {
display: none !important;
content: none !important;
}
.legacy-root .bsplus-founder-badge-actions .bsplus-cal-btn--ghost {
background: color-mix(in srgb, var(--text-primary, #111) 8%, transparent) !important;
}
.legacy-root .bsplus-founder-badge-actions .bsplus-cal-btn--ghost:hover {
background: color-mix(in srgb, var(--text-primary, #111) 14%, transparent) !important;
}
.legacy-root .bsplus-founder-badge-actions .bsplus-cal-btn--primary {
background: var(--better-main, #3b82f6) !important;
}
.bsplus-founder-badge {
position: relative;
display: inline-flex;
padding: 0;
margin: 0;
border: none;
border-radius: 5px;
background: transparent;
vertical-align: middle;
cursor: pointer;
font-family: var(--betterseqta-font-family, Rubik), sans-serif !important;
transition: transform 0.2s ease;
white-space: nowrap;
}
.bsplus-founder-badge--hero {
border-radius: 12px;
}
.bsplus-founder-badge:hover {
transform: scale(1.02);
}
.bsplus-founder-badge:focus {
outline: none;
}
.bsplus-founder-badge:focus-visible .bsplus-founder-badge__glass {
box-shadow:
inset 0 0 0 1px rgba(255, 255, 255, 0.78),
inset 0 1px 0 rgba(255, 255, 255, 0.52),
inset 0 2px 8px rgba(255, 255, 255, 0.14),
inset 0 -1px 0 rgba(0, 0, 0, 0.08),
0 0 0 2px var(--theme-primary, #f97316),
0 0 0 4px rgba(249, 115, 22, 0.35);
}
.bsplus-founder-badge__glass {
position: relative;
display: inline-flex;
overflow: hidden;
border-radius: inherit;
background: var(--badge-base, #1e293b);
}
.bsplus-founder-badge__blobs {
position: absolute;
inset: 0;
pointer-events: none;
background:
radial-gradient(ellipse 72% 68% at 18% 42%, var(--badge-blob-a), transparent 72%),
radial-gradient(ellipse 68% 62% at 82% 58%, var(--badge-blob-b), transparent 70%),
radial-gradient(ellipse 64% 56% at 50% 88%, var(--badge-blob-c), transparent 68%);
filter: blur(1px);
}
.bsplus-founder-badge__content {
position: relative;
z-index: 1;
display: inline-flex;
align-items: center;
gap: 5px;
padding: 0 10px;
min-height: 22px;
border-radius: inherit;
color: #fff;
font-size: 15px;
font-weight: 600;
line-height: 22px;
letter-spacing: 0.01em;
font-family: inherit;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(14px) saturate(1.3);
-webkit-backdrop-filter: blur(14px) saturate(1.3);
background: rgba(255, 255, 255, 0.16);
box-shadow:
inset 0 0 0 1px rgba(255, 255, 255, 0.78),
inset 0 1px 0 rgba(255, 255, 255, 0.52),
inset 0 2px 8px rgba(255, 255, 255, 0.14),
inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}
.bsplus-founder-badge--hero .bsplus-founder-badge__content {
gap: 8px;
padding: 10px 16px;
min-height: auto;
font-size: 14px;
line-height: 1.2;
backdrop-filter: none;
-webkit-backdrop-filter: none;
background: rgba(255, 255, 255, 0.2);
}
.bsplus-founder-badge--hero .bsplus-founder-badge__glass {
background: transparent;
}
.bsplus-founder-badge__icon {
flex-shrink: 0;
width: 15px;
height: 15px;
opacity: 0.95;
}
.bsplus-founder-badge--hero .bsplus-founder-badge__icon {
width: 20px;
height: 20px;
}
.bsplus-founder-badge-hero {
position: relative;
display: block;
overflow: hidden;
margin: 0 auto;
width: 90%;
aspect-ratio: 16 / 9;
border-radius: 16px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
background: var(--badge-base, #0f172a);
}
.bsplus-founder-badge-hero__blobs {
position: absolute;
inset: -22%;
pointer-events: none;
background:
radial-gradient(ellipse 72% 62% at 18% 34%, var(--badge-blob-a), transparent 76%),
radial-gradient(ellipse 68% 58% at 82% 42%, var(--badge-blob-b), transparent 74%),
radial-gradient(ellipse 74% 64% at 52% 88%, var(--badge-blob-c), transparent 76%),
radial-gradient(ellipse 78% 68% at 48% 52%, var(--badge-blob-b), transparent 78%);
filter: blur(10px);
}
.bsplus-founder-badge-hero__vignette {
position: absolute;
inset: 0;
pointer-events: none;
background: radial-gradient(ellipse at center, transparent 34%, rgba(0, 0, 0, 0.62) 100%);
opacity: 0.84;
}
.bsplus-founder-badge-hero__stage {
position: absolute;
inset: 0;
display: grid;
place-items: center;
pointer-events: none;
}
.bsplus-founder-badge-hero__stage .bsplus-founder-badge {
pointer-events: auto;
}
.whatsnewTextContainer.bsplus-founder-badge-body p {
margin: 0 0 1rem;
font-size: 1.2rem;
line-height: 1.6;
}
.whatsnewTextContainer.bsplus-founder-badge-body a {
color: inherit;
text-decoration: underline;
text-underline-offset: 2px;
}
.bsplus-founder-badge-signup {
margin: 0 0 1rem !important;
padding: 0.55rem 0.75rem;
border-radius: 0.6rem;
border: 1px solid color-mix(in srgb, var(--text-primary) 12%, transparent);
background: color-mix(in srgb, var(--text-primary) 5%, transparent);
font-size: 1rem !important;
font-weight: 600;
font-variant-numeric: tabular-nums;
}
.bsplus-founder-badge-header {
align-items: center;
text-align: center;
h1,
p {
width: 100%;
}
}
.bsplus-founder-badge-actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
margin-top: 1.25rem;
}
.bsplus-founder-badge-actions .bsplus-cal-btn {
padding: 8px 14px;
border: none;
border-radius: 10px;
font-size: 13px;
font-weight: 600;
font-family: inherit;
line-height: 1.25;
cursor: pointer;
transition: all 0.2s ease;
}
.bsplus-founder-badge-actions .bsplus-cal-btn:focus-visible {
outline: none;
box-shadow:
0 0 0 2px var(--background-primary, #fff),
0 0 0 4px var(--better-main, #3b82f6);
}
.bsplus-founder-badge-actions .bsplus-cal-btn--ghost {
background: color-mix(in srgb, var(--text-primary, #111) 8%, transparent);
color: var(--text-primary, #111);
}
.bsplus-founder-badge-actions .bsplus-cal-btn--ghost:hover {
background: color-mix(in srgb, var(--text-primary, #111) 14%, transparent);
transform: scale(1.02);
}
.bsplus-founder-badge-actions .bsplus-cal-btn--primary {
background: var(--better-main, #3b82f6);
color: #fff;
}
.bsplus-founder-badge-actions .bsplus-cal-btn--primary:hover {
filter: brightness(1.06);
transform: scale(1.02);
}
.bsplus-founder-badge-actions .bsplus-cal-btn:active {
transform: scale(0.98);
}
.userInfosvg {
width: 50px;
@@ -3898,6 +4200,7 @@ div.day-empty {
color: var(--text-primary);
background: var(--auto-background);
outline: solid 1px black;
text-align: center;
}
.DarkLightButton {
right: 145px !important;
+8 -3
View File
@@ -283,9 +283,14 @@
const applyDestination = (destination: SettingsDestination) => {
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";
} else if (destination.page === "backgrounds" && destination.view) {
+43 -2
View File
@@ -173,6 +173,27 @@
return !q || parts.some((part) => part?.toLowerCase().includes(q));
};
const founderBadgeSetting = {
title: "Titlebar founder badge",
description: "Show your Cloud founder badge in the SEQTA titlebar",
} as const;
const showCloudCardHeader = $derived(
matchesSearch("BetterSEQTA Cloud", "Account & sync"),
);
const showFounderBadgeSetting = $derived(
matchesSearch(
founderBadgeSetting.title,
founderBadgeSetting.description,
"founder badge",
"titlebar",
"founder",
),
);
const showCloudAccountCard = $derived(showCloudCardHeader || showFounderBadgeSetting);
const pluginHit = (plugin: Plugin) =>
matchesSearch(plugin.name, plugin.description, ...Object.values(plugin.settings).flatMap((s) => [s.title, s.description]));
@@ -214,9 +235,10 @@
props: {}
})}
{#if matchesSearch("BetterSEQTA Cloud", "Account & sync")}
{#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-5 py-4">
<div class="pr-4">
<h2 class="text-xl font-bold">BetterSEQTA Cloud</h2>
@@ -226,9 +248,28 @@
<CloudHeader alwaysShowUserName onClick={showCloudPanel} />
</div>
</div>
{/if}
{#if cloudState.isLoggedIn}
<div class="px-3 pb-3">
<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}
{@render Setting({
title: founderBadgeSetting.title,
description: founderBadgeSetting.description,
id: 17,
Component: Switch,
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>
+99 -48
View File
@@ -52,7 +52,8 @@ function showEditModal(
const modal = document.createElement("div");
modal.className = "timetable-edit-modal";
const override = overrides?.[String(item.ci)] ?? overridesBySubject?.[item.description];
const override =
overrides?.[String(item.ci)] ?? overridesBySubject?.[item.description];
const roomValue = override?.room ?? item.room ?? "";
const staffValue = override?.staff ?? item.staff ?? "";
@@ -97,21 +98,31 @@ function showEditModal(
modal.addEventListener("mousedown", (e) => e.stopPropagation());
modal.addEventListener("mouseup", (e) => e.stopPropagation());
const roomInput = modal.querySelector("#timetable-edit-room") as HTMLInputElement;
const staffInput = modal.querySelector("#timetable-edit-staff") as HTMLInputElement;
const applyFutureCheckbox = modal.querySelector("#timetable-edit-apply-future") as HTMLInputElement;
const roomInput = modal.querySelector(
"#timetable-edit-room",
) as HTMLInputElement;
const staffInput = modal.querySelector(
"#timetable-edit-staff",
) as HTMLInputElement;
const applyFutureCheckbox = modal.querySelector(
"#timetable-edit-apply-future",
) as HTMLInputElement;
modal.querySelector(".timetable-edit-btn-save")?.addEventListener("click", () => {
onSave(
item.ci,
roomInput.value.trim(),
staffInput.value.trim(),
applyFutureCheckbox?.checked ?? false,
);
removeModal();
});
modal
.querySelector(".timetable-edit-btn-save")
?.addEventListener("click", () => {
onSave(
item.ci,
roomInput.value.trim(),
staffInput.value.trim(),
applyFutureCheckbox?.checked ?? false,
);
removeModal();
});
modal.querySelector(".timetable-edit-btn-cancel")?.addEventListener("click", removeModal);
modal
.querySelector(".timetable-edit-btn-cancel")
?.addEventListener("click", removeModal);
const clearBtn = modal.querySelector(".timetable-edit-btn-clear");
if (clearBtn) {
@@ -163,7 +174,9 @@ const timetableEditPlugin = {
if (byCalendar) return byCalendar as HTMLElement;
}
for (const entry of document.querySelectorAll(".timetablepage .entry.class")) {
for (const entry of document.querySelectorAll(
".timetablepage .entry.class",
)) {
const entryTitle = entry.querySelector(".title")?.textContent?.trim();
if (entryTitle === title) return entry as HTMLElement;
}
@@ -174,7 +187,8 @@ const timetableEditPlugin = {
const title = quickbar.querySelector(".title")?.textContent?.trim() ?? "";
if (!title) return;
const quickbarRoom = quickbar.querySelector(".meta .room")?.textContent?.trim() ?? "";
const quickbarRoom =
quickbar.querySelector(".meta .room")?.textContent?.trim() ?? "";
const quickbarStaff =
quickbar.querySelector(".meta .teacher")?.textContent?.trim() ?? "";
@@ -211,7 +225,10 @@ const timetableEditPlugin = {
};
const processEntry = (entry: HTMLElement): void => {
if (entry.classList.contains("assessment") || entry.hasAttribute("data-timetable-edit-processed")) return;
// Mixed timetable entries can include both the `class` and `assessment`
// classes, especially when an assessment is attached to a lesson. We still
// need to apply the per-lesson override to that element.
if (entry.hasAttribute("data-timetable-edit-processed")) return;
const ciStr = entry.getAttribute("data-instance");
if (!ciStr) return;
@@ -233,8 +250,10 @@ const timetableEditPlugin = {
const override = getEffectiveOverride(ci, description);
if (override) {
if (override.room !== undefined && roomEl) roomEl.textContent = override.room;
if (override.staff !== undefined && teacherEl) teacherEl.textContent = override.staff;
if (override.room !== undefined && roomEl)
roomEl.textContent = override.room;
if (override.staff !== undefined && teacherEl)
teacherEl.textContent = override.staff;
}
entry.addEventListener(
@@ -250,14 +269,19 @@ const timetableEditPlugin = {
};
const processAllEntries = () => {
document.querySelectorAll(".timetablepage .entry.class").forEach((entry) => {
processEntry(entry as HTMLElement);
});
document
.querySelectorAll(".timetablepage .entry.class")
.forEach((entry) => {
processEntry(entry as HTMLElement);
});
};
const getVisibleClassQuickbar = (): HTMLElement | null => {
const quickbar = document.querySelector(".timetablepage .quickbar.visible");
if (!quickbar || quickbar.getAttribute("data-type") !== "class") return null;
const quickbar = document.querySelector(
".timetablepage .quickbar.visible",
);
if (!quickbar || quickbar.getAttribute("data-type") !== "class")
return null;
return quickbar as HTMLElement;
};
@@ -284,10 +308,18 @@ const timetableEditPlugin = {
if (override.room !== undefined && !roomEl) return;
if (override.staff !== undefined && !teacherEl) return;
if (override.room !== undefined && roomEl && roomEl.textContent !== override.room) {
if (
override.room !== undefined &&
roomEl &&
roomEl.textContent !== override.room
) {
roomEl.textContent = override.room;
}
if (override.staff !== undefined && teacherEl && teacherEl.textContent !== override.staff) {
if (
override.staff !== undefined &&
teacherEl &&
teacherEl.textContent !== override.staff
) {
teacherEl.textContent = override.staff;
}
@@ -300,7 +332,8 @@ const timetableEditPlugin = {
const roomEl = quickbar.querySelector(".meta .room");
const teacherEl = quickbar.querySelector(".meta .teacher");
if (roomEl && roomEl.textContent !== room) roomEl.textContent = room;
if (teacherEl && teacherEl.textContent !== staff) teacherEl.textContent = staff;
if (teacherEl && teacherEl.textContent !== staff)
teacherEl.textContent = staff;
if (lastClickedCi !== null) lastSyncedQuickbarCi = lastClickedCi;
};
@@ -325,7 +358,9 @@ const timetableEditPlugin = {
syncClassQuickbar(quickbar);
const hasButton = quickbar.querySelector(".timetable-edit-quickbar-btn");
const hasButton = quickbar.querySelector(
".timetable-edit-quickbar-btn",
);
const hasActions = quickbar.querySelector(".actions");
if ((!hasButton || !hasActions) && ++attempts < maxAttempts) {
quickbarSyncTimer = setTimeout(trySync, 50);
@@ -364,9 +399,12 @@ const timetableEditPlugin = {
const entryData = lastClickedEntry;
if (!entryData) return;
const quickbarRoom = qb.querySelector(".meta .room")?.textContent?.trim() ?? "";
const quickbarTeacher = qb.querySelector(".meta .teacher")?.textContent?.trim() ?? "";
const quickbarTitle = qb.querySelector(".title")?.textContent?.trim() ?? "";
const quickbarRoom =
qb.querySelector(".meta .room")?.textContent?.trim() ?? "";
const quickbarTeacher =
qb.querySelector(".meta .teacher")?.textContent?.trim() ?? "";
const quickbarTitle =
qb.querySelector(".title")?.textContent?.trim() ?? "";
const ci = lastClickedCi ?? entryData.item.ci;
const item: TimetableEntryData = {
ci,
@@ -391,7 +429,10 @@ const timetableEditPlugin = {
const current = getOverrides();
api.storage.timetableOverrides = {
...current,
[String(saveCi)]: { room: room || undefined, staff: staff || undefined },
[String(saveCi)]: {
room: room || undefined,
staff: staff || undefined,
},
};
}
if (entryData.roomEl) entryData.roomEl.textContent = room;
@@ -409,17 +450,15 @@ const timetableEditPlugin = {
delete bySubject[item.description];
api.storage.timetableOverridesBySubject = bySubject;
if (entryData.roomEl) entryData.roomEl.textContent = item.room;
if (entryData.teacherEl) entryData.teacherEl.textContent = item.staff;
if (entryData.teacherEl)
entryData.teacherEl.textContent = item.staff;
updateVisibleQuickbar(item.room, item.staff);
processAllEntries();
},
);
});
actions.insertBefore(
btn,
colourBtn ?? actions.firstChild,
);
actions.insertBefore(btn, colourBtn ?? actions.firstChild);
};
const syncQuickbarFromDOM = () => {
@@ -437,13 +476,19 @@ const timetableEditPlugin = {
if (!quickbar) return;
const shouldSync = mutations.some((mutation) => {
if (mutation.type === "attributes" && mutation.attributeName === "class") {
if (
mutation.type === "attributes" &&
mutation.attributeName === "class"
) {
const target = mutation.target as HTMLElement;
return target.classList.contains("quickbar");
}
if (mutation.type === "childList") {
const target = mutation.target as HTMLElement;
return target.classList?.contains("quickbar") || target.closest?.(".quickbar");
return (
target.classList?.contains("quickbar") ||
target.closest?.(".quickbar")
);
}
return false;
});
@@ -483,11 +528,13 @@ const timetableEditPlugin = {
const timetablePage = document.querySelector(".timetablepage");
if (timetablePage && !observer) {
observer = new MutationObserver(() => {
document.querySelectorAll(".timetablepage .entry.class").forEach((entry) => {
if (!entry.hasAttribute("data-timetable-edit-processed")) {
processEntry(entry as HTMLElement);
}
});
document
.querySelectorAll(".timetablepage .entry.class")
.forEach((entry) => {
if (!entry.hasAttribute("data-timetable-edit-processed")) {
processEntry(entry as HTMLElement);
}
});
});
observer.observe(timetablePage, { childList: true, subtree: true });
}
@@ -501,10 +548,14 @@ const timetableEditPlugin = {
observer?.disconnect();
quickbarObserver?.disconnect();
if (quickbarSyncTimer !== null) clearTimeout(quickbarSyncTimer);
document.querySelectorAll("[data-timetable-edit-processed]").forEach((el) => {
el.removeAttribute("data-timetable-edit-processed");
});
document.querySelectorAll(".timetable-edit-quickbar-btn").forEach((el) => el.remove());
document
.querySelectorAll("[data-timetable-edit-processed]")
.forEach((el) => {
el.removeAttribute("data-timetable-edit-processed");
});
document
.querySelectorAll(".timetable-edit-quickbar-btn")
.forEach((el) => el.remove());
};
},
};
+21 -6
View File
@@ -16,6 +16,7 @@ import { updateAllColors } from "./colors/Manager";
import { delay } from "@/seqta/utils/delay";
import { LUCIDE_MOON_ICON_SVG } from "@/lib/icons/lucideMoon";
import { LUCIDE_SUN_ICON_SVG } from "@/lib/icons/lucideSun";
import { ensureTitlebarFounderBadgeMounted, refreshTitlebarFounderBadge } from "@/seqta/ui/founderBadge/mountTitlebarFounderBadge";
let cachedUserInfo: any = null;
let userInfoFetchPromise: Promise<any> | null = null;
@@ -181,6 +182,7 @@ async function handleUserInfoAndStudentData() {
]);
updateUserInfo(userInfo);
ensureTitlebarFounderBadgeMounted();
await updateStudentInfo((await studentResponse.json()).payload, userInfo);
} catch (error) {
console.error(
@@ -227,11 +229,16 @@ function updateUserInfo(info: {
stringToHTML(/* html */ `
<div class="userInfo">
<div class="userInfoText">
<div style="display: flex; align-items: center;">
<p class="userInfohouse userInfoCode" style="display: none;"></p>
${displayName ? `<p class="userInfoName">${displayName}</p>` : ""}
<div class="userInfoNameRow">
<div class="userInfoHouseWrap">
<p class="userInfohouse userInfoCode" style="display: none;"></p>
<span class="bsplus-founder-badge-slot" hidden></span>
</div>
<div class="userInfoDetails">
${displayName ? `<p class="userInfoName">${displayName}</p>` : ""}
${metadata ? `<p class="userInfoCode">${metadata}</p>` : ""}
</div>
</div>
${metadata ? `<p class="userInfoCode">${metadata}</p>` : ""}
</div>
</div>
`).firstChild!,
@@ -277,6 +284,7 @@ async function updateStudentInfo(students: any, info: Awaited<ReturnType<typeof
houseelement.innerText = text;
houseelement.style.display = text ? "block" : "none";
refreshTitlebarFounderBadge();
}
function createNewsButton(fragment: DocumentFragment, menu: HTMLElement) {
@@ -413,13 +421,20 @@ async function addEngageUserInfo() {
stringToHTML(/* html */ `
<div class="userInfo">
<div class="userInfoText">
${displayName ? `<p class="userInfoName">${displayName}</p>` : ""}
${subText ? `<p class="userInfoCode">${subText}</p>` : ""}
<div class="userInfoNameRow">
<span class="bsplus-founder-badge-slot" hidden></span>
<div class="userInfoDetails">
${displayName ? `<p class="userInfoName">${displayName}</p>` : ""}
${subText ? `<p class="userInfoCode">${subText}</p>` : ""}
</div>
</div>
</div>
</div>
`).firstChild!,
);
ensureTitlebarFounderBadgeMounted();
const iconNode = stringToHTML(/* html */ `
<div class="userInfosvgdiv tooltip" id="engage-logouttooltip-wrap">
<svg class="userInfosvg" viewBox="0 0 24 24"><path fill="var(--text-primary)" d="M12,19.2C9.5,19.2 7.29,17.92 6,16C6.03,14 10,12.9 12,12.9C14,12.9 17.97,14 18,16C16.71,17.92 14.5,19.2 12,19.2M12,5A3,3 0 0,1 15,8A3,3 0 0,1 12,11A3,3 0 0,1 9,8A3,3 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z"></path></svg>
+1 -1
View File
@@ -76,7 +76,7 @@ const contentConfig: ContentConfig = {
},
},
userCode: {
selector: ".userInfoText > .userInfoCode",
selector: ".userInfoText .userInfoCode",
action: (element) => {
element.textContent = generateMockUserCode();
},
@@ -0,0 +1,79 @@
import { cloudAuth } from "@/seqta/utils/CloudAuth";
import { refreshCloudUserFromServer } from "@/seqta/utils/cloudPfpSync";
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
import {
founderBadgeChipHtml,
pickPrimaryFounderBadge,
type FounderBadgeItem,
} from "@/seqta/utils/founderBadges";
import { openFounderBadgeModal } from "@/seqta/ui/founderBadge/openFounderBadgeModal";
let subscribed = false;
let refreshPending = false;
function renderBadgeChip(
slot: HTMLElement,
badge: FounderBadgeItem,
signupNumber?: number | null,
): void {
const house = slot
.closest(".userInfoHouseWrap")
?.querySelector<HTMLElement>(".userInfohouse");
if (house?.style.display === "none") {
slot.replaceChildren();
slot.hidden = true;
return;
}
slot.hidden = false;
slot.innerHTML = founderBadgeChipHtml(badge, { titlebar: true });
const chip = slot.querySelector<HTMLButtonElement>(".bsplus-founder-badge");
if (!chip) return;
chip.setAttribute("aria-label", `${badge.label}, click for details`);
chip.addEventListener("click", () => openFounderBadgeModal(badge, signupNumber));
}
async function syncTitlebarFounderBadge(): Promise<void> {
const slots = document.querySelectorAll<HTMLElement>(".titlebar .bsplus-founder-badge-slot");
for (const slot of slots) {
slot.replaceChildren();
slot.hidden = true;
}
if (settingsState.showTitlebarFounderBadge === false || !cloudAuth.state.isLoggedIn) return;
let user = cloudAuth.state.user;
if (user && user.signup_number == null && !user.badges?.length) {
if (!refreshPending) {
refreshPending = true;
try {
await refreshCloudUserFromServer();
user = cloudAuth.state.user;
} finally {
refreshPending = false;
}
}
}
const badge = pickPrimaryFounderBadge(user?.badges ?? [], user?.signup_number);
if (!badge) return;
for (const slot of slots) {
renderBadgeChip(slot, badge, user?.signup_number);
}
}
export function refreshTitlebarFounderBadge(): void {
void syncTitlebarFounderBadge();
}
export function ensureTitlebarFounderBadgeMounted(): void {
if (!subscribed) {
subscribed = true;
cloudAuth.subscribe(() => void syncTitlebarFounderBadge());
settingsState.register("showTitlebarFounderBadge", () => void syncTitlebarFounderBadge());
}
void syncTitlebarFounderBadge();
}
@@ -0,0 +1,83 @@
import stringToHTML from "@/seqta/utils/stringToHTML";
import { closePopup, openPopup } from "@/seqta/utils/Openers/PopupManager";
import { openFounderBadgeSettings } from "@/seqta/ui/founderBadge/openFounderBadgeSettings";
import {
founderBadgeChipHtml,
tierBlobStyle,
tierForBadgeKey,
type FounderBadgeItem,
} from "@/seqta/utils/founderBadges";
const ACCOUNTS_URL = "https://accounts.betterseqta.org";
function esc(value: string): string {
return value
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
}
export function openFounderBadgeModal(
badge: FounderBadgeItem,
signupNumber?: number | null,
): void {
const tier = tierForBadgeKey(badge.key);
if (!tier) return;
const header = stringToHTML(/* html */ `
<div class="whatsnewHeader bsplus-founder-badge-header">
<h1>${esc(badge.label)}</h1>
<p>${esc(tier.rankLabel)}</p>
</div>
`).firstChild as HTMLElement;
const signupLine =
signupNumber != null
? `<p class="bsplus-founder-badge-signup">Cloud user #${signupNumber.toLocaleString()}</p>`
: "";
const hero = stringToHTML(/* html */ `
<div class="whatsnewImgContainer">
<div class="bsplus-founder-badge-hero whatsnewImg" data-tier="${badge.key}" style="${tierBlobStyle(tier)}">
<div class="bsplus-founder-badge-hero__blobs" aria-hidden="true"></div>
<div class="bsplus-founder-badge-hero__vignette" aria-hidden="true"></div>
<div class="bsplus-founder-badge-hero__stage">
${founderBadgeChipHtml(badge, { hero: true })}
</div>
</div>
</div>
`).firstChild as HTMLElement;
const text = stringToHTML(/* html */ `
<div class="whatsnewTextContainer bsplus-founder-badge-body" style="overflow-y: auto;">
<p>${esc(tier.description)}</p>
<p>
Linked to your BetterSEQTA Cloud account at
<a href="${ACCOUNTS_URL}" target="_blank" rel="noopener noreferrer">accounts.betterseqta.org</a>.
</p>
${signupLine}
<div class="bsplus-founder-badge-actions">
<button type="button" id="bsplus-founder-badge-settings-link" class="bsplus-cal-btn bsplus-cal-btn--ghost">
Hide in settings
</button>
<button type="button" id="bsplus-founder-badge-dismiss" class="bsplus-cal-btn bsplus-cal-btn--primary">
Got it
</button>
</div>
</div>
`).firstChild as HTMLElement;
openPopup({
header,
content: [hero, text],
animateSelector: ".whatsnewImgContainer, .whatsnewTextContainer *",
actions: [
{ id: "bsplus-founder-badge-dismiss", onClick: () => closePopup() },
{
id: "bsplus-founder-badge-settings-link",
onClick: () => void closePopup().then(() => openFounderBadgeSettings()),
},
],
});
}
@@ -0,0 +1,16 @@
import { requestSettingsDestination } from "@/seqta/utils/settingsNavigation";
import { openSettingsPopup } from "@/seqta/utils/setupSettingsButton";
const FOUNDER_BADGE_SETTING_SEARCH = "Titlebar founder badge";
/** Open BetterSEQTA+ settings on the titlebar founder badge toggle. */
export async function openFounderBadgeSettings(): Promise<void> {
requestSettingsDestination({
page: "settings",
section: "account",
search: FOUNDER_BADGE_SETTING_SEARCH,
});
await openSettingsPopup();
}
export { FOUNDER_BADGE_SETTING_SEARCH };
+51 -1
View File
@@ -37,6 +37,12 @@ function filterVisible(items: SidebarItem[]): SidebarItem[] {
return items.filter((item) => menuItems[item.key]?.toggle !== false);
}
function ensureActive(el: Element | null | undefined) {
if (el instanceof HTMLElement && !el.classList.contains("active")) {
el.classList.add("active");
}
}
function resetSidebarScroll() {
const root = document.getElementById("bsplus-sidebar-root");
if (!(root instanceof HTMLElement)) return;
@@ -46,6 +52,48 @@ function resetSidebarScroll() {
});
}
/**
* SEQTA strips `.active` from menu items after navigation. Restore the custom list
* state so the active subject/folder still matches the route and theme chrome.
*/
export function restoreCustomMenuActive() {
const root = document.getElementById("bsplus-sidebar-root");
if (!root) return;
for (const li of root.querySelectorAll("li.hasChildren")) {
if (!(li instanceof HTMLElement)) continue;
if (!li.querySelector(":scope > .sub")) continue;
ensureActive(li);
}
const activeKey = sidebarState.activeKey;
const drilling = sidebarState.isDrilling;
if (drilling) {
if (activeKey) {
ensureActive(
root.querySelector(`.sub li.item[data-key="${CSS.escape(activeKey)}"]`),
);
}
for (const li of root.querySelectorAll(
'.sub li.item[aria-current="page"]',
)) {
ensureActive(li);
}
return;
}
if (activeKey) {
ensureActive(
root.querySelector(`li.item[data-key="${CSS.escape(activeKey)}"]`),
);
}
for (const li of root.querySelectorAll('li.item[aria-current="page"]')) {
ensureActive(li);
}
}
/** Clear native drill state so it cannot steal pointer-events from the custom list. */
export function clearNativeDrillActive(menu: HTMLElement) {
getNativeMenuList(menu)
@@ -224,7 +272,9 @@ class SidebarState {
label: item.label,
items: filterVisible(item.children),
};
const isRoot = this.visibleRootItems.some((entry) => entry.key === item.key);
const isRoot = this.visibleRootItems.some(
(entry) => entry.key === item.key,
);
this.enterFrameKey = item.key;
// Root folders replace the stack; nested folders append.
+9
View File
@@ -12,6 +12,12 @@ const STORAGE_KEYS = {
user: "bsplus_user",
} as const;
export type CloudBadge = {
key: string;
label: string;
awarded_at?: number;
};
export type CloudUser = {
id: string;
email?: string;
@@ -20,6 +26,9 @@ export type CloudUser = {
pfpUrl?: string;
pfpHash?: string | null;
admin_level?: number;
signup_number?: number | null;
badges?: CloudBadge[];
is_founding_2500?: boolean;
};
export type CloudAuthState = {
+62 -5
View File
@@ -3,8 +3,20 @@ import { animate as motionAnimate, stagger } from "motion";
type AnimationTarget = string | Element | Element[] | NodeList | null;
export interface PopupRoot {
background: HTMLElement;
container: HTMLElement;
}
export interface PopupAction {
/** Element id inside popup content (e.g. button#bsplus-founder-badge-settings-link). */
id: string;
onClick: () => void | Promise<void>;
}
let isClosing = false;
let pendingAfterClose: (() => void) | undefined;
let escapeListener: ((event: KeyboardEvent) => void) | null = null;
function invokeAfterClose() {
const fn = pendingAfterClose;
@@ -12,9 +24,24 @@ function invokeAfterClose() {
fn?.();
}
function detachEscapeListener() {
if (!escapeListener) return;
document.removeEventListener("keydown", escapeListener);
escapeListener = null;
}
function attachEscapeListener() {
detachEscapeListener();
escapeListener = (event: KeyboardEvent) => {
if (event.key === "Escape") void closePopup();
};
document.addEventListener("keydown", escapeListener);
}
export async function closePopup() {
if (isClosing) return;
isClosing = true;
detachEscapeListener();
const background = document.getElementById("whatsnewbk");
const popup = document.getElementsByClassName("whatsnewContainer")[0] as
@@ -47,6 +74,7 @@ export async function closePopup() {
interface OpenPopupOptions {
header?: Node | null;
hero?: Node | null;
content?: (Node | null | undefined)[];
animateSelector?: AnimationTarget;
/** Called once after this popup is fully closed (including skip-animation path). */
@@ -55,6 +83,12 @@ interface OpenPopupOptions {
clearJustUpdated?: boolean;
/** Extra classes on `.whatsnewContainer` (e.g. `whatsnewContainer--scrollBody`). */
containerClass?: string;
/** Extra classes on `.whatsnewBackground` (e.g. frosted backdrop). */
backgroundClass?: string;
/** Wire click handlers for buttons/links by element id (deep links, dismiss, etc.). */
actions?: PopupAction[];
/** Called after the popup DOM is mounted — use for one-off setup when actions are not enough. */
onReady?: (root: PopupRoot) => void;
}
function chainAfterClose(next?: () => void) {
@@ -66,13 +100,35 @@ function chainAfterClose(next?: () => void) {
};
}
function applyClassList(element: HTMLElement, classNames?: string) {
if (!classNames) return;
for (const name of classNames.split(/\s+/)) {
if (name) element.classList.add(name);
}
}
function wirePopupActions(actions?: PopupAction[]) {
if (!actions?.length) return;
queueMicrotask(() => {
for (const action of actions) {
document.getElementById(action.id)?.addEventListener("click", () => {
void Promise.resolve(action.onClick());
});
}
});
}
export function openPopup({
header,
hero,
content = [],
animateSelector = ".whatsnewTextContainer *",
afterClose,
clearJustUpdated = false,
containerClass,
backgroundClass,
actions,
onReady,
}: OpenPopupOptions = {}) {
if (document.getElementById("whatsnewbk")) {
chainAfterClose(afterClose);
@@ -84,15 +140,13 @@ export function openPopup({
const background = document.createElement("div");
background.id = "whatsnewbk";
background.classList.add("whatsnewBackground");
applyClassList(background, backgroundClass);
const container = document.createElement("div");
container.classList.add("whatsnewContainer");
if (containerClass) {
for (const name of containerClass.split(/\s+/)) {
if (name) container.classList.add(name);
}
}
applyClassList(container, containerClass);
if (hero) container.append(hero);
if (header) container.append(header);
for (const node of content) if (node) container.append(node);
@@ -139,4 +193,7 @@ export function openPopup({
});
closeButton.addEventListener("click", () => void closePopup());
attachEscapeListener();
wirePopupActions(actions);
onReady?.({ background, container });
}
@@ -11,10 +11,13 @@ export const WHATS_NEW_CHANGELOG: WhatsNewRelease[] = [
"Added an option in the Timetable to sync to Google Calendar and Outlook Calendar",
"Added a new sidebar customisation page in the settings menu to change the sidebar layout, icons, and more.",
"Added extension feedback in settings.",
"Added a new toggleable titlebar founder badge to the topbar for BetterSEQTA Cloud celebrations.",
"Addded Editing a teacher's name in the timetable editor now affect Assements.",
"Added a 'this year' & custom date range option to grade analyitics.",
"Removed white background around SEQTA Learn mobile App icons in settings.",
"Re-added the kitten back to the 404 Error pages.",
"Improved the sidebar to be more stable and performant.",
"Fixed some issues related to HTML Sanitisation.",
"Fixed Analytics page not respecting no animations setting. (#474)",
"Fixed dropdown contrast and readability in settings and across SEQTA pages.",
"Fixed Analytics sidebar item not hiding when toggled off in Edit Sidebar.",
+3
View File
@@ -72,6 +72,9 @@ function mergeMeIntoUser(current: CloudUser, data: Record<string, unknown>): Clo
username: (raw.username as string | undefined) ?? current.username,
displayName: (raw.displayName as string | undefined) ?? current.displayName,
admin_level: (raw.admin_level as number | undefined) ?? current.admin_level,
signup_number: (raw.signup_number as number | null | undefined) ?? current.signup_number,
badges: (raw.badges as CloudUser["badges"]) ?? current.badges,
is_founding_2500: (raw.is_founding_2500 as boolean | undefined) ?? current.is_founding_2500,
pfpUrl,
pfpHash,
};
+1
View File
@@ -74,6 +74,7 @@ export function getDefaultSettingsState(): SettingsState {
adaptiveThemeColourTransition: true,
themeOfTheMonthDisabled: false,
autoCloudSettingsSync: true,
showTitlebarFounderBadge: true,
selectedFont: "rubik",
timeFormat: "24",
privacyStatementShown: false,
+165
View File
@@ -0,0 +1,165 @@
/** Founder badge tiers — keep in sync with betterseqta-accounts/utils/badges.ts */
export const BADGE_TIERS = [
{
key: "founder_10",
label: "Pioneer",
threshold: 10,
rankLabel: "Top 10",
description: "One of the first 10 people to create a BetterSEQTA Cloud account.",
base: "#78350f",
blobs: ["rgba(251,191,36,0.58)", "rgba(234,88,12,0.48)", "rgba(254,243,199,0.42)"],
icon: "sparkles",
},
{
key: "founder_25",
label: "Early Adopter",
threshold: 25,
rankLabel: "Top 25",
description: "One of the first 25 people to join BetterSEQTA Cloud.",
base: "#1e3a8a",
blobs: ["rgba(79,70,229,0.52)", "rgba(37,99,235,0.46)", "rgba(129,140,248,0.38)"],
icon: "sparkles",
},
{
key: "founder_50",
label: "Founding Member",
threshold: 50,
rankLabel: "Top 50",
description: "One of the first 50 Cloud members, early supporter of BetterSEQTA.",
base: "#0c4a6e",
blobs: ["rgba(2,132,199,0.5)", "rgba(13,148,136,0.44)", "rgba(56,189,248,0.36)"],
icon: "star",
},
{
key: "founder_100",
label: "Centurion",
threshold: 100,
rankLabel: "Top 100",
description: "Among the first 100 BetterSEQTA Cloud accounts ever created.",
base: "#064e3b",
blobs: ["rgba(5,150,105,0.5)", "rgba(22,163,74,0.44)", "rgba(52,211,153,0.36)"],
icon: "star",
},
{
key: "founder_250",
label: "Quarter Thousand",
threshold: 250,
rankLabel: "Top 250",
description: "One of the first 250 people to sign up for BetterSEQTA Cloud.",
base: "#7c2d12",
blobs: ["rgba(217,119,6,0.52)", "rgba(234,88,12,0.46)", "rgba(251,191,36,0.38)"],
icon: "trophy",
},
{
key: "founder_500",
label: "Half Thousand",
threshold: 500,
rankLabel: "Top 500",
description: "Among the first 500 BetterSEQTA Cloud members.",
base: "#7c2d12",
blobs: ["rgba(234,88,12,0.52)", "rgba(249,115,22,0.46)", "rgba(251,146,60,0.38)"],
icon: "trophy",
},
{
key: "founder_1000",
label: "Thousand Club",
threshold: 1000,
rankLabel: "Top 1,000",
description: "One of the first 1,000 BetterSEQTA Cloud accounts.",
base: "#881337",
blobs: ["rgba(225,29,72,0.5)", "rgba(219,39,119,0.44)", "rgba(251,113,133,0.36)"],
icon: "fire",
},
{
key: "founder_2500",
label: "Founding Cloud",
threshold: 2500,
rankLabel: "Top 2,500",
description: "One of the first 2,500 Cloud members.",
base: "#713f12",
blobs: ["rgba(245,158,11,0.52)", "rgba(234,179,8,0.46)", "rgba(252,211,77,0.4)"],
icon: "fire",
},
] as const;
export type BadgeKey = (typeof BADGE_TIERS)[number]["key"];
export type FounderBadgeItem = {
key: string;
label: string;
awarded_at?: number;
};
const TIER_BY_KEY = new Map(BADGE_TIERS.map((t) => [t.key, t]));
export function tierForBadgeKey(key: string) {
return TIER_BY_KEY.get(key as BadgeKey);
}
export function primaryFounderBadgeKey(signupNumber: number): BadgeKey | null {
const tier = BADGE_TIERS.find((t) => signupNumber <= t.threshold);
return tier?.key ?? null;
}
export function pickPrimaryFounderBadge(
badges: FounderBadgeItem[],
signupNumber?: number | null,
): FounderBadgeItem | null {
if (signupNumber != null) {
const key = primaryFounderBadgeKey(signupNumber);
if (!key) return null;
return badges.find((b) => b.key === key) ?? { key, label: TIER_BY_KEY.get(key)?.label ?? key };
}
if (badges.length === 0) return null;
let best: FounderBadgeItem | null = null;
let bestThreshold = Infinity;
for (const badge of badges) {
const tier = TIER_BY_KEY.get(badge.key as BadgeKey);
if (tier && tier.threshold < bestThreshold) {
bestThreshold = tier.threshold;
best = badge;
}
}
return best;
}
const ICON_PATHS: Record<string, string> = {
sparkles:
"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z",
star: "M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005z",
trophy:
"M16.5 18.75h-9m9 0a3 3 0 013 3h-15a3 3 0 013-3m9 0v-3.375c0-.621-.503-1.125-1.125-1.125h-.871M7.5 18.75v-3.375c0-.621.504-1.125 1.125-1.125h.872m5.007 0H9.497m5.007 0a7.454 7.454 0 01-.982-3.172M9.497 14.25a7.454 7.454 0 00.981-3.172M5.25 4.236c-.982.143-1.954.317-2.916.52A6.003 6.003 0 007.73 9.728M5.25 4.236V4.5c0 2.108.966 3.99 2.48 5.228M5.25 4.236V2.721C7.456 2.41 9.71 2.25 12 2.25c2.291 0 4.545.16 6.75.47v1.516M7.73 9.728a6.726 6.726 0 002.748 1.35m8.272-6.842V4.5c0 2.108-.966 3.99-2.48 5.228m2.48-5.492a46.32 46.32 0 012.916.52 6.003 6.003 0 01-5.395 4.972m0 0a6.726 6.726 0 01-2.749 1.35m0 0a6.726 6.726 0 01-3.128 0m3.128 0a6.726 6.726 0 01-3.128 0",
fire: "M15.362 5.214A8.252 8.252 0 0112 21 8.25 8.25 0 016.038 7.048 8.287 8.287 0 009 9.6a8.983 8.983 0 013.361-6.867 8.21 8.21 0 003 2.48zM12 18a3.75 3.75 0 00.495-7.467 5.99 5.99 0 00-1.925 3.546 5.974 5.974 0 01-2.133-1A3.75 3.75 0 0012 18z",
};
export function badgeIconSvg(icon: string, size = 15): string {
const path = ICON_PATHS[icon] ?? ICON_PATHS.sparkles;
return `<svg class="bsplus-founder-badge__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="${size}" height="${size}" aria-hidden="true"><path d="${path}"/></svg>`;
}
export function tierBlobStyle(tier: (typeof BADGE_TIERS)[number]): string {
return [
`--badge-base:${tier.base}`,
`--badge-blob-a:${tier.blobs[0]}`,
`--badge-blob-b:${tier.blobs[1]}`,
`--badge-blob-c:${tier.blobs[2]}`,
].join(";");
}
export function founderBadgeChipHtml(
badge: FounderBadgeItem,
options?: { hero?: boolean; titlebar?: boolean },
): string {
const tier = tierForBadgeKey(badge.key);
if (!tier) return "";
const hero = options?.hero ?? false;
const titlebar = options?.titlebar ?? false;
const mods = `${hero ? " bsplus-founder-badge--hero" : ""}${titlebar ? " bsplus-founder-badge--titlebar" : ""}`;
const icon = titlebar ? "" : badgeIconSvg(tier.icon, hero ? 20 : 15);
return `<button type="button" class="bsplus-founder-badge${mods}" data-tier="${badge.key}" style="${tierBlobStyle(tier)}"><span class="bsplus-founder-badge__glass"><span class="bsplus-founder-badge__blobs" aria-hidden="true"></span><span class="bsplus-founder-badge__content">${icon}<span class="bsplus-founder-badge__label">${badge.label}</span></span></span></button>`;
}
+1 -1
View File
@@ -1,5 +1,5 @@
export type SettingsDestination =
| { page: "settings"; section?: string }
| { page: "settings"; section?: string; search?: string }
| { page: "themes" | "backgrounds"; view?: "settings" | "store" };
export const SETTINGS_NAVIGATION_EVENT = "bsplus:navigate-settings";
+13
View File
@@ -0,0 +1,13 @@
import stringToHTML from "./stringToHTML";
describe("stringToHTML", () => {
it("preserves inline onclick handlers used by lesson action buttons", () => {
const body = stringToHTML(
`<div class="day-button clickable" onclick="location.href='../#?page=/courses/123:456'">Go</div>`,
);
const el = body.firstElementChild as HTMLElement | null;
expect(el).not.toBeNull();
expect(el?.getAttribute("onclick")).toContain("location.href");
});
});
+2 -1
View File
@@ -16,8 +16,9 @@ export default function stringToHTML(str: string, styles = false) {
const parser = new DOMParser();
str = DOMPurify.sanitize(str, {
ADD_ATTR: ["onclick"],
ALLOWED_URI_REGEXP:
/^(?:(?:https?|mailto|tel):|\/|#|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|chrome-extension):|\/|#|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
});
const doc = parser.parseFromString(str, "text/html");
+2
View File
@@ -96,6 +96,8 @@ export interface SettingsState {
// BetterSEQTA Cloud (accounts.betterseqta.org) — stored via CloudAuth, not settingsState
/** When not `false`, automatic cloud settings sync is enabled (default-on). */
autoCloudSettingsSync?: boolean;
/** When not `false`, show the Cloud founder badge in the SEQTA titlebar (default-on). */
showTitlebarFounderBadge?: boolean;
}
interface ToggleItem {