feat: remove redundent CSS in settings and fix badge width

This commit is contained in:
AdenMGB committed 2026-11-01 09:20:32 +10:30
1 parent ee334c901b
commit d5cac1e5fa
5 files changed
+142 -698

No files matched your search

+4 -5
View File
@@ -3893,17 +3893,16 @@ div.day-empty {
} }
.userInfoHouseWrap .bsplus-founder-badge-slot { .userInfoHouseWrap .bsplus-founder-badge-slot {
display: block; display: block;
width: max-content; width: 100%;
max-width: 100%; max-width: 100%;
margin-top: 4px; margin-top: 4px;
margin-left: auto; box-sizing: border-box;
margin-right: auto;
} }
.bsplus-founder-badge-carousel { .bsplus-founder-badge-carousel {
display: grid; display: grid;
width: 100%;
max-width: 100%; max-width: 100%;
margin-left: auto; box-sizing: border-box;
margin-right: auto;
} }
.bsplus-founder-badge-carousel > .bsplus-founder-badge { .bsplus-founder-badge-carousel > .bsplus-founder-badge {
grid-area: 1 / 1; grid-area: 1 / 1;
+135 -657
View File
@@ -1,12 +1,14 @@
<script lang="ts"> <script lang="ts">
import SettingsCard from "@/interface/pages/settings/SettingsCard.svelte";
import SettingRow from "@/interface/pages/settings/SettingRow.svelte";
import Select from "@/interface/components/Select.svelte"; import Select from "@/interface/components/Select.svelte";
import Slider from "@/interface/components/Slider.svelte"; import Slider from "@/interface/components/Slider.svelte";
import Switch from "@/interface/components/Switch.svelte"; import Switch from "@/interface/components/Switch.svelte";
import { settingsState } from "@/seqta/utils/listeners/SettingsState"; import { settingsState } from "@/seqta/utils/listeners/SettingsState";
import { matchesSearch } from "@/interface/pages/settings/shared";
import { import {
DEFAULT_SIDEBAR_BLUR, DEFAULT_SIDEBAR_BLUR,
DEFAULT_SIDEBAR_RADIUS, DEFAULT_SIDEBAR_RADIUS,
getSidebarStyle,
normalizeSidebarBlur, normalizeSidebarBlur,
normalizeSidebarDensity, normalizeSidebarDensity,
normalizeSidebarIndicator, normalizeSidebarIndicator,
@@ -15,676 +17,152 @@
normalizeSidebarWidth, normalizeSidebarWidth,
normalizeSidebarPosition, normalizeSidebarPosition,
SIDEBAR_STYLES, SIDEBAR_STYLES,
type SidebarStyleId,
} from "@/seqta/ui/sidebar/sidebarStyles"; } from "@/seqta/ui/sidebar/sidebarStyles";
const PREVIEW_ITEMS = [ let { searchQuery = "" }: { searchQuery?: string } = $props();
{ label: "Home", active: true },
{ label: "Timetable", active: false },
{ label: "Assessments", active: false },
{ label: "Messages", active: false },
{ label: "Documents", active: false },
] as const;
const selectedId = $derived( const styleOptions = SIDEBAR_STYLES.map((s) => ({ value: s.id, label: s.label }));
normalizeSidebarStyleId($settingsState.sidebarStyle),
); const rows = $derived.by(() => {
const selected = $derived(getSidebarStyle(selectedId)); const density = normalizeSidebarDensity($settingsState.sidebarDensity);
const density = $derived( const indicator = normalizeSidebarIndicator($settingsState.sidebarActiveIndicator);
normalizeSidebarDensity($settingsState.sidebarDensity), const width = normalizeSidebarWidth($settingsState.sidebarWidth);
); const position = normalizeSidebarPosition($settingsState.sidebarPosition);
const indicator = $derived( const radius = normalizeSidebarRadius(
normalizeSidebarIndicator($settingsState.sidebarActiveIndicator),
);
const width = $derived(normalizeSidebarWidth($settingsState.sidebarWidth));
const position = $derived(
normalizeSidebarPosition($settingsState.sidebarPosition),
);
const radius = $derived(
normalizeSidebarRadius(
$settingsState.sidebarCornerRadius ?? DEFAULT_SIDEBAR_RADIUS, $settingsState.sidebarCornerRadius ?? DEFAULT_SIDEBAR_RADIUS,
), );
); const blur = normalizeSidebarBlur($settingsState.sidebarBlur ?? DEFAULT_SIDEBAR_BLUR);
const blur = $derived( const transparencyOn = $settingsState.transparencyEffects === true;
normalizeSidebarBlur($settingsState.sidebarBlur ?? DEFAULT_SIDEBAR_BLUR), const styleId = normalizeSidebarStyleId($settingsState.sidebarStyle);
);
const transparencyOn = $derived($settingsState.transparencyEffects === true);
function selectStyle(id: SidebarStyleId) { const base = [
if (selectedId !== id) settingsState.sidebarStyle = id; {
} title: "Sidebar Style",
</script> description: "Choose how the navigation menu looks",
id: 1,
<div class="sidebar-appearance"> Component: Select,
<div class="card"> props: {
<header class="card-header split"> value: styleId,
<div> onChange: (value: string) => (settingsState.sidebarStyle = value),
<h2 class="title">Sidebar Style</h2> options: styleOptions,
<p class="subtitle">Choose how the navigation menu looks</p> },
</div> },
<div class="selected-meta" aria-live="polite"> {
<span class="selected-label">{selected.label}</span> title: "Item Size",
<span class="selected-desc">{selected.description}</span> description: "Spacing and type size for menu rows",
</div> id: 2,
</header> Component: Select,
props: {
<div class="picker-body"> value: density,
<div class="preview-pane" aria-hidden="true"> onChange: (value: string) => (settingsState.sidebarDensity = value),
<div class={`preview style-${selectedId}`}> options: [
<div class="preview-chrome">
<div class="preview-logo"></div>
{#each PREVIEW_ITEMS as item (item.label)}
<div class="preview-item" class:active={item.active}>
<span class="preview-dot"></span>
<span class="preview-label">{item.label}</span>
</div>
{/each}
</div>
</div>
</div>
<div
class="options"
role="listbox"
tabindex="0"
aria-label="Sidebar styles"
aria-activedescendant={`sidebar-style-${selectedId}`}
>
{#each SIDEBAR_STYLES as style (style.id)}
{@const active = style.id === selectedId}
<button
type="button"
id={`sidebar-style-${style.id}`}
class={`option style-${style.id}`}
class:active
role="option"
aria-selected={active}
onclick={() => selectStyle(style.id)}
>
<div class={`thumb style-${style.id}`}>
<div class="thumb-chrome">
{#each PREVIEW_ITEMS.slice(0, 3) as item (item.label)}
<div class="thumb-item" class:active={item.active}></div>
{/each}
</div>
</div>
<span class="option-label">{style.label}</span>
</button>
{/each}
</div>
</div>
</div>
<div class="card">
<header class="card-header">
<h2 class="title">Sidebar Look</h2>
<p class="subtitle">Density, size, and active-state details</p>
</header>
<div class="rows">
<div class="row">
<div class="copy">
<h3 class="row-title">Item Size</h3>
<p class="row-desc">Spacing and type size for menu rows</p>
</div>
<div class="control">
<Select
value={density}
onChange={(value) => (settingsState.sidebarDensity = value)}
options={[
{ value: "compact", label: "Compact" }, { value: "compact", label: "Compact" },
{ value: "comfortable", label: "Comfortable" }, { value: "comfortable", label: "Comfortable" },
{ value: "large", label: "Large" }, { value: "large", label: "Large" },
]} ],
/> },
</div> },
</div> {
title: "Corner Radius",
<div class="row"> description: `Roundness of menu items (${radius}px)`,
<div class="copy"> id: 3,
<h3 class="row-title">Corner Radius</h3> Component: Slider,
<p class="row-desc">Roundness of menu items ({radius}px)</p> props: {
</div> state: radius,
<div class="control slider"> min: 0,
<Slider max: 24,
state={radius} step: 1,
min={0} onChange: (value: number) => (settingsState.sidebarCornerRadius = value),
max={24} },
step={1} },
onChange={(value) => (settingsState.sidebarCornerRadius = value)} {
/> title: "Active Indicator",
</div> description: "How the current page is highlighted",
</div> id: 4,
Component: Select,
<div class="row"> props: {
<div class="copy"> value: indicator,
<h3 class="row-title">Active Indicator</h3> onChange: (value: string) => (settingsState.sidebarActiveIndicator = value),
<p class="row-desc">How the current page is highlighted</p> options: [
</div>
<div class="control">
<Select
value={indicator}
onChange={(value) => (settingsState.sidebarActiveIndicator = value)}
options={[
{ value: "fill", label: "Fill" }, { value: "fill", label: "Fill" },
{ value: "bar", label: "Left bar" }, { value: "bar", label: "Left bar" },
{ value: "outline", label: "Outline" }, { value: "outline", label: "Outline" },
{ value: "underline", label: "Underline" }, { value: "underline", label: "Underline" },
]} ],
/> },
</div> },
</div> {
title: "Sidebar Position",
<div class="row"> description: "Which edge of the screen the navigation sits on",
<div class="copy"> id: 5,
<h3 class="row-title">Sidebar Position</h3> Component: Select,
<p class="row-desc">Which edge of the screen the navigation sits on</p> props: {
</div> value: position,
<div class="control"> onChange: (value: string) => (settingsState.sidebarPosition = value),
<Select options: [
value={position}
onChange={(value) => (settingsState.sidebarPosition = value)}
options={[
{ value: "left", label: "Left" }, { value: "left", label: "Left" },
{ value: "right", label: "Right" }, { value: "right", label: "Right" },
]} ],
/> },
</div> },
</div> {
title: "Sidebar Width",
<div class="row"> description: "Overall navigation column width",
<div class="copy"> id: 6,
<h3 class="row-title">Sidebar Width</h3> Component: Select,
<p class="row-desc">Overall navigation column width</p> props: {
</div> value: width,
<div class="control"> onChange: (value: string) => (settingsState.sidebarWidth = value),
<Select options: [
value={width}
onChange={(value) => (settingsState.sidebarWidth = value)}
options={[
{ value: "narrow", label: "Narrow" }, { value: "narrow", label: "Narrow" },
{ value: "default", label: "Default" }, { value: "default", label: "Default" },
{ value: "wide", label: "Wide" }, { value: "wide", label: "Wide" },
]} ],
/> },
</div> },
</div> {
title: "Transparency Effects",
<div class="row"> description: "Glass effects on supported surfaces (may impact battery life)",
<div class="copy"> id: 7,
<h3 class="row-title">Transparency Effects</h3> Component: Switch,
<p class="row-desc">Use glass effects on supported surfaces (may impact battery life)</p> props: {
</div> state: transparencyOn,
<div class="control toggle"> onChange: (value: boolean) => (settingsState.transparencyEffects = value),
<Switch },
state={transparencyOn} },
onChange={(value) => (settingsState.transparencyEffects = value)} ];
/>
</div> if (!transparencyOn) return base;
</div>
return [
{#if transparencyOn} ...base,
<div class="row"> {
<div class="copy"> title: "Blur Strength",
<h3 class="row-title">Blur Strength</h3> description: `Glass blur on the sidebar (${blur}px)`,
<p class="row-desc">Glass blur on the sidebar ({blur}px)</p> id: 8,
</div> Component: Slider,
<div class="control slider"> props: {
<Slider state: blur,
state={blur} min: 0,
min={0} max: 80,
max={80} step: 1,
step={1} onChange: (value: number) => (settingsState.sidebarBlur = value),
onChange={(value) => (settingsState.sidebarBlur = value)} },
/> },
</div> ];
</div> });
{/if}
</div> const visible = $derived(
</div> rows.some((row) => matchesSearch(searchQuery, row.title, row.description)),
);
</div> </script>
<style> {#if visible}
.sidebar-appearance { <SettingsCard class="divide-y divide-zinc-200/60 dark:divide-zinc-700/40">
container: sidebar-appearance / inline-size; {#each rows as row (row.id)}
} {#if matchesSearch(searchQuery, row.title, row.description)}
<SettingRow {...row} {searchQuery} />
.card { {/if}
margin: 4px 0; {/each}
padding: 4px; </SettingsCard>
border-radius: 0.75rem; {/if}
border: 1px solid rgb(228 228 231 / 0.5);
background: linear-gradient(to bottom right, white, rgb(244 244 245));
box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
:global(.dark) .card {
border-color: rgb(63 63 70 / 0.4);
background: linear-gradient(
to bottom right,
rgb(24 24 27 / 0.4),
rgb(24 24 27 / 0.5)
);
}
.card-header {
padding: 1rem 1.25rem 0.5rem;
}
.card-header.split {
display: flex;
justify-content: space-between;
gap: 1rem;
align-items: flex-start;
}
.title {
font-size: 0.875rem;
font-weight: 700;
line-height: 1.3;
}
.subtitle {
margin-top: 0.15rem;
font-size: 0.75rem;
color: rgb(82 82 91);
}
:global(.dark) .subtitle {
color: rgb(212 212 216);
}
.selected-meta {
display: flex;
flex-direction: column;
align-items: flex-end;
text-align: right;
max-width: 14rem;
gap: 0.15rem;
}
.selected-label {
font-size: 0.875rem;
font-weight: 700;
}
.selected-desc {
font-size: 0.75rem;
line-height: 1.35;
color: rgb(113 113 122);
}
:global(.dark) .selected-desc {
color: rgb(161 161 170);
}
.picker-body {
display: grid;
grid-template-columns: minmax(160px, 210px) 1fr;
gap: 1rem;
padding: 0.5rem 1rem 1rem;
}
@media (max-width: 720px) {
.picker-body {
grid-template-columns: 1fr;
}
}
.preview-pane {
display: flex;
align-items: center;
}
.preview {
width: 100%;
max-width: 196px;
height: 280px;
border-radius: 18px;
overflow: hidden;
box-shadow: 0 14px 32px rgb(0 0 0 / 0.22);
background: linear-gradient(160deg, #aa053a, #141414 70%);
}
.preview-chrome {
display: flex;
flex-direction: column;
height: 100%;
padding: 14px 0 10px;
color: #fff;
}
.preview-logo {
width: 42%;
height: 10px;
margin: 0 16px 14px;
border-radius: 999px;
background: rgb(255 255 255 / 0.35);
}
.preview-item {
display: flex;
align-items: center;
gap: 8px;
margin: 0 8px 6px;
padding: 8px 10px;
border-radius: 12px;
}
.preview-item.active {
background: rgba(0, 0, 0, 0.35);
}
.preview.style-soft .preview-item {
margin: 0 10px 8px;
border-radius: 16px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.preview.style-pill .preview-item {
margin: 0 12px 7px;
border-radius: 999px;
}
.preview.style-glass .preview-item {
margin: 0 10px 7px;
background: rgba(255, 255, 255, 0.12);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.preview.style-glass .preview-item.active {
background: rgba(255, 255, 255, 0.22);
}
.preview.style-sharp .preview-item {
margin: 0 6px 4px;
border-radius: 4px;
}
.preview.style-strip .preview-item {
margin: 0;
border-radius: 0;
background: transparent;
}
.preview.style-strip .preview-item.active {
position: relative;
background: rgba(255, 255, 255, 0.12);
}
.preview.style-strip .preview-item.active::after {
content: "";
position: absolute;
left: 0;
top: 6px;
bottom: 6px;
width: 3px;
border-radius: 2px;
background: #fff;
box-shadow: 0 0 8px rgba(255, 255, 255, 0.55);
}
.preview.style-neon .preview-item.active {
background: rgba(255, 255, 255, 0.1);
box-shadow:
0 0 0 1px rgba(255, 255, 255, 0.55),
0 0 12px rgba(255, 255, 255, 0.4),
0 0 22px rgba(255, 255, 255, 0.22);
}
.preview-dot {
width: 10px;
height: 10px;
border-radius: 999px;
background: rgb(255 255 255 / 0.75);
flex: 0 0 auto;
}
.preview-label {
font-size: 11px;
font-weight: 600;
white-space: nowrap;
}
.options {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
gap: 0.65rem;
align-content: start;
}
.option {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.4rem;
padding: 0.45rem;
border: 1px solid transparent;
border-radius: 0.75rem;
background: rgb(255 255 255 / 0.55);
color: inherit;
cursor: pointer;
transition:
transform 0.2s ease,
border-color 0.2s ease,
box-shadow 0.2s ease;
}
:global(.dark) .option {
background: rgb(39 39 42 / 0.55);
}
.option:hover {
transform: scale(1.02);
}
.option:active {
transform: scale(0.98);
}
.option.active {
border-color: var(--theme-primary, #f43f5e);
box-shadow: 0 0 0 1px var(--theme-primary, #f43f5e);
}
.option:focus-visible {
outline: none;
box-shadow: 0 0 0 2px var(--theme-primary, #f43f5e);
}
.thumb {
width: 100%;
aspect-ratio: 3 / 4;
border-radius: 10px;
overflow: hidden;
background: linear-gradient(160deg, #aa053a, #141414 70%);
}
.thumb-chrome {
display: flex;
flex-direction: column;
justify-content: center;
gap: 4px;
height: 100%;
padding: 8px 6px;
}
.thumb-item {
height: 10px;
border-radius: 6px;
background: rgba(255, 255, 255, 0.18);
}
.thumb-item.active {
background: rgba(0, 0, 0, 0.4);
}
.thumb.style-pill .thumb-item {
border-radius: 999px;
}
.thumb.style-sharp .thumb-item {
border-radius: 2px;
}
.thumb.style-strip .thumb-item {
border-radius: 0;
}
.thumb.style-strip .thumb-item.active {
background: rgba(255, 255, 255, 0.22);
box-shadow: inset 3px 0 0 #fff;
}
.thumb.style-glass .thumb-item {
background: rgba(255, 255, 255, 0.22);
}
.thumb.style-neon .thumb-item.active {
background: rgba(255, 255, 255, 0.2);
box-shadow:
0 0 0 1px rgba(255, 255, 255, 0.5),
0 0 8px rgba(255, 255, 255, 0.55);
}
.option-label {
font-size: 0.8rem;
font-weight: 700;
}
.rows {
display: flex;
flex-direction: column;
padding: 0.25rem 0.5rem 0.75rem;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.85rem 0.75rem;
border-top: 1px solid rgb(244 244 245);
}
:global(.dark) .row {
border-top-color: rgb(63 63 70 / 0.5);
}
.row:first-child {
border-top: none;
}
.copy {
min-width: 0;
flex: 1 1 auto;
padding-right: 0.5rem;
}
.row-title {
font-size: 0.875rem;
font-weight: 700;
line-height: 1.3;
}
.row-desc {
margin-top: 0.1rem;
font-size: 0.75rem;
color: rgb(82 82 91);
}
:global(.dark) .row-desc {
color: rgb(212 212 216);
}
.control {
flex: 0 0 auto;
min-width: 9.5rem;
max-width: 12rem;
}
.control.slider {
min-width: 10rem;
width: 11rem;
}
.control.toggle {
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>
@@ -44,9 +44,7 @@
{/if} {/if}
{#if !isEngage && matchesSearch(searchQuery, "Sidebar Style", "Item Size", "Corner Radius", "Active Indicator", "Sidebar Position", "Sidebar Width", "Transparency Effects", "Blur Strength")} {#if !isEngage && matchesSearch(searchQuery, "Sidebar Style", "Item Size", "Corner Radius", "Active Indicator", "Sidebar Position", "Sidebar Width", "Transparency Effects", "Blur Strength")}
<div class="border-none"> <SidebarAppearance {searchQuery} />
<SidebarAppearance />
</div>
{/if} {/if}
{#if matchesSearch(searchQuery, "Adaptive Theme Colour", "Soft Gradient", "Smooth colour transition")} {#if matchesSearch(searchQuery, "Adaptive Theme Colour", "Soft Gradient", "Smooth colour transition")}
+2 -11
View File
@@ -632,7 +632,7 @@
<Divider /> <Divider />
<div class="theme-creator-sidebar -mx-2"> <div class="-mx-2">
<SidebarAppearance /> <SidebarAppearance />
</div> </div>
@@ -721,13 +721,4 @@
{/if} {/if}
</div> </div>
</div> </div>
</div> </div>
<style>
.theme-creator-sidebar :global(.preview-pane) {
display: none;
}
.theme-creator-sidebar :global(.picker-body) {
grid-template-columns: 1fr;
}
</style>
@@ -43,25 +43,6 @@ function setActiveBadgeChip(chips: HTMLButtonElement[], index: number): void {
}); });
} }
/** Carousel chips share the widest label width so the pill does not shrink while cycling. */
function syncCarouselTrackWidth(
carousel: HTMLElement,
chips: HTMLButtonElement[],
): void {
carousel.style.removeProperty("width");
for (const chip of chips) chip.style.width = "max-content";
let maxWidth = 0;
for (const chip of chips) {
maxWidth = Math.max(maxWidth, chip.getBoundingClientRect().width);
}
if (maxWidth <= 0) return;
const px = `${Math.ceil(maxWidth)}px`;
carousel.style.width = px;
for (const chip of chips) chip.style.width = "100%";
}
function startBadgeCarousel( function startBadgeCarousel(
slot: HTMLElement, slot: HTMLElement,
chips: HTMLButtonElement[], chips: HTMLButtonElement[],
@@ -137,9 +118,6 @@ function renderTitlebarBadges(
wireBadgeChip(chip, entry.badge, signupNumber); wireBadgeChip(chip, entry.badge, signupNumber);
}); });
const carousel = slot.querySelector<HTMLElement>(".bsplus-founder-badge-carousel");
if (carousel) syncCarouselTrackWidth(carousel, chips);
startBadgeCarousel( startBadgeCarousel(
slot, slot,
chips, chips,