mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
feat: combining classes for analyitics and some other chores
This commit is contained in:
1 parent
a19b43ef37
commit
c150e79e1c
18 files changed
+1262
-386
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "betterseqtaplus",
|
||||
"version": "3.7.3",
|
||||
"version": "3.7.4",
|
||||
"type": "module",
|
||||
"description": "Enhance SEQTA Learn's usability and aesthetics! A fork of BetterSEQTA to continue development and add heaps more features!",
|
||||
"browserslist": "> 0.5%, last 2 versions, not dead",
|
||||
|
||||
+15
-7
@@ -739,11 +739,14 @@ html.bsplus-custom-title-pending #title > :not(#bsplus-title-root),
|
||||
|
||||
> #bsplus-sidebar-root li.hasChildren.bsplus-active > .sub {
|
||||
pointer-events: auto;
|
||||
transform: none;
|
||||
background: transparent !important;
|
||||
background-image: none !important;
|
||||
}
|
||||
|
||||
> #bsplus-sidebar-root li.hasChildren.bsplus-active > .sub:not(.bsplus-sub-enter) {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
> #bsplus-sidebar-root li.hasChildren.bsplus-active
|
||||
> .sub:has(.hasChildren.bsplus-active) {
|
||||
pointer-events: none !important;
|
||||
@@ -790,8 +793,8 @@ html.bsplus-custom-title-pending #title > :not(#bsplus-title-root),
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
> #bsplus-sidebar-root.drilling > li:not(.hasChildren)::before,
|
||||
> #bsplus-sidebar-root.drilling > li:not(.hasChildren)::after {
|
||||
> #bsplus-sidebar-root.drilling:not(.drill-entering) > li:not(.hasChildren)::before,
|
||||
> #bsplus-sidebar-root.drilling:not(.drill-entering) > li:not(.hasChildren)::after {
|
||||
content: none !important;
|
||||
display: none !important;
|
||||
animation: none !important;
|
||||
@@ -833,7 +836,7 @@ html.bsplus-custom-title-pending #title > :not(#bsplus-title-root),
|
||||
}
|
||||
|
||||
/* Icon Only Sidebar - compact mode. When submenu is open, all styles are disabled so it behaves as normal sidebar. */
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren.active)) {
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) {
|
||||
#menu {
|
||||
width: 70px !important;
|
||||
transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
@@ -968,7 +971,7 @@ body > .sortable-fallback.bsplus-sortable-drag,
|
||||
}
|
||||
|
||||
#menu {
|
||||
li.active > .sub > ul > .item:not(.hasChildren) {
|
||||
li:is(.active, .hasChildren.bsplus-active) > .sub > ul > .item:not(.hasChildren) {
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
@@ -983,10 +986,11 @@ body > .sortable-fallback.bsplus-sortable-drag,
|
||||
width 100ms,
|
||||
transform 0.3s ease;
|
||||
border-radius: 8px 0 0 8px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&:hover::before,
|
||||
&.active::before {
|
||||
&:is(.active, .bsplus-active)::before {
|
||||
width: 6px;
|
||||
background: var(--item-colour, transparent);
|
||||
}
|
||||
@@ -995,6 +999,10 @@ body > .sortable-fallback.bsplus-sortable-drag,
|
||||
li.active > .sub > ul > .active {
|
||||
background: rgba(0, 0, 0, 0.3) !important;
|
||||
}
|
||||
|
||||
li.hasChildren.bsplus-active > .sub > ul > .bsplus-sidebar-item.bsplus-active:not(.hasChildren) {
|
||||
background: rgba(0, 0, 0, 0.3) !important;
|
||||
}
|
||||
}
|
||||
|
||||
#userActions {
|
||||
@@ -1429,7 +1437,7 @@ html.transparencyEffects
|
||||
transform: translatex(var(--bsplus-sidebar-width, 270px));
|
||||
}
|
||||
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren.active)) {
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) {
|
||||
#menu {
|
||||
-webkit-transform: translatex(-70px);
|
||||
transform: translatex(-70px);
|
||||
|
||||
@@ -47,3 +47,8 @@
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Feedback modal scrollport — host overflow:hidden otherwise clips fixed overlays. */
|
||||
#ExtensionPopup.bsplus-feedback-open {
|
||||
overflow: auto !important;
|
||||
}
|
||||
@@ -8,14 +8,14 @@
|
||||
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 {
|
||||
#menu:not(.bsplus-custom-sidebar) > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::before,
|
||||
#menu:not(.bsplus-custom-sidebar) > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::after,
|
||||
#menu:not(.bsplus-custom-sidebar) > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::before,
|
||||
#menu:not(.bsplus-custom-sidebar) > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::after,
|
||||
#menu:not(.bsplus-custom-sidebar) > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > label,
|
||||
#menu:not(.bsplus-custom-sidebar) > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > svg,
|
||||
#menu:not(.bsplus-custom-sidebar) > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > label,
|
||||
#menu:not(.bsplus-custom-sidebar) > 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;
|
||||
animation: none !important;
|
||||
@@ -30,6 +30,17 @@
|
||||
transition: transform 0.3s ease, left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
/* Custom sidebar — single timing source. */
|
||||
#menu.bsplus-custom-sidebar {
|
||||
--bsplus-drill-duration: 350ms;
|
||||
--bsplus-drill-ease: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--bsplus-slide-off: -320px;
|
||||
|
||||
.sub {
|
||||
transition: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
#menu > ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li:is(.active, .bsplus-active) {
|
||||
background: transparent !important;
|
||||
@@ -48,34 +59,34 @@
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Icon-only collapsed: submenu slides over narrow icons */
|
||||
/* Icon-only collapsed: submenu slides over narrow icons (native sidebar only). */
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
#menu:not(.bsplus-custom-sidebar)
|
||||
> ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li::before,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
#menu:not(.bsplus-custom-sidebar)
|
||||
> 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
|
||||
#menu:not(.bsplus-custom-sidebar)
|
||||
> ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li
|
||||
> label,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
#menu:not(.bsplus-custom-sidebar)
|
||||
> ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li
|
||||
> svg,
|
||||
body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)))
|
||||
#menu
|
||||
#menu:not(.bsplus-custom-sidebar)
|
||||
> 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
|
||||
#menu:not(.bsplus-custom-sidebar)
|
||||
> ul
|
||||
ul:has(li.hasChildren:is(.active, .bsplus-active))
|
||||
> li
|
||||
@@ -88,28 +99,11 @@ body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)
|
||||
* not `:has(.active)` (SEQTA strips `.active` on nested clicks).
|
||||
*/
|
||||
#menu.bsplus-custom-sidebar #bsplus-sidebar-root {
|
||||
--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) {
|
||||
/* Hold siblings off-screen after the enter animation completes. */
|
||||
&:not(.drill-returning):not(.drill-entering) {
|
||||
> li::before,
|
||||
> li::after,
|
||||
> li > label,
|
||||
@@ -118,12 +112,29 @@ body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)
|
||||
.sub:has(.sub) > ul > li::after,
|
||||
.sub:has(.sub) > ul > li > label,
|
||||
.sub:has(.sub) > ul > li > svg {
|
||||
transform: translateX(var(--bsplus-slide-off)) !important;
|
||||
transition: none !important;
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
.sub {
|
||||
> li.hasChildren.bsplus-active > .sub:not(.bsplus-sub-enter) {
|
||||
transform: translateX(0) !important;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Slide siblings out in sync with the incoming .sub panel. */
|
||||
&.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 {
|
||||
transform: translateX(var(--bsplus-slide-off)) !important;
|
||||
transition: transform var(--bsplus-drill-duration) var(--bsplus-drill-ease) !important;
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +144,7 @@ body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)
|
||||
}
|
||||
|
||||
&.drill-entering .sub.bsplus-sub-enter {
|
||||
animation: bsplus-submenu-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
animation: bsplus-submenu-enter var(--bsplus-drill-duration) var(--bsplus-drill-ease) both !important;
|
||||
}
|
||||
|
||||
&.drill-returning:not(.drilling) > li::before,
|
||||
@@ -145,14 +156,36 @@ body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)
|
||||
&.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;
|
||||
animation: bsplus-sidebar-return var(--bsplus-drill-duration) var(--bsplus-drill-ease)
|
||||
both !important;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bsplus-submenu-enter {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Icon-only rail uses a shorter slide distance. */
|
||||
body.icon-only-sidebar #menu.bsplus-custom-sidebar #bsplus-sidebar-root {
|
||||
--bsplus-slide-off: -70px;
|
||||
}
|
||||
|
||||
/* Hide off-screen siblings only after the slide finishes (not during enter). */
|
||||
body.icon-only-sidebar
|
||||
#menu.bsplus-custom-sidebar
|
||||
#bsplus-sidebar-root.drilling:not(.drill-returning):not(.drill-entering) {
|
||||
> li:not(.bsplus-active) {
|
||||
opacity: 0 !important;
|
||||
visibility: hidden !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bsplus-sidebar-return {
|
||||
from {
|
||||
transform: translateX(var(--bsplus-slide-off, -320px));
|
||||
@@ -161,14 +194,3 @@ body.icon-only-sidebar #menu.bsplus-custom-sidebar #bsplus-sidebar-root {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bsplus-submenu-enter {
|
||||
from {
|
||||
opacity: 0.35;
|
||||
transform: translateX(28px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -21,9 +21,16 @@
|
||||
timeRange: TimeRange;
|
||||
customTimeRange?: CustomTimeRange;
|
||||
showSubjectTrends?: boolean;
|
||||
combinedLabel?: string;
|
||||
}
|
||||
|
||||
let { data, timeRange, customTimeRange, showSubjectTrends = false }: Props = $props();
|
||||
let {
|
||||
data,
|
||||
timeRange,
|
||||
customTimeRange,
|
||||
showSubjectTrends = false,
|
||||
combinedLabel,
|
||||
}: Props = $props();
|
||||
|
||||
let showPrediction = $state(false);
|
||||
let predictionMonths = $state(3);
|
||||
@@ -34,6 +41,7 @@
|
||||
buildGradeTrendChart(data, timeRange, {
|
||||
showPerSubject: showSubjectTrends,
|
||||
custom: customTimeRange,
|
||||
combinedLabel,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -214,6 +222,8 @@
|
||||
<p class="bsplus-analytics-card-desc">
|
||||
{#if showSubjectTrends}
|
||||
Overall and per-subject averages · {timeRangeText()}
|
||||
{:else if combinedLabel}
|
||||
{combinedLabel} · {timeRangeText()}
|
||||
{:else}
|
||||
Average grades over time · {timeRangeText()}
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
<script lang="ts">
|
||||
import { fade, scale } from "svelte/transition";
|
||||
import type { AnalyticsClassGroup, AnalyticsClassOption } from "./types";
|
||||
import { animationsEnabled } from "@/seqta/utils/performanceMode";
|
||||
|
||||
type Props = {
|
||||
classOptions: AnalyticsClassOption[];
|
||||
groups: AnalyticsClassGroup[];
|
||||
activeGroupId: string | null;
|
||||
onSelectGroup: (group: AnalyticsClassGroup | null) => void;
|
||||
onSaveGroups: (groups: AnalyticsClassGroup[]) => void;
|
||||
};
|
||||
|
||||
let { classOptions, groups, activeGroupId, onSelectGroup, onSaveGroups }: Props = $props();
|
||||
|
||||
let showEditor = $state(false);
|
||||
let groupName = $state("");
|
||||
let draftClassKeys = $state<string[]>([]);
|
||||
let editingId = $state<string | null>(null);
|
||||
|
||||
const fadeDuration = $derived(animationsEnabled() ? 180 : 0);
|
||||
const optionByKey = $derived(new Map(classOptions.map((option) => [option.key, option])));
|
||||
|
||||
function classLabel(key: string): string {
|
||||
const option = optionByKey.get(key);
|
||||
return option ? `${option.title} (${option.yearLabel})` : key;
|
||||
}
|
||||
|
||||
function defaultGroupName(keys: string[]): string {
|
||||
if (!keys.length) return "";
|
||||
const labels = keys.map(classLabel);
|
||||
if (labels.length === 1) return labels[0]!;
|
||||
return `${labels[0]} + ${labels.length - 1} more`;
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
editingId = null;
|
||||
const active = groups.find((g) => g.id === activeGroupId);
|
||||
draftClassKeys = active?.classKeys.length
|
||||
? [...active.classKeys]
|
||||
: classOptions.slice(0, Math.min(2, classOptions.length)).map((option) => option.key);
|
||||
groupName = defaultGroupName(draftClassKeys);
|
||||
showEditor = true;
|
||||
}
|
||||
|
||||
function openEdit(group: AnalyticsClassGroup) {
|
||||
editingId = group.id;
|
||||
groupName = group.name;
|
||||
draftClassKeys = [...group.classKeys];
|
||||
showEditor = true;
|
||||
}
|
||||
|
||||
function cancelEditor() {
|
||||
showEditor = false;
|
||||
editingId = null;
|
||||
groupName = "";
|
||||
draftClassKeys = [];
|
||||
}
|
||||
|
||||
function toggleDraftClass(key: string) {
|
||||
draftClassKeys = draftClassKeys.includes(key)
|
||||
? draftClassKeys.filter((entry) => entry !== key)
|
||||
: [...draftClassKeys, key];
|
||||
}
|
||||
|
||||
function saveGroup() {
|
||||
if (!draftClassKeys.length) return;
|
||||
|
||||
if (editingId) {
|
||||
onSaveGroups(
|
||||
groups.map((g) =>
|
||||
g.id === editingId
|
||||
? { ...g, name: groupName.trim() || g.name, classKeys: [...draftClassKeys] }
|
||||
: g,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
const created: AnalyticsClassGroup = {
|
||||
id: crypto.randomUUID(),
|
||||
name: groupName.trim() || defaultGroupName(draftClassKeys),
|
||||
classKeys: [...new Set(draftClassKeys)],
|
||||
};
|
||||
onSaveGroups([...groups, created]);
|
||||
onSelectGroup(created);
|
||||
}
|
||||
cancelEditor();
|
||||
}
|
||||
|
||||
function deleteGroup(id: string) {
|
||||
onSaveGroups(groups.filter((g) => g.id !== id));
|
||||
if (activeGroupId === id) onSelectGroup(null);
|
||||
}
|
||||
|
||||
function onModalKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
cancelEditor();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={showEditor ? onModalKeydown : undefined} />
|
||||
|
||||
<div class="bsplus-analytics-filter-group bsplus-analytics-class-groups">
|
||||
<div class="bsplus-analytics-class-groups-head">
|
||||
<span class="bsplus-analytics-field-label">Combined classes</span>
|
||||
<button
|
||||
type="button"
|
||||
class="bsplus-analytics-class-groups-add"
|
||||
onclick={openCreate}
|
||||
disabled={!classOptions.length}
|
||||
>
|
||||
Combine
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if groups.length}
|
||||
<ul class="bsplus-analytics-class-groups-list" role="list">
|
||||
{#each groups as group (group.id)}
|
||||
{@const active = activeGroupId === group.id}
|
||||
<li class="bsplus-analytics-class-group-row">
|
||||
<button
|
||||
type="button"
|
||||
class="bsplus-analytics-class-group-btn"
|
||||
class:is-active={active}
|
||||
onclick={() => onSelectGroup(active ? null : group)}
|
||||
title={group.classKeys.map(classLabel).join(", ")}
|
||||
>
|
||||
<span class="bsplus-analytics-class-group-name">{group.name}</span>
|
||||
<span class="bsplus-analytics-class-group-meta"
|
||||
>{group.classKeys.length} class{group.classKeys.length === 1 ? "" : "es"}</span
|
||||
>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="bsplus-analytics-class-group-icon"
|
||||
aria-label="Edit {group.name}"
|
||||
onclick={() => openEdit(group)}
|
||||
>
|
||||
✎
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="bsplus-analytics-class-group-icon bsplus-analytics-class-group-delete"
|
||||
aria-label="Delete {group.name}"
|
||||
onclick={() => deleteGroup(group.id)}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else}
|
||||
<p class="bsplus-analytics-class-groups-empty">
|
||||
Save classes from any year to view their combined grades in one trend.
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if showEditor}
|
||||
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
||||
<div
|
||||
class="bsplus-analytics-class-groups-modal"
|
||||
role="presentation"
|
||||
transition:fade={{ duration: fadeDuration }}
|
||||
onclick={(e) => {
|
||||
if (e.target === e.currentTarget) cancelEditor();
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="bsplus-analytics-class-groups-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="bsplus-class-group-modal-title"
|
||||
transition:scale={{ duration: fadeDuration, start: 0.96 }}
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<header class="bsplus-analytics-class-groups-dialog-head">
|
||||
<div>
|
||||
<h2 id="bsplus-class-group-modal-title" class="bsplus-analytics-class-groups-dialog-title">
|
||||
{editingId ? "Edit combined classes" : "Combine classes"}
|
||||
</h2>
|
||||
<p class="bsplus-analytics-class-groups-dialog-desc">
|
||||
Every class from every programme year — same folders as Courses.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="bsplus-analytics-class-groups-close"
|
||||
aria-label="Close"
|
||||
onclick={cancelEditor}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="bsplus-analytics-class-groups-dialog-body">
|
||||
<label class="bsplus-analytics-class-groups-field">
|
||||
<span class="bsplus-analytics-field-label">Group name</span>
|
||||
<input
|
||||
type="text"
|
||||
class="bsplus-analytics-input"
|
||||
bind:value={groupName}
|
||||
placeholder="e.g. English block"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="bsplus-analytics-class-groups-field">
|
||||
<span class="bsplus-analytics-field-label">
|
||||
Classes ({draftClassKeys.length} selected)
|
||||
</span>
|
||||
<div
|
||||
class="bsplus-analytics-class-groups-picks"
|
||||
role="group"
|
||||
aria-label="Classes in this group"
|
||||
>
|
||||
{#each classOptions as option (option.key)}
|
||||
{@const picked = draftClassKeys.includes(option.key)}
|
||||
<label class="bsplus-analytics-class-groups-pick">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={picked}
|
||||
onchange={() => toggleDraftClass(option.key)}
|
||||
/>
|
||||
<span class="bsplus-analytics-class-groups-check" aria-hidden="true">
|
||||
{#if picked}✓{/if}
|
||||
</span>
|
||||
<span class="bsplus-analytics-class-groups-pick-text">
|
||||
<span class="bsplus-analytics-class-groups-pick-label">{option.title}</span>
|
||||
<span class="bsplus-analytics-class-groups-year">{option.yearLabel}</span>
|
||||
</span>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="bsplus-analytics-class-groups-dialog-actions">
|
||||
<button type="button" class="bsplus-analytics-btn" onclick={cancelEditor}>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="bsplus-analytics-btn bsplus-analytics-btn-primary"
|
||||
disabled={!draftClassKeys.length}
|
||||
onclick={saveGroup}
|
||||
>
|
||||
{editingId ? "Save changes" : "Create group"}
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -6,6 +6,8 @@
|
||||
loadGradeAnalytics,
|
||||
syncGradeAnalytics,
|
||||
getCacheTtlMs,
|
||||
loadAnalyticsClassCatalog,
|
||||
getStudentId,
|
||||
} from "./api";
|
||||
import AnalyticsAreaChart from "./AnalyticsAreaChart.svelte";
|
||||
import AnalyticsBarChart from "./AnalyticsBarChart.svelte";
|
||||
@@ -22,6 +24,9 @@
|
||||
import { openAnalyticsPrivacyPopup } from "./openAnalyticsPrivacyPopup";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { animationsEnabled } from "@/seqta/utils/performanceMode";
|
||||
import ClassGroupsPanel from "./ClassGroupsPanel.svelte";
|
||||
import type { AnalyticsClassGroup, AnalyticsClassOption } from "./types";
|
||||
import { loadClassGroups, saveClassGroups } from "./storage";
|
||||
|
||||
let { simpleMode = false } = $props<{ simpleMode?: boolean }>();
|
||||
|
||||
@@ -40,6 +45,10 @@
|
||||
let timeRange: TimeRange = $state("all");
|
||||
let customTimeRange: CustomTimeRange = $state(defaultCustomTimeRange());
|
||||
let showSubjectTrends = $state(false);
|
||||
let classGroups: AnalyticsClassGroup[] = $state([]);
|
||||
let classCatalog: AnalyticsClassOption[] = $state([]);
|
||||
let activeClassGroupId: string | null = $state(null);
|
||||
let studentId: number | null = $state(null);
|
||||
|
||||
let timestampInterval: ReturnType<typeof setInterval> | null = null;
|
||||
let contentReady = $state(false);
|
||||
@@ -51,6 +60,16 @@
|
||||
return formatLastUpdated(lastUpdated);
|
||||
});
|
||||
|
||||
const activeClassGroup = $derived(
|
||||
classGroups.find((g) => g.id === activeClassGroupId) ?? null,
|
||||
);
|
||||
|
||||
const activeClassKeys = $derived(activeClassGroup?.classKeys ?? []);
|
||||
|
||||
const combinedChartLabel = $derived(
|
||||
activeClassGroup && !showSubjectTrends ? activeClassGroup.name : undefined,
|
||||
);
|
||||
|
||||
const uniqueSubjects = $derived(() => {
|
||||
if (!analyticsData) return [];
|
||||
return [...new Set(analyticsData.map((a) => a.subject))].sort();
|
||||
@@ -60,7 +79,12 @@
|
||||
if (!analyticsData) return [];
|
||||
const [minG, maxG] = gradeRange;
|
||||
return analyticsData.filter((a) => {
|
||||
if (filterSubjects.length && !filterSubjects.includes(a.subject)) return false;
|
||||
if (activeClassKeys.length) {
|
||||
const key = `${a.programmeID}-${a.metaclassID}`;
|
||||
if (!activeClassKeys.includes(key)) return false;
|
||||
} else if (filterSubjects.length && !filterSubjects.includes(a.subject)) {
|
||||
return false;
|
||||
}
|
||||
if (a.finalGrade !== undefined) {
|
||||
if (a.finalGrade < minG || a.finalGrade > maxG) return false;
|
||||
}
|
||||
@@ -114,6 +138,7 @@
|
||||
const result = await syncGradeAnalytics();
|
||||
analyticsData = result.assessments;
|
||||
lastUpdated = new Date(result.updatedAt);
|
||||
await loadClassCatalog(result.assessments);
|
||||
} catch (e) {
|
||||
console.error("[BetterSEQTA+] Analytics sync failed:", e);
|
||||
error =
|
||||
@@ -127,11 +152,13 @@
|
||||
filterSubjects = [];
|
||||
filterSearch = "";
|
||||
gradeRange = [0, 100];
|
||||
activeClassGroupId = null;
|
||||
}
|
||||
|
||||
function hasActiveFilters() {
|
||||
return !!(
|
||||
filterSubjects.length ||
|
||||
activeClassGroupId ||
|
||||
filterSearch ||
|
||||
gradeRange[0] !== 0 ||
|
||||
gradeRange[1] !== 100
|
||||
@@ -139,6 +166,7 @@
|
||||
}
|
||||
|
||||
function toggleSubject(subject: string) {
|
||||
activeClassGroupId = null;
|
||||
if (filterSubjects.includes(subject)) {
|
||||
filterSubjects = filterSubjects.filter((s) => s !== subject);
|
||||
} else {
|
||||
@@ -146,6 +174,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
function selectClassGroup(group: AnalyticsClassGroup | null) {
|
||||
activeClassGroupId = group?.id ?? null;
|
||||
if (group) {
|
||||
filterSubjects = [];
|
||||
showSubjectTrends = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function persistClassGroups(groups: AnalyticsClassGroup[]) {
|
||||
classGroups = groups;
|
||||
if (activeClassGroupId && !groups.some((g) => g.id === activeClassGroupId)) {
|
||||
activeClassGroupId = null;
|
||||
}
|
||||
if (studentId == null) return;
|
||||
await saveClassGroups(location.origin, studentId, groups);
|
||||
}
|
||||
|
||||
async function loadClassCatalog(assessments: Assessment[]) {
|
||||
classCatalog = await loadAnalyticsClassCatalog(assessments);
|
||||
}
|
||||
|
||||
const timeRangeLabel = $derived(() => getTimeRangeLabel(timeRange, customTimeRange));
|
||||
|
||||
function closeToolbarDropdowns() {
|
||||
@@ -176,6 +225,16 @@
|
||||
const result = await loadGradeAnalytics();
|
||||
analyticsData = result.assessments;
|
||||
lastUpdated = result.updatedAt ? new Date(result.updatedAt) : null;
|
||||
|
||||
try {
|
||||
const id = await getStudentId();
|
||||
studentId = id;
|
||||
classGroups = await loadClassGroups(location.origin, id);
|
||||
await loadClassCatalog(result.assessments);
|
||||
} catch {
|
||||
classGroups = [];
|
||||
classCatalog = await loadAnalyticsClassCatalog(result.assessments);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[BetterSEQTA+] Failed to load analytics:", e);
|
||||
analyticsData = [];
|
||||
@@ -351,8 +410,10 @@
|
||||
aria-expanded={showSubjectsDropdown}
|
||||
aria-haspopup="listbox"
|
||||
>
|
||||
{#if filterSubjects.length === 0}
|
||||
{#if !activeClassGroup && filterSubjects.length === 0}
|
||||
All subjects
|
||||
{:else if activeClassGroup}
|
||||
{activeClassGroup.name}
|
||||
{:else if filterSubjects.length === 1}
|
||||
{filterSubjects[0]}
|
||||
{:else}
|
||||
@@ -364,14 +425,15 @@
|
||||
<button
|
||||
type="button"
|
||||
class="bsplus-analytics-dropdown-item"
|
||||
class:is-selected={filterSubjects.length === 0}
|
||||
class:is-selected={!activeClassGroup && filterSubjects.length === 0}
|
||||
onclick={() => {
|
||||
filterSubjects = [];
|
||||
activeClassGroupId = null;
|
||||
showSubjectsDropdown = false;
|
||||
}}
|
||||
>
|
||||
<span class="bsplus-analytics-dropdown-check"
|
||||
>{filterSubjects.length === 0 ? "✓" : ""}</span
|
||||
>{!activeClassGroup && filterSubjects.length === 0 ? "✓" : ""}</span
|
||||
>
|
||||
All subjects
|
||||
</button>
|
||||
@@ -394,6 +456,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if !simpleMode}
|
||||
<ClassGroupsPanel
|
||||
classOptions={classCatalog}
|
||||
groups={classGroups}
|
||||
activeGroupId={activeClassGroupId}
|
||||
onSelectGroup={selectClassGroup}
|
||||
onSaveGroups={persistClassGroups}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<div class="bsplus-analytics-filter-group">
|
||||
<span class="bsplus-analytics-field-label">Search</span>
|
||||
<input
|
||||
@@ -449,6 +521,7 @@
|
||||
{timeRange}
|
||||
{customTimeRange}
|
||||
showSubjectTrends={showSubjectTrends}
|
||||
combinedLabel={combinedChartLabel}
|
||||
/>
|
||||
</div>
|
||||
<div class="bsplus-analytics-chart-cell">
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
resolveNumericGradeFromAssessmentPayload,
|
||||
} from "./letterGradeScale";
|
||||
import { loadAnalyticsCache, saveAnalyticsCache } from "./storage";
|
||||
import type { Assessment, AssessmentStatus } from "./types";
|
||||
import type { Assessment, AssessmentStatus, AnalyticsClassOption } from "./types";
|
||||
|
||||
const PAST_FETCH_CONCURRENCY = 8;
|
||||
const DEFAULT_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
||||
@@ -152,65 +152,119 @@ function extractLetterGrade(
|
||||
);
|
||||
}
|
||||
|
||||
/** All programme years / folders from SEQTA (active and inactive), matching DesQTA analytics. */
|
||||
function flattenSubjectFolders(payload: unknown): Subject[] {
|
||||
if (!Array.isArray(payload)) return [];
|
||||
function classKey(programme: number, metaclass: number): string {
|
||||
return `${programme}-${metaclass}`;
|
||||
}
|
||||
|
||||
const subjects: Subject[] = [];
|
||||
function folderYearLabel(description: unknown): string {
|
||||
const text = String(description ?? "").trim();
|
||||
const match = text.match(/\b(20\d{2})\b/);
|
||||
return match?.[1] ?? (text || "?");
|
||||
}
|
||||
|
||||
function parseClassOption(raw: unknown, yearLabel: string): AnalyticsClassOption | null {
|
||||
if (!raw || typeof raw !== "object") return null;
|
||||
const row = raw as Record<string, unknown>;
|
||||
const programme = Number(row.programme ?? row.programmeID);
|
||||
const metaclass = Number(row.metaclass ?? row.metaclassID);
|
||||
if (!programme || !metaclass || Number.isNaN(programme) || Number.isNaN(metaclass)) {
|
||||
return null;
|
||||
}
|
||||
const title = String(row.title ?? row.description ?? row.code ?? row.subject ?? "").trim();
|
||||
if (!title) return null;
|
||||
return {
|
||||
key: classKey(programme, metaclass),
|
||||
title,
|
||||
yearLabel,
|
||||
programme,
|
||||
metaclass,
|
||||
};
|
||||
}
|
||||
|
||||
function parseClassOptionsFromPayload(payload: unknown): AnalyticsClassOption[] {
|
||||
if (!Array.isArray(payload)) return [];
|
||||
const map = new Map<string, AnalyticsClassOption>();
|
||||
for (const folder of payload) {
|
||||
if (!folder || typeof folder !== "object") continue;
|
||||
const list = (folder as { subjects?: Subject[] }).subjects;
|
||||
if (!Array.isArray(list)) continue;
|
||||
|
||||
for (const raw of list) {
|
||||
if (!raw || typeof raw !== "object") continue;
|
||||
const programme = Number(
|
||||
(raw as Subject).programme ?? (raw as { programmeID?: number }).programmeID,
|
||||
);
|
||||
const metaclass = Number(
|
||||
(raw as Subject).metaclass ?? (raw as { metaclassID?: number }).metaclassID,
|
||||
);
|
||||
if (!programme || !metaclass || isNaN(programme) || isNaN(metaclass)) continue;
|
||||
|
||||
subjects.push({
|
||||
code: String((raw as Subject).code ?? (raw as { subject?: string }).subject ?? ""),
|
||||
programme,
|
||||
metaclass,
|
||||
});
|
||||
const term = folder as { description?: unknown; code?: unknown; subjects?: unknown[] };
|
||||
const yearLabel = folderYearLabel(term.description ?? term.code);
|
||||
for (const raw of term.subjects ?? []) {
|
||||
const option = parseClassOption(raw, yearLabel);
|
||||
if (option) map.set(option.key, option);
|
||||
}
|
||||
}
|
||||
return subjects;
|
||||
return sortClassOptions([...map.values()]);
|
||||
}
|
||||
|
||||
/** Subjects implied by cached assessments (covers metaclasses no longer listed). */
|
||||
function subjectsFromAssessments(assessments: Assessment[]): Subject[] {
|
||||
const map = new Map<string, Subject>();
|
||||
function classOptionsFromAssessments(assessments: Assessment[]): AnalyticsClassOption[] {
|
||||
const map = new Map<string, AnalyticsClassOption>();
|
||||
for (const a of assessments) {
|
||||
if (!a.programmeID || !a.metaclassID) continue;
|
||||
const key = `${a.programmeID}-${a.metaclassID}`;
|
||||
if (!map.has(key)) {
|
||||
map.set(key, {
|
||||
code: a.code || a.subject,
|
||||
programme: a.programmeID,
|
||||
metaclass: a.metaclassID,
|
||||
});
|
||||
}
|
||||
const key = classKey(a.programmeID, a.metaclassID);
|
||||
if (map.has(key)) continue;
|
||||
map.set(key, {
|
||||
key,
|
||||
title: a.subject || a.code,
|
||||
yearLabel: a.due ? String(new Date(a.due).getFullYear()) : "?",
|
||||
programme: a.programmeID,
|
||||
metaclass: a.metaclassID,
|
||||
});
|
||||
}
|
||||
return Array.from(map.values());
|
||||
return [...map.values()];
|
||||
}
|
||||
|
||||
function dedupeSubjects(subjects: Subject[]): Subject[] {
|
||||
const map = new Map<string, Subject>();
|
||||
for (const s of subjects) {
|
||||
map.set(`${s.programme}-${s.metaclass}`, s);
|
||||
function sortClassOptions(options: AnalyticsClassOption[]): AnalyticsClassOption[] {
|
||||
return [...options].sort((a, b) => {
|
||||
const yearA = Number.parseInt(a.yearLabel, 10);
|
||||
const yearB = Number.parseInt(b.yearLabel, 10);
|
||||
if (!Number.isNaN(yearA) && !Number.isNaN(yearB) && yearA !== yearB) {
|
||||
return yearB - yearA;
|
||||
}
|
||||
if (a.yearLabel !== b.yearLabel) {
|
||||
return a.yearLabel.localeCompare(b.yearLabel, undefined, { sensitivity: "base" });
|
||||
}
|
||||
return a.title.localeCompare(b.title, undefined, { sensitivity: "base" });
|
||||
});
|
||||
}
|
||||
|
||||
function mergeClassCatalog(
|
||||
folderPayload: unknown,
|
||||
assessments: Assessment[],
|
||||
): AnalyticsClassOption[] {
|
||||
const map = new Map<string, AnalyticsClassOption>();
|
||||
for (const option of parseClassOptionsFromPayload(folderPayload)) {
|
||||
map.set(option.key, option);
|
||||
}
|
||||
return Array.from(map.values());
|
||||
for (const option of classOptionsFromAssessments(assessments)) {
|
||||
map.set(option.key, option);
|
||||
}
|
||||
return sortClassOptions([...map.values()]);
|
||||
}
|
||||
|
||||
function catalogToSubjects(catalog: AnalyticsClassOption[]): Subject[] {
|
||||
return catalog.map((c) => ({
|
||||
code: c.title,
|
||||
programme: c.programme,
|
||||
metaclass: c.metaclass,
|
||||
}));
|
||||
}
|
||||
|
||||
async function loadAllSubjects(existingAssessments: Assessment[] = []): Promise<Subject[]> {
|
||||
const res = await fetchJSON("/seqta/student/load/subjects?", {});
|
||||
const fromFolders = flattenSubjectFolders(res.payload);
|
||||
return dedupeSubjects([...fromFolders, ...subjectsFromAssessments(existingAssessments)]);
|
||||
const catalog = await loadAnalyticsClassCatalog(existingAssessments);
|
||||
return catalogToSubjects(catalog);
|
||||
}
|
||||
|
||||
/** All programme-year classes for combine-groups UI (active + inactive folders). */
|
||||
export async function loadAnalyticsClassCatalog(
|
||||
existingAssessments: Assessment[] = [],
|
||||
): Promise<AnalyticsClassOption[]> {
|
||||
try {
|
||||
const res = await fetchJSON("/seqta/student/load/subjects?", {});
|
||||
return mergeClassCatalog(res.payload, existingAssessments);
|
||||
} catch (error) {
|
||||
console.error("[BetterSEQTA+] Failed to load analytics class catalog:", error);
|
||||
return sortClassOptions(classOptionsFromAssessments(existingAssessments));
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUpcoming(studentId: number): Promise<Record<string, unknown>[]> {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import browser from "webextension-polyfill";
|
||||
import type { DistributionMode } from "./gradeDistribution";
|
||||
import type { AnalyticsCache } from "./types";
|
||||
import type { AnalyticsCache, AnalyticsClassGroup } from "./types";
|
||||
|
||||
const STORAGE_PREFIX = "bsplus.analytics.v2";
|
||||
const DISTRIBUTION_MODE_PREFIX = "bsplus.analytics.distMode.v1";
|
||||
const CLASS_GROUPS_PREFIX = "bsplus.analytics.groups.v1";
|
||||
|
||||
export function analyticsStorageKey(origin: string, studentId: number): string {
|
||||
return `${STORAGE_PREFIX}.${origin}.${studentId}`;
|
||||
@@ -66,3 +67,38 @@ export async function saveDistributionMode(
|
||||
const key = distributionModeStorageKey(origin, studentId);
|
||||
await browser.storage.local.set({ [key]: mode });
|
||||
}
|
||||
|
||||
export function classGroupsStorageKey(origin: string, studentId: number): string {
|
||||
return `${CLASS_GROUPS_PREFIX}.${origin}.${studentId}`;
|
||||
}
|
||||
|
||||
function isClassGroup(value: unknown): value is AnalyticsClassGroup {
|
||||
if (!value || typeof value !== "object") return false;
|
||||
const g = value as AnalyticsClassGroup;
|
||||
return (
|
||||
typeof g.id === "string" &&
|
||||
typeof g.name === "string" &&
|
||||
Array.isArray(g.classKeys) &&
|
||||
g.classKeys.every((key) => typeof key === "string")
|
||||
);
|
||||
}
|
||||
|
||||
export async function loadClassGroups(
|
||||
origin: string,
|
||||
studentId: number,
|
||||
): Promise<AnalyticsClassGroup[]> {
|
||||
const key = classGroupsStorageKey(origin, studentId);
|
||||
const result = await browser.storage.local.get(key);
|
||||
const raw = result[key];
|
||||
if (!Array.isArray(raw)) return [];
|
||||
return raw.filter(isClassGroup);
|
||||
}
|
||||
|
||||
export async function saveClassGroups(
|
||||
origin: string,
|
||||
studentId: number,
|
||||
groups: AnalyticsClassGroup[],
|
||||
): Promise<void> {
|
||||
const key = classGroupsStorageKey(origin, studentId);
|
||||
await browser.storage.local.set({ [key]: groups });
|
||||
}
|
||||
@@ -929,6 +929,315 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Combined class groups */
|
||||
.bsplus-analytics-class-groups-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-add {
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--bsplus-analytics-accent, var(--better-main, #007bff));
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
padding: 0.15rem 0.35rem;
|
||||
border-radius: 0.375rem;
|
||||
transition: background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-add:hover:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--bsplus-analytics-accent, #007bff) 12%, transparent);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-add:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-empty {
|
||||
margin: 0.35rem 0 0;
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.45;
|
||||
color: var(--bsplus-analytics-muted, rgba(127, 127, 127, 0.95));
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-list {
|
||||
list-style: none;
|
||||
margin: 0.5rem 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-row {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-btn {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.1rem;
|
||||
padding: 0.55rem 0.65rem;
|
||||
border-radius: 0.625rem;
|
||||
border: 1px solid var(--bsplus-analytics-border, rgba(127, 127, 127, 0.25));
|
||||
background: var(--bsplus-analytics-surface, rgba(255, 255, 255, 0.04));
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-btn:hover,
|
||||
.bsplus-analytics-class-group-btn.is-active {
|
||||
border-color: var(--bsplus-analytics-accent, #007bff);
|
||||
background: color-mix(in srgb, var(--bsplus-analytics-accent, #007bff) 10%, transparent);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-name {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-meta {
|
||||
font-size: 0.75rem;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-icon {
|
||||
flex: 0 0 auto;
|
||||
width: 2rem;
|
||||
border: 1px solid var(--bsplus-analytics-border, rgba(127, 127, 127, 0.25));
|
||||
border-radius: 0.625rem;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-icon:hover {
|
||||
border-color: var(--bsplus-analytics-accent, #007bff);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-group-delete:hover {
|
||||
color: #ef4444;
|
||||
border-color: color-mix(in srgb, #ef4444 45%, transparent);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 10000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1.25rem;
|
||||
background: rgba(0, 0, 0, 0.52);
|
||||
backdrop-filter: blur(4px);
|
||||
-webkit-backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-dialog {
|
||||
width: min(100%, 34rem);
|
||||
max-height: min(88vh, 42rem);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: 1rem;
|
||||
border: 1px solid var(--bsplus-analytics-border, rgba(127, 127, 127, 0.28));
|
||||
background: var(--bsplus-analytics-panel, var(--background-primary, #1a1a1a));
|
||||
color: inherit;
|
||||
box-shadow:
|
||||
0 24px 48px rgba(0, 0, 0, 0.28),
|
||||
0 0 0 1px rgba(255, 255, 255, 0.04) inset;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-dialog-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 1.1rem 0.85rem;
|
||||
border-bottom: 1px solid var(--bsplus-analytics-border, rgba(127, 127, 127, 0.22));
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-dialog-title {
|
||||
margin: 0;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-dialog-desc {
|
||||
margin: 0.35rem 0 0;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.45;
|
||||
color: var(--bsplus-analytics-muted, rgba(127, 127, 127, 0.95));
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-close {
|
||||
flex: 0 0 auto;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font-size: 1.35rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
opacity: 0.75;
|
||||
transition:
|
||||
opacity 0.15s ease,
|
||||
background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-close:hover {
|
||||
opacity: 1;
|
||||
background: rgba(127, 127, 127, 0.16);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-dialog-body {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.85rem;
|
||||
padding: 0.95rem 1.1rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.5rem;
|
||||
padding: 0.85rem 1.1rem 1rem;
|
||||
border-top: 1px solid var(--bsplus-analytics-border, rgba(127, 127, 127, 0.22));
|
||||
background: color-mix(in srgb, var(--bsplus-analytics-panel, #111) 92%, transparent);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-field:last-child {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-picks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.45rem;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
max-height: min(52vh, 24rem);
|
||||
overflow-y: auto;
|
||||
padding: 0.15rem 0.1rem 0.15rem 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-pick {
|
||||
display: grid;
|
||||
grid-template-columns: 1.125rem minmax(0, 1fr);
|
||||
gap: 0.75rem;
|
||||
align-items: start;
|
||||
padding: 0.6rem 0.7rem;
|
||||
border-radius: 0.625rem;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-pick:hover {
|
||||
background: rgba(127, 127, 127, 0.08);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-pick:has(input:checked) {
|
||||
border-color: color-mix(in srgb, var(--bsplus-analytics-accent, #007bff) 45%, transparent);
|
||||
background: color-mix(in srgb, var(--bsplus-analytics-accent, #007bff) 8%, transparent);
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-pick input[type="checkbox"] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
margin: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-check {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.125rem;
|
||||
height: 1.125rem;
|
||||
margin-top: 0.1rem;
|
||||
border: 2px solid var(--bsplus-analytics-accent, var(--better-main, #007bff));
|
||||
border-radius: 0.3rem;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-pick:has(input:checked) .bsplus-analytics-class-groups-check {
|
||||
background: var(--bsplus-analytics-accent, var(--better-main, #007bff));
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-pick-text {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 0.45rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-pick-label {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.bsplus-analytics-class-groups-year {
|
||||
flex: 0 0 auto;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
padding: 0.12rem 0.45rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(127, 127, 127, 0.16);
|
||||
color: var(--bsplus-analytics-muted, rgba(220, 220, 220, 0.92));
|
||||
}
|
||||
|
||||
/* ─── Chart grid & cards ─── */
|
||||
.bsplus-analytics-charts {
|
||||
display: grid;
|
||||
|
||||
@@ -193,7 +193,11 @@ function slugSubjectKey(name: string, keyBySubject: Map<string, string>): string
|
||||
export function buildGradeTrendChart(
|
||||
data: Assessment[],
|
||||
timeRange: TimeRange,
|
||||
options: { showPerSubject?: boolean; custom?: CustomTimeRange } = {},
|
||||
options: {
|
||||
showPerSubject?: boolean;
|
||||
custom?: CustomTimeRange;
|
||||
combinedLabel?: string;
|
||||
} = {},
|
||||
): { points: TrendPoint[]; series: TrendSeries[]; accentColor: string } {
|
||||
const accentColor =
|
||||
"var(--bsplus-analytics-accent, var(--better-main, #007bff))";
|
||||
@@ -283,7 +287,7 @@ export function buildGradeTrendChart(
|
||||
const series: TrendSeries[] = [
|
||||
{
|
||||
key: "average",
|
||||
label: "Overall average",
|
||||
label: options.combinedLabel?.trim() || "Overall average",
|
||||
color: accentColor,
|
||||
isOverall: true,
|
||||
},
|
||||
|
||||
@@ -27,3 +27,17 @@ export interface AnalyticsCache {
|
||||
updatedAt: number;
|
||||
assessments: Assessment[];
|
||||
}
|
||||
|
||||
export interface AnalyticsClassOption {
|
||||
key: string;
|
||||
title: string;
|
||||
yearLabel: string;
|
||||
programme: number;
|
||||
metaclass: number;
|
||||
}
|
||||
|
||||
export interface AnalyticsClassGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
classKeys: string[];
|
||||
}
|
||||
@@ -105,7 +105,7 @@ function applyBetterseqtaLogoBackground(isDark: boolean) {
|
||||
background-image: url("${fullUrl}") !important;
|
||||
}
|
||||
/* Icon-only sidebar: wordmark → compact mark (theme-aware). */
|
||||
body.student.icon-only-sidebar:not(:has(#menu li.hasChildren.active)) #menu > ul::before {
|
||||
body.student.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) #menu > ul::before {
|
||||
background-image: url("${iconUrl}") !important;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { fly } from "svelte/transition";
|
||||
import type { SidebarItem } from "./types";
|
||||
|
||||
type Props = {
|
||||
@@ -8,7 +7,7 @@
|
||||
compact: boolean;
|
||||
editMode: boolean;
|
||||
visible: boolean;
|
||||
/** Play intro fly only when the parent folder first opens. */
|
||||
/** Reserved — panel slide handles enter motion; no per-item fly. */
|
||||
drillEnter?: boolean;
|
||||
onActivate: (item: SidebarItem) => void;
|
||||
onToggleVisible?: (key: string, visible: boolean) => void;
|
||||
@@ -20,7 +19,7 @@
|
||||
compact,
|
||||
editMode,
|
||||
visible,
|
||||
drillEnter = false,
|
||||
drillEnter: _drillEnter = false,
|
||||
onActivate,
|
||||
onToggleVisible,
|
||||
}: Props = $props();
|
||||
@@ -49,7 +48,6 @@
|
||||
tabindex={editMode ? -1 : 0}
|
||||
aria-label={item.label}
|
||||
aria-current={active ? "page" : undefined}
|
||||
in:fly={drillEnter ? { x: 24, duration: 180 } : undefined}
|
||||
onclick={(e) => {
|
||||
// Keep SEQTA's #menu handlers from seeing custom-list clicks — that fights
|
||||
// our drill UI and can freeze the tab (Goals / Folios / etc.).
|
||||
@@ -94,9 +92,6 @@
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
{#if item.itemColour && !item.hasChildren}
|
||||
<span class="colour-bar" aria-hidden="true"></span>
|
||||
{/if}
|
||||
</li>
|
||||
|
||||
<style>
|
||||
@@ -248,18 +243,4 @@
|
||||
flex-shrink: 0;
|
||||
accent-color: var(--theme-primary, #fff);
|
||||
}
|
||||
|
||||
.colour-bar {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
box-shadow: inset 3px 0 var(--item-colour, transparent);
|
||||
transition: box-shadow 100ms ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.bsplus-sidebar-item:hover .colour-bar,
|
||||
.bsplus-sidebar-item.bsplus-active .colour-bar {
|
||||
box-shadow: inset 6px 0 var(--item-colour, transparent);
|
||||
}
|
||||
</style>
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
} from "./parseNativeMenu";
|
||||
import type { SidebarDrillFrame, SidebarItem } from "./types";
|
||||
|
||||
export const BSPLUS_DRILL_MS = 350;
|
||||
|
||||
function orderItems(items: SidebarItem[], order: string[]): SidebarItem[] {
|
||||
if (!order.length) return items;
|
||||
|
||||
@@ -273,9 +275,12 @@ class SidebarState {
|
||||
(entry) => entry.key === item.key,
|
||||
);
|
||||
|
||||
this.enterFrameKey = item.key;
|
||||
// Root folders replace the stack; nested folders append.
|
||||
this.drillStack = isRoot ? [frame] : [...this.drillStack, frame];
|
||||
this.enterFrameKey = item.key;
|
||||
|
||||
if (!animationsEnabled()) {
|
||||
queueMicrotask(() => this.clearEnterFrame(item.key));
|
||||
}
|
||||
|
||||
// Keep native drill closed so SEQTA CSS :has(> ul > li.hasChildren.active)
|
||||
// does not lock pointer-events on the custom list.
|
||||
@@ -304,7 +309,7 @@ class SidebarState {
|
||||
this.drillReturning = true;
|
||||
window.setTimeout(() => {
|
||||
this.drillReturning = false;
|
||||
}, 360);
|
||||
}, BSPLUS_DRILL_MS + 20);
|
||||
}
|
||||
|
||||
resetDrill() {
|
||||
|
||||
@@ -12,10 +12,15 @@ function extensionOutsideClickHandler(extensionPopup: HTMLElement) {
|
||||
return (event: MouseEvent) => {
|
||||
if (!SettingsClicked) return;
|
||||
|
||||
if (!(event.target as HTMLElement).closest("#AddedSettings")) {
|
||||
if (event.target == extensionPopup) return;
|
||||
changeSettingsClicked(closeExtensionPopup());
|
||||
}
|
||||
const target = event.target;
|
||||
if (!(target instanceof Node)) return;
|
||||
|
||||
if (extensionPopup.shadowRoot?.contains(target)) return;
|
||||
if (target instanceof HTMLElement && target.closest(".feedback-overlay")) return;
|
||||
if (target instanceof HTMLElement && target.closest("#AddedSettings")) return;
|
||||
if (target === extensionPopup) return;
|
||||
|
||||
changeSettingsClicked(closeExtensionPopup());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,18 @@ export type WhatsNewRelease = {
|
||||
};
|
||||
|
||||
export const WHATS_NEW_CHANGELOG: WhatsNewRelease[] = [
|
||||
{
|
||||
"title": "3.7.4 – Performance Mode & various fixes",
|
||||
"items": [
|
||||
"Added Performance Mode in General settings dramatically improving performance with little sacrifice to looks.",
|
||||
"Fixed custom background images and videos not uploading.",
|
||||
"Added combined class groups in Grade Analytics to merge multiple subjects into one trend.",
|
||||
"Fixed icon-only sidebar not expanding when opening a folder.",
|
||||
"Fixed icon-only sidebar root labels overlapping folder view when drilling in.",
|
||||
"Fixed feedback modal not scrolling on long bug reports and replies.",
|
||||
"Fixed the look and feel of the sidebar to be more like how it used to be.",
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "3.7.3 – Timetable sync into Calendars, Sidebar Customisation, new loading animations & Bugfix Bundle",
|
||||
"items": [
|
||||
|
||||
Reference in new issue
Block a user