feat(web): add the calm redesign as a sidebar switch
The redesign proposed after the anti-slop audit (anti-slop/audit-001) is now an opt-in design layer. The "New design" switch at the bottom of the sidebar sets data-design="calm" on <html> and remembers it; theme-init.js applies the stored choice before the first paint. The classic look stays the default and is unchanged. styles/calm.css, scoped to that attribute, keeps the Hive DS colors and: bundles Hanken Grotesk and JetBrains Mono (@fontsource-variable, OFL-1.1); uses three radii (6 / 10 / 14 px); drops the honeycomb wallpaper, gradient fills, glass, glows and pulsing dots; keeps shadows only on menus and dialogs; shows labels as written instead of tracked capitals; and marks the active sidebar item with fill, a 1px line and weight instead of a stripe. Screen layouts are unchanged.
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
"dependencies": {
|
||||
"@clerk/clerk-react": "^5.61.8",
|
||||
"@clerk/themes": "^2.4.57",
|
||||
"@fontsource-variable/hanken-grotesk": "^5.3.0",
|
||||
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
||||
"@hookform/resolvers": "^3.10.0",
|
||||
"@radix-ui/react-accordion": "^1.2.11",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.14",
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
(value === 'system' && window.matchMedia &&
|
||||
!window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
if (useLightTheme) document.documentElement.setAttribute('data-theme', 'light');
|
||||
// The calm redesign (src/lib/design-mode.ts) is opt-in from the sidebar.
|
||||
if (localStorage.getItem('waggle-design') === 'calm') {
|
||||
document.documentElement.setAttribute('data-design', 'calm');
|
||||
}
|
||||
} catch (_error) {
|
||||
// Storage can be unavailable in hardened webviews; dark is the default.
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ import { createRoot } from 'react-dom/client';
|
||||
import { flushSync } from 'react-dom';
|
||||
import App from './App.tsx';
|
||||
import './index.css';
|
||||
// Bundled fonts and the opt-in calm design layer (src/lib/design-mode.ts).
|
||||
import '@fontsource-variable/hanken-grotesk';
|
||||
import '@fontsource-variable/jetbrains-mono';
|
||||
import './styles/calm.css';
|
||||
import { applyStoredThemeEarly } from '@/providers/ThemeProvider';
|
||||
|
||||
export function mountApp(): void {
|
||||
|
||||
@@ -452,7 +452,7 @@ const ShellLayout = () => {
|
||||
|
||||
return (
|
||||
<div className="relative w-screen h-screen overflow-hidden select-none">
|
||||
<img src={theme === 'light' ? wallpaperLight : wallpaperDark} alt="" className="absolute inset-0 w-full h-full object-cover" width={1920} height={1080} />
|
||||
<img src={theme === 'light' ? wallpaperLight : wallpaperDark} alt="" className="desktop-wallpaper absolute inset-0 w-full h-full object-cover" width={1920} height={1080} />
|
||||
<div className="absolute inset-0 desktop-overlay" />
|
||||
|
||||
<StatusBar workspaceName={effectiveActiveWorkspace?.name}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { ElementType, ReactElement } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { ChevronDown, Plus, Search } from "lucide-react";
|
||||
import { ChevronDown, Palette, Plus, Search } from "lucide-react";
|
||||
import { cmdKLabel } from "@/lib/platform";
|
||||
import { useDesignMode } from "@/lib/design-mode";
|
||||
import { HintTooltip } from "@/components/ui/hint-tooltip";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
|
||||
@@ -70,6 +71,8 @@ const Sidebar = ({
|
||||
}: SidebarProps) => {
|
||||
const navigate = useNavigate();
|
||||
const { pathname } = useLocation();
|
||||
const [design, setDesign] = useDesignMode();
|
||||
const calm = design === "calm";
|
||||
|
||||
const isActive = (item: SidebarNavItem): boolean =>
|
||||
item.activeWhen
|
||||
@@ -95,7 +98,7 @@ const Sidebar = ({
|
||||
{active && (
|
||||
<span
|
||||
aria-hidden
|
||||
className="absolute -left-3 top-1/2 h-[18px] w-[3px] -translate-y-1/2 rounded bg-[var(--honey)]"
|
||||
className="nav-active-stripe absolute -left-3 top-1/2 h-[18px] w-[3px] -translate-y-1/2 rounded bg-[var(--honey)]"
|
||||
/>
|
||||
)}
|
||||
<Icon
|
||||
@@ -197,6 +200,36 @@ const Sidebar = ({
|
||||
|
||||
<div className="flex-1" />
|
||||
|
||||
{/* Design switch: the classic look or the calm redesign (styles/calm.css) */}
|
||||
<RailHint content={calm ? "New design: on" : "New design: off"}>
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={calm}
|
||||
aria-label="New design"
|
||||
data-testid="sidebar-design-switch"
|
||||
onClick={() => setDesign(calm ? "classic" : "calm")}
|
||||
className="flex items-center justify-center gap-3 rounded-[10px] px-2.5 py-2 text-left text-[var(--text-2)] transition-colors hover:bg-[var(--surface-2)] hover:text-[var(--text)] lg:justify-start"
|
||||
>
|
||||
{/* Honey when on, so the icon-only rail shows the state too. */}
|
||||
<Palette
|
||||
className={`h-[18px] w-[18px] shrink-0 ${calm ? "text-[var(--honey-text)]" : ""}`}
|
||||
strokeWidth={1.7}
|
||||
/>
|
||||
<span className="hidden flex-1 text-[13px] font-medium lg:inline">New design</span>
|
||||
<span
|
||||
aria-hidden
|
||||
className={`hidden h-[18px] w-8 shrink-0 items-center rounded-full border p-[2px] transition-colors lg:inline-flex ${
|
||||
calm
|
||||
? "justify-end border-[var(--honey)] bg-[var(--honey)]"
|
||||
: "justify-start border-[var(--line-strong)] bg-[var(--surface-2)]"
|
||||
}`}
|
||||
>
|
||||
<span className={`h-3 w-3 rounded-full ${calm ? "bg-[#1a1407]" : "bg-[var(--text-2)]"}`} />
|
||||
</span>
|
||||
</button>
|
||||
</RailHint>
|
||||
|
||||
{/* User row → Settings */}
|
||||
<RailHint content={userName ?? "Account"}>
|
||||
<button
|
||||
|
||||
41
apps/web/src/lib/design-mode.ts
Normal file
41
apps/web/src/lib/design-mode.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Interface design: the classic Waggle look, or the calm redesign from the
|
||||
* anti-slop audit (anti-slop/audit-001-2026-10-14.md). Calm is a CSS layer
|
||||
* keyed on `data-design="calm"` on <html> (styles/calm.css). The attribute is
|
||||
* the source of truth; public/theme-init.js applies the stored choice before
|
||||
* the first paint, so a reload never flashes the other design.
|
||||
*/
|
||||
import { useSyncExternalStore } from 'react';
|
||||
|
||||
export type DesignMode = 'classic' | 'calm';
|
||||
|
||||
export const DESIGN_STORAGE_KEY = 'waggle-design';
|
||||
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
export function getDesignMode(): DesignMode {
|
||||
if (typeof document === 'undefined') return 'classic';
|
||||
return document.documentElement.getAttribute('data-design') === 'calm' ? 'calm' : 'classic';
|
||||
}
|
||||
|
||||
export function setDesignMode(mode: DesignMode): void {
|
||||
const root = document.documentElement;
|
||||
if (mode === 'calm') root.setAttribute('data-design', 'calm');
|
||||
else root.removeAttribute('data-design');
|
||||
try {
|
||||
localStorage.setItem(DESIGN_STORAGE_KEY, mode);
|
||||
} catch {
|
||||
// Storage can be unavailable in hardened webviews; the choice lasts the session.
|
||||
}
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
}
|
||||
|
||||
export function useDesignMode(): [DesignMode, (mode: DesignMode) => void] {
|
||||
const mode = useSyncExternalStore(subscribe, getDesignMode, () => 'classic' as const);
|
||||
return [mode, setDesignMode];
|
||||
}
|
||||
141
apps/web/src/styles/calm.css
Normal file
141
apps/web/src/styles/calm.css
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Calm design — the redesign proposal from the anti-slop audit
|
||||
* (anti-slop/audit-001-2026-10-14.md). Opt-in through data-design="calm" on
|
||||
* <html>: the sidebar switch sets it (src/lib/design-mode.ts) and
|
||||
* public/theme-init.js applies it before the first paint. Every rule is scoped
|
||||
* to that attribute, so the classic look is untouched.
|
||||
*
|
||||
* Same Hive DS colors in both themes. What changes: bundled Hanken Grotesk and
|
||||
* JetBrains Mono, three radii (6 / 10 / 14 px), flat surfaces with 1px lines,
|
||||
* a shadow only on menus and dialogs, and no glass, glow, honeycomb texture,
|
||||
* pulsing dots or tracked capitals.
|
||||
*/
|
||||
|
||||
:root[data-design="calm"] {
|
||||
--sans: 'Hanken Grotesk Variable', 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
--mono: 'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, monospace;
|
||||
--font-sans: var(--sans);
|
||||
--font-mono: var(--mono);
|
||||
--radius: 10px;
|
||||
--r-xl: 14px;
|
||||
--shadow-card: none;
|
||||
--shadow-elevated: none;
|
||||
--shadow-sm: none;
|
||||
--shadow-honey: none;
|
||||
--shadow-honey-bloom: none;
|
||||
--honey-glow: transparent;
|
||||
}
|
||||
|
||||
/* ── Type ─────────────────────────────────────────────────────────────── */
|
||||
|
||||
:root[data-design="calm"] :is(body, .font-sans, .font-display) {
|
||||
font-family: var(--sans);
|
||||
}
|
||||
|
||||
:root[data-design="calm"] :is(.font-mono, code, kbd, pre, samp) {
|
||||
font-family: var(--mono);
|
||||
}
|
||||
|
||||
/* Labels read as written instead of tracked capitals. */
|
||||
:root[data-design="calm"] .uppercase {
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
}
|
||||
|
||||
/* ── Radii: 6 for controls, 10 for cards, 14 for windows ──────────────── */
|
||||
|
||||
:root[data-design="calm"] :is(.rounded-sm, .rounded-md) {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] :is(.rounded-lg, .rounded-xl) {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] :is(.rounded-2xl, .rounded-3xl) {
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
/* ── Depth: flat surfaces; only menus and dialogs float ───────────────── */
|
||||
|
||||
:root[data-design="calm"] :is(.shadow-sm, .shadow, .shadow-md, .shadow-lg, .shadow-xl, .shadow-2xl):not(
|
||||
[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [data-radix-popper-content-wrapper] *
|
||||
) {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] :is(.glass, .glass-strong) {
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
:root[data-design="calm"] :is(.glass, .glass-strong, [class*="backdrop-blur"]) {
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
|
||||
/* ── No glow, texture or idle motion ──────────────────────────────────── */
|
||||
|
||||
:root[data-design="calm"] .glow-primary {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] .text-glow {
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] :is(.comb, .honeycomb-bg) {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] [data-testid="ambient-hive-glow"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* A status dot shows a state; it does not pulse. Loading skeletons keep
|
||||
animate-pulse, since they mark real loading. */
|
||||
:root[data-design="calm"] :is(.animate-ping, .honey-pulse, .glow-breathe, .hive-ambient-breath) {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
/* ── Sidebar: active item by fill, 1px line and weight, no stripe ─────── */
|
||||
|
||||
:root[data-design="calm"] .waggle-sidebar .nav-active-stripe {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] .waggle-sidebar [aria-current="page"] {
|
||||
background: var(--surface);
|
||||
box-shadow: inset 0 0 0 1px var(--line);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] .waggle-sidebar [aria-current="page"] svg {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* ── Surfaces: a plain backdrop and flat cards ─────────────────────────── */
|
||||
|
||||
:root[data-design="calm"] body {
|
||||
background-color: var(--bg);
|
||||
}
|
||||
|
||||
:root[data-design="calm"] :is(.desktop-wallpaper, .desktop-overlay) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root[data-design="calm"] [class*="bg-[linear-gradient"]:not(.hex) {
|
||||
background: var(--surface);
|
||||
border-color: var(--line);
|
||||
}
|
||||
|
||||
/* Decorative glows sit behind content and never take pointer events. */
|
||||
:root[data-design="calm"] [class*="bg-[radial-gradient"].pointer-events-none {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* The hexagon stays as the workspace and agent mark, in a neutral fill. Agent
|
||||
colors arrive as inline styles, hence !important. */
|
||||
:root[data-design="calm"] .hex:is([class*="gradient"], [style*="gradient"]) {
|
||||
background: var(--surface-2) !important;
|
||||
color: var(--text) !important;
|
||||
}
|
||||
73
apps/web/src/test/design-mode.test.tsx
Normal file
73
apps/web/src/test/design-mode.test.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* The calm redesign is opt-in from the sidebar: the switch sets
|
||||
* data-design="calm" on <html> and remembers it, and public/theme-init.js
|
||||
* applies the stored choice before the first paint.
|
||||
*/
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { Home } from 'lucide-react';
|
||||
import Sidebar from '@/components/os/Sidebar';
|
||||
import { DESIGN_STORAGE_KEY, getDesignMode, setDesignMode } from '@/lib/design-mode';
|
||||
|
||||
const root = document.documentElement;
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
root.removeAttribute('data-design');
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
function renderSidebar() {
|
||||
return render(
|
||||
<MemoryRouter initialEntries={['/home']}>
|
||||
<Sidebar
|
||||
workspaceName="Acme"
|
||||
spine={[{ key: 'home', label: 'Home', icon: Home, to: '/home', match: ['/home'] }]}
|
||||
onOpenWorkspaceSwitcher={() => {}}
|
||||
onOpenCommand={() => {}}
|
||||
onSpawnAgent={() => {}}
|
||||
userName="Marko"
|
||||
/>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
}
|
||||
|
||||
describe('design mode', () => {
|
||||
it('sets and clears the calm attribute and remembers the choice', () => {
|
||||
setDesignMode('calm');
|
||||
expect(root.getAttribute('data-design')).toBe('calm');
|
||||
expect(localStorage.getItem(DESIGN_STORAGE_KEY)).toBe('calm');
|
||||
expect(getDesignMode()).toBe('calm');
|
||||
|
||||
setDesignMode('classic');
|
||||
expect(root.hasAttribute('data-design')).toBe(false);
|
||||
expect(localStorage.getItem(DESIGN_STORAGE_KEY)).toBe('classic');
|
||||
expect(getDesignMode()).toBe('classic');
|
||||
});
|
||||
|
||||
it('switches between the designs from the sidebar', () => {
|
||||
renderSidebar();
|
||||
const toggle = screen.getByRole('switch', { name: 'New design' });
|
||||
expect(toggle).toHaveAttribute('aria-checked', 'false');
|
||||
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toHaveAttribute('aria-checked', 'true');
|
||||
expect(root.getAttribute('data-design')).toBe('calm');
|
||||
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toHaveAttribute('aria-checked', 'false');
|
||||
expect(root.hasAttribute('data-design')).toBe(false);
|
||||
});
|
||||
|
||||
it('applies the stored choice before the app loads', () => {
|
||||
const script = fs.readFileSync(path.resolve(__dirname, '../../public/theme-init.js'), 'utf8');
|
||||
localStorage.setItem(DESIGN_STORAGE_KEY, 'calm');
|
||||
|
||||
new Function(script)();
|
||||
|
||||
expect(root.getAttribute('data-design')).toBe('calm');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user