Commit b1407273 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Swap visual identity to shadcn preset b311momZs0 with real light/dark mode

Re-themes the whole app by bridging the existing cobalt token names in
src/index.css to shadcn's new CSS variables, rather than rewriting every
component. Adds ThemeContext + a Settings appearance toggle so .dark now
actually gets applied somewhere in the app - closing the token collision
where shadcn's --color-background/--color-primary/--color-secondary would
otherwise silently fall back to shadcn's light values next to an
all-dark app. Defaults new visitors to dark to match the app's prior
dark-only behavior. Self-hosts DM Sans/Outfit via @fontsource-variable
instead of the old Google Fonts link.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent c7c9043b
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "base-maia",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/index.css",
"baseColor": "mist",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "lucide",
"rtl": false,
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"menuColor": "default",
"menuAccent": "subtle",
"registries": {}
}
......@@ -6,15 +6,35 @@
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="theme-color" content="#131313" />
<meta name="theme-color" content="#0b0b10" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Stax" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="" />
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet" />
<title>Stax</title>
<script>
// Applies the saved theme (or system preference, on first visit) before React mounts -
// ThemeProvider (src/context/ThemeContext.tsx) does the same resolution on every render,
// this just avoids a flash of the wrong theme between first paint and React hydrating.
// Stax has always been a dark app with no toggle until now (2026-10-07's shadcn swap), so
// a returning user with no saved preference and a light-mode OS still gets dark, not a
// surprise flip - only a genuinely new choice (explicit 'light', or 'system' once they've
// opted into it) can produce light mode.
(function () {
try {
var stored = localStorage.getItem('stax_theme')
var isDark =
stored === 'light'
? false
: stored === 'system'
? window.matchMedia('(prefers-color-scheme: dark)').matches
: true
document.documentElement.classList.toggle('dark', isDark)
} catch (e) {
document.documentElement.classList.add('dark')
}
})()
</script>
</head>
<body>
<div id="root"></div>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,13 +12,19 @@
"test:watch": "vitest"
},
"dependencies": {
"@base-ui/react": "^1.8.0",
"@fontsource-variable/dm-sans": "^5.3.0",
"@fontsource-variable/outfit": "^5.3.0",
"@vitejs/plugin-basic-ssl": "^2.3.0",
"class-variance-authority": "^0.7.1",
"cn": "^0.4.0",
"leaflet": "^1.9.4",
"lucide-react": "^1.31.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-leaflet": "^5.0.0",
"react-router-dom": "^7.18.2"
"react-router-dom": "^7.18.2",
"tw-animate-css": "^1.4.0"
},
"devDependencies": {
"@tailwindcss/vite": "^4.3.3",
......@@ -32,6 +38,7 @@
"@vitejs/plugin-react": "^6.0.4",
"jsdom": "^29.1.1",
"oxlint": "^1.75.0",
"shadcn": "^4.21.3",
"tailwindcss": "^4.3.3",
"typescript": "~6.0.2",
"vite": "^8.2.0",
......
import { createContext, useContext, useEffect, useState, type ReactNode } from 'react'
export type ThemePreference = 'light' | 'dark' | 'system'
const STORAGE_KEY = 'stax_theme'
function resolveIsDark(pref: ThemePreference): boolean {
if (pref === 'system') return window.matchMedia('(prefers-color-scheme: dark)').matches
return pref === 'dark'
}
interface ThemeContextValue {
theme: ThemePreference
isDark: boolean
setTheme: (theme: ThemePreference) => void
}
const ThemeContext = createContext<ThemeContextValue | null>(null)
/** Stax has always been a dark-only app with no toggle until the 2026-10-07 shadcn swap - the
* blocking inline script in index.html already applies the right `.dark` class before React
* even mounts (avoiding a flash), and defaults a first-time visitor with no stored preference
* to dark rather than 'system', so a returning user on a light-mode OS doesn't get surprised by
* their familiar dark app suddenly turning white. This provider's own initial state has to
* agree with that same default, not re-derive it independently. */
export function ThemeProvider({ children }: { children: ReactNode }) {
const [theme, setThemeState] = useState<ThemePreference>(() => {
const stored = localStorage.getItem(STORAGE_KEY)
return stored === 'light' || stored === 'dark' || stored === 'system' ? stored : 'dark'
})
useEffect(() => {
document.documentElement.classList.toggle('dark', resolveIsDark(theme))
if (theme !== 'system') return
// Keeps following the OS live while "system" is selected, rather than only resolving once
// at mount - matches what picking "system" actually implies.
const mql = window.matchMedia('(prefers-color-scheme: dark)')
const onChange = () => document.documentElement.classList.toggle('dark', mql.matches)
mql.addEventListener('change', onChange)
return () => mql.removeEventListener('change', onChange)
}, [theme])
function setTheme(next: ThemePreference) {
localStorage.setItem(STORAGE_KEY, next)
setThemeState(next)
}
return (
<ThemeContext.Provider value={{ theme, isDark: resolveIsDark(theme), setTheme }}>
{children}
</ThemeContext.Provider>
)
}
export function useTheme(): ThemeContextValue {
const ctx = useContext(ThemeContext)
if (!ctx) throw new Error('useTheme must be used within a ThemeProvider')
return ctx
}
@import "tailwindcss";
@import "leaflet/dist/leaflet.css";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@import "@fontsource-variable/dm-sans";
@import "@fontsource-variable/outfit";
/* Design system tokens - cobalt/periwinkle palette, Material-3-style naming to match the
Stitch design export these were sourced from (verified against library_bauhaus_edition's
and stax_web_home's applied tailwind.config, not just their doc files - some of the export's
named "editions" don't actually match their own DESIGN.md). Deliberately dark-only: this
product has never had a light theme and isn't getting one as part of this pass.
rounded/rounded-lg/rounded-xl/rounded-full already equal the spec's 4px/8px/12px/full with
zero overrides, since Tailwind's stock radius scale happens to match exactly. */
@theme {
--font-sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
--color-background: #131313;
--color-surface: #131313;
--color-surface-dim: #131313;
--color-surface-bright: #3a3939;
--color-surface-variant: #353534;
--color-surface-container-lowest: #0e0e0e;
--color-surface-container-low: #1c1b1b;
--color-surface-container: #201f1f;
--color-surface-container-high: #2a2a2a;
--color-surface-container-highest: #353534;
--color-on-background: #e5e2e1;
--color-on-surface: #e5e2e1;
--color-on-surface-variant: #c4c5d9;
--color-inverse-surface: #e5e2e1;
--color-inverse-on-surface: #313030;
--color-outline: #8e90a2;
--color-outline-variant: #434656;
--color-primary: #b8c3ff;
--color-on-primary: #002388;
--color-primary-container: #2e5bff;
--color-on-primary-container: #efefff;
--color-primary-fixed: #dde1ff;
--color-primary-fixed-dim: #b8c3ff;
--color-inverse-primary: #124af0;
--color-secondary: #c6c6c6;
--color-on-secondary: #2f3131;
--color-secondary-container: #454747;
--color-on-secondary-container: #b4b5b5;
--color-secondary-fixed: #e2e2e2;
--color-secondary-fixed-dim: #c6c6c6;
--color-tertiary: #ffb4aa;
--color-on-tertiary: #690003;
--color-tertiary-container: #d71a18;
--color-on-tertiary-container: #ffece9;
--color-error: #ffb4ab;
--color-on-error: #690005;
--color-error-container: #93000a;
--color-on-error-container: #ffdad6;
@custom-variant dark (&:is(.dark *));
/* Design system tokens - Material-3-style naming (on-surface, surface-container, etc.) kept
from the original Stitch-sourced cobalt system, but every VALUE now points at the shadcn
preset's own variables (defined further down in :root/.dark, see useTheme/ThemeProvider for
how `.dark` actually gets applied) instead of hardcoded hex - this is the full visual swap to
the shadcn preset (2026-10-07), done as a token bridge rather than rewriting every component's
className. Zero component files changed: `bg-surface-container-low`, `text-on-primary`, etc.
all still work exactly as before, they just resolve to the new palette/light-dark-aware
values now. A handful of our token names have no real shadcn equivalent (no "hover-lightened
primary" token exists, for instance) - those use color-mix() against the nearest real token
rather than inventing a new hardcoded color that wouldn't track light/dark switches.
`inline` (same as shadcn's own block below) matters here, not just style: every value on the
right references another custom property that itself changes between :root and .dark - a
plain (non-inline) @theme block can resolve that reference once at build time instead of
live per-render, which would silently freeze these on whichever theme happened to be active
first and break the toggle for every one of these tokens. */
@theme inline {
--color-background: var(--background);
--color-surface: var(--background);
--color-surface-dim: var(--background);
--color-surface-bright: var(--card);
--color-surface-variant: var(--muted);
--color-surface-container-lowest: var(--background);
--color-surface-container-low: var(--card);
--color-surface-container: var(--card);
--color-surface-container-high: var(--accent);
--color-surface-container-highest: var(--accent);
--color-on-background: var(--foreground);
--color-on-surface: var(--foreground);
--color-on-surface-variant: var(--muted-foreground);
--color-inverse-surface: var(--foreground);
--color-inverse-on-surface: var(--background);
--color-outline: var(--border);
--color-outline-variant: var(--border);
--color-primary: var(--primary);
--color-on-primary: var(--primary-foreground);
--color-primary-container: var(--primary);
--color-on-primary-container: var(--primary-foreground);
--color-primary-fixed: color-mix(in oklch, var(--primary) 85%, white);
--color-primary-fixed-dim: var(--primary);
--color-inverse-primary: var(--primary);
--color-secondary: var(--secondary);
--color-on-secondary: var(--secondary-foreground);
--color-secondary-container: var(--secondary);
--color-on-secondary-container: var(--secondary-foreground);
--color-secondary-fixed: color-mix(in oklch, var(--secondary) 85%, white);
--color-secondary-fixed-dim: var(--secondary);
--color-tertiary: var(--accent);
--color-on-tertiary: var(--accent-foreground);
--color-tertiary-container: var(--accent);
--color-on-tertiary-container: var(--accent-foreground);
--color-error: var(--destructive);
--color-on-error: var(--primary-foreground);
--color-error-container: var(--destructive);
--color-on-error-container: var(--primary-foreground);
}
@keyframes message-enter {
......@@ -218,3 +230,127 @@
.seek-range:disabled::-moz-range-thumb {
display: none;
}
:root {
--background: oklch(1 0 0);
--foreground: oklch(0.148 0.004 228.8);
--card: oklch(1 0 0);
--card-foreground: oklch(0.148 0.004 228.8);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.148 0.004 228.8);
--primary: oklch(0.488 0.243 264.376);
--primary-foreground: oklch(0.97 0.014 254.604);
--secondary: oklch(0.967 0.001 286.375);
--secondary-foreground: oklch(0.21 0.006 285.885);
--muted: oklch(0.963 0.002 197.1);
--muted-foreground: oklch(0.56 0.021 213.5);
--accent: oklch(0.963 0.002 197.1);
--accent-foreground: oklch(0.218 0.008 223.9);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.925 0.005 214.3);
--input: oklch(0.925 0.005 214.3);
--ring: oklch(0.723 0.014 214.4);
--chart-1: oklch(0.872 0.007 219.6);
--chart-2: oklch(0.56 0.021 213.5);
--chart-3: oklch(0.45 0.017 213.2);
--chart-4: oklch(0.378 0.015 216);
--chart-5: oklch(0.275 0.011 216.9);
--radius: 0.875rem;
--sidebar: oklch(0.987 0.002 197.1);
--sidebar-foreground: oklch(0.148 0.004 228.8);
--sidebar-primary: oklch(0.546 0.245 262.881);
--sidebar-primary-foreground: oklch(0.97 0.014 254.604);
--sidebar-accent: oklch(0.963 0.002 197.1);
--sidebar-accent-foreground: oklch(0.218 0.008 223.9);
--sidebar-border: oklch(0.925 0.005 214.3);
--sidebar-ring: oklch(0.723 0.014 214.4);
}
.dark {
--background: oklch(0.148 0.004 228.8);
--foreground: oklch(0.987 0.002 197.1);
--card: oklch(0.218 0.008 223.9);
--card-foreground: oklch(0.987 0.002 197.1);
--popover: oklch(0.218 0.008 223.9);
--popover-foreground: oklch(0.987 0.002 197.1);
--primary: oklch(0.424 0.199 265.638);
--primary-foreground: oklch(0.97 0.014 254.604);
--secondary: oklch(0.274 0.006 286.033);
--secondary-foreground: oklch(0.985 0 0);
--muted: oklch(0.275 0.011 216.9);
--muted-foreground: oklch(0.723 0.014 214.4);
--accent: oklch(0.275 0.011 216.9);
--accent-foreground: oklch(0.987 0.002 197.1);
--destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 10%);
--input: oklch(1 0 0 / 15%);
--ring: oklch(0.56 0.021 213.5);
--chart-1: oklch(0.872 0.007 219.6);
--chart-2: oklch(0.56 0.021 213.5);
--chart-3: oklch(0.45 0.017 213.2);
--chart-4: oklch(0.378 0.015 216);
--chart-5: oklch(0.275 0.011 216.9);
--sidebar: oklch(0.218 0.008 223.9);
--sidebar-foreground: oklch(0.987 0.002 197.1);
--sidebar-primary: oklch(0.623 0.214 259.815);
--sidebar-primary-foreground: oklch(0.97 0.014 254.604);
--sidebar-accent: oklch(0.275 0.011 216.9);
--sidebar-accent-foreground: oklch(0.987 0.002 197.1);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.56 0.021 213.5);
}
@theme inline {
--font-sans: 'DM Sans Variable', sans-serif;
--font-heading: 'Outfit Variable', sans-serif;
--color-sidebar-ring: var(--sidebar-ring);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
--color-sidebar-accent: var(--sidebar-accent);
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
--color-sidebar-primary: var(--sidebar-primary);
--color-sidebar-foreground: var(--sidebar-foreground);
--color-sidebar: var(--sidebar);
--color-chart-5: var(--chart-5);
--color-chart-4: var(--chart-4);
--color-chart-3: var(--chart-3);
--color-chart-2: var(--chart-2);
--color-chart-1: var(--chart-1);
--color-ring: var(--ring);
--color-input: var(--input);
--color-border: var(--border);
--color-destructive: var(--destructive);
--color-accent-foreground: var(--accent-foreground);
--color-accent: var(--accent);
--color-muted-foreground: var(--muted-foreground);
--color-muted: var(--muted);
--color-secondary-foreground: var(--secondary-foreground);
--color-secondary: var(--secondary);
--color-primary-foreground: var(--primary-foreground);
--color-primary: var(--primary);
--color-popover-foreground: var(--popover-foreground);
--color-popover: var(--popover);
--color-card-foreground: var(--card-foreground);
--color-card: var(--card);
--color-foreground: var(--foreground);
--color-background: var(--background);
--radius-sm: calc(var(--radius) * 0.6);
--radius-md: calc(var(--radius) * 0.8);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) * 1.4);
--radius-2xl: calc(var(--radius) * 1.8);
--radius-3xl: calc(var(--radius) * 2.2);
--radius-4xl: calc(var(--radius) * 2.6);
}
@layer base {
* {
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
html {
@apply font-sans;
}
}
\ No newline at end of file
export { cn } from "cn"
......@@ -6,15 +6,18 @@ import './lib/leafletIcons'
import { App } from './App.tsx'
import { AuthProvider } from './context/AuthContext.tsx'
import { PlayerProvider } from './context/PlayerContext.tsx'
import { ThemeProvider } from './context/ThemeContext.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<BrowserRouter>
<AuthProvider>
<PlayerProvider>
<App />
</PlayerProvider>
</AuthProvider>
</BrowserRouter>
<ThemeProvider>
<BrowserRouter>
<AuthProvider>
<PlayerProvider>
<App />
</PlayerProvider>
</AuthProvider>
</BrowserRouter>
</ThemeProvider>
</StrictMode>,
)
......@@ -168,7 +168,10 @@ const FRONTEND_DONE: DoneGroup[] = [
{
area: 'Design System',
items: [
'Full visual redesign (2026-08-23), sourced from a Stitch design export: cobalt/periwinkle-on-deep-ink Material-3-style token system (primary #b8c3ff / primary-container #2e5bff on #131313), Space Grotesk, sharp 4px-radius geometry - deliberately not the export\'s mint-green "Stax" variant, which read too close to an existing music app\'s brand color',
'Second full visual redesign (2026-10-07): swapped onto a real shadcn/ui preset (style "maia", blue theme, DM Sans body / Outfit headings, large radius, Base UI primitives - `npx shadcn init --preset b311momZs0`) rather than the cobalt/Space-Grotesk system from 2026-08-23 below, after that one wasn\'t landing well. Done as a token bridge, not a per-component rewrite: every one of the ~40 existing Material-3-style token names (bg-surface-container-low, text-on-primary, etc.) stayed exactly as-is in every component file - only their underlying CSS values in src/index.css changed, from hardcoded hex to `var()` references into the shadcn preset\'s own :root/.dark variables. Zero page/component files touched; every existing page automatically re-themed for free. A few tokens have no direct shadcn equivalent (no "hover-lightened primary" token exists) - those use `color-mix()` against the nearest real token instead of a new hardcoded color that wouldn\'t track light/dark. Border radius needed no bridging at all: the app never overrode Tailwind\'s stock rounded-* scale, so shadcn\'s own --radius-* tokens (which directly define rounded-sm/md/lg/xl/etc.) applied cleanly with zero collision the moment they were defined.',
'Real light/dark mode (2026-10-07), the app\'s first - previously deliberately dark-only with no toggle at all, which is exactly why plugging in the shadcn preset directly (its CSS defines genuinely different light vs. dark values) would have silently broken without this: the preset\'s `.dark` class was never applied anywhere, so background/primary/secondary would have resolved to its light-mode values sitting next to the rest of the still-dark-styled app. New ThemeContext (light/dark/system, persisted to localStorage) toggles `.dark` on <html>; a blocking inline script in index.html applies the right class before React even mounts, avoiding a flash - and defaults a first-time visitor with no stored preference to dark specifically (not "system"), so a returning user on a light-mode OS doesn\'t get surprised by their familiar dark app turning white. New "Appearance" segmented control (Light/Dark/System) on the Settings page, a local-only preference with no backend round trip, next to the existing privacy toggles.',
'Space Grotesk (Google Fonts, external CDN link in index.html) replaced by the preset\'s own DM Sans Variable / Outfit Variable, both self-hosted via @fontsource-variable - no external font request at all now, consistent with how the rest of the app avoids third-party runtime dependencies.',
'First full visual redesign (2026-08-23), sourced from a Stitch design export: cobalt/periwinkle-on-deep-ink Material-3-style token system (primary #b8c3ff / primary-container #2e5bff on #131313), Space Grotesk, sharp 4px-radius geometry - deliberately not the export\'s mint-green "Stax" variant, which read too close to an existing music app\'s brand color. Superseded by the shadcn swap above, but the token *names* and page structure it established are still exactly what every component uses today.',
'Tailwind v4 @theme tokens (bg-background, bg-surface-container*, text-on-surface*, bg-primary, etc.) replace the old ad-hoc neutral-900/emerald-500 classes app-wide, including UI primitives (Button, Input, EmptyState, Skeleton, ProgressBar)',
'Desktop: 256px fixed sidebar with the full nav list. Mobile: 5-tab bottom bar (Library, Discover, Social, Soundmarks, Remix) + a "More" sheet for the rest - the export\'s own floating-pill nav only assumed ~4 destinations, not enough for this app\'s real feature count',
'Every page rebuilt from its matching Stitch screen where one existed (Library, Discovery, Remix, Rooms, Channels, Upload, Business/Admin panels, Now Playing); Login, Playlists, and Telegram linking - which had no Stitch mockup - were designed from scratch to match the same system',
......@@ -276,11 +279,6 @@ const FRONTEND_TODO: WorkItem[] = [
status: 'needs-design',
note: "Noted 2026-10-06, not started - there's currently no first-run walkthrough at all; a brand-new account lands straight on Home/Library with no explanation of what Stax does or how to get music into it (Upload vs. Telegram linking vs. Discovery).",
},
{
item: 'Full visual redesign',
status: 'needs-design',
note: "Noted 2026-10-06, not started - current design system (cobalt/Space Grotesk, from the 2026-08-23 pass) isn't landing well. Discussed shadcn/ui as a reference point: worth borrowing its component anatomy/states/spacing rhythm and accessibility patterns (built on Radix primitives), but not its default visual skin (neutral grays, rounded-md) wholesale, since that would undo the deliberate cobalt/sharp-radius identity choice made over the generic/templated look.",
},
{
item: 'Investigate perceived slow-to-start playback',
status: 'needs-design',
......
......@@ -5,17 +5,20 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { Settings } from './Settings'
import { AuthProvider } from '../context/AuthContext'
import { PlayerProvider } from '../context/PlayerContext'
import { ThemeProvider } from '../context/ThemeContext'
import { ApiError } from '../api/client'
import * as authApi from '../api/auth'
function renderSettings() {
return render(
<MemoryRouter>
<AuthProvider>
<PlayerProvider>
<Settings />
</PlayerProvider>
</AuthProvider>
<ThemeProvider>
<AuthProvider>
<PlayerProvider>
<Settings />
</PlayerProvider>
</AuthProvider>
</ThemeProvider>
</MemoryRouter>,
)
}
......@@ -35,6 +38,22 @@ describe('Settings', () => {
afterEach(() => {
vi.restoreAllMocks()
localStorage.removeItem('stax_theme')
})
it('defaults to dark and lets you switch appearance', async () => {
renderSettings()
const darkButton = await screen.findByRole('button', { name: 'Dark' })
expect(darkButton).toHaveAttribute('aria-pressed', 'true')
expect(screen.getByRole('button', { name: 'Light' })).toHaveAttribute('aria-pressed', 'false')
await userEvent.click(screen.getByRole('button', { name: 'Light' }))
expect(screen.getByRole('button', { name: 'Light' })).toHaveAttribute('aria-pressed', 'true')
expect(darkButton).toHaveAttribute('aria-pressed', 'false')
expect(localStorage.getItem('stax_theme')).toBe('light')
expect(document.documentElement.classList.contains('dark')).toBe(false)
})
it('renders both toggles off by default', async () => {
......
import { useEffect, useState } from 'react'
import { MapPin, MessageCircle, type LucideIcon } from 'lucide-react'
import { MapPin, MessageCircle, Monitor, Moon, Sun, type LucideIcon } from 'lucide-react'
import { Layout } from '../components/Layout'
import { ApiError } from '../api/client'
import { getMe, updatePrivacy, type PrivacySettings } from '../api/auth'
import { useTheme, type ThemePreference } from '../context/ThemeContext'
const THEME_OPTIONS: { value: ThemePreference; label: string; icon: LucideIcon }[] = [
{ value: 'light', label: 'Light', icon: Sun },
{ value: 'dark', label: 'Dark', icon: Moon },
{ value: 'system', label: 'System', icon: Monitor },
]
/** Local-only preference (see ThemeContext) - no backend round trip, unlike the privacy
* toggles below, so there's no saving/error state to manage here at all. */
function AppearanceRow() {
const { theme, setTheme } = useTheme()
return (
<div className="rounded-xl border border-outline-variant bg-surface-container p-4">
<p className="mb-3 text-sm font-medium text-on-surface">Appearance</p>
<div className="flex gap-2">
{THEME_OPTIONS.map((option) => {
const active = theme === option.value
return (
<button
key={option.value}
onClick={() => setTheme(option.value)}
aria-pressed={active}
className={`flex flex-1 items-center justify-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors duration-150 ${
active
? 'bg-primary text-on-primary'
: 'border border-outline-variant bg-transparent text-on-surface-variant hover:border-primary hover:text-on-surface'
}`}
>
<option.icon size={14} strokeWidth={2} />
{option.label}
</button>
)
})}
</div>
</div>
)
}
function ToggleRow({
icon: Icon,
......@@ -84,6 +122,10 @@ export function Settings() {
{error && <p className="mb-4 text-sm text-error">{error}</p>}
<div className="mb-3">
<AppearanceRow />
</div>
{privacy && (
<div className="space-y-3">
<ToggleRow
......
......@@ -8,6 +8,12 @@
"allowArbitraryExtensions": true,
"skipLibCheck": true,
/* Path aliases - no baseUrl: deprecated under moduleResolution "bundler" (TS 6+), which
resolves `paths` relative to this file's own directory without it. */
"paths": {
"@/*": ["./src/*"]
},
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
......
......@@ -22,6 +22,11 @@ export default defineConfig(({ mode }) => {
const backendProxyTarget = env.BACKEND_PROXY_TARGET || 'http://127.0.0.1:8000'
return {
resolve: {
alias: {
'@': `${import.meta.dirname}/src`,
},
},
// The Geolocation API (and other browser APIs) refuse to run at all on a plain http://
// origin that isn't localhost - "secure context" is a hard browser requirement, not a
// permission you can grant around. basicSsl generates a self-signed cert automatically so
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment