mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
feat: add compact expandable settings popup
This commit is contained in:
1 parent
bd29ab62c6
commit
776c1e98d9
15 files changed
+478
-209
No files matched your search
@@ -55,6 +55,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="sidebar-appearance">
|
||||
<div class="card">
|
||||
<header class="card-header split">
|
||||
<div>
|
||||
@@ -94,7 +95,7 @@
|
||||
<button
|
||||
type="button"
|
||||
id={`sidebar-style-${style.id}`}
|
||||
class="option"
|
||||
class={`option style-${style.id}`}
|
||||
class:active
|
||||
role="option"
|
||||
aria-selected={active}
|
||||
@@ -242,7 +243,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.sidebar-appearance {
|
||||
container: sidebar-appearance / inline-size;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin: 4px 0;
|
||||
padding: 4px;
|
||||
@@ -606,4 +613,78 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@container sidebar-appearance (max-width: 500px) {
|
||||
.preview-pane,
|
||||
.thumb {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.picker-body {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.options {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.option {
|
||||
min-height: 2.5rem;
|
||||
justify-content: center;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.option.style-soft {
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 3px 8px rgb(0 0 0 / 0.2);
|
||||
}
|
||||
|
||||
.option.style-pill {
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.option.style-glass {
|
||||
background: linear-gradient(135deg, rgb(148 163 184 / 0.24), rgb(148 163 184 / 0.08));
|
||||
box-shadow: inset 0 0 0 1px rgb(148 163 184 / 0.35);
|
||||
}
|
||||
|
||||
.option.style-sharp {
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.option.style-strip {
|
||||
border-radius: 0;
|
||||
border-left: 3px solid currentColor;
|
||||
}
|
||||
|
||||
.option.style-neon {
|
||||
box-shadow: 0 0 0 1px rgb(148 163 184 / 0.6), 0 0 12px rgb(148 163 184 / 0.4);
|
||||
}
|
||||
|
||||
.option.active {
|
||||
outline: 1px solid currentColor;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
font-size: 0.775rem;
|
||||
}
|
||||
|
||||
.card-header.split {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card-header.split .title {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.card-header.split .subtitle {
|
||||
font-size: 0.65rem;
|
||||
}
|
||||
|
||||
.selected-meta {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,50 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { animate } from 'motion';
|
||||
import { onMount } from "svelte";
|
||||
import { standalone } from '../utils/standalone.svelte';
|
||||
import { fullMotionEffectsEnabled } from '@/seqta/utils/performanceMode';
|
||||
|
||||
let { state, onChange } = $props<{ state: boolean, onChange: (newState: boolean) => void }>();
|
||||
let handle: HTMLElement | null = null;
|
||||
let { state: checked, onChange } = $props<{ state: boolean, onChange: (newState: boolean) => void }>();
|
||||
|
||||
const springParams = {
|
||||
stiffness: 600,
|
||||
damping: 30,
|
||||
};
|
||||
let motionReady = $state(false);
|
||||
onMount(() => {
|
||||
// Paint the hydrated position before enabling transitions for later toggles.
|
||||
let frame = requestAnimationFrame(() => {
|
||||
frame = requestAnimationFrame(() => { motionReady = true; });
|
||||
});
|
||||
return () => cancelAnimationFrame(frame);
|
||||
});
|
||||
|
||||
const knobX = $derived(state ? (standalone.standalone ? 24 : 20) : 0);
|
||||
|
||||
const animateSwitch = (enabled: boolean) => {
|
||||
if (!handle) return;
|
||||
const x = enabled ? (standalone.standalone ? 24 : 20) : 0;
|
||||
if (!fullMotionEffectsEnabled()) {
|
||||
handle.style.transform = `translateX(${x}px)`;
|
||||
return;
|
||||
}
|
||||
animate(
|
||||
handle,
|
||||
{ x },
|
||||
{
|
||||
type: 'spring',
|
||||
stiffness: springParams.stiffness,
|
||||
damping: springParams.damping,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
$effect(() => animateSwitch(state));
|
||||
const knobX = $derived(checked ? (standalone.standalone ? 24 : 20) : 0);
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex w-14 p-1 cursor-pointer transition-all duration-150 rounded-full bg-gradient-to-tr select-none shadow-2xl ring-[1px] ring-[#DDDDDD]/30 dark:ring-[#38373D]/30 {state ? 'to-[#30D259]/80 from-[#30D259] dark:from-[#30D259]/40 dark:to-[#30D259]' : 'dark:from-[#38373D]/50 dark:to-[#38373D] to-[#DDDDDD]/50 from-[#DDDDDD]'}"
|
||||
onclick={() => onChange(!state)}
|
||||
onkeydown={(e) => e.key === "Enter" && onChange(!state)}
|
||||
class="flex w-14 p-1 cursor-pointer transition-all duration-150 rounded-full bg-gradient-to-tr select-none shadow-2xl ring-[1px] ring-[#DDDDDD]/30 dark:ring-[#38373D]/30 {checked ? 'to-[#30D259]/80 from-[#30D259] dark:from-[#30D259]/40 dark:to-[#30D259]' : 'dark:from-[#38373D]/50 dark:to-[#38373D] to-[#DDDDDD]/50 from-[#DDDDDD]'}"
|
||||
onclick={() => onChange(!checked)}
|
||||
onkeydown={(e) => e.key === "Enter" && onChange(!checked)}
|
||||
role="switch"
|
||||
aria-checked={state}
|
||||
aria-checked={checked}
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
bind:this={handle}
|
||||
class="w-6 h-6 bg-white dark:bg-[#FEFEFE] rounded-full drop-shadow-md transition-transform duration-200"
|
||||
style={fullMotionEffectsEnabled() ? undefined : `transform: translateX(${knobX}px)`}
|
||||
style={`transform: translateX(${knobX}px); transition-duration: ${motionReady && fullMotionEffectsEnabled() ? 200 : 0}ms`}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
[role="switch"] > div { transition: none !important; }
|
||||
}
|
||||
</style>
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import MotionDiv from "./MotionDiv.svelte";
|
||||
import LazyPanel from "./LazyPanel.svelte";
|
||||
import type { Component } from "svelte";
|
||||
import { onMount } from "svelte";
|
||||
import { fullMotionEffectsEnabled } from "@/seqta/utils/performanceMode";
|
||||
|
||||
type TabDef = {
|
||||
title: string;
|
||||
@@ -16,37 +16,6 @@
|
||||
activeTab?: number;
|
||||
}>();
|
||||
|
||||
let containerRef: HTMLElement | null = $state(null);
|
||||
let tabWidth = $state(0);
|
||||
let containerWidth = $state(0);
|
||||
|
||||
const springTransition = { type: "spring", stiffness: 250, damping: 25 };
|
||||
|
||||
function measureTabs() {
|
||||
if (!containerRef || tabs.length === 0) return;
|
||||
tabWidth = 100 / tabs.length;
|
||||
containerRef.style.setProperty("--tab-width", `${tabWidth}%`);
|
||||
containerWidth = containerRef.getBoundingClientRect().width;
|
||||
}
|
||||
|
||||
const indicatorX = $derived((tabWidth * activeTab * containerWidth) / 100);
|
||||
|
||||
$effect(() => {
|
||||
tabs.length;
|
||||
if (!containerRef) return;
|
||||
|
||||
measureTabs();
|
||||
requestAnimationFrame(measureTabs);
|
||||
|
||||
const ro =
|
||||
typeof ResizeObserver !== "undefined"
|
||||
? new ResizeObserver(measureTabs)
|
||||
: null;
|
||||
ro?.observe(containerRef);
|
||||
|
||||
return () => ro?.disconnect();
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
const handleMessage = (event: MessageEvent) => {
|
||||
if (event.data === "popupClosed") {
|
||||
@@ -60,12 +29,11 @@
|
||||
|
||||
<div class="flex flex-col h-full min-h-0">
|
||||
<div class="top-0 z-10 shrink-0 text-[0.875rem] pb-0.5 mx-4 px-2 tab-width-container" role="tablist">
|
||||
<div bind:this={containerRef} class="flex relative">
|
||||
<MotionDiv
|
||||
<div class="flex relative">
|
||||
<div
|
||||
class="absolute top-0 left-0 z-0 h-full bg-gradient-to-tr dark:from-[#38373D]/80 dark:to-[#38373D] from-[#DDDDDD]/80 to-[#DDDDDD] rounded-full opacity-40 tab-width"
|
||||
animate={{ x: indicatorX }}
|
||||
transition={springTransition}
|
||||
/>
|
||||
style={`width: ${100 / Math.max(1, tabs.length)}%; transform: translateX(${activeTab * 100}%); transition: transform ${fullMotionEffectsEnabled() ? 250 : 0}ms cubic-bezier(0.22, 1, 0.36, 1)`}
|
||||
></div>
|
||||
{#each tabs as { title }, index}
|
||||
<button
|
||||
role="tab"
|
||||
@@ -78,17 +46,17 @@
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow-hidden px-4 flex-1 min-h-0">
|
||||
<div class="relative overflow-hidden px-4 flex-1 min-h-0">
|
||||
<div
|
||||
class="tab-scroll-fade absolute inset-x-4 top-0 h-3 bg-gradient-to-b from-white/80 dark:from-zinc-800/80 to-transparent pointer-events-none z-[1]"
|
||||
aria-hidden="true"
|
||||
></div>
|
||||
{#each tabs as tab, index (index)}
|
||||
{#if activeTab === index}
|
||||
<div
|
||||
role="tabpanel"
|
||||
class="focus:outline-none w-full h-full min-h-0 pt-2 overflow-y-auto no-scrollbar pb-6 tab active relative"
|
||||
>
|
||||
<div
|
||||
class="sticky top-0 w-full h-3 -mb-3 bg-gradient-to-b from-white/80 dark:from-zinc-800/80 to-transparent pointer-events-none z-[1]"
|
||||
aria-hidden="true"
|
||||
></div>
|
||||
{#if tab.loader}
|
||||
<LazyPanel loader={tab.loader} props={tab.props} />
|
||||
{:else if tab.Content}
|
||||
@@ -99,3 +67,9 @@
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.tab-width { transition: none !important; }
|
||||
}
|
||||
</style>
|
||||
@@ -4,9 +4,10 @@
|
||||
import CloudPfpAvatar from "@/interface/components/CloudPfpAvatar.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
|
||||
let { alwaysShowUserName = false, onClick = undefined } = $props<{
|
||||
let { alwaysShowUserName = false, onClick = undefined, compact = false } = $props<{
|
||||
alwaysShowUserName?: boolean;
|
||||
onClick?: () => void;
|
||||
compact?: boolean;
|
||||
}>();
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
@@ -71,7 +72,7 @@
|
||||
<button
|
||||
type="button"
|
||||
onclick={handleButtonClick}
|
||||
class="flex h-12 items-center gap-2 rounded-full bg-zinc-100/80 px-4 text-sm font-medium text-zinc-700 transition-colors duration-150 hover:bg-zinc-200 hover:text-zinc-950 focus:outline-none dark:bg-zinc-900/50 dark:text-zinc-200 dark:hover:bg-zinc-700 dark:hover:text-white"
|
||||
class="flex items-center gap-2 bg-zinc-100/80 font-medium text-zinc-700 transition-colors duration-150 hover:bg-zinc-200 hover:text-zinc-950 focus:outline-none dark:bg-zinc-900/50 dark:text-zinc-200 dark:hover:bg-zinc-700 dark:hover:text-white {compact ? 'h-8 rounded-lg px-3 text-[0.75rem]' : 'h-12 rounded-full px-4 text-sm'}"
|
||||
>
|
||||
{#if cloudState.isLoggedIn}
|
||||
{#if cloudState.user?.pfpUrl}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
showStoreTools,
|
||||
onLogoClick,
|
||||
onClose,
|
||||
onToggleSize,
|
||||
} = $props<{
|
||||
searchTerm: string;
|
||||
setSearchTerm: (term: string) => void;
|
||||
@@ -25,6 +26,7 @@
|
||||
showStoreTools: boolean;
|
||||
onLogoClick: () => void;
|
||||
onClose: () => void;
|
||||
onToggleSize?: () => void;
|
||||
}>();
|
||||
|
||||
const tabs: { id: SettingsPage; title: string }[] = [
|
||||
@@ -115,6 +117,13 @@
|
||||
<CloudHeader />
|
||||
{/if}
|
||||
|
||||
{#if onToggleSize}
|
||||
<button type="button" onclick={onToggleSize}
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center text-zinc-500 transition-[color,transform] duration-150 hover:text-zinc-950 active:scale-[0.96] focus:outline-none dark:text-zinc-400 dark:hover:text-white"
|
||||
aria-label="Collapse settings" title="Collapse settings" aria-expanded="true">
|
||||
<span class="font-IconFamily text-2xl" aria-hidden="true">{"\uec06"}</span>
|
||||
</button>
|
||||
{/if}
|
||||
<PlainCloseButton onclick={onClose} label="Close settings" />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
import { resolveExtensionAssetUrl } from "@/lib/extensionAssetUrl";
|
||||
|
||||
import { standalone as StandaloneStore } from "../utils/standalone.svelte";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import { onMount, onDestroy, tick } from "svelte";
|
||||
import { animate } from "motion";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { isPerformanceMode } from "@/seqta/utils/performanceMode";
|
||||
|
||||
@@ -54,6 +55,8 @@
|
||||
|
||||
let devModeSequence = "";
|
||||
let compactActiveTab = $state(0);
|
||||
let expanded = $state(settingsState.settingsPopupExpanded === true);
|
||||
let lastExpandedTab: number | null = null;
|
||||
let activePage = $state<PageId>("settings");
|
||||
let activeSection = $state("general");
|
||||
let activeThemeView = $state<ThemeView>("theme-store");
|
||||
@@ -89,18 +92,22 @@
|
||||
{ id: "appearance", label: "Appearance" },
|
||||
];
|
||||
|
||||
const appNav: NavItem[] = [
|
||||
$effect(() => {
|
||||
if (!$settingsState.devMode && activeSection === "advanced") activeSection = "general";
|
||||
});
|
||||
|
||||
const appNav = $derived<NavItem[]>([
|
||||
{ id: "timetable", label: "Timetable" },
|
||||
{ id: "assessments", label: "Assessments" },
|
||||
{ id: "features", label: "Features" },
|
||||
{ id: "advanced", label: "Advanced" },
|
||||
...($settingsState.devMode ? [{ id: "advanced", label: "Advanced" }] : []),
|
||||
{ id: "shortcuts", label: "Shortcuts" },
|
||||
];
|
||||
]);
|
||||
|
||||
const settingsNavGroups = [
|
||||
const settingsNavGroups = $derived([
|
||||
{ label: "User Settings", items: userNav },
|
||||
{ label: "App Settings", items: appNav },
|
||||
];
|
||||
]);
|
||||
|
||||
const themeNavGroups = [
|
||||
{
|
||||
@@ -290,7 +297,109 @@
|
||||
showCloudPanel: openCloudPanel,
|
||||
};
|
||||
|
||||
let settingsPanel = $state<HTMLElement>();
|
||||
let settingsContent = $state<HTMLElement>();
|
||||
let resizeSnapshot: HTMLElement | undefined;
|
||||
let resizeAnimation: ReturnType<typeof animate> | undefined;
|
||||
let resizeGeneration = 0;
|
||||
const bounds = ["width", "height", "top", "right"] as const;
|
||||
const clearMorphContent = () => {
|
||||
resizeSnapshot?.remove();
|
||||
resizeSnapshot = undefined;
|
||||
if (settingsContent) {
|
||||
settingsContent.style.removeProperty("width");
|
||||
settingsContent.style.removeProperty("height");
|
||||
settingsContent.style.removeProperty("opacity");
|
||||
}
|
||||
};
|
||||
const clearResize = () => {
|
||||
resizeGeneration++;
|
||||
resizeAnimation?.stop();
|
||||
resizeAnimation = undefined;
|
||||
if (settingsPanel) for (const key of bounds) settingsPanel.style.removeProperty(key);
|
||||
clearMorphContent();
|
||||
};
|
||||
|
||||
const resizePanel = async (nextExpanded: boolean) => {
|
||||
const panel = settingsPanel;
|
||||
const content = settingsContent;
|
||||
const generation = ++resizeGeneration;
|
||||
const from = panel ? getComputedStyle(panel) : null;
|
||||
const start = bounds.map((key) => parseFloat(from?.[key] ?? "0"));
|
||||
resizeAnimation?.stop();
|
||||
const motionEnabled = $settingsState.animations !== false && !$settingsState.performanceMode &&
|
||||
!window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
const root = panel?.getRootNode() as ShadowRoot | Document | undefined;
|
||||
const restoreFocus = !!content?.contains(root?.activeElement ?? null);
|
||||
|
||||
// A visual snapshot has no live component listeners or accessible controls.
|
||||
// Include the current crossfade when a second click reverses the morph.
|
||||
if (panel && content && motionEnabled) {
|
||||
const snapshot = document.createElement("div");
|
||||
snapshot.inert = true;
|
||||
snapshot.setAttribute("aria-hidden", "true");
|
||||
snapshot.setAttribute("data-settings-snapshot", "");
|
||||
snapshot.style.cssText = `position:absolute;top:0;right:0;width:${panel.clientWidth}px;height:${panel.clientHeight}px;overflow:hidden;pointer-events:none;z-index:20;`;
|
||||
snapshot.append(content.cloneNode(true));
|
||||
if (resizeSnapshot) snapshot.append(resizeSnapshot.cloneNode(true));
|
||||
snapshot.querySelectorAll("[id]").forEach((element) => element.removeAttribute("id"));
|
||||
resizeSnapshot?.remove();
|
||||
resizeSnapshot = snapshot;
|
||||
panel.append(snapshot);
|
||||
content.style.opacity = "0";
|
||||
} else {
|
||||
clearMorphContent();
|
||||
}
|
||||
|
||||
expanded = nextExpanded;
|
||||
await tick();
|
||||
if (!panel || !content || generation !== resizeGeneration) return;
|
||||
for (const key of bounds) panel.style.removeProperty(key);
|
||||
if (restoreFocus) content.querySelector<HTMLButtonElement>(
|
||||
`[aria-label="${nextExpanded ? "Collapse" : "Expand"} settings"]`,
|
||||
)?.focus({ preventScroll: true });
|
||||
if (!motionEnabled) return;
|
||||
const targetStyle = getComputedStyle(panel);
|
||||
const target = bounds.map((key) => parseFloat(targetStyle[key]));
|
||||
// The incoming layout stays at its destination size while the outer bounds
|
||||
// move, so compact text and images never stretch across the expanded panel.
|
||||
content.style.width = `${panel.clientWidth}px`;
|
||||
content.style.height = `${panel.clientHeight}px`;
|
||||
bounds.forEach((key, index) => { panel.style[key] = `${start[index]}px`; });
|
||||
resizeAnimation = animate(0, 1, {
|
||||
type: "spring", stiffness: 420, damping: 36,
|
||||
onUpdate: (progress) => {
|
||||
if (generation !== resizeGeneration) return;
|
||||
const opacity = Math.max(0, Math.min(1, progress));
|
||||
content.style.opacity = String(opacity);
|
||||
if (resizeSnapshot) resizeSnapshot.style.opacity = String(1 - opacity);
|
||||
bounds.forEach((key, index) => {
|
||||
panel.style[key] = `${start[index] + (target[index] - start[index]) * progress}px`;
|
||||
});
|
||||
},
|
||||
onComplete: () => {
|
||||
if (generation !== resizeGeneration) return;
|
||||
for (const key of bounds) panel.style.removeProperty(key);
|
||||
clearMorphContent();
|
||||
resizeAnimation = undefined;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
let restoreSizeAfterClose = false;
|
||||
const resetClosedLayout = () => {
|
||||
if (!restoreSizeAfterClose) return;
|
||||
clearResize();
|
||||
expanded = settingsState.settingsPopupExpanded === true;
|
||||
restoreSizeAfterClose = false;
|
||||
};
|
||||
const closePopupsOnSettingsClose = () => {
|
||||
resizeGeneration++;
|
||||
resizeAnimation?.stop();
|
||||
resizeAnimation = undefined;
|
||||
if (expanded) syncCompactTab();
|
||||
restoreSizeAfterClose = true;
|
||||
if (document.getElementById("ExtensionPopup")?.style.opacity === "0") resetClosedLayout();
|
||||
showColourPicker = false;
|
||||
showFontPicker = false;
|
||||
showCloudPanel = false;
|
||||
@@ -304,6 +413,33 @@
|
||||
}
|
||||
};
|
||||
|
||||
const syncCompactTab = () => {
|
||||
compactActiveTab = activePage === "settings"
|
||||
? activeSection === "shortcuts" ? 1 : 0
|
||||
: 2;
|
||||
lastExpandedTab = compactActiveTab;
|
||||
};
|
||||
|
||||
const toggleExpanded = () => {
|
||||
settingsState.settingsPopupExpanded = !expanded;
|
||||
if (expanded) {
|
||||
syncCompactTab();
|
||||
} else if (compactActiveTab === lastExpandedTab) {
|
||||
void resizePanel(true);
|
||||
return;
|
||||
} else if (compactActiveTab === 1) {
|
||||
activePage = "settings";
|
||||
activeSection = "shortcuts";
|
||||
} else if (compactActiveTab === 2) {
|
||||
activePage = "themes";
|
||||
activeThemeView = "theme-settings";
|
||||
} else {
|
||||
activePage = "settings";
|
||||
if (activeSection === "shortcuts") activeSection = "general";
|
||||
}
|
||||
void resizePanel(!expanded);
|
||||
};
|
||||
|
||||
const selectNavItem = (id: string) => {
|
||||
if (activePage === "settings") {
|
||||
settingsSearch = "";
|
||||
@@ -325,6 +461,9 @@
|
||||
};
|
||||
|
||||
const applyDestination = (destination: SettingsDestination) => {
|
||||
clearResize();
|
||||
restoreSizeAfterClose = false;
|
||||
expanded = true;
|
||||
activePage = destination.page;
|
||||
if (destination.page === "settings") {
|
||||
if (destination.section) {
|
||||
@@ -356,6 +495,8 @@
|
||||
|
||||
onMount(() => {
|
||||
settingsPopup.addListener(closePopupsOnSettingsClose);
|
||||
window.addEventListener("bsplus:settings-hidden", resetClosedLayout);
|
||||
window.addEventListener("bsplus:settings-opening", resetClosedLayout);
|
||||
|
||||
if (standalone) {
|
||||
StandaloneStore.setStandalone(true);
|
||||
@@ -401,6 +542,8 @@
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("bsplus:settings-hidden", resetClosedLayout);
|
||||
window.removeEventListener("bsplus:settings-opening", resetClosedLayout);
|
||||
window.removeEventListener("keydown", onKeyDown);
|
||||
window.removeEventListener("bsplus:open-feedback", onOpenFeedback);
|
||||
window.removeEventListener(SETTINGS_NAVIGATION_EVENT, onNavigateSettings);
|
||||
@@ -408,6 +551,7 @@
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
clearResize();
|
||||
settingsPopup.removeListener(closePopupsOnSettingsClose);
|
||||
});
|
||||
</script>
|
||||
@@ -429,6 +573,7 @@
|
||||
showStoreTools={isOfficialStoreView || activeThemeView === "community-themes"}
|
||||
onLogoClick={handleDevModeToggle}
|
||||
onClose={handleClose}
|
||||
onToggleSize={standalone ? undefined : toggleExpanded}
|
||||
/>
|
||||
|
||||
<!-- Body: left nav + content -->
|
||||
@@ -611,13 +756,13 @@
|
||||
class="flex h-full min-h-0 flex-col gap-2 overflow-hidden bg-white dark:bg-zinc-800 dark:text-white"
|
||||
>
|
||||
<div
|
||||
class="grid shrink-0 place-items-center border-b border-zinc-200/40 dark:border-zinc-700/40"
|
||||
class="grid shrink-0 items-center border-b border-zinc-200/40 dark:border-zinc-700/40 {standalone ? 'grid-cols-1' : 'grid-cols-[minmax(0,1fr)_44px] gap-2 px-2'}"
|
||||
>
|
||||
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<img
|
||||
src={resolveExtensionAssetUrl(darkLogo)}
|
||||
class="w-4/5 dark:hidden"
|
||||
class="min-w-0 dark:hidden {standalone ? 'mx-auto w-4/5' : 'h-auto w-full max-w-[296px] justify-self-center object-contain'}"
|
||||
alt="BetterSEQTA+"
|
||||
onclick={handleDevModeToggle}
|
||||
/>
|
||||
@@ -625,10 +770,17 @@
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<img
|
||||
src={resolveExtensionAssetUrl(lightLogo)}
|
||||
class="hidden w-4/5 dark:block"
|
||||
class="hidden min-w-0 dark:block {standalone ? 'mx-auto w-4/5' : 'h-auto w-full max-w-[296px] justify-self-center object-contain'}"
|
||||
alt="BetterSEQTA+"
|
||||
onclick={handleDevModeToggle}
|
||||
/>
|
||||
{#if !standalone}
|
||||
<button type="button" onclick={toggleExpanded}
|
||||
class="mt-2 flex h-11 w-11 shrink-0 self-start items-center justify-center text-zinc-500 transition-[color,transform] duration-150 hover:text-zinc-950 active:scale-[0.96] focus:outline-none dark:text-zinc-400 dark:hover:text-white"
|
||||
aria-label="Expand settings" title="Expand settings" aria-expanded="false">
|
||||
<span class="font-IconFamily text-2xl" aria-hidden="true">{"\uebdb"}</span>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-hidden">
|
||||
@@ -668,7 +820,7 @@
|
||||
</div>
|
||||
{:else}
|
||||
<div
|
||||
class="absolute inset-0 z-50 flex items-center justify-center p-4 sm:p-6 {$settingsState.DarkMode
|
||||
class="absolute inset-0 z-50 {$settingsState.DarkMode
|
||||
? 'dark'
|
||||
: ''}"
|
||||
role="dialog"
|
||||
@@ -677,22 +829,69 @@
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 bg-black/60 {$settingsState.performanceMode
|
||||
? 'backdrop-blur-none'
|
||||
: 'backdrop-blur-sm'} transition-colors duration-200"
|
||||
class="settings-backdrop absolute inset-0 {expanded ? 'bg-black/60' : 'bg-transparent'} {expanded && !$settingsState.performanceMode
|
||||
? 'backdrop-blur-sm'
|
||||
: 'backdrop-blur-none'}"
|
||||
class:settings-backdrop--motion={$settingsState.animations !== false && !$settingsState.performanceMode}
|
||||
aria-label="Close settings"
|
||||
onclick={handleClose}
|
||||
></button>
|
||||
|
||||
<div
|
||||
class="relative z-10 h-[min(860px,92vh)] w-[min(1180px,96vw)] no-scrollbar overflow-clip"
|
||||
class="settings-panel absolute z-10 no-scrollbar overflow-clip bg-white dark:bg-zinc-800 shadow-2xl border border-zinc-200/60 dark:border-zinc-700/60"
|
||||
class:settings-panel--expanded={expanded}
|
||||
bind:this={settingsPanel}
|
||||
data-settings-panel
|
||||
>
|
||||
{@render settingsShell()}
|
||||
<div class="settings-content" bind:this={settingsContent}>
|
||||
{#if expanded}
|
||||
{@render settingsShell()}
|
||||
{:else}
|
||||
{@render compactSettings()}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.settings-content {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.settings-panel {
|
||||
width: min(384px, calc(100vw - 20px));
|
||||
height: min(600px, calc(100vh - 95px));
|
||||
top: min(80px, 10vh);
|
||||
right: 10px;
|
||||
border-radius: 1rem;
|
||||
transform-origin: 70% 0;
|
||||
}
|
||||
|
||||
.settings-panel--expanded {
|
||||
border-radius: 0.75rem;
|
||||
transform-origin: center;
|
||||
width: min(1180px, 96vw);
|
||||
height: min(860px, 92vh);
|
||||
top: calc((100% - min(860px, 92vh)) / 2);
|
||||
right: calc((100% - min(1180px, 96vw)) / 2);
|
||||
}
|
||||
|
||||
.settings-backdrop--motion {
|
||||
transition: background-color 200ms ease;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.settings-backdrop--motion {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if showColourPicker && ColourPickerComponent}
|
||||
<ColourPickerComponent
|
||||
hidePicker={() => {
|
||||
|
||||
@@ -89,9 +89,9 @@
|
||||
{/if}
|
||||
|
||||
{#if plugin.disableToggle}
|
||||
<div class="flex justify-between items-center px-5 py-4 {perfPaused ? 'pointer-events-none' : ''}">
|
||||
<div class="flex justify-between items-center px-4 py-3 {perfPaused ? 'pointer-events-none' : ''}">
|
||||
<div class="pr-4">
|
||||
<h2 class="flex gap-2 items-center text-xl font-bold">
|
||||
<h2 class="flex gap-2 items-center text-sm font-bold">
|
||||
Enable {plugin.name}
|
||||
{#if plugin.beta}
|
||||
<span
|
||||
@@ -101,7 +101,7 @@
|
||||
</span>
|
||||
{/if}
|
||||
</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{plugin.description}</p>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">{plugin.description}</p>
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
@@ -128,10 +128,10 @@
|
||||
{#if !perfPaused && (!plugin.disableToggle || ((pluginSettingsStore.values[plugin.pluginId]?.enabled as boolean | undefined) ?? true))}
|
||||
{#each Object.entries(plugin.settings) as [key, setting] (key)}
|
||||
{#if key !== "enabled" && !(key === "useCloudPfp" && !cloudState.isLoggedIn)}
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">{setting.title || key}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{setting.description || ""}</p>
|
||||
<h2 class="text-sm font-bold">{setting.title || key}</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">{setting.description || ""}</p>
|
||||
</div>
|
||||
<div>
|
||||
{#if setting.type === "boolean"}
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div class="flex justify-between items-center px-5 py-5">
|
||||
<div class="pr-5">
|
||||
<h2 class="text-xl font-bold">{title}</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">{description}</p>
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-sm font-bold">{title}</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">{description}</p>
|
||||
</div>
|
||||
<div class="shrink-0">
|
||||
<Component {...props} />
|
||||
|
||||
@@ -61,13 +61,13 @@
|
||||
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="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">BetterSEQTA Cloud</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">Account & sync</p>
|
||||
<h2 class="text-sm font-bold">BetterSEQTA Cloud</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">Account & sync</p>
|
||||
</div>
|
||||
<div>
|
||||
<CloudHeader alwaysShowUserName onClick={showCloudPanel} />
|
||||
<CloudHeader compact alwaysShowUserName onClick={showCloudPanel} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Switch from "@/interface/components/Switch.svelte";
|
||||
import Button from "@/interface/components/Button.svelte";
|
||||
import SettingRow from "../SettingRow.svelte";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { showPrivacyNotification } from "@/seqta/utils/Openers/OpenPrivacyNotification";
|
||||
import { showThemeOfTheMonthPopupNow } from "@/seqta/utils/Openers/OpenThemeOfTheMonthPopup";
|
||||
@@ -52,18 +51,6 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<SettingRow
|
||||
title="BetterSEQTA+"
|
||||
description="Enables BetterSEQTA+ features"
|
||||
id={12}
|
||||
Component={Switch}
|
||||
{searchQuery}
|
||||
props={{
|
||||
state: $settingsState.onoff,
|
||||
onChange: (isOn: boolean) => (settingsState.onoff = isOn),
|
||||
}}
|
||||
/>
|
||||
|
||||
{#if $settingsState.devMode && matchesSearch(
|
||||
searchQuery,
|
||||
"Developer Mode",
|
||||
@@ -80,10 +67,10 @@
|
||||
<div
|
||||
class="flex-col p-1 my-1 bg-gradient-to-br from-white rounded-xl border shadow-sm to-zinc-100 border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Developer Mode</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Developer Mode</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Enables developer mode, allowing you to test new features and changes.
|
||||
</p>
|
||||
</div>
|
||||
@@ -94,10 +81,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Verbose logging</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Verbose logging</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Show diagnostic console output (indexer, theme manager, timetable colour patch, etc.)
|
||||
</p>
|
||||
</div>
|
||||
@@ -108,10 +95,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Delay loading screen</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Delay loading screen</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Keep the loading overlay visible for 5 extra seconds so you can preview canvas variants.
|
||||
</p>
|
||||
</div>
|
||||
@@ -122,10 +109,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Sensitive Hider</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Sensitive Hider</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Replace sensitive content with mock data
|
||||
</p>
|
||||
</div>
|
||||
@@ -136,10 +123,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Mock Notices</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Mock Notices</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Use fake notice data on homepage instead of real data
|
||||
</p>
|
||||
</div>
|
||||
@@ -150,10 +137,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Privacy Notification</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Show Privacy Notification</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Show the privacy notification popup on next page load
|
||||
</p>
|
||||
</div>
|
||||
@@ -170,10 +157,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Show Theme of the Month</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Show Theme of the Month</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Fetch and show the current month's popup now (ignores dismissed state)
|
||||
</p>
|
||||
</div>
|
||||
@@ -188,10 +175,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Export cloud settings JSON</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Export cloud settings JSON</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Download the same payload as cloud sync (OAuth tokens stripped). For debugging and server
|
||||
testing.
|
||||
</p>
|
||||
@@ -203,14 +190,14 @@
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div class="flex justify-between items-start gap-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">API Base URL (session only)</h2>
|
||||
<h2 class="text-sm font-bold">API Base URL (session only)</h2>
|
||||
{#if isExtensionDevBuild}
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Extension dev builds always use production ({PRODUCTION_API_BASE}) for the theme store,
|
||||
community submit, and related APIs. Build a release package to test a staging host override.
|
||||
</p>
|
||||
{:else}
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Override the content API host for this browser session. Cleared on restart. Affects
|
||||
themes, theme of the month, and other server-driven content.
|
||||
</p>
|
||||
@@ -239,8 +226,8 @@
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-4 py-3">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold">GitHub latest version override</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">GitHub latest version override</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Pretend a newer GitHub release exists to test the update badge. Only applies when dev mode
|
||||
is on.
|
||||
</p>
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Adaptive Theme Colour</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Adaptive Theme Colour</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Change the theme colour based on the current class (e.g. when viewing a course or
|
||||
assessments page)
|
||||
</p>
|
||||
@@ -66,11 +66,11 @@
|
||||
</div>
|
||||
{#if $settingsState.adaptiveThemeColour}
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Soft Gradient</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Soft Gradient</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Use a soft gradient instead of a solid colour when viewing a class
|
||||
</p>
|
||||
</div>
|
||||
@@ -82,11 +82,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Smooth colour transition</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Smooth colour transition</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Ease between class/subject colours when navigating instead of switching instantly
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -17,6 +17,16 @@
|
||||
const isEngage = isSeqtaEngageExperience();
|
||||
|
||||
const generalOptions = $derived([
|
||||
{
|
||||
title: "BetterSEQTA+",
|
||||
description: "Enables BetterSEQTA+ features",
|
||||
id: 12,
|
||||
Component: Switch,
|
||||
props: {
|
||||
state: $settingsState.onoff,
|
||||
onChange: (isOn: boolean) => (settingsState.onoff = isOn),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Performance Mode",
|
||||
description:
|
||||
@@ -170,20 +180,20 @@
|
||||
<div
|
||||
class="p-1 my-1 from-white to-zinc-100 bg-gradient-to-br rounded-xl border shadow-sm border-zinc-200/50 dark:border-zinc-700/40 dark:to-zinc-900/50 dark:from-zinc-900/40"
|
||||
>
|
||||
<div class="flex justify-between items-center px-5 py-4">
|
||||
<div class="flex justify-between items-center px-4 py-3">
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Home Page Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Home Page Assessments</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Limit upcoming assessments shown on the home page by subject
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Include Past Assessments</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Include Past Assessments</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Show past-due assessments from the upcoming list, matching the Assessments page
|
||||
</p>
|
||||
</div>
|
||||
@@ -195,11 +205,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Subjects</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Maximum Subjects</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Number of subjects to include, ordered by soonest due date
|
||||
</p>
|
||||
</div>
|
||||
@@ -217,11 +227,11 @@
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="flex justify-between items-center px-5 py-4 pl-7 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
class="flex justify-between items-center px-4 py-3 pl-6 border-t border-zinc-100 dark:border-zinc-700/50"
|
||||
>
|
||||
<div class="pr-4">
|
||||
<h2 class="text-xl font-bold">Maximum Assessments per Subject</h2>
|
||||
<p class="text-base text-zinc-600 dark:text-zinc-300">
|
||||
<h2 class="text-sm font-bold">Maximum Assessments per Subject</h2>
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-300">
|
||||
Assessments shown for each included subject
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,7 @@ export function getDefaultSettingsState(): SettingsState {
|
||||
|
||||
return {
|
||||
onoff: true,
|
||||
settingsPopupExpanded: false,
|
||||
animatedbk: true,
|
||||
bksliderinput: "50",
|
||||
transparencyEffects: false,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { animate } from "motion";
|
||||
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
|
||||
export const HOST_OPEN_CLASS = "bsplus-settings-host--open";
|
||||
@@ -19,52 +20,68 @@ function settingsPanel(host: HTMLElement): HTMLElement | null {
|
||||
return host.shadowRoot?.querySelector<HTMLElement>("[data-settings-panel]") ?? null;
|
||||
}
|
||||
|
||||
export function animateSettingsOpen(host: HTMLElement): void {
|
||||
host.style.transform = "none";
|
||||
host.classList.remove(HOST_CLOSING_CLASS, "hide");
|
||||
const popupAnimations = new WeakMap<HTMLElement, {
|
||||
progress: number;
|
||||
animation?: ReturnType<typeof animate>;
|
||||
}>();
|
||||
|
||||
function animatePopup(host: HTMLElement, opening: boolean): void {
|
||||
const previous = popupAnimations.get(host);
|
||||
previous?.animation?.stop();
|
||||
const state = { progress: previous?.progress ?? 0, animation: undefined as ReturnType<typeof animate> | undefined };
|
||||
popupAnimations.set(host, state);
|
||||
if (opening) host.dispatchEvent(new Event("bsplus:settings-opening", { bubbles: true }));
|
||||
const panel = settingsPanel(host);
|
||||
if (!settingsState.animations) {
|
||||
host.style.opacity = "1";
|
||||
host.classList.add(HOST_OPEN_CLASS);
|
||||
panel?.classList.add(PANEL_OPEN_CLASS);
|
||||
const backdrop = host.shadowRoot?.querySelector<HTMLElement>(".settings-backdrop");
|
||||
host.style.transform = "none";
|
||||
host.style.transition = "none";
|
||||
host.style.opacity = "1";
|
||||
host.classList.toggle("hide", !opening);
|
||||
host.classList.toggle(HOST_OPEN_CLASS, opening);
|
||||
host.classList.toggle(HOST_CLOSING_CLASS, !opening);
|
||||
panel?.classList.toggle(PANEL_OPEN_CLASS, opening);
|
||||
|
||||
const update = (progress: number) => {
|
||||
state.progress = progress;
|
||||
const opacity = String(Math.max(0, Math.min(1, progress)));
|
||||
if (backdrop) backdrop.style.opacity = opacity;
|
||||
if (panel) {
|
||||
panel.style.transition = "none";
|
||||
panel.style.opacity = opacity;
|
||||
panel.style.transform = `scale(${Math.max(0, progress)})`;
|
||||
}
|
||||
};
|
||||
const complete = () => {
|
||||
if (popupAnimations.get(host) !== state) return;
|
||||
update(opening ? 1 : 0);
|
||||
if (!opening) {
|
||||
host.classList.remove(HOST_CLOSING_CLASS);
|
||||
host.style.opacity = "0";
|
||||
host.dispatchEvent(new Event("bsplus:settings-hidden", { bubbles: true }));
|
||||
}
|
||||
state.animation = undefined;
|
||||
};
|
||||
const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
||||
if (!panel || !settingsState.animations || settingsState.performanceMode || reducedMotion) {
|
||||
complete();
|
||||
return;
|
||||
}
|
||||
|
||||
host.style.opacity = "";
|
||||
host.classList.remove(HOST_OPEN_CLASS);
|
||||
panel?.classList.remove(PANEL_OPEN_CLASS);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
host.classList.add(HOST_OPEN_CLASS);
|
||||
panel?.classList.add(PANEL_OPEN_CLASS);
|
||||
update(state.progress);
|
||||
state.animation = animate(state.progress, opening ? 1 : 0, {
|
||||
type: "spring",
|
||||
stiffness: opening ? 280 : 520,
|
||||
damping: 20,
|
||||
onUpdate: update,
|
||||
onComplete: complete,
|
||||
});
|
||||
}
|
||||
|
||||
export function animateSettingsOpen(host: HTMLElement): void {
|
||||
animatePopup(host, true);
|
||||
}
|
||||
|
||||
export function animateSettingsClose(host: HTMLElement): void {
|
||||
host.classList.add("hide");
|
||||
const panel = settingsPanel(host);
|
||||
|
||||
if (!settingsState.animations) {
|
||||
host.classList.remove(HOST_OPEN_CLASS, HOST_CLOSING_CLASS);
|
||||
panel?.classList.remove(PANEL_OPEN_CLASS);
|
||||
host.style.opacity = "0";
|
||||
return;
|
||||
}
|
||||
|
||||
host.classList.remove(HOST_OPEN_CLASS);
|
||||
host.classList.add(HOST_CLOSING_CLASS);
|
||||
panel?.classList.remove(PANEL_OPEN_CLASS);
|
||||
|
||||
const durationMs = document.documentElement.classList.contains("performanceMode")
|
||||
? 160
|
||||
: 200;
|
||||
|
||||
window.setTimeout(() => {
|
||||
if (!host.classList.contains(HOST_CLOSING_CLASS)) return;
|
||||
host.classList.remove(HOST_CLOSING_CLASS);
|
||||
host.style.opacity = "0";
|
||||
}, durationMs);
|
||||
animatePopup(host, false);
|
||||
}
|
||||
|
||||
let prefetchStarted = false;
|
||||
|
||||
@@ -26,6 +26,8 @@ export interface SettingsState {
|
||||
};
|
||||
menuorder: any[];
|
||||
onoff: boolean;
|
||||
/** Last popup size explicitly selected with the expand/collapse control. */
|
||||
settingsPopupExpanded?: boolean;
|
||||
selectedColor: string;
|
||||
originalSelectedColor: string;
|
||||
shortcuts: Shortcut[];
|
||||
|
||||
Reference in new issue
Block a user