From b64dc2acf97242671ac81548cb0f92b07d46f938 Mon Sep 17 00:00:00 2001 From: Elizabet Oliveira Date: Wed, 4 Nov 2026 12:11:05 +0000 Subject: [PATCH 1/5] feat(app): always use the ClickStack brand Drop the HyperDX palette and the brand and font pickers so every deployment shares one look. Color mode stays a preference. Fixes HDX-5662. Co-authored-by: Cursor --- .changeset/remove-brand-themes.md | 5 + agent_docs/README.md | 2 +- agent_docs/code_style.md | 10 +- agent_docs/data_viz_colors.md | 119 ++-- agent_docs/themes.md | 579 ++++-------------- packages/app/.storybook/preview.tsx | 30 +- packages/app/package.json | 2 +- packages/app/pages/_app.tsx | 58 +- packages/app/pages/_document.tsx | 46 +- .../favicons/hyperdx/apple-touch-icon.png | Bin 9071 -> 0 bytes .../public/favicons/hyperdx/favicon-16x16.png | Bin 596 -> 0 bytes .../public/favicons/hyperdx/favicon-32x32.png | Bin 1200 -> 0 bytes .../app/public/favicons/hyperdx/favicon.svg | 12 - packages/app/src/AlertDetailPage.tsx | 2 +- packages/app/src/AlertsPage.tsx | 2 +- packages/app/src/AuthLoadingBlocker.tsx | 2 +- packages/app/src/AuthPage.tsx | 2 +- packages/app/src/ClickhousePage.tsx | 2 +- packages/app/src/DBChartPage.tsx | 2 +- packages/app/src/DBDashboardImportPage.tsx | 2 +- packages/app/src/DBDashboardPage.tsx | 2 +- packages/app/src/DBSearchPage.tsx | 7 +- packages/app/src/DBSearchPageAlertModal.tsx | 2 +- packages/app/src/DBServiceMapPage.tsx | 2 +- packages/app/src/HDXMultiSeriesTableChart.tsx | 2 +- packages/app/src/JoinTeamPage.tsx | 2 +- packages/app/src/KubernetesDashboardPage.tsx | 2 +- packages/app/src/LandingHeader.tsx | 2 +- .../useOnboardingCompletion.ts | 2 +- .../ServicesDashboardPage.tsx | 2 +- .../__tests__/ServicesDashboardPage.test.tsx | 7 +- packages/app/src/SessionsPage.tsx | 2 +- packages/app/src/Spotlights.tsx | 2 +- packages/app/src/TeamPage.tsx | 2 +- packages/app/src/ThemeWrapper.tsx | 12 +- packages/app/src/UserPreferencesModal.tsx | 90 +-- .../DBSearchPage.directTrace.test.tsx | 8 +- .../__tests__/DBSearchPageAlertModal.test.tsx | 4 +- .../__tests__/OnboardingChecklist.test.tsx | 22 +- packages/app/src/__tests__/utils.test.ts | 3 +- .../themes/clickstack => brand}/Logomark.tsx | 0 .../themes/clickstack => brand}/Wordmark.tsx | 0 packages/app/src/brand/index.tsx | 38 ++ packages/app/src/components/Alert.stories.tsx | 5 +- packages/app/src/components/AppNav/AppNav.tsx | 2 +- .../components/DBRowSidePanelErrorState.tsx | 2 +- .../Dashboards/DashboardTemplatesPage.tsx | 2 +- .../Dashboards/DashboardsListPage.tsx | 2 +- .../__tests__/DashboardsListPage.test.tsx | 7 +- .../app/src/components/DynamicFavicon.tsx | 89 --- .../ResourceTerraformPopover.test.tsx | 2 +- .../components/Iac/useTerraformSnippets.ts | 2 +- .../app/src/components/OnboardingModal.tsx | 2 +- .../SavedSearches/SavedSearchesListPage.tsx | 2 +- .../Sources/SourceForm/LogTableModelForm.tsx | 2 +- .../Sources/SourceForm/MaterializedViews.tsx | 2 +- .../SourceForm/MetricTableModelForm.tsx | 2 +- .../SourceForm/SessionTableModelForm.tsx | 2 +- .../SourceForm/TraceTableModelForm.tsx | 2 +- .../TeamSettings/TeamMembersSection.tsx | 2 +- .../TeamSettings/TeamQueryConfigSection.tsx | 2 +- .../components/TeamSettings/WebhookForm.tsx | 2 +- .../TeamSettings/WebhooksSection.tsx | 2 +- .../DBRowSidePanelErrorState.test.tsx | 2 +- .../__tests__/DynamicFavicon.test.tsx | 119 ---- .../__tests__/MetricTableModelForm.test.tsx | 4 +- .../__tests__/OnboardingModal.test.tsx | 4 +- .../src/components/alerts/AlertRowMenu.tsx | 2 +- .../src/components/alerts/EditAlertModal.tsx | 2 +- .../alerts/EditInlineAlertModal.tsx | 2 +- .../alerts/__tests__/AlertRowMenu.test.tsx | 4 +- .../alerts/__tests__/EditAlertModal.test.tsx | 4 +- .../__tests__/EditInlineAlertModal.test.tsx | 4 +- packages/app/src/config/fonts.ts | 8 - .../src/llm/dashboard/LLMDashboardPage.tsx | 2 +- packages/app/src/stories/Brand.stories.tsx | 49 +- .../app/src/theme/ChartColors.stories.tsx | 7 +- .../src/theme/SemanticVariants.stories.tsx | 4 +- packages/app/src/theme/ThemeProvider.tsx | 256 -------- .../theme/__tests__/ThemeProvider.test.tsx | 229 ------- .../app/src/theme/__tests__/index.test.ts | 213 ------- packages/app/src/theme/_base-tokens.scss | 16 + .../_chart-categorical-tokens.scss | 17 +- .../{themes/clickstack => }/_tokens.scss | 14 +- .../theme/{themes => }/components.module.scss | 0 packages/app/src/theme/index.ts | 277 --------- .../{themes/clickstack => }/mantineTheme.ts | 13 +- .../theme/{themes => }/semanticVariants.ts | 6 +- .../app/src/theme/themes/_base-tokens.scss | 33 - .../app/src/theme/themes/clickstack/index.ts | 21 - .../app/src/theme/themes/hyperdx/Logomark.tsx | 27 - .../app/src/theme/themes/hyperdx/Wordmark.tsx | 28 - .../app/src/theme/themes/hyperdx/_tokens.scss | 302 --------- .../app/src/theme/themes/hyperdx/index.ts | 21 - .../src/theme/themes/hyperdx/mantineTheme.ts | 422 ------------- packages/app/src/theme/types.ts | 65 -- packages/app/src/useUserPreferences.tsx | 2 +- packages/app/src/utils.ts | 84 +-- packages/app/styles/app.scss | 2 +- packages/common-utils/src/types.ts | 8 +- 100 files changed, 413 insertions(+), 3087 deletions(-) create mode 100644 .changeset/remove-brand-themes.md delete mode 100644 packages/app/public/favicons/hyperdx/apple-touch-icon.png delete mode 100644 packages/app/public/favicons/hyperdx/favicon-16x16.png delete mode 100644 packages/app/public/favicons/hyperdx/favicon-32x32.png delete mode 100644 packages/app/public/favicons/hyperdx/favicon.svg rename packages/app/src/{theme/themes/clickstack => brand}/Logomark.tsx (100%) rename packages/app/src/{theme/themes/clickstack => brand}/Wordmark.tsx (100%) create mode 100644 packages/app/src/brand/index.tsx delete mode 100644 packages/app/src/components/DynamicFavicon.tsx delete mode 100644 packages/app/src/components/__tests__/DynamicFavicon.test.tsx delete mode 100644 packages/app/src/theme/ThemeProvider.tsx delete mode 100644 packages/app/src/theme/__tests__/ThemeProvider.test.tsx delete mode 100644 packages/app/src/theme/__tests__/index.test.ts create mode 100644 packages/app/src/theme/_base-tokens.scss rename packages/app/src/theme/{themes => }/_chart-categorical-tokens.scss (74%) rename packages/app/src/theme/{themes/clickstack => }/_tokens.scss (98%) rename packages/app/src/theme/{themes => }/components.module.scss (100%) delete mode 100644 packages/app/src/theme/index.ts rename packages/app/src/theme/{themes/clickstack => }/mantineTheme.ts (97%) rename packages/app/src/theme/{themes => }/semanticVariants.ts (87%) delete mode 100644 packages/app/src/theme/themes/_base-tokens.scss delete mode 100644 packages/app/src/theme/themes/clickstack/index.ts delete mode 100644 packages/app/src/theme/themes/hyperdx/Logomark.tsx delete mode 100644 packages/app/src/theme/themes/hyperdx/Wordmark.tsx delete mode 100644 packages/app/src/theme/themes/hyperdx/_tokens.scss delete mode 100644 packages/app/src/theme/themes/hyperdx/index.ts delete mode 100644 packages/app/src/theme/themes/hyperdx/mantineTheme.ts delete mode 100644 packages/app/src/theme/types.ts diff --git a/.changeset/remove-brand-themes.md b/.changeset/remove-brand-themes.md new file mode 100644 index 0000000000..1440afbdd5 --- /dev/null +++ b/.changeset/remove-brand-themes.md @@ -0,0 +1,5 @@ +--- +'@hyperdx/app': minor +--- + +The app always uses ClickStack branding. Brand selection, the HyperDX palette, and the font picker are removed. Light, dark, and system color mode stay in Preferences. diff --git a/agent_docs/README.md b/agent_docs/README.md index 2e3c1de63d..a8aafa3cb3 100644 --- a/agent_docs/README.md +++ b/agent_docs/README.md @@ -19,7 +19,7 @@ Instead of stuffing all instructions into `AGENTS.md` (which goes into every con - **`page_layout.md`** - PageHeader, PageLayout, and consistent page chrome (titles, actions, tool pages) - **`naming_objects.md`** - How users name and rename objects (dashboards, saved searches, tiles) with `InlineNameInput`. Read before adding or changing any place where something gets a name. - **`data_viz_colors.md`** - Chart, heatmap, and semantic status colors. Read before adding or changing any color in a chart, sparkline, heatmap, legend, or status pill. -- **`themes.md`** - How the brand theme system (HyperDX vs ClickStack) and color mode (light/dark/system) work. Read before changing anything in `packages/app/src/theme/`, adding semantic CSS variables, or touching brand-conditional UI. +- **`themes.md`** - ClickStack appearance and color mode (light/dark/system). Read before changing anything in `packages/app/src/theme/`, adding semantic CSS variables, or hard-coding a color, logo, or favicon. - **`observability.md`** - Instrumentation standards (tracing, metrics, context) and the shared helpers. Read when adding or changing a feature. - **`evals.md`** - MCP eval framework: dual-slot setup, running A/B comparisons between branches, interpreting results. Read before running evals or benchmarking MCP changes. diff --git a/agent_docs/code_style.md b/agent_docs/code_style.md index cc4b5ff14c..a925429dce 100644 --- a/agent_docs/code_style.md +++ b/agent_docs/code_style.md @@ -177,14 +177,14 @@ This pattern cannot be enforced by ESLint and requires manual code review. ### Semantic component variants (Alert / Text / danger controls) -We ship **themed semantic variants** for `Alert`, `Text`, `Button`, and `ActionIcon` so callouts and status text are token-driven and consistent across the HyperDX and ClickStack brands (and light/dark). **Prefer these over raw Mantine palette colors** (`color="yellow"`, `color="red"`, `c="green"`, etc.). +We ship **semantic variants** for `Alert`, `Text`, `Button`, and `ActionIcon` so callouts and status text are token-driven in both light and dark. **Prefer these over raw Mantine palette colors** (`color="yellow"`, `color="red"`, `c="green"`, etc.). -The variant → token mapping is centralized in `packages/app/src/theme/themes/semanticVariants.ts` (the single source of truth, consumed by both brand themes' `mantineTheme.ts`). See the Storybook stories `Components/Alert` (interactive `Playground`) and `Design tokens/Semantic variants` for the full visual matrix. +The variant → token mapping is centralized in `packages/app/src/theme/semanticVariants.ts` (the single source of truth, consumed by `theme/mantineTheme.ts`). See the Storybook stories `Components/Alert` (interactive `Playground`) and `Design tokens/Semantic variants` for the full visual matrix. **`Alert`** — `info` | `success` | `warning` | `danger`. Renders a tinted `-subtle` background with the title, icon, **and body text** in the semantic color token: ```tsx -// ✅ token-driven, works in both brands + light/dark, meets WCAG AA +// ✅ token-driven, works in light and dark, meets WCAG AA This may take a while. Could not save the alert. @@ -398,11 +398,11 @@ render those verbatim. ## Semantic design tokens (prefer over raw Mantine colors) -The UI is built with **Mantine components**, but **colors and surfaces** should follow the **semantic CSS custom properties** in our themes (`--color-*`, etc.), not ad-hoc Mantine palette values. Those tokens are defined in `packages/app/src/theme/themes/**/_tokens.scss`, align with a **Click UI**–style system, and keep HyperDX and ClickStack visually consistent. They are the path toward a shared design system even while Mantine remains the component layer. +The UI is built with **Mantine components**, but **colors and surfaces** should follow the **semantic CSS custom properties** in our themes (`--color-*`, etc.), not ad-hoc Mantine palette values. Those tokens are defined in `packages/app/src/theme/_tokens.scss`, align with a **Click UI**–style system, and are shared by every deployment. They are the path toward a shared design system even while Mantine remains the component layer. - **Do**: Use Mantine for layout, components, and spacing; use **semantic tokens** for themed backgrounds, text colors, borders, and states (e.g. `style={{ color: 'var(--color-text-muted)' }}` or `style={{ border: '1px solid var(--color-border)' }}`). - **Do not**: Rely on raw Mantine color props for app chrome and content when a semantic token exists — e.g. `c="gray.5"`, `bg="dark.7"`, or arbitrary `color="blue.4"` for surfaces that should match the rest of the product. -- **Reference**: `packages/app/src/theme/semanticColorsGrouped.ts` (token names), theme SCSS under `packages/app/src/theme/themes/`, and Storybook (`SemanticColors` and related theme stories) for a visual map. +- **Reference**: `packages/app/src/theme/semanticColorsGrouped.ts` (token names), `packages/app/src/theme/_tokens.scss`, and Storybook (`SemanticColors` and related theme stories) for a visual map. Mantine theme overrides in `packages/app/src/theme/**` may map Mantine’s scale to our palette; that does not replace using **`var(--color-...)`** in new styling where you need explicit color control. diff --git a/agent_docs/data_viz_colors.md b/agent_docs/data_viz_colors.md index 53fec06188..92d7960281 100644 --- a/agent_docs/data_viz_colors.md +++ b/agent_docs/data_viz_colors.md @@ -51,13 +51,12 @@ and ClickStack: | `chart-gray` | `#9498a0` | **Source of truth for categorical hues lives in JS.** The matching -`--color-chart-{hue}` CSS vars in both -`packages/app/src/theme/themes/hyperdx/_tokens.scss` and -`packages/app/src/theme/themes/clickstack/_tokens.scss` are a stylesheet-author +`--color-chart-{hue}` CSS vars, included from +`packages/app/src/theme/_tokens.scss`, are a stylesheet-author affordance only — `getColorFromCSSVariable` and `getColorFromCSSToken` skip `getComputedStyle` for categorical tokens and return values straight from -`CATEGORICAL_HEX_BY_TOKEN` in `utils.ts`. The palette is the same on every theme -today, so a DOM round-trip per series buys nothing. +`CATEGORICAL_HEX_BY_TOKEN` in `utils.ts`. A DOM round-trip per series buys +nothing. The CSS vars exist for: @@ -69,21 +68,20 @@ The CSS vars exist for: add per-brand entries to `CATEGORICAL_HEX_BY_TOKEN`. The categorical hues and semantic chart colors live in a single shared partial, -`packages/app/src/theme/themes/_chart-categorical-tokens.scss` (`chart-categorical-tokens` -and `chart-semantic-tokens` mixins). Both brand themes `@use` it and `@include` -both mixins inside their per-theme `chart-tokens` mixin. Each theme's -`chart-tokens` mixin is then `@include`'d inside both `[data-mantine-color-scheme]` -selectors. Sass inlines the bodies at each call site, so the emitted CSS has the -same per-scheme specificity as a hand-duplicated block would — but the source -lives in **one place** for both layers. **If you change a categorical hex in the -shared partial, change it in `CATEGORICAL_HEX_BY_TOKEN` in `utils.ts` too. If -you change a semantic hex, update `SEMANTIC_CHART_PALETTE` in `utils.ts` too — -the SCSS and JS sources are intentionally mirrored.** - -Brand identity for charts is carried by non-chart UI chrome (Mantine accent, -sidebar gradient, Click UI globals), not by per-brand chart semantic colors — -`success` and `info` reuse categorical `chart-green` and `chart-blue` on both -brands. +`packages/app/src/theme/_chart-categorical-tokens.scss` (`chart-categorical-tokens` +and `chart-semantic-tokens` mixins). `theme/_tokens.scss` `@use`s it and +`@include`s both mixins inside its `chart-tokens` mixin, which is then +`@include`'d inside both `[data-mantine-color-scheme]` selectors. Sass inlines +the bodies at each call site, so the emitted CSS has the same per-scheme +specificity as a hand-duplicated block would — but the source lives in **one +place**. **If you change a categorical hex in the shared partial, change it in +`CATEGORICAL_HEX_BY_TOKEN` in `utils.ts` too. If you change a semantic hex, +update `SEMANTIC_CHART_PALETTE` in `utils.ts` too — the SCSS and JS sources are +intentionally mirrored.** + +Chart series colors are not the brand accent. `success` and `info` reuse +categorical `chart-green` and `chart-blue`. The yellow ClickStack accent stays +in non-chart chrome (Mantine accent, sidebar, Click UI globals). ### Semantic chart colors (`--color-chart-{success|warning|error|info}`) @@ -97,23 +95,22 @@ brands. --color-chart-error-highlight ``` -Defined in both `_tokens.scss` files. **Unified on both brands**: `success` -reuses categorical `chart-green` (`#3ca951`); `info` reuses categorical -`chart-blue` (`#437eef`). Warning and error use the same Observable hexes across -themes. +Defined in the shared `chart-semantic-tokens` mixin. `success` reuses +categorical `chart-green` (`#3ca951`); `info` reuses categorical `chart-blue` +(`#437eef`). Warning and error use the same Observable hexes. Unlike the categorical hues, **the semantic CSS vars are read at runtime** via `getComputedStyle` (see `getSemanticChartColor` in `utils.ts`). That keeps -inline `var(--color-chart-warning)` consumers like `LogLevel.tsx` reacting to -theme switches without a React re-render, and it lets JS callers like -`getChartColorSuccess()` return the correct hex for the active theme. +inline `var(--color-chart-warning)` consumers like `LogLevel.tsx` in sync with +the stylesheet, and it lets JS callers like `getChartColorSuccess()` return the +same hex. ### Single source of truth in TS (`packages/app/src/utils.ts`) ```text CATEGORICAL_HEX_BY_TOKEN # { 'chart-blue': '#437eef', ... } — file-private, # authoritative for categorical hues -SEMANTIC_CHART_PALETTE # { hyperdx: {...}, clickstack: {...} } — file-private, +SEMANTIC_CHART_PALETTE # { success, warning, error, info, …highlight } — file-private, # SSR/fallback for the semantic CSS vars COLORS # ordered hex array, derived from CATEGORICAL_PALETTE_TOKENS ``` @@ -153,14 +150,12 @@ Internals worth knowing: `CATEGORICAL_HEX_BY_TOKEN` — same shortcut, no `getComputedStyle`. - Semantic tokens (`chart-success`, `-warning`, `-error`) read `--color-{token}` from `documentElement` via `getComputedStyle` and fall - back to the active theme's `SEMANTIC_CHART_PALETTE` entry when running - server-side or when the DOM read fails. + back to `SEMANTIC_CHART_PALETTE` when running server-side or when the DOM + read fails. - `getSemanticChartColor(varName, key)` is the shared helper that backs the - `getChartColor{Success,Warning,Error,Info}()` readers. It uses - `detectActiveTheme()` (checks for the `theme-clickstack` class on ``) to - pick the correct per-brand fallback. -- During SSR, semantic readers return the **HyperDX** default — the hydration - mismatch window is tiny because charts render after data fetch on the client. + `getChartColor{Success,Warning,Error,Info}()` readers. SSR and DOM-read + failures use `SEMANTIC_CHART_PALETTE`. Charts usually render after data + fetch on the client, so that fallback rarely reaches the DOM. ### Legacy `chart-1` … `chart-10` tokens @@ -361,38 +356,21 @@ const slices = sorted.map((d, i) => ({ `ChartUtils.tsx → buildPieChartData` already does this. -## Per-theme considerations - -The categorical palette is identical on both themes — Observable 10. Semantic -`success` and `info` also reuse categorical hues on both brands. - -### HyperDX +## Color mode - `--color-chart-success` uses categorical `chart-green` (`#3ca951`). -- `--color-chart-info` uses categorical `chart-blue` (`#437eef`), so info-level - logs and `getChartColorInfo()` render the same blue as multi-series slot 0. -- Multi-series charts start at brand blue (slot 0, `#437eef`) and proceed - through the canonical palette — brand identity is preserved via the Mantine - green accent and sidebar gradient, not via chart semantic colors. - -### ClickStack - +- `--color-chart-info` uses categorical `chart-blue` (`#437eef`, same as + `--click-global-color-text-link-default`), so info-level logs and + `getChartColorInfo()` render that blue. - The brand accent is **yellow** (`--palette-brand-300: #faff69`). It is **not** in the chart palette and should not be added — yellow on a light background fails contrast, and yellow as a series color reads as "warning" in most contexts. -- `--color-chart-success` uses categorical `chart-green` (`#3ca951`). -- `--color-chart-info` uses categorical `chart-blue` (`#437eef`, same as - `--click-global-color-text-link-default`), so info-level logs and - `getChartColorInfo()` render the brand blue. - -### Both themes - - The dark/light scheme split is handled by CSS (the same vars get redefined inside each scheme selector). React code does not need to branch on scheme except for the heatmap palette. -- The chart vars in `_tokens.scss` are intentionally duplicated across the dark - and light blocks. If you change one, change the other. +- The chart vars are intentionally included in both the dark and light blocks. + Change the shared mixin, not one selector. ## Adding new entries @@ -406,8 +384,8 @@ preference: 1. **Group small categories** into "Other" before charting. 2. **Reuse slots** with patterns/strokes/labels for disambiguation. 3. If you really must extend: add `--color-chart-{newhue}` to the shared - `_chart-categorical-tokens.scss` partial — one edit covers both brands and - both schemes via the existing `@include` chain. Then append + `_chart-categorical-tokens.scss` partial — one edit covers both schemes via + the existing `@include` chain. Then append `'chart-{newhue}'` to `CHART_PALETTE_TOKENS` in `common-utils/src/types.ts`, add the hex to `CATEGORICAL_HEX_BY_TOKEN` in `utils.ts`, and add a label entry in `ColorSwatchInput.tsx` → `TOKEN_LABELS` and @@ -415,15 +393,14 @@ preference: ### A new semantic color (e.g. `--color-chart-pending`) -1. Pick the hex (unified across brands unless you have a deliberate per-brand split). +1. Pick the hex. 2. Add `--color-chart-pending` and (if needed) `--color-chart-pending-highlight` to the `@mixin chart-semantic-tokens` block in - `_chart-categorical-tokens.scss`. The mixin is `@include`'d in each theme's - `chart-tokens` mixin, which is `@include`'d in each scheme selector — one edit - covers dark and light for both brands. For a per-brand override only, declare - the var in that brand's `chart-tokens` mixin after the shared `@include`. -3. Add `pending` (and optionally `pendingHighlight`) to - `SEMANTIC_CHART_PALETTE.hyperdx` and `.clickstack` in `utils.ts`. + `_chart-categorical-tokens.scss`. The mixin is `@include`'d from + `theme/_tokens.scss` inside each scheme selector — one edit covers dark + and light. +3. Add `pending` (and optionally `pendingHighlight`) to `SEMANTIC_CHART_PALETTE` + in `utils.ts`. 4. Append `'chart-pending'` to `CHART_PALETTE_TOKENS` (and `SEMANTIC_PALETTE_TOKENS` slice will pick it up automatically) in `common-utils/src/types.ts`. @@ -470,8 +447,6 @@ Why each is wrong: ## Pre-merge checklist for chart-touching PRs -- [ ] Toggled HyperDX ↔ ClickStack theme — semantic success and info stay - unified (chart-green / chart-blue); categorical palette stays identical. - [ ] Toggled dark ↔ light — categorical and semantic colors stay legible on both backgrounds; heatmap gradient flips palettes. - [ ] Status indicators use `getChartColor*()` / `var(--color-chart-*)`, not raw @@ -483,15 +458,15 @@ Why each is wrong: `CATEGORICAL_HEX_BY_TOKEN` in `utils.ts`). - [ ] If you added or changed a semantic hex, changed it in **both** places (`chart-semantic-tokens` mixin in `_chart-categorical-tokens.scss`, - `SEMANTIC_CHART_PALETTE.{theme}` in `utils.ts`). + `SEMANTIC_CHART_PALETTE` in `utils.ts`). - [ ] Storybook `Design tokens / Chart colors` still renders correctly. ## File reference summary | What | Where | | --------------------------------------------------- | -------------------------------------------------------------------------------- | -| Shared chart vars (10 categorical hues + semantics) | `packages/app/src/theme/themes/_chart-categorical-tokens.scss` | -| Per-theme `chart-tokens` mixin (`@include` chain) | `packages/app/src/theme/themes/hyperdx/_tokens.scss`, `clickstack/_tokens.scss` | +| Shared chart vars (10 categorical hues + semantics) | `packages/app/src/theme/_chart-categorical-tokens.scss` | +| `chart-tokens` mixin (`@include` chain) | `packages/app/src/theme/_tokens.scss` | | JS palette objects + reader functions | `packages/app/src/utils.ts` | | Palette token enum + legacy migration | `packages/common-utils/src/types.ts` | | Multi-series wiring (`setLineColors` etc.) | `packages/app/src/ChartUtils.tsx` | diff --git a/agent_docs/themes.md b/agent_docs/themes.md index e162f9c9a6..c322650805 100644 --- a/agent_docs/themes.md +++ b/agent_docs/themes.md @@ -1,179 +1,94 @@ -# Themes (HyperDX & ClickStack) +# Appearance (ClickStack + color mode) -> How the brand theme system works, how it interacts with light/dark color -> mode, and where to make changes safely. Read this before touching anything -> in `packages/app/src/theme/`, before adding a new brand, or before -> hard-coding any color, logo, or favicon path in the app. +> How colors, logos, and light/dark mode work. Read this before changing +> anything in `packages/app/src/theme/`, adding a semantic CSS variable, or +> hard-coding a color, logo, or favicon path. > -> For **chart colors specifically** (categorical palette, heatmap gradient, -> semantic success/warn/error chart colors) see -> [`data_viz_colors.md`](data_viz_colors.md) — it covers the chart-specific -> rules in more depth. This doc covers everything else. +> For chart colors see [`data_viz_colors.md`](data_viz_colors.md). ## TL;DR -The app has **two independent theming concepts**: - -| Concept | Values | Who controls it | Stored in | What it affects | -| ------------------ | ------------------------------ | --------------------------- | ------------------------------------------ | ----------------------------------------------------- | -| **Brand theme** | `hyperdx` \| `clickstack` | Deployment (build/env) | `NEXT_PUBLIC_THEME` + html class | Branding: logos, favicons, accent colors, fonts | -| **Color mode** | `light` \| `dark` \| `system` | End user (preferences UI) | `localStorage: hdx-user-preferences` | Light/dark appearance: backgrounds, text, borders | - -Each deployment ships **one** brand theme. Users can flip between light and -dark inside that brand but cannot switch brands in production. In dev you -can override the brand via `window.__HDX_THEME.set('clickstack')`. - -The runtime wiring is: - -1. Server-side (`pages/_document.tsx`) puts `theme-hyperdx` or - `theme-clickstack` on `` based on `NEXT_PUBLIC_THEME`. -2. An inline script (`SystemColorSchemeScript`) sets - `data-mantine-color-scheme="light|dark"` on `` from - `localStorage.hdx-user-preferences.colorMode` before React hydrates. -3. SCSS in `packages/app/src/theme/themes/{brand}/_tokens.scss` defines all - semantic CSS variables (`--color-bg-body`, `--color-text-primary`, …) - inside `.theme-{brand}[data-mantine-color-scheme='{mode}']` selectors — - one block per (brand × mode) combination, four blocks total. -4. Mantine config (`{brand}/mantineTheme.ts`) sets `primaryColor`, - font, spacing, and per-component overrides — most colors come back out - via CSS vars rather than Mantine palette entries. -5. React reads the active brand via `useAppTheme()` (rarely needed — - prefer CSS vars). +The product is ClickStack. There is no brand switch, no `NEXT_PUBLIC_THEME`, +and no second palette. -**Hard rules**: +| Concept | Values | Who controls it | Stored in | What it affects | +| -------------- | ----------------------------- | ------------------------- | ------------------------------------ | ------------------------------------------------- | +| **Color mode** | `light` \| `dark` \| `system` | End user (preferences) | `localStorage: hdx-user-preferences` | Backgrounds, text, borders | -- **Never** hard-code a hex/named color in a component. Use a semantic CSS - var (`var(--color-bg-surface)`, `var(--color-text-primary)`, …). -- **Never** branch on `themeName` to choose colors. The CSS var already - resolves to the right value per brand. Branching is OK for *layout* or - *content* differences (different copy, different logo placement) — not - colors. -- **Never** confuse `IS_CLICKHOUSE_BUILD` with the theme. That flag gates - *features* (e.g. embedded mode, ClickHouse Cloud onboarding) and is - unrelated to brand colors. A `clickstack`-themed build can have - `IS_CLICKHOUSE_BUILD=false` and vice versa. +The UI font is Inter. Mono faces (IBM Plex Mono, Roboto Mono) stay available +for logs and code. The preferences modal does not offer a font picker. -## Brand theme +Color mode: -### Where the themes are defined +- Values: `'system' | 'light' | 'dark'`. Default `'system'`. +- `'system'` follows `window.matchMedia('(prefers-color-scheme: dark)')`. +- `SystemColorSchemeScript` sets `data-mantine-color-scheme` on `` + before React hydrates. +- `useResolvedColorScheme()` returns `'light' | 'dark'` for `ThemeWrapper`, + which passes it to `MantineProvider` as `forceColorScheme`. -Everything lives under `packages/app/src/theme/`: +Older stored preferences used a `theme` key for light/dark. Migration in +`useUserPreferences.tsx` rewrites that to `colorMode`. Don't reintroduce +the old name. -```text -theme/ -├── index.ts # Registry, validation, DEFAULT_THEME, getDevThemeName -├── types.ts # ThemeName, ThemeConfig, FaviconConfig types -├── ThemeProvider.tsx # AppThemeProvider + useAppTheme/useWordmark/useLogomark hooks -├── semanticColorsGrouped.ts # Grouping metadata for the storybook -├── ChartColors.stories.tsx # Visual reference for chart palette -├── SemanticColors.stories.tsx# Visual reference for semantic vars -├── themes/ -│ ├── _base-tokens.scss # Fallback vars when no theme class is applied (SSR safety) -│ ├── components.module.scss# Shared component overrides (slider marks, etc.) -│ ├── hyperdx/ -│ │ ├── index.ts # ThemeConfig export: name, displayName, logos, favicon, mantineTheme -│ │ ├── _tokens.scss # All semantic CSS vars (dark + light), scoped to .theme-hyperdx -│ │ ├── mantineTheme.ts # Mantine palette + component overrides -│ │ ├── Logomark.tsx # Icon-only logo (used in collapsed sidenav, favicons context) -│ │ └── Wordmark.tsx # Full "HyperDX" wordmark -│ └── clickstack/ -│ ├── index.ts # Same shape as hyperdx/index.ts -│ ├── _tokens.scss # Same shape — adds Click UI palette + yellow brand -│ ├── mantineTheme.ts # Same shape — yellow primaryColor -│ ├── Logomark.tsx -│ └── Wordmark.tsx -└── __tests__/ # ThemeProvider + theme validation tests -``` - -Favicons live under `packages/app/public/favicons/{brand}/`. The -`FaviconConfig` type in `types.ts` enforces the directory/filename -convention via Zod. - -### Each `ThemeConfig` ships: - -```ts -type ThemeConfig = { - name: 'hyperdx' | 'clickstack'; - displayName: string; // 'HyperDX' | 'ClickStack' — used in UI copy - cssClass: string; // 'theme-hyperdx' | 'theme-clickstack' - mantineTheme: MantineThemeOverride; - Wordmark: React.ComponentType; - Logomark: React.ComponentType<{ size?: number }>; - favicon: { svg, png32, png16, appleTouchIcon, themeColor }; -}; +```html + ``` -The registry in `theme/index.ts` validates both themes against a Zod -schema at module load time. In production, a failed validation throws; -in development it logs and falls back to `hyperdx`. +Tokens live in `packages/app/src/theme/_tokens.scss`, scoped to +`[data-mantine-color-scheme='dark']` and +`[data-mantine-color-scheme='light']`. +`packages/app/src/theme/_base-tokens.scss` imports that file. +Mantine component overrides are in `packages/app/src/theme/mantineTheme.ts`. -### How brand resolution works at runtime - -| Phase | Source of truth | Notes | -| --------------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------- | -| SSR (`_document.tsx`) | `process.env.NEXT_PUBLIC_THEME` | Adds `theme-{name}` class to `` so SCSS vars resolve on the first paint. | -| Initial React render | `propsThemeName ?? DEFAULT_THEME` in provider | Matches SSR — never reads localStorage during render to avoid hydration mismatch. | -| Post-hydration (dev only) | `localStorage.hdx-dev-theme` via `getDevThemeName` | Updates state in a `useEffect`. Causes a one-frame flash; intentional for dev UX. | -| Post-hydration (prod) | Stable — no reads from storage | `setTheme`/`toggleTheme` are no-ops in production. Confirmed by the `IS_DEV` gate. | - -`IS_DEV` is true when `NODE_ENV === 'development'` **or** -`NEXT_PUBLIC_IS_LOCAL_MODE === 'true'` — so the OSS local-mode build also -exposes the dev theme switcher in `UserPreferencesModal`. - -### Dev-mode theme switching - -Three ways to flip brand in dev: - -1. **UI**: open the user preferences modal — there's a "Brand theme" - select gated on `isDev`. -2. **Console**: `window.__HDX_THEME.set('clickstack')`, - `window.__HDX_THEME.toggle()`, `window.__HDX_THEME.clear()`. -3. **Storage**: set `localStorage.setItem('hdx-dev-theme', 'clickstack')` - and reload. +**Hard rules**: -`clear()` removes the override and reverts to `NEXT_PUBLIC_THEME` (or -`hyperdx` if unset). +- Don't hard-code a hex or named color in a component. Use a semantic CSS + var (`var(--color-bg-surface)`, `var(--color-text-primary)`, …). +- Don't branch on color mode to pick a semantic color. The var already + resolves. Branch only when a component truly needs a different asset + (for example the heatmap palette). +- Don't confuse `IS_CLICKHOUSE_BUILD` with appearance. That flag gates + features (embedded mode, ClickHouse Cloud onboarding). -## Color mode (light / dark / system) +## Brand -Color mode is **per-user**, persisted to -`localStorage.hdx-user-preferences` under the `colorMode` key. Defined in -`packages/app/src/useUserPreferences.tsx`: +Product name, page titles, and logos come from `packages/app/src/brand/`. +`useBrandDisplayName()` and `usePageTitle()` return ClickStack (plus +`INSTANCE_TITLE_SUFFIX` on titles). `useWordmark()` and `useLogomark()` +return the marks in that folder. Call sites use those hooks. A downstream +build replaces `brand/` and keeps the same call sites. The color tokens +stay shared. -- Values: `'system' | 'light' | 'dark'`. Default `'system'`. -- `'system'` follows `window.matchMedia('(prefers-color-scheme: dark)')` - and reacts to changes. -- The inline `SystemColorSchemeScript` (rendered very early) sets - `data-mantine-color-scheme` before React hydrates so there's no flash. -- `useResolvedColorScheme()` returns the resolved `'light' | 'dark'` for - consumption by `ThemeWrapper` (which forwards it to `MantineProvider` - as `forceColorScheme`). - -The user preferences storage also handles **migration from the legacy -`theme` key** — older versions used `theme: 'light'|'dark'|'system'`; -the migration code in `useUserPreferences.tsx` rewrites it to -`colorMode` so existing users don't lose their preference. Don't -re-introduce the old name. - -### Why two attributes (`class` + `data-attr`)? +```tsx +import { useLogomark, useWordmark } from '@/brand'; -```html - +function TopBar() { + const logo = useLogomark({ size: 24 }); + const wordmark = useWordmark(); + return ( + + {logo} + {wordmark} + + ); +} ``` -The combined selector `.theme-clickstack[data-mantine-color-scheme='dark']` -in `_tokens.scss` lets a single SCSS file define **all four** variants -(2 brands × 2 modes) without duplication at the call site. Each block -redefines `--color-bg-body`, `--color-text`, etc. for that specific -combination. There is no JS branching on brand/mode for color -resolution — CSS handles it. +Favicons are static links in `packages/app/pages/_document.tsx`, under +`packages/app/public/favicons/clickstack/`. -## How to consume themes in code +ClickStack specifics: -### From CSS / SCSS +- Mantine `primaryColor: 'yellow'`. The yellow ramp is the Click UI brand + palette (`--palette-brand-*`) from `theme/_tokens.scss`. +- Accent `#faff69` (`--palette-brand-300`) is for links and outlines, not + chart series. +- Warning tokens use Mantine `orange`, because yellow is the brand gold. +- Most semantic vars reference Click UI globals (`--click-global-color-*`). +- Tabler icons use `stroke-width: 1.5`. -Just use the semantic vars. They resolve automatically based on the -brand + mode classes on ``: +## How to consume colors ```scss .sidenav { @@ -181,339 +96,57 @@ brand + mode classes on ``: color: var(--color-text-sidenav-link); border-right: 1px solid var(--color-border); } - -.sidenav__link[data-active='true'] { - background: var(--color-bg-sidenav-link-active); - color: var(--color-text-sidenav-link-active); -} -``` - -The full list of semantic vars is in -`packages/app/src/theme/semanticColorsGrouped.ts` (used to build the -storybook story). Categories: backgrounds, borders, text, icons, -overlay, states, json (syntax highlight), charts. - -### From React (inline style, when CSS won't reach) - -Use the var string directly in `style={}` — `MantineProvider` doesn't -need to know about it: - -```tsx - ``` -Use **`useMantineColorScheme()`** when you genuinely need to branch on -`light` vs `dark` (e.g. picking a heatmap palette). Don't branch on it -to pick a semantic color — the var does that for you. +The list of semantic vars is in +`packages/app/src/theme/semanticColorsGrouped.ts`. In React, use the var +string in `style={{}}`. Use `useMantineColorScheme()` only when you must +branch on light vs dark. -### From React (reading the active brand) +### Semantic component variants -```tsx -import { useAppTheme, useThemeName, useBrandDisplayName } from '@/theme/ThemeProvider'; +Prefer these over raw Mantine palette props (`color="yellow"`, `c="green"`): -function Header() { - const { theme } = useAppTheme(); // full ThemeConfig - const themeName = useThemeName(); // 'hyperdx' | 'clickstack' - const brand = useBrandDisplayName(); // 'HyperDX' | 'ClickStack' — use in UI copy - // … -} -``` +- `` +- `` +- `` — soft tint, not a solid red fill -Use these only for: +The mapping is `packages/app/src/theme/semanticVariants.ts` +(`SEMANTIC_ALERT_VARS`, `SEMANTIC_TEXT_COLORS`, `SEMANTIC_CONTROL_COLORS`), +consumed by `theme/mantineTheme.ts`. Tokens only, never raw +`--mantine-color-*`. -- **Logo / wordmark rendering** — but prefer `useWordmark()` / - `useLogomark()`, which return memoized JSX. -- **Brand-specific UI copy** — e.g. "Connect ClickStack" vs "Connect HyperDX". -- **Rare layout differences** — e.g. ClickStack hides the font picker - because it's locked to Inter (see `_app.tsx`). +Semantic text (`--color-text-{danger,warning,success,info}`) clears WCAG AA +(4.5:1) on its `-subtle` background in both schemes. Keep the light-mode +`color-mix` darkening on success and warning. -**Don't use `themeName` to pick colors.** Bad: +Storybook: `Components/Alert` and `Design tokens/Semantic variants`. Use the +light/dark toolbar. -```tsx -// ❌ bypasses the whole CSS var system, breaks dark mode, breaks future themes -const accent = themeName === 'clickstack' ? '#faff69' : '#00c28a'; -``` +## Adding a semantic CSS variable -Good: +1. Name it `--color-{category}-{role}[-{state}]`. +2. Add it to both scheme blocks in `theme/_tokens.scss` (dark and light). +3. Add it to the matching group in `theme/semanticColorsGrouped.ts`. +4. Consume it with `var(--color-…)`. -```tsx -// ✅ resolves correctly for both brands and both color modes - -``` +If it backs an Alert, Text, or danger control, wire it through +`semanticVariants.ts` and check the Semantic variants story in both schemes. -### Logos +Chart vars (`--color-chart-*`) have extra steps in `data_viz_colors.md`. +The chart mixins are included inside both scheme selectors so specificity +stays the same when Mantine swaps `data-mantine-color-scheme`. Keep that +duplication. -```tsx -import { useWordmark, useLogomark } from '@/theme/ThemeProvider'; +## Where things live -function TopBar() { - const wordmark = useWordmark(); - const logo = useLogomark({ size: 24 }); - return {logo}{wordmark}; -} -``` - -Both hooks return memoized JSX elements so component identity stays -stable across renders. - -## Semantic component variants (Alert / Text / danger controls) - -On top of the raw `--color-*` vars, we expose **semantic component -variants** so callouts and status text stay token-driven and consistent -across brands and color modes. Reach for these instead of raw Mantine -palette props (`color="yellow"`, `color="red"`, `c="green"`, …). - -- **``** — tinted `-subtle` - background with the title, icon, and **body text** in the semantic - color. -- **``** — semantic inline status - text. -- **``** — a *soft* tinted control - (`--color-bg-danger-subtle` + hover), not a solid red fill. - `warning`/`success` are intentionally not control variants. - -The variant → token mapping is centralized in -**`packages/app/src/theme/themes/semanticVariants.ts`** (single source of -truth: `SEMANTIC_ALERT_VARS`, `SEMANTIC_TEXT_COLORS`, -`SEMANTIC_CONTROL_COLORS`), consumed by both brands' `mantineTheme.ts` -(`Alert.extend`, `Text.extend`, `Button.extend`, `ActionIcon.extend`). It -references only `--color-*` design tokens — never raw -`--mantine-color-*`. - -### Semantic token families - -- **Semantic text**: `--color-text-{danger,warning,success,info}` - (+ `--color-text-success-hover`). Used by `Text` and `Alert` - foregrounds. -- **Subtle backgrounds**: `--color-bg-{danger,warning,success,info}-subtle` - (+ `-subtle-hover`). Scheme-aware — pale tints in **light** (Mantine - `-0`/`-1`), deep tints in **dark** (inlined hex, since the numbered - scale's darkest green/yellow shades are mid-tone and can't hit AA). - Consumed by `Alert` and the `danger` soft control. - -**Accessibility**: every semantic text token clears **WCAG AA (4.5:1)** -on its `-subtle` tint (including hover) in both schemes. In light mode -`success`/`warning` text is darkened past the palette with a small -`color-mix` because `green-9`/`yellow-9`/`orange-9` are mid-tone — -preserve these `color-mix` adjustments when editing. - -**ClickStack `warning` is orange-based**: ClickStack remaps the `yellow` -palette to its brand gold, so its warning tokens use Mantine `orange` -(unremapped) for a true orange warning; HyperDX stays yellow-based. - -Storybook: `Components/Alert` (interactive `Playground`) and -`Design tokens/Semantic variants` — use the Brand and Theme toolbar -toggles to review all combinations. - -## Per-brand differences - -### HyperDX (default, green-first) - -- Mantine `primaryColor: 'green'`, `primaryShade: 8`. -- Brand palette: custom green ramp in `hyperdx/mantineTheme.ts` (peaks - at `#00c28a`). -- Fonts: user-selectable via `useUserPreferences().font` (IBM Plex Sans - default). The font picker is visible in the preferences modal. -- Semantic success **uses the brand green**; that's intentional. A - green chart series next to a green success pill is expected, not a - bug. -- Sidenav background = body background (`--mantine-color-dark-9` in - dark mode). -- Logo: HyperDX wordmark + logomark (SVG, currentColor for theming). - -### ClickStack (yellow-first, Click UI tokens) - -- Mantine `primaryColor: 'yellow'`. The yellow palette is overridden - by the Click UI brand palette (`--palette-brand-50` … - `--palette-brand-900`) in `clickstack/_tokens.scss`. -- Brand accent: `#faff69` (yellow `--palette-brand-300`). Used for - links, primary outlines, accent indicators — but **never for - chart series**, because yellow on a light background fails - contrast and reads as "warning". -- Fonts: locked to Inter. `_app.tsx` overrides - `userPreferences.font` to `'Inter'` when `themeName === 'clickstack'`, - and `UserPreferencesModal.tsx` hides the font picker entirely. Don't - add brand-conditional font logic anywhere else. -- Uses Click UI design tokens (`--click-global-color-*`) as an - intermediate layer. Most semantic vars in `clickstack/_tokens.scss` - reference Click UI globals rather than Mantine palette entries — keep - this layering when extending. -- Sidenav background = body background but uses Click UI neutrals. -- Tabler icons get `stroke-width: 1.5` by default (HyperDX uses the - Mantine default of 2). Defined as a nested rule inside the dark-mode - selector. - -### Shared between both brands - -- Both define **the same set of semantic CSS vars** (see - `semanticColorsGrouped.ts`). Adding a new var means adding it to - **all four** SCSS blocks: hyperdx-dark, hyperdx-light, - clickstack-dark, clickstack-light. -- The semantic chart highlight colors - (`--color-chart-success-highlight`, `-warning-`, `-error-`) are - **identical** across both brands. See `data_viz_colors.md` for the - reasoning. -- The categorical chart palette has the **same hue families** in both - brands; only slot 1 differs (green for HyperDX, blue for ClickStack). - -## SSR / hydration safety - -A few things that look like bugs but are intentional: - -- **`_base-tokens.scss`** defines the same vars as `hyperdx/_tokens.scss` - but **unscoped** (i.e. inside bare `[data-mantine-color-scheme='dark']` - / `[data-mantine-color-scheme='light']` selectors). This is the - fallback for the brief window where the theme class hasn't been added - yet, e.g. during error boundaries or pre-hydration paints. It always - uses HyperDX tokens. **Don't** swap it for ClickStack tokens — it's a - "safe default" not a "guess". -- The chart CSS vars are **duplicated** inside the dark and light - selector blocks (not factored into a shared `.theme-{brand}` block). - This is called out in both `_tokens.scss` files. CSS specificity - requires it: a `.theme-clickstack` rule has lower specificity than - `.theme-clickstack[data-mantine-color-scheme='dark']`, so when - Mantine swaps the data attribute, the unscoped chart vars would be - *overridden by* the scheme-scoped block of the *other* mode. - Keep them duplicated. -- `themeColor` in each favicon config is the **browser chrome color** - (Android address bar, iOS status bar), not a semantic UI color. -- `_document.tsx` re-derives the theme class from - `process.env.NEXT_PUBLIC_THEME` rather than importing - `DEFAULT_THEME`. This is deliberate: `_document.tsx` runs in Node and - importing the full theme module pulls in React components. Keep the - resolution duplicated and minimal. -- `AppThemeProvider` updates `resolvedThemeName` in a `useEffect` - rather than `useSyncExternalStore`. This means in dev there is a - one-frame flash when localStorage overrides the SSR default. That's - the agreed-on trade-off for hydration safety; don't "fix" it by - reading localStorage during render. - -## Adding things - -### Adding a new semantic CSS variable - -1. Pick a name following the existing convention: - `--color-{category}-{role}[-{state}]`, e.g. - `--color-text-link-hover`. -2. Add it to **all four** SCSS blocks: - - `hyperdx/_tokens.scss` → `.theme-hyperdx[data-mantine-color-scheme='dark']` - - `hyperdx/_tokens.scss` → `.theme-hyperdx[data-mantine-color-scheme='light']` - - `clickstack/_tokens.scss` → `.theme-clickstack[data-mantine-color-scheme='dark']` - - `clickstack/_tokens.scss` → `.theme-clickstack[data-mantine-color-scheme='light']` -3. If it should also work pre-hydration, add it to the matching mixin - in `hyperdx/_tokens.scss` (`@mixin dark-mode-tokens` / - `@mixin light-mode-tokens`) so it gets picked up by - `_base-tokens.scss`. -4. Add it to the relevant group in - `theme/semanticColorsGrouped.ts` so the storybook renders it. -5. Consume it via `var(--color-…)` in your component. - -If the token backs a **semantic component variant** (Alert / Text / -danger control), wire it through `theme/themes/semanticVariants.ts` -rather than referencing it directly in each brand's `mantineTheme.ts`, -and verify it in the `Design tokens/Semantic variants` story across both -brands and schemes. - -For chart-specific vars (`--color-chart-*`) there are additional steps — -see `data_viz_colors.md`. - -### Adding a new brand theme (rare) - -If you're adding a third brand: - -1. Add the new name to the `ThemeName` union in `theme/types.ts` and the - `name` enum inside `themeConfigSchema` in `theme/index.ts`. -2. Create `theme/themes/{newbrand}/` with the same five files - (`index.ts`, `_tokens.scss`, `mantineTheme.ts`, `Wordmark.tsx`, - `Logomark.tsx`). -3. Add `@use './newbrand/tokens' as newbrand-tokens;` to - `_base-tokens.scss` if you want it to be the fallback (you almost - certainly don't — keep HyperDX as fallback). -4. Register it in the `themes` map in `theme/index.ts`. -5. Add favicon assets under `public/favicons/{newbrand}/` matching the - `FaviconConfig` regex (`/^\/favicons\/[a-z]+\/[a-z0-9-]+\.{svg,png}$/`). -6. Update `pages/_document.tsx` `getThemeClass()` so the new name is - accepted (the validation list is duplicated there — keep it in sync). -7. Verify both storybook stories (`SemanticColors.stories.tsx` and - `ChartColors.stories.tsx`) render for the new theme. -8. Update this doc and `data_viz_colors.md` with the new brand's - conventions. - -The runtime validation will refuse to load a broken `ThemeConfig` — -prefer to start by copying the hyperdx folder and tweaking incrementally. - -### Adding a new color mode (e.g. high-contrast) - -We don't support this today, and adding it is invasive — every SCSS -block in every theme would need to be duplicated. Don't do this without -a design owner. - -## Anti-patterns - -```tsx - // ❌ raw Mantine palette index - // ❌ hex literal - // ❌ branching on brand for color -const c = useMantineTheme().colors.green[5]; // ❌ reading Mantine palette for theming -import { theme as hyperdxTheme } from '@/theme/themes/hyperdx/mantineTheme'; // ❌ bypassing the registry +```text +packages/app/src/brand/ # display name, page titles, logos +packages/app/src/ThemeWrapper.tsx # MantineProvider + color mode +packages/app/src/theme/_tokens.scss # light and dark color tokens +packages/app/src/theme/_base-tokens.scss +packages/app/src/theme/mantineTheme.ts +packages/app/src/theme/semanticVariants.ts +packages/app/src/theme/semanticColorsGrouped.ts +packages/app/public/favicons/clickstack/ ``` - -Why each is wrong: - -- **Raw Mantine palette**: `dark.9` resolves differently per brand because - ClickStack overrides `--mantine-color-dark-*` to point at its slate - neutrals. The result *might* look right, but it skips the semantic - layer and breaks the moment we tweak the brand mapping. -- **Hex literal**: bypasses light/dark and brand. ClickStack light users - will see a black box on white. -- **Branching on `themeName`**: leaks brand assumptions into every - component. If a third brand appears, every branch needs to be - audited. -- **Reading Mantine palette directly**: same as raw Mantine palette, plus - it forces a re-render on theme change. -- **Importing a brand's `mantineTheme` directly**: skips validation and - the registry. Always go through `useAppTheme()`. - -## Pre-merge checklist for theme-touching PRs - -- [ ] No new hex/named colors in components — everything uses - `var(--color-*)` or, for charts, the helpers from - `data_viz_colors.md`. -- [ ] If a new semantic var was added, it exists in **all four** SCSS - blocks (HyperDX dark + light, ClickStack dark + light) and the - shared mixins where appropriate. -- [ ] Toggled HyperDX ↔ ClickStack (`window.__HDX_THEME.toggle()` in - dev) — the change looks correct in both brands. -- [ ] Toggled light ↔ dark via preferences modal — change looks correct - in both modes. -- [ ] Storybook `Design tokens / Semantic colors` and - `Design tokens / Chart colors` still render and look correct. -- [ ] No new `themeName === 'clickstack'` branches for *colors*; brand - branches are only for *content*, *layout*, or *feature-locked - preferences* (e.g. font picker). -- [ ] No new `IS_CLICKHOUSE_BUILD` checks added in service of branding - — that flag is for features, not appearance. -- [ ] `make ci-lint` and the theme tests in - `packages/app/src/theme/__tests__/` pass. - -## File reference summary - -| What | Where | -| ------------------------------------------- | ---------------------------------------------------------------------------------- | -| Theme registry + validation | `packages/app/src/theme/index.ts` | -| Theme types | `packages/app/src/theme/types.ts` | -| Provider + hooks (`useAppTheme`, etc.) | `packages/app/src/theme/ThemeProvider.tsx` | -| Mantine wrapper (color scheme + fontFamily) | `packages/app/src/ThemeWrapper.tsx` | -| SSR theme class application | `packages/app/pages/_document.tsx` (`getThemeClass`) | -| Color-mode preference + system follow | `packages/app/src/useUserPreferences.tsx` | -| Brand + font selection UI (dev gated) | `packages/app/src/UserPreferencesModal.tsx` | -| Brand-conditional font wiring | `packages/app/pages/_app.tsx` (`AppContent`) | -| HyperDX brand definition | `packages/app/src/theme/themes/hyperdx/{index.ts,_tokens.scss,mantineTheme.ts,…}` | -| ClickStack brand definition | `packages/app/src/theme/themes/clickstack/{index.ts,_tokens.scss,mantineTheme.ts,…}` | -| SSR fallback CSS vars | `packages/app/src/theme/themes/_base-tokens.scss` | -| Semantic var groups (storybook source) | `packages/app/src/theme/semanticColorsGrouped.ts` | -| Semantic component variants (source of truth)| `packages/app/src/theme/themes/semanticVariants.ts` | -| Storybook visual references | `packages/app/src/theme/{SemanticColors,SemanticVariants,ChartColors}.stories.tsx` + `packages/app/src/components/Alert.stories.tsx` | -| Favicon assets | `packages/app/public/favicons/{hyperdx,clickstack}/` | -| Provider tests | `packages/app/src/theme/__tests__/ThemeProvider.test.tsx` | -| Theme validation tests | `packages/app/src/theme/__tests__/index.test.ts` | diff --git a/packages/app/.storybook/preview.tsx b/packages/app/.storybook/preview.tsx index f6672435ee..d33182a0a5 100644 --- a/packages/app/.storybook/preview.tsx +++ b/packages/app/.storybook/preview.tsx @@ -10,8 +10,6 @@ import { } from '../src/config/fonts'; import { ibmPlexMono, inter, roboto, robotoMono } from '../src/fonts'; import { meHandler } from '../src/mocks/handlers'; -import { AppThemeProvider } from '../src/theme/ThemeProvider'; -import { ThemeName } from '../src/theme/types'; import { ThemeWrapper } from '../src/ThemeWrapper'; import '@mantine/core/styles.css'; @@ -52,19 +50,6 @@ export const globalTypes = { ], }, }, - brand: { - name: 'Brand', - description: 'Brand theme', - defaultValue: 'hyperdx', - toolbar: { - icon: 'paintbrush', - title: 'Brand', - items: [ - { value: 'hyperdx', title: 'HyperDX' }, - { value: 'clickstack', title: 'ClickStack' }, - ], - }, - }, font: { name: 'Font', description: 'App font family', @@ -142,7 +127,6 @@ const preview: Preview = { const font = fontMap[selectedFont as keyof typeof fontMap] ?? fontMap.inter; const fontFamily = MANTINE_FONT_MAP[font.name] ?? MANTINE_FONT_MAP.Inter; - const brandTheme = (context.globals.brand || 'hyperdx') as ThemeName; const layout = context.parameters.layout ?? 'centered'; @@ -166,14 +150,12 @@ const preview: Preview = { fontClassName={font.nextFont.className} /> - - - - - + + + ); diff --git a/packages/app/package.json b/packages/app/package.json index a0f735174e..d2fb34b072 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -11,7 +11,7 @@ "dev": "npx dotenv -e .env.development -- next dev --turbopack", "dev:local": "NEXT_PUBLIC_IS_LOCAL_MODE=true npx dotenv -e .env.development -- next dev --turbopack", "build": "next build --webpack", - "build:clickhouse": "NEXT_PUBLIC_THEME=clickstack NEXT_PUBLIC_IS_LOCAL_MODE=true NEXT_PUBLIC_CLICKHOUSE_BUILD=true next build --webpack && node scripts/prepare-clickhouse-build-export.js", + "build:clickhouse": "NEXT_PUBLIC_IS_LOCAL_MODE=true NEXT_PUBLIC_CLICKHOUSE_BUILD=true next build --webpack && node scripts/prepare-clickhouse-build-export.js", "run:clickhouse": "test -d out && npx rimraf tmp && mkdir tmp && cp -r out tmp/clickstack && echo 'visit http://localhost:3000/clickstack to start' && npx serve tmp -l 3000 || echo 'run build:clickhouse first'", "start": "next start", "lint": "npx eslint . --ext .ts,.tsx --max-warnings 568", diff --git a/packages/app/pages/_app.tsx b/packages/app/pages/_app.tsx index 3e6d401f32..14382f4b13 100644 --- a/packages/app/pages/_app.tsx +++ b/packages/app/pages/_app.tsx @@ -14,20 +14,11 @@ import { } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; -import { DynamicFavicon } from '@/components/DynamicFavicon'; +import { usePageTitle } from '@/brand'; import { IS_LOCAL_MODE, parseResourceAttributes } from '@/config'; -import { - DEFAULT_FONT_VAR, - FONT_VAR_MAP, - MANTINE_FONT_MAP, -} from '@/config/fonts'; +import { MANTINE_FONT_MAP } from '@/config/fonts'; import { ibmPlexMono, inter, roboto, robotoMono } from '@/fonts'; import { fetchServerVersion, installHdxDebug } from '@/hdxDebug'; -import { - AppThemeProvider, - useAppTheme, - usePageTitle, -} from '@/theme/ThemeProvider'; import { ThemeWrapper } from '@/ThemeWrapper'; import { NextApiConfigResponseData } from '@/types'; import { ConfirmProvider } from '@/useConfirm'; @@ -35,7 +26,6 @@ import { SystemColorSchemeScript, useContentFontSize, useResolvedColorScheme, - useUserPreferences, } from '@/useUserPreferences'; import '@mantine/core/styles.css'; @@ -72,8 +62,6 @@ type AppPropsWithLayout = AppProps & { Component: NextPageWithLayout; }; -// Component that renders Head content requiring user preferences -// Must be rendered inside AppThemeProvider to avoid hydration mismatch function AppHeadContent() { const title = usePageTitle(); @@ -87,8 +75,6 @@ function AppHeadContent() { ); } -// Component that uses user preferences for theme wrapper -// Must be rendered inside AppThemeProvider to avoid hydration mismatch function AppContent({ Component, pageProps, @@ -96,28 +82,10 @@ function AppContent({ Component: NextPageWithLayout; pageProps: AppProps['pageProps']; }) { - const { userPreferences } = useUserPreferences(); const resolvedColorScheme = useResolvedColorScheme(); - const { themeName } = useAppTheme(); const { base: contentFontSize, compact: compactContentFontSize } = useContentFontSize(); - // ClickStack theme always uses Inter font - user preference is ignored - // HyperDX theme allows user to select font preference - const isClickStackTheme = themeName === 'clickstack'; - const effectiveFont = isClickStackTheme ? 'Inter' : userPreferences.font; - const selectedMantineFont = effectiveFont - ? MANTINE_FONT_MAP[effectiveFont] || undefined - : undefined; - - useEffect(() => { - // Update CSS variable for global font cascading - if (typeof document !== 'undefined') { - const fontVar = FONT_VAR_MAP[effectiveFont] || DEFAULT_FONT_VAR; - document.documentElement.style.setProperty('--app-font-family', fontVar); - } - }, [effectiveFont]); - useEffect(() => { // Single write point for the content font size preference; tables and // chart CSS read these vars (see styles/app.scss for the defaults). @@ -137,7 +105,7 @@ function AppContent({ return ( @@ -196,10 +164,9 @@ export default function MyApp({ Component, pageProps }: AppPropsWithLayout) { }, []); useEffect(() => { - // Apply font classes to html element for CSS variable resolution. - // Although _document.tsx sets these server-side, they must be re-applied client-side - // during hydration to ensure CSS variables are available for dynamic font switching. - // This is critical for the --app-font-family CSS variable to work across all components. + // Apply font classes to html so next/font CSS variables resolve. + // _document.tsx sets these server-side; re-apply on the client so + // portaled overlays inherit the same families. if (typeof document !== 'undefined') { const fontClasses = [ ibmPlexMono.variable, @@ -213,14 +180,11 @@ export default function MyApp({ Component, pageProps }: AppPropsWithLayout) { return ( - - - - - - - - + + + + + ); } diff --git a/packages/app/pages/_document.tsx b/packages/app/pages/_document.tsx index 50ec1d6afb..25d906b6c7 100644 --- a/packages/app/pages/_document.tsx +++ b/packages/app/pages/_document.tsx @@ -2,25 +2,6 @@ import { Head, Html, Main, NextScript } from 'next/document'; import { IS_CLICKHOUSE_BUILD, IS_NOINDEX } from '@/config'; import { ibmPlexMono, inter, roboto, robotoMono } from '@/fonts'; -import { themes } from '@/theme'; - -// Applied before React hydrates to prevent a flash of the wrong theme. -// Reads the runtime value from window.__ENV (set by __ENV.js) and swaps -// the theme class on so CSS variables are correct on first paint. -const validThemes = Object.keys(themes); -const themeClasses = validThemes.map(t => `theme-${t}`); -const THEME_INIT_SCRIPT = ` -(function () { - var theme = window.__ENV && window.__ENV.NEXT_PUBLIC_THEME; - var valid = ${JSON.stringify(validThemes)}; - if (valid.indexOf(theme) !== -1) { - var html = document.documentElement; - var remove = ${JSON.stringify(themeClasses)}; - for (var i = 0; i < remove.length; i++) html.classList.remove(remove[i]); - html.classList.add('theme-' + theme); - } -})(); -`; export default function Document() { const fontClasses = [ @@ -31,12 +12,35 @@ export default function Document() { ].join(' '); return ( - + {IS_NOINDEX && } {/* eslint-disable-next-line @next/next/no-sync-scripts */} ')).toBe( - DEFAULT_THEME_COLOR, - ); - - // Event handler injection - expect(sanitizeThemeColor('#000000" onload="alert(1)"')).toBe( - DEFAULT_THEME_COLOR, - ); - - // JavaScript protocol - expect(sanitizeThemeColor("javascript:alert('xss')")).toBe( - DEFAULT_THEME_COLOR, - ); - - // Data URI - expect( - sanitizeThemeColor('data:text/html,'), - ).toBe(DEFAULT_THEME_COLOR); - - // CSS injection - expect(sanitizeThemeColor('#000000; background: url(evil.com)')).toBe( - DEFAULT_THEME_COLOR, - ); - }); - - it('should handle edge cases', () => { - // @ts-expect-error Testing runtime behavior with null - expect(sanitizeThemeColor(null)).toBe(DEFAULT_THEME_COLOR); - - // @ts-expect-error Testing runtime behavior with undefined - expect(sanitizeThemeColor(undefined)).toBe(DEFAULT_THEME_COLOR); - - // @ts-expect-error Testing runtime behavior with number - expect(sanitizeThemeColor(123)).toBe(DEFAULT_THEME_COLOR); - - // @ts-expect-error Testing runtime behavior with object - expect(sanitizeThemeColor({})).toBe(DEFAULT_THEME_COLOR); - }); - }); - - describe('DEFAULT_THEME_COLOR', () => { - it('should be a valid hex color', () => { - expect(HEX_COLOR_PATTERN.test(DEFAULT_THEME_COLOR)).toBe(true); - }); - - it('should be the expected value', () => { - expect(DEFAULT_THEME_COLOR).toBe('#25292e'); - }); - }); -}); diff --git a/packages/app/src/components/__tests__/MetricTableModelForm.test.tsx b/packages/app/src/components/__tests__/MetricTableModelForm.test.tsx index 2f1ce9abab..7e34cdd87d 100644 --- a/packages/app/src/components/__tests__/MetricTableModelForm.test.tsx +++ b/packages/app/src/components/__tests__/MetricTableModelForm.test.tsx @@ -51,8 +51,8 @@ jest.mock('@/source', () => ({ }), })); -jest.mock('@/theme/ThemeProvider', () => ({ - useBrandDisplayName: () => 'HyperDX', +jest.mock('@/brand', () => ({ + useBrandDisplayName: () => 'ClickStack', })); jest.mock('@mantine/notifications', () => ({ diff --git a/packages/app/src/components/__tests__/OnboardingModal.test.tsx b/packages/app/src/components/__tests__/OnboardingModal.test.tsx index ac54701a4c..b66ae46f87 100644 --- a/packages/app/src/components/__tests__/OnboardingModal.test.tsx +++ b/packages/app/src/components/__tests__/OnboardingModal.test.tsx @@ -53,8 +53,8 @@ jest.mock('@/hooks/useMetadata', () => ({ useMetadataWithSettings: () => mockMetadata, })); -jest.mock('@/theme/ThemeProvider', () => ({ - useBrandDisplayName: () => 'HyperDX', +jest.mock('@/brand', () => ({ + useBrandDisplayName: () => 'ClickStack', })); jest.mock('@/components/ConnectionForm', () => ({ ConnectionForm: () => null, diff --git a/packages/app/src/components/alerts/AlertRowMenu.tsx b/packages/app/src/components/alerts/AlertRowMenu.tsx index b8560c320e..f18ae76bfc 100644 --- a/packages/app/src/components/alerts/AlertRowMenu.tsx +++ b/packages/app/src/components/alerts/AlertRowMenu.tsx @@ -14,12 +14,12 @@ import { import { useQueryClient } from '@tanstack/react-query'; import api from '@/api'; +import { useBrandDisplayName } from '@/brand'; import { EditAlertModal } from '@/components/alerts/EditAlertModal'; import { EditInlineAlertModal } from '@/components/alerts/EditInlineAlertModal'; import { TerraformHelperPanel } from '@/components/Iac/TerraformHelperPanel'; import { useTerraformSnippets } from '@/components/Iac/useTerraformSnippets'; import { IS_IAC_EXPORT_ENABLED } from '@/config'; -import { useBrandDisplayName } from '@/theme/ThemeProvider'; import type { AlertsPageItem } from '@/types'; import { useConfirm } from '@/useConfirm'; import { intervalToDateRange } from '@/utils/alerts'; diff --git a/packages/app/src/components/alerts/EditAlertModal.tsx b/packages/app/src/components/alerts/EditAlertModal.tsx index 2d670aa2cd..c0864bbe01 100644 --- a/packages/app/src/components/alerts/EditAlertModal.tsx +++ b/packages/app/src/components/alerts/EditAlertModal.tsx @@ -34,6 +34,7 @@ import { IconChartLine, IconInfoCircleFilled } from '@tabler/icons-react'; import { useQueryClient } from '@tanstack/react-query'; import api from '@/api'; +import { useBrandDisplayName } from '@/brand'; import { AlertDisplayFields } from '@/components/AlertDisplayFields'; import { AlertNoteField } from '@/components/AlertNoteField'; import { AlertChannelForm } from '@/components/Alerts'; @@ -42,7 +43,6 @@ import { AlertScheduleFields } from '@/components/AlertScheduleFields'; import { SQLInlineEditorControlled } from '@/components/SQLEditor/SQLInlineEditor'; import { useSavedSearch } from '@/savedSearch'; import { useSource } from '@/source'; -import { useBrandDisplayName } from '@/theme/ThemeProvider'; import type { AlertsPageItem } from '@/types'; import { optionsToSelectData } from '@/utils'; import { diff --git a/packages/app/src/components/alerts/EditInlineAlertModal.tsx b/packages/app/src/components/alerts/EditInlineAlertModal.tsx index 12aecdd0cb..98dbc95907 100644 --- a/packages/app/src/components/alerts/EditInlineAlertModal.tsx +++ b/packages/app/src/components/alerts/EditInlineAlertModal.tsx @@ -8,9 +8,9 @@ import { notifications } from '@mantine/notifications'; import { useQueryClient } from '@tanstack/react-query'; import api from '@/api'; +import { useBrandDisplayName } from '@/brand'; import EditTimeChartForm from '@/components/DBEditTimeChartForm'; import EmptyState from '@/components/EmptyState'; -import { useBrandDisplayName } from '@/theme/ThemeProvider'; import type { AlertsPageItem } from '@/types'; import { useConfirm } from '@/useConfirm'; import { diff --git a/packages/app/src/components/alerts/__tests__/AlertRowMenu.test.tsx b/packages/app/src/components/alerts/__tests__/AlertRowMenu.test.tsx index babbfd2193..31291afee9 100644 --- a/packages/app/src/components/alerts/__tests__/AlertRowMenu.test.tsx +++ b/packages/app/src/components/alerts/__tests__/AlertRowMenu.test.tsx @@ -45,8 +45,8 @@ jest.mock('@/components/alerts/EditInlineAlertModal', () => ({ const confirm = jest.fn().mockResolvedValue(true); jest.mock('@/useConfirm', () => ({ useConfirm: () => confirm })); -jest.mock('@/theme/ThemeProvider', () => ({ - useBrandDisplayName: () => 'HyperDX', +jest.mock('@/brand', () => ({ + useBrandDisplayName: () => 'ClickStack', })); // ObjectId hex: buildImportBlock refuses to emit Terraform for anything else, diff --git a/packages/app/src/components/alerts/__tests__/EditAlertModal.test.tsx b/packages/app/src/components/alerts/__tests__/EditAlertModal.test.tsx index c7054865f1..72d302904e 100644 --- a/packages/app/src/components/alerts/__tests__/EditAlertModal.test.tsx +++ b/packages/app/src/components/alerts/__tests__/EditAlertModal.test.tsx @@ -41,9 +41,9 @@ jest.mock('@/source', () => ({ useSource: () => ({ data: undefined }), })); -jest.mock('@/theme/ThemeProvider', () => ({ +jest.mock('@/brand', () => ({ __esModule: true, - useBrandDisplayName: () => 'HyperDX', + useBrandDisplayName: () => 'ClickStack', })); // Heavy / visual child components are stubbed so the form still renders and diff --git a/packages/app/src/components/alerts/__tests__/EditInlineAlertModal.test.tsx b/packages/app/src/components/alerts/__tests__/EditInlineAlertModal.test.tsx index 6eba1b42ba..b18a9e8f2e 100644 --- a/packages/app/src/components/alerts/__tests__/EditInlineAlertModal.test.tsx +++ b/packages/app/src/components/alerts/__tests__/EditInlineAlertModal.test.tsx @@ -31,9 +31,9 @@ jest.mock('@/api', () => ({ })); jest.mock('@/useConfirm', () => ({ useConfirm: () => jest.fn() })); -jest.mock('@/theme/ThemeProvider', () => ({ +jest.mock('@/brand', () => ({ __esModule: true, - useBrandDisplayName: () => 'HyperDX', + useBrandDisplayName: () => 'ClickStack', })); // The chart editor has its own suite; here it is stubbed to a "save what I was diff --git a/packages/app/src/config/fonts.ts b/packages/app/src/config/fonts.ts index 015dee8345..032f8ae489 100644 --- a/packages/app/src/config/fonts.ts +++ b/packages/app/src/config/fonts.ts @@ -43,14 +43,6 @@ export const MANTINE_FONT_MAP = Object.entries(FONT_CONFIG).reduce( export const DEFAULT_FONT_VAR = DEFAULT_FONT_CONFIG.variable; -// UI options for font selection -export const OPTIONS_FONTS = [ - 'IBM Plex Mono', - 'Roboto Mono', - 'Inter', - 'Roboto', -]; - export type ContentFontSize = 'sm' | 'md' | 'lg'; /** diff --git a/packages/app/src/llm/dashboard/LLMDashboardPage.tsx b/packages/app/src/llm/dashboard/LLMDashboardPage.tsx index 06f4bb7d20..2cdb54d167 100644 --- a/packages/app/src/llm/dashboard/LLMDashboardPage.tsx +++ b/packages/app/src/llm/dashboard/LLMDashboardPage.tsx @@ -26,6 +26,7 @@ import { } from '@mantine/core'; import { IconInfoCircle } from '@tabler/icons-react'; +import { usePageTitle } from '@/brand'; import OnboardingModal from '@/components/OnboardingModal'; import SearchWhereInput, { getStoredLanguage, @@ -39,7 +40,6 @@ import { } from '@/llm/hooks/useLLMDashboardExpressions'; import { getEffectiveTraceSourceId } from '@/ServicesDashboardPage'; import { useSource, useSources } from '@/source'; -import { usePageTitle } from '@/theme/ThemeProvider'; import { useDefaultTimeRange, useNewTimeQuery } from '@/timeQuery'; import { AgentToolCharts } from './AgentToolCharts'; diff --git a/packages/app/src/stories/Brand.stories.tsx b/packages/app/src/stories/Brand.stories.tsx index c8cf5b7667..86dc860f6a 100644 --- a/packages/app/src/stories/Brand.stories.tsx +++ b/packages/app/src/stories/Brand.stories.tsx @@ -1,12 +1,7 @@ -import { Group, Paper, Stack, Text } from '@mantine/core'; +import { Group, Stack, Text } from '@mantine/core'; +import { BRAND_DISPLAY_NAME, useLogomark, useWordmark } from '@/brand'; import { CopySnippet } from '@/components/ClickStackOnboarding/CopySnippet'; -import { - useBrandDisplayName, - useLogomark, - useThemeName, - useWordmark, -} from '@/theme/ThemeProvider'; import { AssetCard } from './AssetCard'; @@ -18,7 +13,7 @@ const story = { }; export default story; -const USAGE = `import { useWordmark, useLogomark } from '@/theme/ThemeProvider'; +const USAGE = `import { useLogomark, useWordmark } from '@/brand'; function TopBar() { const logo = useLogomark({ size: 24 }); @@ -32,32 +27,28 @@ function TopBar() { }`; export const Logos = () => { - const brand = useBrandDisplayName(); - const themeName = useThemeName(); const logomark16 = useLogomark({ size: 16 }); const logomark24 = useLogomark({ size: 24 }); const logomark48 = useLogomark({ size: 48 }); const logomarkDownload = useLogomark({ size: 48 }); const wordmark = useWordmark(); - const wordmarkIsSvg = themeName === 'clickstack'; return (
- {brand} logo + {BRAND_DISPLAY_NAME} logo - Use the Brand toolbar to switch HyperDX and ClickStack, and the Theme - toolbar for light and dark. Prefer{' '} + Use the Theme toolbar for light and dark. Read the marks from{' '} useLogomark {' '} and{' '} useWordmark - {' '} - so the active brand is used automatically. + + .
@@ -90,9 +81,9 @@ export const Logos = () => {
{logomarkDownload} @@ -103,22 +94,14 @@ export const Logos = () => { Wordmark
- {wordmarkIsSvg - ? 'Full brand lockup as a single SVG.' - : 'Logomark plus the HyperDX label in UI type. Download the logomark SVG above; the wordmark is not a standalone SVG.'} + Full brand lockup as a single SVG. - {wordmarkIsSvg ? ( - - {wordmark} - - ) : ( - - {wordmark} - - )} + + {wordmark} +
diff --git a/packages/app/src/theme/ChartColors.stories.tsx b/packages/app/src/theme/ChartColors.stories.tsx index 946b8caee0..6e57c9cc1a 100644 --- a/packages/app/src/theme/ChartColors.stories.tsx +++ b/packages/app/src/theme/ChartColors.stories.tsx @@ -142,10 +142,9 @@ export const AllChartColors = () => ( fontSize: 13, }} > - Semantic chart colors are unified across HyperDX and ClickStack — - `success` aliases categorical `chart-green` and `info` aliases - `chart-blue`. Brand identity for charts is carried by non-chart UI chrome - (Mantine accent, sidebar gradient), not by these tokens. + Semantic chart colors alias the categorical palette: `success` uses + `chart-green` and `info` uses `chart-blue`. The yellow accent stays in + non-chart chrome (Mantine accent, sidebar), not in these tokens.

{SEMANTIC_CHART_COLORS.map(({ name, hex, label }) => ( diff --git a/packages/app/src/theme/SemanticVariants.stories.tsx b/packages/app/src/theme/SemanticVariants.stories.tsx index 736d4b4dab..37c233677e 100644 --- a/packages/app/src/theme/SemanticVariants.stories.tsx +++ b/packages/app/src/theme/SemanticVariants.stories.tsx @@ -10,8 +10,8 @@ import { /** * Showcases the semantic component variants wired to the `--color-text-*` - * design tokens. Use the Brand (HyperDX / ClickStack) and Theme (Light / Dark) - * toolbar toggles to verify each variant across all four combinations. + * design tokens. Use the Theme (Light / Dark) toolbar toggle to verify each + * variant in both color modes. */ const story = { title: 'Design tokens/Semantic variants', diff --git a/packages/app/src/theme/ThemeProvider.tsx b/packages/app/src/theme/ThemeProvider.tsx deleted file mode 100644 index 4ba8c23528..0000000000 --- a/packages/app/src/theme/ThemeProvider.tsx +++ /dev/null @@ -1,256 +0,0 @@ -import React, { - createContext, - use, - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from 'react'; - -import { INSTANCE_TITLE_SUFFIX } from '@/config'; - -import { - DEFAULT_THEME, - getDevThemeName, - getTheme, - IS_DEV, - safeLocalStorageRemove, - safeLocalStorageSet, - THEME_STORAGE_KEY, - themes, -} from './index'; -import { ThemeConfig, ThemeName } from './types'; - -// Type declaration for window namespace (avoids conflicts) -declare global { - interface Window { - __HDX_THEME?: { - current: ThemeName; - set: (name: ThemeName) => void; - toggle: () => void; - clear: () => void; - }; - } -} - -interface ThemeContextValue { - theme: ThemeConfig; - themeName: ThemeName; - availableThemes: ThemeName[]; - // Dev-only functions - setTheme: (name: ThemeName) => void; - toggleTheme: () => void; - clearThemeOverride: () => void; - isDev: boolean; -} - -const ThemeContext = createContext(null); - -export function AppThemeProvider({ - themeName: propsThemeName, - children, -}: { - themeName?: ThemeName; - children: React.ReactNode; -}) { - // SSR/initial render: Always use props or DEFAULT_THEME for hydration consistency. - // The server cannot read localStorage, so we must start with a deterministic value. - // - // HYDRATION NOTE: In dev mode, the useEffect below may update the theme after hydration - // if localStorage contains a different theme. This is intentional for dev testing - // and will cause a brief flash. In production (IS_DEV=false), theme is stable and - // matches server render. To avoid any flash in production, pass themeName prop explicitly. - const [resolvedThemeName, setResolvedThemeName] = useState( - () => propsThemeName ?? DEFAULT_THEME, - ); - - // After hydration, read from localStorage in dev mode only. - // Uses consolidated getDevThemeName() from index.ts as single source of truth. - // This effect only changes state in dev mode, so production has no hydration mismatch. - useEffect(() => { - // If theme is explicitly passed via props, use that (no dev override) - if (propsThemeName) { - setResolvedThemeName(propsThemeName); - return; - } - - // In dev mode only, allow localStorage override for testing themes - if (IS_DEV) { - const devTheme = getDevThemeName(); - setResolvedThemeName(devTheme); - } - }, [propsThemeName]); - - const theme = useMemo(() => { - return getTheme(resolvedThemeName); - }, [resolvedThemeName]); - - // Theme control functions - DEV MODE ONLY - // Brand theme is deployment-configured in production (via NEXT_PUBLIC_THEME). - // These functions are intentionally disabled in production - users should not - // be able to switch brand themes; each deployment is branded for one product. - const setTheme = useCallback((name: ThemeName) => { - if (!IS_DEV) { - console.warn( - 'setTheme only works in development mode. Brand theme is deployment-configured in production.', - ); - return; - } - if (themes[name]) { - safeLocalStorageSet(THEME_STORAGE_KEY, name); - setResolvedThemeName(name); - } - }, []); - - const toggleTheme = useCallback(() => { - if (!IS_DEV) return; - const themeNames = Object.keys(themes) as ThemeName[]; - setResolvedThemeName(current => { - const currentIndex = themeNames.indexOf(current); - const nextIndex = (currentIndex + 1) % themeNames.length; - const nextTheme = themeNames[nextIndex]; - safeLocalStorageSet(THEME_STORAGE_KEY, nextTheme); - return nextTheme; - }); - }, []); - - const clearThemeOverride = useCallback(() => { - safeLocalStorageRemove(THEME_STORAGE_KEY); - setResolvedThemeName(propsThemeName ?? DEFAULT_THEME); - }, [propsThemeName]); - - const contextValue = useMemo( - () => ({ - theme, - themeName: theme.name, - availableThemes: Object.keys(themes) as ThemeName[], - setTheme, - toggleTheme, - clearThemeOverride, - isDev: IS_DEV, - }), - [theme, setTheme, toggleTheme, clearThemeOverride], - ); - - // Track previous theme class for efficient swap - const prevThemeClassRef = useRef(null); - - // Apply theme CSS class to document (single class swap for performance) - useEffect(() => { - if (typeof document !== 'undefined') { - const html = document.documentElement; - const newClass = theme.cssClass; - - // Remove only the previous theme class (not all themes) - if (prevThemeClassRef.current && prevThemeClassRef.current !== newClass) { - html.classList.remove(prevThemeClassRef.current); - } - - // Add new theme class if not already present - if (!html.classList.contains(newClass)) { - html.classList.add(newClass); - } - - prevThemeClassRef.current = newClass; - } - }, [theme]); - - // Dev mode: expose theme API to window (namespaced to avoid global pollution) - useEffect(() => { - if (!IS_DEV || typeof window === 'undefined') return; - - // eslint-disable-next-line no-console - console.info( - `🎨 Theme: ${theme.displayName} (${theme.name})`, - '\n Set via console: window.__HDX_THEME.set("clickstack")', - ); - - // Expose namespaced helper object to window for console access - window.__HDX_THEME = { - current: theme.name, - set: setTheme, - toggle: toggleTheme, - clear: clearThemeOverride, - }; - - // Cleanup on unmount - return () => { - delete window.__HDX_THEME; - }; - }, [theme, setTheme, toggleTheme, clearThemeOverride]); - - return {children}; -} - -export function useAppTheme(): ThemeContextValue { - const context = use(ThemeContext); - if (!context) { - // Fallback for when used outside provider - always use default to avoid hydration issues - const theme = getTheme(DEFAULT_THEME); - return { - theme, - themeName: theme.name, - availableThemes: Object.keys(themes) as ThemeName[], - // No-op functions when outside provider context - setTheme: () => { - console.warn( - 'useAppTheme: setTheme called outside of AppThemeProvider', - ); - }, - toggleTheme: () => { - console.warn( - 'useAppTheme: toggleTheme called outside of AppThemeProvider', - ); - }, - clearThemeOverride: () => { - console.warn( - 'useAppTheme: clearThemeOverride called outside of AppThemeProvider', - ); - }, - isDev: IS_DEV, - }; - } - return context; -} - -// Convenience hooks -// NOTE: These hooks return JSX elements, not component references, to avoid -// creating components during render (which would violate react-hooks/static-components) -export function useWordmark() { - const { theme } = useAppTheme(); - const WordmarkComponent = theme.Wordmark; - return useMemo(() => , [WordmarkComponent]); -} - -export function useLogomark(props?: { size?: number }) { - const { theme } = useAppTheme(); - const LogomarkComponent = theme.Logomark; - return useMemo( - () => , - [LogomarkComponent, props], - ); -} - -// Hook to get current theme name (useful for conditional rendering) -export function useThemeName(): ThemeName { - const { themeName } = useAppTheme(); - return themeName; -} - -/** Hook to get the current theme's display name for UI copy (e.g. "HyperDX" or "ClickStack"). */ -export function useBrandDisplayName(): string { - const { theme } = useAppTheme(); - return theme.displayName; -} - -/** - * Hook to build a ``/`<NextSeo title>` value: brand name plus the - * configured instance label, with an optional page name prepended. - * e.g. usePageTitle('Search') => "Search - HyperDX USA" - */ -export function usePageTitle(page?: string): string { - const brandName = useBrandDisplayName(); - const brandTitle = `${brandName}${INSTANCE_TITLE_SUFFIX}`; - return page ? `${page} - ${brandTitle}` : brandTitle; -} diff --git a/packages/app/src/theme/__tests__/ThemeProvider.test.tsx b/packages/app/src/theme/__tests__/ThemeProvider.test.tsx deleted file mode 100644 index 008239a8f3..0000000000 --- a/packages/app/src/theme/__tests__/ThemeProvider.test.tsx +++ /dev/null @@ -1,229 +0,0 @@ -/** - * Unit tests for ThemeProvider - * - * Tests cover: - * - Context provides correct theme data - * - useAppTheme hook functionality - * - useWordmark and useLogomark hooks - * - Fallback behavior outside provider - * - Theme CSS class application - */ - -import React from 'react'; -import { renderHook } from '@testing-library/react'; - -import { DEFAULT_THEME, themes } from '@/theme/index'; -import { - AppThemeProvider, - useAppTheme, - useLogomark, - usePageTitle, - useThemeName, - useWordmark, -} from '@/theme/ThemeProvider'; - -jest.mock('@/config', () => ({ INSTANCE_TITLE_SUFFIX: ' UK' })); - -// Mock localStorage -let localStorageMock: jest.Mocked<Storage>; - -beforeEach(() => { - localStorageMock = { - getItem: jest.fn().mockReturnValue(null), - setItem: jest.fn(), - removeItem: jest.fn(), - clear: jest.fn(), - key: jest.fn(), - length: 0, - }; - - Object.defineProperty(window, 'localStorage', { - value: localStorageMock, - writable: true, - }); - - // Reset document classList - document.documentElement.className = ''; -}); - -afterEach(() => { - jest.clearAllMocks(); -}); - -describe('ThemeProvider', () => { - describe('AppThemeProvider', () => { - const wrapper = ({ children }: { children: React.ReactNode }) => ( - <AppThemeProvider>{children}</AppThemeProvider> - ); - - it('should provide default theme when no props passed', () => { - const { result } = renderHook(() => useAppTheme(), { wrapper }); - - expect(result.current.theme).toBeDefined(); - expect(result.current.themeName).toBe(DEFAULT_THEME); - }); - - it('should use themeName prop when provided', () => { - const customWrapper = ({ children }: { children: React.ReactNode }) => ( - <AppThemeProvider themeName="clickstack">{children}</AppThemeProvider> - ); - - const { result } = renderHook(() => useAppTheme(), { - wrapper: customWrapper, - }); - - expect(result.current.themeName).toBe('clickstack'); - expect(result.current.theme.name).toBe('clickstack'); - }); - - it('should provide list of available themes', () => { - const { result } = renderHook(() => useAppTheme(), { wrapper }); - - expect(result.current.availableThemes).toEqual( - expect.arrayContaining(['hyperdx', 'clickstack']), - ); - }); - - it('should provide isDev flag', () => { - const { result } = renderHook(() => useAppTheme(), { wrapper }); - - expect(typeof result.current.isDev).toBe('boolean'); - }); - - it('should apply theme CSS class to document', () => { - renderHook(() => useAppTheme(), { wrapper }); - - // Check that exactly one theme class is applied - const appliedThemeClasses = Object.values(themes) - .map(t => t.cssClass) - .filter(cls => document.documentElement.classList.contains(cls)); - - expect(appliedThemeClasses.length).toBe(1); - }); - }); - - describe('useAppTheme outside provider', () => { - it('should return fallback values without crashing', () => { - // Mock console.warn to avoid noise - const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {}); - - const { result } = renderHook(() => useAppTheme()); - - expect(result.current.theme).toBeDefined(); - expect(result.current.themeName).toBe(DEFAULT_THEME); - expect(result.current.availableThemes).toBeDefined(); - - // Calling setTheme outside provider should warn - result.current.setTheme('clickstack'); - expect(warnSpy).toHaveBeenCalled(); - - warnSpy.mockRestore(); - }); - }); - - describe('useWordmark', () => { - const wrapper = ({ children }: { children: React.ReactNode }) => ( - <AppThemeProvider>{children}</AppThemeProvider> - ); - - it('should return a component', () => { - const { result } = renderHook(() => useWordmark(), { wrapper }); - - expect(result.current).toBeDefined(); - expect(typeof result.current).toBe('object'); - }); - }); - - describe('useLogomark', () => { - const wrapper = ({ children }: { children: React.ReactNode }) => ( - <AppThemeProvider>{children}</AppThemeProvider> - ); - - it('should return a component', () => { - const { result } = renderHook(() => useLogomark(), { wrapper }); - - expect(result.current).toBeDefined(); - expect(typeof result.current).toBe('object'); - }); - }); - - describe('usePageTitle', () => { - const wrapper = ({ children }: { children: React.ReactNode }) => ( - <AppThemeProvider>{children}</AppThemeProvider> - ); - - it('appends the brand name and instance suffix with no page name', () => { - const { result } = renderHook(() => usePageTitle(), { wrapper }); - - expect(result.current).toBe('HyperDX UK'); - }); - - it('prepends the page name when given one', () => { - const { result } = renderHook(() => usePageTitle('Search'), { wrapper }); - - expect(result.current).toBe('Search - HyperDX UK'); - }); - }); - - describe('useThemeName', () => { - it('should return current theme name', () => { - const wrapper = ({ children }: { children: React.ReactNode }) => ( - <AppThemeProvider themeName="clickstack">{children}</AppThemeProvider> - ); - - const { result } = renderHook(() => useThemeName(), { wrapper }); - - expect(result.current).toBe('clickstack'); - }); - }); - - describe('theme switching (dev mode)', () => { - const wrapper = ({ children }: { children: React.ReactNode }) => ( - <AppThemeProvider>{children}</AppThemeProvider> - ); - - it('should have setTheme function', () => { - const { result } = renderHook(() => useAppTheme(), { wrapper }); - - expect(typeof result.current.setTheme).toBe('function'); - }); - - it('should have toggleTheme function', () => { - const { result } = renderHook(() => useAppTheme(), { wrapper }); - - expect(typeof result.current.toggleTheme).toBe('function'); - }); - - it('should have clearThemeOverride function', () => { - const { result } = renderHook(() => useAppTheme(), { wrapper }); - - expect(typeof result.current.clearThemeOverride).toBe('function'); - }); - }); - - describe('hydration safety', () => { - it('should start with deterministic theme for SSR consistency', () => { - // Initial render should use DEFAULT_THEME or props, not localStorage - // This ensures server and client render the same initially - const { result } = renderHook(() => useAppTheme(), { - wrapper: ({ children }) => ( - <AppThemeProvider>{children}</AppThemeProvider> - ), - }); - - // Should be deterministic (props or DEFAULT_THEME) - expect(result.current.themeName).toBe(DEFAULT_THEME); - }); - - it('should use props theme for consistent hydration', () => { - const { result } = renderHook(() => useAppTheme(), { - wrapper: ({ children }) => ( - <AppThemeProvider themeName="clickstack">{children}</AppThemeProvider> - ), - }); - - // Props should take precedence for hydration consistency - expect(result.current.themeName).toBe('clickstack'); - }); - }); -}); diff --git a/packages/app/src/theme/__tests__/index.test.ts b/packages/app/src/theme/__tests__/index.test.ts deleted file mode 100644 index 202a7cb31d..0000000000 --- a/packages/app/src/theme/__tests__/index.test.ts +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Unit tests for theme utilities - * - * Tests cover: - * - Theme registry and validation - * - getTheme() function - * - getDevThemeName() function (localStorage-based) - * - Safe localStorage helpers - * - THEME_STORAGE_KEY constant - */ - -import { - DEFAULT_THEME, - getDevThemeName, - getTheme, - safeLocalStorageGet, - safeLocalStorageRemove, - safeLocalStorageSet, - THEME_STORAGE_KEY, - themes, -} from '@/theme/index'; - -describe('theme/index', () => { - beforeEach(() => { - // Clear localStorage before each test - window.localStorage.clear(); - }); - - afterEach(() => { - jest.clearAllMocks(); - window.localStorage.clear(); - }); - - describe('themes registry', () => { - it('should contain hyperdx theme', () => { - expect(themes.hyperdx).toBeDefined(); - expect(themes.hyperdx.name).toBe('hyperdx'); - expect(themes.hyperdx.displayName).toBe('HyperDX'); - }); - - it('should contain clickstack theme', () => { - expect(themes.clickstack).toBeDefined(); - expect(themes.clickstack.name).toBe('clickstack'); - expect(themes.clickstack.displayName).toBe('ClickStack'); - }); - - it('should have required properties for each theme', () => { - Object.values(themes).forEach(theme => { - expect(theme.name).toBeDefined(); - expect(theme.displayName).toBeDefined(); - expect(theme.mantineTheme).toBeDefined(); - expect(theme.Wordmark).toBeDefined(); - expect(theme.Logomark).toBeDefined(); - expect(theme.cssClass).toBeDefined(); - expect(theme.favicon).toBeDefined(); - }); - }); - - it('should have valid favicon config for each theme', () => { - Object.values(themes).forEach(theme => { - expect(theme.favicon.svg).toBeDefined(); - expect(theme.favicon.png32).toBeDefined(); - expect(theme.favicon.png16).toBeDefined(); - expect(theme.favicon.appleTouchIcon).toBeDefined(); - expect(theme.favicon.themeColor).toMatch(/^#[0-9A-Fa-f]{6}$/); - }); - }); - - it('should have unique cssClass for each theme', () => { - const cssClasses = Object.values(themes).map(t => t.cssClass); - const uniqueClasses = new Set(cssClasses); - expect(uniqueClasses.size).toBe(cssClasses.length); - }); - }); - - describe('DEFAULT_THEME', () => { - it('should be a valid theme name', () => { - expect(['hyperdx', 'clickstack']).toContain(DEFAULT_THEME); - }); - - it('should exist in themes registry', () => { - expect(themes[DEFAULT_THEME]).toBeDefined(); - }); - }); - - describe('getTheme', () => { - it('should return hyperdx theme for "hyperdx"', () => { - const theme = getTheme('hyperdx'); - expect(theme.name).toBe('hyperdx'); - }); - - it('should return clickstack theme for "clickstack"', () => { - const theme = getTheme('clickstack'); - expect(theme.name).toBe('clickstack'); - }); - - it('should return default theme when called without arguments', () => { - const theme = getTheme(); - expect(theme).toBeDefined(); - expect(theme.name).toBe(DEFAULT_THEME); - }); - - it('should fallback to hyperdx for invalid theme name', () => { - // @ts-expect-error Testing invalid input - const theme = getTheme('invalid-theme'); - expect(theme.name).toBe('hyperdx'); - }); - - it('should return theme with all required properties', () => { - const theme = getTheme('hyperdx'); - expect(theme.name).toBeDefined(); - expect(theme.displayName).toBeDefined(); - expect(theme.mantineTheme).toBeDefined(); - expect(theme.Wordmark).toBeDefined(); - expect(theme.Logomark).toBeDefined(); - expect(theme.cssClass).toBeDefined(); - expect(theme.favicon).toBeDefined(); - }); - }); - - describe('safeLocalStorageGet', () => { - it('should return value from localStorage', () => { - window.localStorage.setItem(THEME_STORAGE_KEY, 'clickstack'); - const result = safeLocalStorageGet(THEME_STORAGE_KEY); - expect(result).toBe('clickstack'); - }); - - it('should return undefined when localStorage item does not exist', () => { - const result = safeLocalStorageGet('non-existent-key'); - expect(result).toBeUndefined(); - }); - - it('should handle different value types stored as strings', () => { - window.localStorage.setItem('test-key', 'some-value'); - const result = safeLocalStorageGet('test-key'); - expect(result).toBe('some-value'); - }); - }); - - describe('safeLocalStorageSet', () => { - it('should set value in localStorage', () => { - safeLocalStorageSet(THEME_STORAGE_KEY, 'clickstack'); - expect(window.localStorage.getItem(THEME_STORAGE_KEY)).toBe('clickstack'); - }); - - it('should overwrite existing value', () => { - window.localStorage.setItem(THEME_STORAGE_KEY, 'hyperdx'); - safeLocalStorageSet(THEME_STORAGE_KEY, 'clickstack'); - expect(window.localStorage.getItem(THEME_STORAGE_KEY)).toBe('clickstack'); - }); - }); - - describe('safeLocalStorageRemove', () => { - it('should remove item from localStorage', () => { - window.localStorage.setItem(THEME_STORAGE_KEY, 'clickstack'); - safeLocalStorageRemove(THEME_STORAGE_KEY); - expect(window.localStorage.getItem(THEME_STORAGE_KEY)).toBeNull(); - }); - - it('should not throw when removing non-existent key', () => { - expect(() => safeLocalStorageRemove('non-existent-key')).not.toThrow(); - }); - }); - - describe('getDevThemeName', () => { - it('should return DEFAULT_THEME when no localStorage override exists', () => { - // No localStorage override, should use default - const result = getDevThemeName(); - expect(result).toBe(DEFAULT_THEME); - }); - - it('should use localStorage when set', () => { - window.localStorage.setItem(THEME_STORAGE_KEY, 'clickstack'); - const result = getDevThemeName(); - expect(result).toBe('clickstack'); - }); - - it('should ignore invalid localStorage value', () => { - window.localStorage.setItem(THEME_STORAGE_KEY, 'invalid-theme'); - const result = getDevThemeName(); - expect(result).toBe(DEFAULT_THEME); - }); - }); - - describe('THEME_STORAGE_KEY', () => { - it('should be the expected key', () => { - expect(THEME_STORAGE_KEY).toBe('hdx-dev-theme'); - }); - - it('should be a non-empty string', () => { - expect(typeof THEME_STORAGE_KEY).toBe('string'); - expect(THEME_STORAGE_KEY.length).toBeGreaterThan(0); - }); - }); - - describe('theme favicon paths', () => { - it('should have consistent path structure for hyperdx', () => { - const favicon = themes.hyperdx.favicon; - expect(favicon.svg).toContain('/favicons/hyperdx/'); - expect(favicon.png32).toContain('/favicons/hyperdx/'); - expect(favicon.png16).toContain('/favicons/hyperdx/'); - expect(favicon.appleTouchIcon).toContain('/favicons/hyperdx/'); - }); - - it('should have consistent path structure for clickstack', () => { - const favicon = themes.clickstack.favicon; - expect(favicon.svg).toContain('/favicons/clickstack/'); - expect(favicon.png32).toContain('/favicons/clickstack/'); - expect(favicon.png16).toContain('/favicons/clickstack/'); - expect(favicon.appleTouchIcon).toContain('/favicons/clickstack/'); - }); - }); -}); diff --git a/packages/app/src/theme/_base-tokens.scss b/packages/app/src/theme/_base-tokens.scss new file mode 100644 index 0000000000..6ce1c06d1e --- /dev/null +++ b/packages/app/src/theme/_base-tokens.scss @@ -0,0 +1,16 @@ +/* Design tokens. ClickStack is the only palette; light and dark are + * selected with data-mantine-color-scheme. Importing the tokens file + * emits those selectors. */ + +@use './tokens'; + +/* + * Menu.Item + color="red": Mantine inlines --menu-item-color as red-6 while + * --menu-item-hover uses red-light-hover. `Menu.extend` styles do not reach items + * because Popover defaults to withinPortal — the dropdown is outside the Menu + * root, so component-scoped theme CSS never matches. Global rule + !important + * beats inline vars; substring matches Mantine red light hover token. + */ +[data-menu-item][style*='red-light-hover'] { + --menu-item-color: var(--mantine-color-red-light-color) !important; +} diff --git a/packages/app/src/theme/themes/_chart-categorical-tokens.scss b/packages/app/src/theme/_chart-categorical-tokens.scss similarity index 74% rename from packages/app/src/theme/themes/_chart-categorical-tokens.scss rename to packages/app/src/theme/_chart-categorical-tokens.scss index 4c9454babf..9ed075ac81 100644 --- a/packages/app/src/theme/themes/_chart-categorical-tokens.scss +++ b/packages/app/src/theme/_chart-categorical-tokens.scss @@ -1,15 +1,10 @@ -/* Shared Chart Tokens - used by both theme files */ +/* Shared chart tokens */ /* - * Categorical hues and semantic chart colors are unified across HyperDX and - * ClickStack. This file is the SCSS source of truth for both layers; each - * brand theme `@use`s it and `@include`s the mixins inside its per-theme - * `chart-tokens` mixin (categorical first, then semantic — semantics reference - * `var(--color-chart-green)` / `var(--color-chart-blue)`). - * - * Per-brand overrides: if a future brand needs a different semantic hex, - * declare it in that theme's `chart-tokens` mixin *after* the shared - * `@include chart-semantic-tokens` call. + * Categorical hues and semantic chart colors. This file is the SCSS source + * of truth; `_tokens.scss` `@use`s it and `@include`s the mixins + * inside its `chart-tokens` mixin (categorical first, then semantic — + * semantics reference `var(--color-chart-green)` / `var(--color-chart-blue)`). * * Categorical hues — React reads these from `CATEGORICAL_HEX_BY_TOKEN` in * `packages/app/src/utils.ts` directly (`getColorFromCSSVariable` / @@ -41,7 +36,7 @@ } /* - * Semantic chart colors — unified on both brands. All four semantic vars + * Semantic chart colors. All four semantic vars * alias their matching categorical hue var so a future tweak to e.g. * `--color-chart-orange` propagates to `--color-chart-warning` without * a second edit. Must be `@include`d after `chart-categorical-tokens`. diff --git a/packages/app/src/theme/themes/clickstack/_tokens.scss b/packages/app/src/theme/_tokens.scss similarity index 98% rename from packages/app/src/theme/themes/clickstack/_tokens.scss rename to packages/app/src/theme/_tokens.scss index b88e7a86d5..c9087ba403 100644 --- a/packages/app/src/theme/themes/clickstack/_tokens.scss +++ b/packages/app/src/theme/_tokens.scss @@ -1,6 +1,6 @@ -/* ClickStack Theme Design Tokens */ +/* Design tokens */ -/* Yellow/Gold accent theme for ClickStack branding */ +/* Yellow/Gold accent */ /* Uses Click UI design tokens */ @@ -14,7 +14,7 @@ * `chart-categorical-tokens` partial (two mixins: hues, then semantics). */ -@use '../chart-categorical-tokens' as shared-chart; +@use './chart-categorical-tokens' as shared-chart; @mixin chart-tokens { @include shared-chart.chart-categorical-tokens; @@ -22,7 +22,7 @@ } /* Dark Mode */ -.theme-clickstack[data-mantine-color-scheme='dark'] { +[data-mantine-color-scheme='dark'] { /* Brand Palette - Yellow/Gold */ --palette-brand-50: #ffffe8; --palette-brand-100: #feffba; @@ -249,7 +249,7 @@ } /* Light Mode */ -.theme-clickstack[data-mantine-color-scheme='light'] { +[data-mantine-color-scheme='light'] { /* Brand Palette - Yellow/Gold */ --palette-brand-50: #ffffe8; --palette-brand-100: #feffc2; @@ -499,8 +499,8 @@ * keeps this independent of Mantine's auto-generated CSS module class * names. `--click-global-color-background-default` is already * scheme-aware: dark in dark mode, white in light mode, so the same - * declaration handles both themes. */ -.theme-clickstack input[role='switch'][data-checked='true'] + * { + * declaration handles both color modes. */ +input[role='switch'][data-checked='true'] + * { --switch-text-color: var(--click-global-color-background-default); --switch-thumb-bg: var(--click-global-color-background-default); } diff --git a/packages/app/src/theme/themes/components.module.scss b/packages/app/src/theme/components.module.scss similarity index 100% rename from packages/app/src/theme/themes/components.module.scss rename to packages/app/src/theme/components.module.scss diff --git a/packages/app/src/theme/index.ts b/packages/app/src/theme/index.ts deleted file mode 100644 index 5429f9f7d1..0000000000 --- a/packages/app/src/theme/index.ts +++ /dev/null @@ -1,277 +0,0 @@ -import { env } from 'next-runtime-env'; -import { z } from 'zod'; - -import { clickstackTheme } from './themes/clickstack'; -import { hyperdxTheme } from './themes/hyperdx'; -import { ThemeConfig, ThemeName } from './types'; - -/** - * Brand Theme System - * - * DESIGN DECISION: Brand theme (hyperdx/clickstack) is DEPLOYMENT-CONFIGURED, not user-selectable. - * - * - Production: Theme is set via NEXT_PUBLIC_THEME environment variable at build/deploy time. - * Each deployment is branded for a specific product (HyperDX or ClickStack). - * Users cannot and should not change the brand theme. - * - * - Development: Theme switching is enabled for testing via: - * - localStorage: hdx-dev-theme (persisted via dev UI) - * - * This is intentionally different from colorMode (light/dark), which IS user-selectable. - */ - -// Zod schema for validating ThemeConfig structure -// Note: React components and MantineThemeOverride are validated at runtime -// but cannot be fully validated with Zod schemas -const faviconConfigSchema = z.object({ - svg: z - .string() - .regex( - /^\/favicons\/[a-z]+\/[a-z0-9-]+\.svg$/, - 'SVG favicon path must match /favicons/{theme}/{name}.svg', - ), - png32: z - .string() - .regex( - /^\/favicons\/[a-z]+\/[a-z0-9-]+\.png$/, - 'PNG32 favicon path must match /favicons/{theme}/{name}.png', - ), - png16: z - .string() - .regex( - /^\/favicons\/[a-z]+\/[a-z0-9-]+\.png$/, - 'PNG16 favicon path must match /favicons/{theme}/{name}.png', - ), - appleTouchIcon: z - .string() - .regex( - /^\/favicons\/[a-z]+\/[a-z0-9-]+\.png$/, - 'Apple Touch Icon path must match /favicons/{theme}/{name}.png', - ), - themeColor: z.string().regex(/^#[0-9A-F]{6}$/i, 'Must be a valid hex color'), -}); - -const themeConfigSchema = z.object({ - name: z.enum(['hyperdx', 'clickstack']), - displayName: z.string().min(1), - cssClass: z.string().min(1), - favicon: faviconConfigSchema, - // Wordmark and Logomark are React components - validate they exist and are callable - Wordmark: z - .any() - .refine( - val => typeof val === 'function' || (val && typeof val === 'object'), - 'Wordmark must be a React component', - ), - Logomark: z - .any() - .refine( - val => typeof val === 'function' || (val && typeof val === 'object'), - 'Logomark must be a React component', - ), - // mantineTheme is complex - just check it exists - mantineTheme: z - .any() - .refine( - val => val !== null && val !== undefined, - 'mantineTheme must be defined', - ), -}); - -/** - * Validates a theme configuration at runtime. - * Throws an error with details if validation fails. - * - * @param theme - Theme configuration to validate - * @param themeName - Name of the theme (for error messages) - * @throws Error if theme is invalid - */ -function validateThemeConfig( - theme: unknown, - themeName: string, -): asserts theme is ThemeConfig { - try { - themeConfigSchema.parse(theme); - } catch (error) { - if (error instanceof z.ZodError) { - const details = error.errors - .map(e => `${e.path.join('.')}: ${e.message}`) - .join('; '); - throw new Error( - `Invalid theme configuration for "${themeName}": ${details}`, - ); - } - throw error; - } -} - -// Validate themes at module load time -try { - validateThemeConfig(hyperdxTheme, 'hyperdx'); - validateThemeConfig(clickstackTheme, 'clickstack'); -} catch (error) { - // Log error but don't crash - fallback to default theme - console.error( - '[Theme Validation] Failed to validate theme configurations:', - error, - ); - // In production, we might want to throw to prevent deployment with invalid configs - if (process.env.NODE_ENV === 'production') { - throw error; - } -} - -// Theme registry -export const themes: Record<ThemeName, ThemeConfig> = { - hyperdx: hyperdxTheme, - clickstack: clickstackTheme, -}; - -// Check if we're in development/local mode -export const IS_DEV = - process.env.NODE_ENV === 'development' || - process.env.NEXT_PUBLIC_IS_LOCAL_MODE === 'true'; - -// LocalStorage key for dev theme override (exported for ThemeProvider) -export const THEME_STORAGE_KEY = 'hdx-dev-theme'; - -// Validate that a theme name is valid -export function isValidThemeName( - name: string | null | undefined, -): name is ThemeName { - return name != null && name in themes; -} - -// Safe localStorage access (handles private browsing, SSR, etc.) -export function safeLocalStorageGet(key: string): string | undefined { - try { - if (typeof window === 'undefined') return undefined; - return localStorage.getItem(key) ?? undefined; - } catch { - // localStorage may throw in private browsing or when disabled - return undefined; - } -} - -export function safeLocalStorageSet(key: string, value: string): void { - try { - if (typeof window === 'undefined') return; - localStorage.setItem(key, value); - } catch { - // localStorage may throw in private browsing or when disabled - } -} - -export function safeLocalStorageRemove(key: string): void { - try { - if (typeof window === 'undefined') return; - localStorage.removeItem(key); - } catch { - // localStorage may throw in private browsing or when disabled - } -} - -// Default theme (validated against registry, falls back to hyperdx) -// Use runtimeEnv so the theme can be changed at container start-up -// without rebuilding the Next.js bundle. -function getEnvTheme(): ThemeName { - const value = env('NEXT_PUBLIC_THEME'); - return isValidThemeName(value) ? value : 'hyperdx'; -} - -let resolvedDefaultTheme: ThemeName = getEnvTheme(); - -// Validate that the resolved default theme exists and is valid -if (!themes[resolvedDefaultTheme]) { - console.warn( - `[Theme Validation] Theme "${resolvedDefaultTheme}" from NEXT_PUBLIC_THEME not found in registry. Falling back to "hyperdx".`, - ); - resolvedDefaultTheme = 'hyperdx'; -} else { - // Validate the theme config structure - try { - validateThemeConfig(themes[resolvedDefaultTheme], resolvedDefaultTheme); - } catch (error) { - console.error( - `[Theme Validation] Theme "${resolvedDefaultTheme}" failed validation. Falling back to "hyperdx".`, - error, - ); - resolvedDefaultTheme = 'hyperdx'; - // In production, throw to prevent deployment with invalid configs - if (process.env.NODE_ENV === 'production') { - throw error; - } - } -} - -export const DEFAULT_THEME: ThemeName = resolvedDefaultTheme; - -/** - * Get the theme name from various sources (dev mode only). - * This is the single source of truth for resolving dev theme names. - * - * Priority: - * 1. localStorage: hdx-dev-theme (persisted via explicit UI action) - * 2. Environment variable: NEXT_PUBLIC_THEME - * 3. Default: hyperdx - */ -export function getDevThemeName(): ThemeName { - if (typeof window === 'undefined') { - return DEFAULT_THEME; - } - - // Check localStorage (set via explicit user action in ThemeProvider) - const storedTheme = safeLocalStorageGet(THEME_STORAGE_KEY); - if (isValidThemeName(storedTheme)) { - return storedTheme; - } - - return DEFAULT_THEME; -} - -// Get theme configuration by name -export function getTheme(name: ThemeName = DEFAULT_THEME): ThemeConfig { - const theme = themes[name] || themes.hyperdx; - - // Runtime validation - ensure theme is valid before returning - // This catches cases where theme config was corrupted after module load - try { - validateThemeConfig(theme, name); - } catch (error) { - console.error( - `[Theme Validation] Theme "${name}" failed runtime validation. Falling back to "hyperdx".`, - error, - ); - // Return hyperdx theme as safe fallback - return themes.hyperdx; - } - - return theme; -} - -/** - * IMPORTANT: To get the current theme in React components, use `useAppTheme()` hook - * from `./ThemeProvider` instead of calling these functions directly. - * - * Why? - * - `useAppTheme()` ensures consistency with ThemeProvider context - * - Prevents hydration mismatches between SSR and client-side rendering - * - Properly handles theme switching in dev mode - * - Matches the theme resolution used throughout the app - * - * Example: - * ```tsx - * import { useAppTheme } from '@/theme/ThemeProvider'; - * - * function MyComponent() { - * const { theme, themeName } = useAppTheme(); - * return <div>{theme.displayName}</div>; - * } - * ``` - * - * These utility functions (`getTheme`, `getDevThemeName`) are for internal use - * by ThemeProvider and should not be used directly in components. - */ - -// Re-export types -export type { ThemeConfig, ThemeName } from './types'; diff --git a/packages/app/src/theme/themes/clickstack/mantineTheme.ts b/packages/app/src/theme/mantineTheme.ts similarity index 97% rename from packages/app/src/theme/themes/clickstack/mantineTheme.ts rename to packages/app/src/theme/mantineTheme.ts index ee902c56d9..c6a520ea88 100644 --- a/packages/app/src/theme/themes/clickstack/mantineTheme.ts +++ b/packages/app/src/theme/mantineTheme.ts @@ -21,17 +21,14 @@ import { SEMANTIC_ALERT_VARS, SEMANTIC_CONTROL_COLORS, SEMANTIC_TEXT_COLORS, -} from '@/theme/themes/semanticVariants'; +} from '@/theme/semanticVariants'; -import componentClasses from '@/theme/themes/components.module.scss'; +import componentClasses from '@/theme/components.module.scss'; import variantClasses from '@styles/variants.module.scss'; /** - * ClickStack Theme - * - * A distinct visual identity for ClickStack branding. - * Primary color: Yellow/Gold accent - * Style: Modern, professional + * App Mantine theme. + * Primary color: yellow/gold accent. */ const makeTheme = ({ fontFamily = '"Inter", sans-serif', @@ -370,7 +367,7 @@ const makeTheme = ({ }, }), // Note: checked-state track-label color and thumb background are - // overridden globally in `clickstack/_tokens.scss` via an + // overridden globally in `theme/_tokens.scss` via an // attribute selector on the checkbox input, because Mantine // forces those values via a `:checked +` sibling selector that // can't be reached from this Mantine vars/styles API. diff --git a/packages/app/src/theme/themes/semanticVariants.ts b/packages/app/src/theme/semanticVariants.ts similarity index 87% rename from packages/app/src/theme/themes/semanticVariants.ts rename to packages/app/src/theme/semanticVariants.ts index d1c03ab262..567d2189ff 100644 --- a/packages/app/src/theme/themes/semanticVariants.ts +++ b/packages/app/src/theme/semanticVariants.ts @@ -1,10 +1,8 @@ /** * Shared semantic component variants (danger / warning / success / info). * - * These map the custom `variant` strings we intercept in each brand theme's - * component overrides onto the semantic design tokens defined in - * `_tokens.scss`. Keeping them here means HyperDX and ClickStack stay in sync - * and there is a single source of truth for what each semantic variant means. + * These map the custom `variant` strings we intercept in the Mantine theme + * onto the semantic design tokens defined in `_tokens.scss`. */ /** `<Text variant="...">` → text color token. */ diff --git a/packages/app/src/theme/themes/_base-tokens.scss b/packages/app/src/theme/themes/_base-tokens.scss deleted file mode 100644 index 451d070a40..0000000000 --- a/packages/app/src/theme/themes/_base-tokens.scss +++ /dev/null @@ -1,33 +0,0 @@ -/* Base Design Tokens - Fallback values when no theme class is applied */ - -/* - * Uses HyperDX theme as default fallback for SSR and initial render. - * This ensures CSS variables are defined before JavaScript applies the theme class. - * - * The hyperdx/_tokens.scss file defines mixins that are reused here, - * avoiding duplication of token definitions. - */ - -@use './hyperdx/tokens' as hyperdx-tokens; -@use './clickstack/tokens' as clickstack-tokens; - -/* Dark Mode (default fallback) - uses HyperDX tokens */ -[data-mantine-color-scheme='dark'] { - @include hyperdx-tokens.dark-mode-tokens; -} - -/* Light Mode (fallback) - uses HyperDX tokens */ -[data-mantine-color-scheme='light'] { - @include hyperdx-tokens.light-mode-tokens; -} - -/* - * Menu.Item + color="red": Mantine inlines --menu-item-color as red-6 while - * --menu-item-hover uses red-light-hover. `Menu.extend` styles do not reach items - * because Popover defaults to withinPortal — the dropdown is outside the Menu - * root, so component-scoped theme CSS never matches. Global rule + !important - * beats inline vars; substring matches Mantine red light hover token. - */ -[data-menu-item][style*='red-light-hover'] { - --menu-item-color: var(--mantine-color-red-light-color) !important; -} diff --git a/packages/app/src/theme/themes/clickstack/index.ts b/packages/app/src/theme/themes/clickstack/index.ts deleted file mode 100644 index 4270911b76..0000000000 --- a/packages/app/src/theme/themes/clickstack/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ThemeConfig } from '@/theme/types'; - -import Logomark from './Logomark'; -import { theme } from './mantineTheme'; -import Wordmark from './Wordmark'; - -export const clickstackTheme: ThemeConfig = { - name: 'clickstack', - displayName: 'ClickStack', - mantineTheme: theme, - Wordmark, - Logomark, - cssClass: 'theme-clickstack', - favicon: { - svg: '/favicons/clickstack/favicon.svg', - png32: '/favicons/clickstack/favicon-32x32.png', - png16: '/favicons/clickstack/favicon-16x16.png', - appleTouchIcon: '/favicons/clickstack/apple-touch-icon.png', - themeColor: '#1a1a1a', // Dark background for ClickStack - }, -}; diff --git a/packages/app/src/theme/themes/hyperdx/Logomark.tsx b/packages/app/src/theme/themes/hyperdx/Logomark.tsx deleted file mode 100644 index 45803043f7..0000000000 --- a/packages/app/src/theme/themes/hyperdx/Logomark.tsx +++ /dev/null @@ -1,27 +0,0 @@ -export default function Logomark({ size = 16 }: { size?: number }) { - return ( - <svg - width={size} - height={size} - viewBox="0 0 512 512" - fill="none" - xmlns="http://www.w3.org/2000/svg" - > - <g clipPath="url(#clip0_614_1164)"> - <path - d="M256 0L477.703 128V384L256 512L34.2975 384V128L256 0Z" - fill="#25E2A5" - /> - <path - d="M311.365 84.4663C314.818 86.9946 316.431 92.1862 315.256 96.9926L284.313 223.563H341.409C344.836 223.563 347.936 226.127 349.295 230.086C350.655 234.046 350.014 238.644 347.665 241.786L210.211 425.598C207.472 429.26 203.089 430.062 199.635 427.534C196.182 425.005 194.569 419.814 195.744 415.007L226.686 288.437H169.591C166.164 288.437 163.064 285.873 161.705 281.914C160.345 277.954 160.986 273.356 163.335 270.214L300.789 86.4023C303.528 82.7403 307.911 81.938 311.365 84.4663Z" - fill="#1E1E1E" - /> - </g> - <defs> - <clipPath id="clip0_614_1164"> - <rect width="512" height="512" fill="white" /> - </clipPath> - </defs> - </svg> - ); -} diff --git a/packages/app/src/theme/themes/hyperdx/Wordmark.tsx b/packages/app/src/theme/themes/hyperdx/Wordmark.tsx deleted file mode 100644 index 9a4e0e4c57..0000000000 --- a/packages/app/src/theme/themes/hyperdx/Wordmark.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; - -import Logomark from './Logomark'; - -export default function Wordmark() { - return ( - <div className="align-items-center d-flex"> - <div - className="me-2" - style={{ - display: 'inline-flex', - alignItems: 'center', - }} - > - <Logomark size={20} /> - </div> - - <span - className="fw-bold mono" - style={{ - fontSize: 15, - }} - > - HyperDX - </span> - </div> - ); -} diff --git a/packages/app/src/theme/themes/hyperdx/_tokens.scss b/packages/app/src/theme/themes/hyperdx/_tokens.scss deleted file mode 100644 index d185840999..0000000000 --- a/packages/app/src/theme/themes/hyperdx/_tokens.scss +++ /dev/null @@ -1,302 +0,0 @@ -/* HyperDX Theme Design Tokens */ - -/* Default theme with green accent */ - -/* - * These mixins define all design tokens for HyperDX theme. - * They are used both here (for .theme-hyperdx scoped selectors) and - * in _base-tokens.scss (for unscoped fallback selectors during SSR). - * - * `chart-tokens` is split out so the chart palette is defined once, - * not duplicated across the dark/light blocks. Both dark and light - * @include it so specificity stays identical to declaring the vars - * inline; Sass inlines the body of the mixin at each call site, so - * the resulting CSS is byte-identical to the previous hand-duplicated - * shape. Categorical and semantic chart tokens come from the shared - * `chart-categorical-tokens` partial (two mixins: hues, then semantics). - */ - -@use '../chart-categorical-tokens' as shared-chart; - -@mixin chart-tokens { - @include shared-chart.chart-categorical-tokens; - @include shared-chart.chart-semantic-tokens; -} - -@mixin dark-mode-tokens { - /* Backgrounds */ - --color-bg-body: var(--mantine-color-dark-9); - --color-bg-surface: var(--mantine-color-dark-5); - --color-bg-inverted: var(--mantine-color-dark-1); - --color-bg-muted: var(--mantine-color-dark-7); - - /* "Sunken" = a recessed backdrop that sits *below* raised content. Use it for - the area behind `--color-bg-body` cards (e.g. dashboard tiles) so the cards - visually pop. It is intentionally darker/greyer than the body itself. */ - --color-bg-sunken: color-mix(in srgb, var(--mantine-color-dark-9), #000 50%); - --color-bg-highlighted: rgb(55 58 64 / 70%); - --color-bg-table-stripe: rgb(255 255 255 / 4%); - --color-bg-sidenav: var(--mantine-color-dark-9); - --color-bg-sidenav-link-active: var(--mantine-color-dark-7); - --color-bg-sidenav-link-active-hover: var(--mantine-color-dark-6); - --color-bg-header: var(--mantine-color-dark-9); - --color-bg-hover: var(--mantine-color-dark-6); - --color-bg-active: var(--mantine-color-dark-5); - - /* Highlight background for an interactive row inside a floating surface - (Select/Combobox options, Menu items, popover/dropdown lists) when it is - hovered or is the currently-selected entry. */ - --color-bg-option-active: var(--mantine-color-dark-5); - --color-bg-field: var(--mantine-color-dark-7); - --color-bg-field-highlighted: var(--mantine-color-dark-6); - --color-bg-field-addon: var(--mantine-color-dark-6); - --color-bg-neutral: var(--mantine-color-dark-4); - --color-bg-brand: var(--mantine-color-green-3); - --color-bg-brand-hover: var(--mantine-color-green-2); - --color-bg-success: var(--mantine-color-green-5); - --color-bg-danger: var(--mantine-color-red-4); - --color-bg-warning: var(--mantine-color-orange-5); - - /* Subtle tinted backgrounds (+ hover) for semantic callouts (Alert, soft - Button/ActionIcon). Deep dark tints inlined as hex — the numbered scale's - darkest shades (`-9`) are mid-tone for green/yellow and can't meet AA with - colored text; these deeper values give ~9-11:1. Hover is one step lighter. */ - --color-bg-danger-subtle: #3d0d0d; - --color-bg-danger-subtle-hover: #651515; - --color-bg-warning-subtle: #3c3310; - --color-bg-warning-subtle-hover: #352d0e; - --color-bg-success-subtle: #0d2913; - --color-bg-success-subtle-hover: #16451f; - --color-bg-info-subtle: #071e34; - --color-bg-info-subtle-hover: #0c3256; - - /* Primary Button - uses brand green colors */ - --color-primary-button-bg: var(--color-bg-brand); - --color-primary-button-bg-hover: var(--color-bg-brand-hover); - --color-primary-button-text: var(--mantine-color-black); - - /* Borders & Dividers */ - --color-border: var(--mantine-color-dark-6); - --color-border-emphasis: var(--mantine-color-dark-4); - --color-border-muted: rgb(255 255 255 / 8%); - - /* Text */ - --color-text: var(--mantine-color-dark-0); - --color-text-inverted: var(--mantine-color-dark-9); - --color-text-primary: var(--mantine-color-green-4); - --color-text-primary-hover: var(--mantine-color-green-3); - --color-text-secondary: var(--mantine-color-dark-2); - --color-text-muted: var(--mantine-color-dark-2); - --color-text-muted-hover: var(--mantine-color-dark-1); - --color-text-brand: var(--mantine-color-green-4); - --color-text-brand-hover: var(--mantine-color-green-3); - --color-text-success: var(--mantine-color-green-4); - --color-text-success-hover: var(--mantine-color-green-3); - --color-text-danger: var(--mantine-color-red-3); - --color-text-warning: var(--mantine-color-yellow-3); - --color-text-info: var(--mantine-color-blue-3); - --color-text-sidenav-link: var(--mantine-color-dark-0); - --color-text-sidenav-link-active: var(--color-text-primary); - - /* Icons */ - --color-icon-primary: var(--mantine-color-dark-1); - --color-icon-muted: var(--mantine-color-dark-4); - - /* Overlay & Backdrop */ - --color-overlay: rgb(0 0 0 / 50%); - --color-backdrop: rgb(0 0 0 / 30%); - - /* States */ - --color-state-hover: var(--mantine-color-dark-6); - --color-state-selected: var(--mantine-color-dark-5); - --color-state-focus: var(--mantine-color-dark-4); - --color-outline-focus: var(--mantine-color-green-4); - - /* Slider */ - --color-slider-bar: var(--mantine-color-green-4); - --color-slider-thumb: var(--mantine-color-green-4); - --color-slider-thumb-border: var(--mantine-color-green-4); - --color-slider-dot: var(--mantine-color-dark-2); - --color-slider-dot-active: var(--mantine-color-green-8); - - /* Code / Misc UI */ - --color-bg-code: var(--mantine-color-dark-7); - --color-border-code: var(--mantine-color-dark-6); - --color-bg-kbd: var(--mantine-color-dark-9); - - /* JSON Syntax Highlighting */ - --color-json-string: var(--mantine-color-green-3); - --color-json-number: var(--mantine-color-orange-3); - --color-json-boolean: var(--mantine-color-orange-3); - --color-json-key: var(--mantine-color-violet-3); - --color-json-object: var(--mantine-color-green-3); - --color-json-array: var(--mantine-color-green-3); - --color-json-punctuation: var(--mantine-color-dark-4); - - @include chart-tokens; - - /* Visualization Range Selector (minimap viewports, brush ranges, etc.) */ - --color-viz-range-handle: var(--mantine-color-dark-2); - --color-viz-range-handle-grip: rgb(255 255 255 / 45%); - --color-viz-range-border: var(--mantine-color-dark-3); - --color-viz-range-overlay: rgb(0 0 0 / 20%); - --color-viz-range-brush: rgb(100 149 237 / 25%); - --color-viz-range-brush-border: rgb(100 149 237 / 60%); - - /* Shadows */ - --shadow-drawer: -4px 0 24px rgb(0 0 0 / 25%); - - /* Mantine Overrides */ - --mantine-color-body: var(--color-bg-body) !important; - --mantine-color-text: var(--color-text); -} - -@mixin light-mode-tokens { - /* Backgrounds - inverted (dark becomes light) */ - --color-bg-body: var(--mantine-color-white); - --color-bg-surface: var(--mantine-color-white); - --color-bg-inverted: var(--mantine-color-dark-3); - --color-bg-muted: #f6f6fa; - - /* "Sunken" = a recessed backdrop that sits *below* raised content. Use it for - the area behind `--color-bg-body` cards (e.g. dashboard tiles) so the cards - visually pop. It is intentionally slightly darker than the body itself. */ - --color-bg-sunken: #fafafc; - --color-bg-highlighted: rgb(230 232 237 / 70%); - --color-bg-table-stripe: rgb(0 0 0 / 3%); - --color-bg-sidenav: var(--mantine-color-white); - --color-bg-sidenav-link-active: #ebebef; - --color-bg-sidenav-link-active-hover: var(--mantine-color-gray-2); - --color-bg-header: var(--mantine-color-gray-1); - --color-bg-modal: var(--mantine-color-white); - --color-bg-hover: var(--mantine-color-gray-1); - --color-bg-active: var(--mantine-color-gray-4); - - /* Highlight background for an interactive row inside a floating surface - (Select/Combobox options, Menu items, popover/dropdown lists) when it is - hovered or is the currently-selected entry. */ - --color-bg-option-active: var(--color-bg-sidenav-link-active); - --color-bg-field: #f9f9fc; - --color-bg-field-highlighted: var(--mantine-color-white); - --color-bg-field-addon: var(--mantine-color-white); - --color-bg-neutral: var(--mantine-color-gray-5); - --color-bg-brand: var(--mantine-color-green-7); - --color-bg-brand-hover: var(--mantine-color-green-8); - --color-bg-success: var(--mantine-color-green-8); - --color-bg-danger: var(--mantine-color-red-8); - --color-bg-warning: var(--mantine-color-yellow-8); - - /* Subtle tinted backgrounds (+ hover) for semantic callouts (Alert, soft - Button/ActionIcon). Light mode uses Mantine's `-0` (bg) / `-1` (hover) - shades. */ - --color-bg-danger-subtle: var(--mantine-color-red-0); - --color-bg-danger-subtle-hover: var(--mantine-color-red-1); - --color-bg-warning-subtle: var(--mantine-color-yellow-0); - --color-bg-warning-subtle-hover: var(--mantine-color-yellow-1); - --color-bg-success-subtle: var(--mantine-color-green-0); - --color-bg-success-subtle-hover: var(--mantine-color-green-1); - --color-bg-info-subtle: var(--mantine-color-blue-0); - --color-bg-info-subtle-hover: var(--mantine-color-blue-1); - - /* Primary Button - uses brand green colors */ - --color-primary-button-bg: var(--color-bg-brand); - --color-primary-button-bg-hover: var(--color-bg-brand-hover); - --color-primary-button-text: var(--mantine-color-white); - - /* Borders & Dividers - inverted */ - --color-border: var(--mantine-color-gray-1); - --color-border-emphasis: var(--mantine-color-gray-2); - --color-border-muted: rgb(0 0 0 / 5%); - - /* Text - inverted */ - --color-text: var(--mantine-color-dark-9); - --color-text-inverted: var(--mantine-color-white); - --color-text-primary: var(--mantine-color-green-8); - --color-text-primary-hover: var(--mantine-color-green-9); - --color-text-secondary: var(--mantine-color-gray-5); - --color-text-muted: var(--mantine-color-dark-6); - --color-text-muted-hover: var(--mantine-color-dark-9); - --color-text-brand: var(--mantine-color-green-8); - --color-text-brand-hover: var(--mantine-color-green-9); - - /* danger/success/warning are darkened past their base shade so semantic text - meets WCAG AA (4.5:1) on the light `-subtle` tints: red-9, green-9 -15%, - yellow-9 -30% (green-9/yellow-9 alone are mid-tone and fall short). */ - --color-text-success: color-mix( - in srgb, - var(--mantine-color-green-9), - #000 15% - ); - --color-text-success-hover: var(--mantine-color-green-9); - --color-text-danger: var(--mantine-color-red-9); - --color-text-warning: color-mix( - in srgb, - var(--mantine-color-yellow-9), - #000 30% - ); - --color-text-info: var(--mantine-color-blue-9); - --color-text-sidenav-link: var(--mantine-color-dark-6); - --color-text-sidenav-link-active: var(--mantine-color-green-9); - - /* Icons - inverted */ - --color-icon-primary: var(--mantine-color-dark-8); - --color-icon-muted: var(--mantine-color-dark-5); - - /* Overlay & Backdrop */ - --color-overlay: rgb(0 0 0 / 30%); - --color-backdrop: rgb(0 0 0 / 10%); - - /* States - inverted */ - --color-state-hover: var(--mantine-color-dark-3); - --color-state-selected: var(--mantine-color-dark-4); - --color-state-focus: var(--mantine-color-dark-5); - --color-outline-focus: var(--mantine-color-green-8); - - /* Slider */ - --color-slider-bar: var(--mantine-color-green-8); - --color-slider-thumb: var(--mantine-color-green-8); - --color-slider-thumb-border: var(--mantine-color-green-8); - --color-slider-dot: var(--mantine-color-gray-6); - --color-slider-dot-active: var(--mantine-color-gray-1); - - /* Code / Misc UI - inverted */ - --color-bg-code: var(--mantine-color-gray-0); - --color-border-code: var(--mantine-color-dark-3); - --color-bg-kbd: var(--mantine-color-dark-0); - - /* JSON Syntax Highlighting */ - --color-json-string: var(--mantine-color-green-9); - --color-json-number: var(--mantine-color-orange-7); - --color-json-boolean: var(--mantine-color-orange-7); - --color-json-key: var(--mantine-color-violet-9); - --color-json-object: var(--mantine-color-green-7); - --color-json-array: var(--mantine-color-green-7); - --color-json-punctuation: var(--mantine-color-dark-5); - - @include chart-tokens; - - /* Visualization Range Selector (minimap viewports, brush ranges, etc.) */ - --color-viz-range-handle: var(--mantine-color-gray-5); - --color-viz-range-handle-grip: rgb(255 255 255 / 80%); - --color-viz-range-border: var(--mantine-color-gray-4); - --color-viz-range-overlay: rgb(0 0 0 / 10%); - --color-viz-range-brush: rgb(66 105 208 / 20%); - --color-viz-range-brush-border: rgb(66 105 208 / 50%); - - /* Shadows */ - --shadow-drawer: -4px 0 24px rgb(0 0 0 / 4%); - - /* Mantine Overrides */ - --mantine-color-body: var(--color-bg-body); - --mantine-color-text: var(--color-text); -} - -/* Dark Mode - scoped to .theme-hyperdx */ -.theme-hyperdx[data-mantine-color-scheme='dark'] { - @include dark-mode-tokens; -} - -/* Light Mode - scoped to .theme-hyperdx */ -.theme-hyperdx[data-mantine-color-scheme='light'] { - @include light-mode-tokens; -} diff --git a/packages/app/src/theme/themes/hyperdx/index.ts b/packages/app/src/theme/themes/hyperdx/index.ts deleted file mode 100644 index 4f2d722f0f..0000000000 --- a/packages/app/src/theme/themes/hyperdx/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ThemeConfig } from '@/theme/types'; - -import Logomark from './Logomark'; -import { theme } from './mantineTheme'; -import Wordmark from './Wordmark'; - -export const hyperdxTheme: ThemeConfig = { - name: 'hyperdx', - displayName: 'HyperDX', - mantineTheme: theme, - Wordmark, - Logomark, - cssClass: 'theme-hyperdx', - favicon: { - svg: '/favicons/hyperdx/favicon.svg', - png32: '/favicons/hyperdx/favicon-32x32.png', - png16: '/favicons/hyperdx/favicon-16x16.png', - appleTouchIcon: '/favicons/hyperdx/apple-touch-icon.png', - themeColor: '#25292e', // Dark background - }, -}; diff --git a/packages/app/src/theme/themes/hyperdx/mantineTheme.ts b/packages/app/src/theme/themes/hyperdx/mantineTheme.ts deleted file mode 100644 index ad3f31cf0e..0000000000 --- a/packages/app/src/theme/themes/hyperdx/mantineTheme.ts +++ /dev/null @@ -1,422 +0,0 @@ -import { - ActionIcon, - Alert, - Button, - Code, - MantineTheme, - MantineThemeOverride, - rem, - SegmentedControl, - Select, - Slider, - Tabs, - Text, - Tooltip, -} from '@mantine/core'; - -import { - SEMANTIC_ALERT_VARS, - SEMANTIC_CONTROL_COLORS, - SEMANTIC_TEXT_COLORS, -} from '@/theme/themes/semanticVariants'; - -import componentClasses from '@/theme/themes/components.module.scss'; -import focusClasses from '@styles/focus.module.scss'; -import variantClasses from '@styles/variants.module.scss'; - -const makeTheme = ({ - fontFamily = '"IBM Plex Sans", monospace', -}: { - fontFamily?: string; -}): MantineThemeOverride => ({ - cursorType: 'pointer', - defaultRadius: 'sm', - fontFamily, - focusClassName: focusClasses.focusRing, - primaryColor: 'green', - primaryShade: 8, - autoContrast: true, - white: '#fff', - fontSizes: { - xxs: '11px', - xs: '12px', - sm: '13px', - md: '15px', - lg: '16px', - xl: '18px', - }, - spacing: { - xxxs: 'calc(0.375rem * var(--mantine-scale))', - xxs: 'calc(0.5rem * var(--mantine-scale))', - xs: 'calc(0.625rem * var(--mantine-scale))', - sm: 'calc(0.75rem * var(--mantine-scale))', - md: 'calc(1rem * var(--mantine-scale))', - lg: 'calc(1.25rem * var(--mantine-scale))', - xl: 'calc(2rem * var(--mantine-scale))', - }, - colors: { - green: [ - '#eafff6', - '#cdfee7', - '#a0fad5', - '#63f2bf', - '#25e2a5', - '#00c28a', - '#00a475', - '#008362', - '#00674e', - '#005542', - ], - gray: [ - '#FAFAFA', - '#e6e6ee', - '#D7D8DB', - '#aeaeb7', - '#A1A1AA', - '#868691', - '#7e7e8b', - '#6c6c79', - '#5f5f6e', - '#515264', - ], - dark: [ - '#C1C2C5', - '#A6A7AB', - '#909296', - '#5C5F66', - '#373A40', - '#2C2E33', - '#25262B', - '#1A1B1E', - '#141517', - '#101113', - ], - }, - headings: { - fontFamily, - }, - components: { - Code: Code.extend({ - vars: () => ({ - root: { - '--code-bg': 'var(--color-bg-code)', - }, - }), - }), - Tooltip: Tooltip.extend({ - styles: () => ({ - tooltip: { - fontFamily: 'var(--mantine-font-family)', - }, - }), - }), - Modal: { - styles: { - header: { - fontFamily, - fontWeight: 'bold', - }, - }, - }, - InputWrapper: { - styles: { - label: { - marginBottom: 4, - }, - description: { - marginBottom: 8, - lineHeight: 1.3, - }, - }, - }, - Select: Select.extend({ - styles: { - input: { - border: '1px solid var(--color-border)', - }, - }, - }), - Slider: Slider.extend({ - vars: () => ({ - root: { - '--slider-color': 'var(--color-slider-bar)', - }, - }), - styles: { - thumb: { - backgroundColor: 'var(--color-slider-thumb)', - borderColor: 'var(--color-slider-thumb-border)', - }, - }, - classNames: { - mark: componentClasses.sliderMark, - }, - }), - Input: { - styles: { - input: { - backgroundColor: 'var(--color-bg-field)', - border: '1px solid var(--color-border)', - }, - }, - }, - Card: { - styles: (_theme: MantineTheme, props: { variant?: string }) => { - if (props.variant === 'muted') { - return { - root: { - backgroundColor: 'var(--color-bg-muted)', - border: '1px solid var(--color-border)', - }, - }; - } - return { - root: { - backgroundColor: 'var(--color-bg-body)', - }, - }; - }, - }, - Divider: { - styles: { - root: { - borderColor: 'var(--color-border)', - borderTopColor: 'var(--color-border)', - '--divider-color': 'var(--color-border)', - '--item-border-color': 'var(--color-border)', - }, - }, - }, - Accordion: { - styles: (_theme: MantineTheme, props: { variant?: string }) => { - const base = { - control: { - '--item-border-color': 'var(--color-border)', - }, - item: { - borderColor: 'var(--color-border)', - }, - }; - if (props.variant === 'noPadding') { - return { - ...base, - content: { - paddingInline: 0, - }, - control: { - paddingInlineStart: 0, - }, - }; - } - return base; - }, - }, - UnstyledButton: { - styles: { - root: { - '--item-border-color': 'var(--color-border)', - }, - }, - }, - Paper: { - classNames: (_theme: MantineTheme, props: { variant?: string }) => { - if (props.variant === 'muted') { - return { - root: 'paper-muted', - }; - } - return {}; - }, - styles: (_theme: MantineTheme, props: { variant?: string }) => { - if (props.variant === 'muted') { - return { - root: { - backgroundColor: 'var(--color-bg-muted)', - border: '1px solid var(--color-border)', - }, - }; - } - return { - root: { - border: '1px solid var(--color-border)', - }, - }; - }, - }, - Alert: Alert.extend({ - vars: (_theme, props) => { - if (props.variant && props.variant in SEMANTIC_ALERT_VARS) { - return { root: SEMANTIC_ALERT_VARS[props.variant] }; - } - return { root: {} }; - }, - styles: (_theme, props) => { - // Body text follows the semantic accent color (title/icon already do - // via --alert-color); Mantine otherwise forces the message to - // black/white. - if (props.variant && props.variant in SEMANTIC_ALERT_VARS) { - return { message: { color: 'var(--alert-color)' } }; - } - return {}; - }, - }), - Text: Text.extend({ - styles: (_theme, props) => { - if (props.variant && props.variant in SEMANTIC_TEXT_COLORS) { - return { - root: { - color: SEMANTIC_TEXT_COLORS[props.variant], - }, - }; - } - return {}; - }, - }), - Button: Button.extend({ - defaultProps: { - variant: 'primary', - }, - classNames: (_theme, props) => { - if (props.variant === 'link') { - return { root: variantClasses.buttonLink }; - } - return {}; - }, - vars: (_theme, props) => { - const baseVars: Record<string, string> = {}; - - if (props.size === 'xxs') { - baseVars['--button-height'] = rem(22); - baseVars['--button-padding-x'] = rem(4); - baseVars['--button-fz'] = rem(12); - } - - // Use semantic CSS vars for primary button styling - if (props.variant === 'primary') { - baseVars['--button-bg'] = 'var(--color-primary-button-bg)'; - baseVars['--button-hover'] = 'var(--color-primary-button-bg-hover)'; - baseVars['--button-color'] = 'var(--color-primary-button-text)'; - baseVars['--button-hover-color'] = 'var(--color-primary-button-text)'; - } - - if (props.variant === 'secondary') { - baseVars['--button-bg'] = 'var(--color-bg-body)'; - baseVars['--button-hover'] = 'var(--color-bg-muted)'; - baseVars['--button-color'] = 'var(--color-text)'; - baseVars['--button-bd'] = '1px solid var(--color-border)'; - } - - if (props.variant && props.variant in SEMANTIC_CONTROL_COLORS) { - const c = SEMANTIC_CONTROL_COLORS[props.variant]; - baseVars['--button-bg'] = c.bg; - baseVars['--button-hover'] = c.hover; - baseVars['--button-color'] = c.color; - } - - if (props.variant === 'subtle') { - baseVars['--button-bg'] = 'transparent'; - baseVars['--button-hover'] = 'var(--color-bg-hover)'; - baseVars['--button-color'] = 'var(--color-text)'; - baseVars['--button-bd'] = 'none'; - } - - if (props.variant === 'link') { - baseVars['--button-bg'] = 'transparent'; - baseVars['--button-hover'] = 'transparent'; - baseVars['--button-color'] = 'var(--color-text-secondary)'; - baseVars['--button-bd'] = 'none'; - baseVars['--button-padding-x'] = '0'; - } - - return { root: baseVars }; - }, - }), - SegmentedControl: SegmentedControl.extend({ - styles: () => ({ - root: { - background: 'var(--color-bg-body)', - border: '1px solid var(--color-border)', - }, - indicator: { - background: 'var(--color-bg-option-active)', - borderRadius: '2px', - boxShadow: 'none', - }, - }), - }), - Tabs: Tabs.extend({ - vars: () => ({ - root: { - '--tabs-color': 'var(--color-text-brand)', - '--tab-border-color': 'var(--color-border)', - }, - }), - classNames: { - list: componentClasses.tabsList, - tab: componentClasses.tabsTab, - }, - styles: { - tabLabel: { textAlign: 'left' }, - }, - }), - ActionIcon: ActionIcon.extend({ - defaultProps: { - variant: 'subtle', - color: 'gray', - }, - classNames: (_theme, props) => { - if (props.variant === 'link') { - return { root: variantClasses.actionIconLink }; - } - return {}; - }, - vars: (_theme, props) => { - const baseVars: Record<string, string> = {}; - - if (props.variant === 'subtle') { - baseVars['--ai-bg'] = 'transparent'; - baseVars['--ai-hover'] = 'var(--color-bg-hover)'; - baseVars['--ai-color'] = 'var(--color-text)'; - } - - if (props.variant === 'default') { - baseVars['--ai-bg'] = 'var(--color-bg-hover)'; - baseVars['--ai-hover'] = 'var(--color-bg-muted)'; - baseVars['--ai-color'] = 'var(--color-text)'; - baseVars['--ai-bd'] = 'none'; - } - - if (props.variant === 'primary') { - baseVars['--ai-bg'] = 'var(--color-primary-button-bg)'; - baseVars['--ai-hover'] = 'var(--color-primary-button-bg-hover)'; - baseVars['--ai-color'] = 'var(--color-primary-button-text)'; - } - - if (props.variant === 'secondary') { - baseVars['--ai-bg'] = 'var(--color-bg-surface)'; - baseVars['--ai-hover'] = 'var(--color-bg-hover)'; - baseVars['--ai-color'] = 'var(--color-text)'; - baseVars['--ai-bd'] = '1px solid var(--color-border)'; - } - - if (props.variant && props.variant in SEMANTIC_CONTROL_COLORS) { - const c = SEMANTIC_CONTROL_COLORS[props.variant]; - baseVars['--ai-bg'] = c.bg; - baseVars['--ai-hover'] = c.hover; - baseVars['--ai-color'] = c.color; - } - - if (props.variant === 'link') { - baseVars['--ai-bg'] = 'transparent'; - baseVars['--ai-hover'] = 'transparent'; - baseVars['--ai-color'] = 'var(--color-text-secondary)'; - baseVars['--ai-bd'] = 'none'; - } - - return { root: baseVars }; - }, - }), - }, -}); - -export const theme = makeTheme({}); diff --git a/packages/app/src/theme/types.ts b/packages/app/src/theme/types.ts deleted file mode 100644 index 9885588594..0000000000 --- a/packages/app/src/theme/types.ts +++ /dev/null @@ -1,65 +0,0 @@ -import React from 'react'; -import { MantineThemeOverride } from '@mantine/core'; - -/** - * ============================================================================ - * THEMING CONCEPTS: Color Mode vs Brand Theme - * ============================================================================ - * - * This codebase has TWO separate theming concepts: - * - * 1. COLOR MODE (light/dark/system) - * - User-selectable preference stored in `useUserPreferences().colorMode` - * - 'system' follows OS prefers-color-scheme; default is 'system' - * - Affects visual appearance: backgrounds, text colors, etc. - * - Managed by Mantine's color scheme system - * - Persisted to localStorage via `hdx-user-preferences` - * - * 2. BRAND THEME (hyperdx/clickstack) - * - Deployment-configured, NOT user-selectable in production - * - Set via `NEXT_PUBLIC_THEME` environment variable - * - Affects branding: logos, accent colors, favicons - * - Each deployment is branded for one specific product - * - Dev mode allows switching via localStorage (set via dev UI) - * - * WHY SEPARATE? - * - Color mode is personal preference (accessibility, comfort) - * - Brand theme is business identity (product differentiation) - * - A ClickStack deployment should never show HyperDX branding, regardless of color mode - * - * @see useUserPreferences - manages colorMode (user preference) - * @see AppThemeProvider - manages brand theme (deployment config) - */ - -/** - * Brand theme identifier. - * This is DEPLOYMENT-CONFIGURED, not user-selectable in production. - */ -export type ThemeName = 'hyperdx' | 'clickstack'; - -/** - * Favicon configuration for a theme. - * Modern best practice includes multiple formats for broad compatibility. - */ -interface FaviconConfig { - /** SVG favicon - best for modern browsers, scalable */ - svg: string; - /** PNG 32x32 - standard fallback */ - png32: string; - /** PNG 16x16 - for small contexts */ - png16: string; - /** Apple Touch Icon 180x180 - for iOS home screen */ - appleTouchIcon: string; - /** Theme color for browser UI (address bar, etc.) */ - themeColor: string; -} - -export interface ThemeConfig { - name: ThemeName; - displayName: string; - mantineTheme: MantineThemeOverride; - Wordmark: React.ComponentType; - Logomark: React.ComponentType<{ size?: number }>; - cssClass: string; // Applied to html element for CSS variable scoping - favicon: FaviconConfig; -} diff --git a/packages/app/src/useUserPreferences.tsx b/packages/app/src/useUserPreferences.tsx index 88c5ac297b..94fc9f2827 100644 --- a/packages/app/src/useUserPreferences.tsx +++ b/packages/app/src/useUserPreferences.tsx @@ -25,7 +25,7 @@ export type UserPreferences = { */ timeZone: string; timeFormat: '12h' | '24h'; - /** Color mode preference (light/dark/system). Separate from brand theme (hyperdx/clickstack). */ + /** Color mode preference (light/dark/system). */ colorMode: ColorModePreference; font: 'IBM Plex Mono' | 'Roboto Mono' | 'Inter' | 'Roboto'; expandSidebarHeader?: boolean; diff --git a/packages/app/src/utils.ts b/packages/app/src/utils.ts index d438f4fb1c..7cdbf972c7 100644 --- a/packages/app/src/utils.ts +++ b/packages/app/src/utils.ts @@ -395,9 +395,8 @@ export function getLogSeverityLevel({ * * Keep in sync with `CATEGORICAL_PALETTE_TOKENS` in * `@hyperdx/common-utils/dist/types` and with the `--color-chart-{hue}` - * vars in `packages/app/src/theme/themes/_chart-categorical-tokens.scss` - * (the single shared SCSS source for categorical hues; both brand - * themes `@use` it). + * vars in `packages/app/src/theme/_chart-categorical-tokens.scss` + * (the single shared SCSS source for categorical hues). */ type CategoricalChartPaletteToken = (typeof CATEGORICAL_PALETTE_TOKENS)[number]; @@ -441,34 +440,13 @@ type SemanticChartColorKey = | 'errorHighlight'; /** - * Per-brand semantic chart palette. SSR / `getComputedStyle` fallback - * for `getChartColor{Success,Warning,Error,Info,*Highlight}` helpers. + * Semantic chart palette. SSR / `getComputedStyle` fallback for + * `getChartColor{Success,Warning,Error,Info,*Highlight}` helpers. * Live values come from `--color-chart-{success|warning|error|info}[-highlight]` * in `_chart-categorical-tokens.scss` (`chart-semantic-tokens` mixin). - * - * Kept per-brand (instead of collapsed to one object) so the - * `Record<'hyperdx' | 'clickstack', SemanticChartHexes>` constraint - * forces both brands to declare every semantic key — dropping or - * renaming one in either entry becomes a compile error rather than a - * silent runtime divergence between SSR and client. The two entries - * are byte-identical today; collapse to a flat object if and when a - * brand actually needs to diverge. */ -type SemanticChartHexes = Readonly<Record<SemanticChartColorKey, string>>; - -const SEMANTIC_CHART_PALETTE: Readonly< - Record<'hyperdx' | 'clickstack', SemanticChartHexes> -> = { - hyperdx: { - success: '#3ca951', - warning: '#efb118', - error: '#ff725c', - info: '#437eef', - successHighlight: '#80d9b3', - warningHighlight: '#f5c94d', - errorHighlight: '#ffa090', - }, - clickstack: { +const SEMANTIC_CHART_PALETTE: Readonly<Record<SemanticChartColorKey, string>> = + { success: '#3ca951', warning: '#efb118', error: '#ff725c', @@ -476,8 +454,7 @@ const SEMANTIC_CHART_PALETTE: Readonly< successHighlight: '#80d9b3', warningHighlight: '#f5c94d', errorHighlight: '#ffa090', - }, -}; + }; /** * Ordered hex array for positional series assignment. @@ -515,27 +492,6 @@ export { } from '@hyperdx/common-utils/dist/types'; export type { ChartPaletteToken }; -/** - * Detects the active theme by checking for theme classes on documentElement. - * Returns 'clickstack' if theme-clickstack class is present, 'hyperdx' otherwise. - * Note: classList.contains() is O(1) and fast - no caching needed. - */ -function detectActiveTheme(): 'clickstack' | 'hyperdx' { - if (typeof window === 'undefined') { - // SSR: default to hyperdx (can't detect theme without DOM) - return 'hyperdx'; - } - - try { - const isClickStack = - document.documentElement.classList.contains('theme-clickstack'); - return isClickStack ? 'clickstack' : 'hyperdx'; - } catch { - // Fallback if DOM access fails - return 'hyperdx'; - } -} - /** * Returns the Nth categorical chart hex by series index. Index wraps * modulo `CATEGORICAL_PALETTE_TOKENS.length`. @@ -561,10 +517,10 @@ function getColorFromCSSVariable(index: number): string { * always resolve to the same value, and skipping `getComputedStyle` * avoids an unnecessary layout read per series. * - * Semantic tokens (`chart-success`, `-warning`, `-error`) DO vary per - * brand, so they read the matching CSS var (`--color-chart-{name}`) - * via `getComputedStyle` and fall back to the active theme's entry in - * `SEMANTIC_CHART_PALETTE` for SSR / `getComputedStyle` failures. + * Semantic tokens (`chart-success`, `-warning`, `-error`) read the + * matching CSS var (`--color-chart-{name}`) via `getComputedStyle` and + * fall back to `SEMANTIC_CHART_PALETTE` for SSR / `getComputedStyle` + * failures. * * @example * getColorFromCSSToken('chart-blue') // Observable blue (both themes) @@ -612,12 +568,11 @@ function semanticTokenFallback( case 'chart-success': case 'chart-warning': case 'chart-error': { - const theme = detectActiveTheme(); const key = token.slice('chart-'.length) as | 'success' | 'warning' | 'error'; - return SEMANTIC_CHART_PALETTE[theme][key]; + return SEMANTIC_CHART_PALETTE[key]; } default: { // Exhaustiveness assertion: if a new semantic token lands on @@ -725,9 +680,8 @@ export function hashCode(str: string) { } /** - * Theme-aware semantic chart color resolver. Reads `cssVarName` from - * `documentElement` and falls back to the active theme's value from - * `SEMANTIC_CHART_PALETTE` (HyperDX during SSR). + * Semantic chart color resolver. Reads `cssVarName` from + * `documentElement` and falls back to `SEMANTIC_CHART_PALETTE`. * * Charts typically render client-side after data fetching, so hydration * mismatches between the SSR fallback and the live var are rare. @@ -737,7 +691,7 @@ function getSemanticChartColor( key: SemanticChartColorKey, ): string { if (typeof window === 'undefined') { - return SEMANTIC_CHART_PALETTE.hyperdx[key]; + return SEMANTIC_CHART_PALETTE[key]; } try { @@ -750,11 +704,11 @@ function getSemanticChartColor( // Fallback if getComputedStyle fails } - return SEMANTIC_CHART_PALETTE[detectActiveTheme()][key]; + return SEMANTIC_CHART_PALETTE[key]; } -// Semantic chart colors (theme-aware). Read from CSS variables with -// per-theme fallbacks in `SEMANTIC_CHART_PALETTE`. +// Semantic chart colors. Read from CSS variables with fallbacks in +// `SEMANTIC_CHART_PALETTE`. export function getChartColorSuccess(): string { return getSemanticChartColor('--color-chart-success', 'success'); } @@ -768,7 +722,7 @@ export function getChartColorError(): string { } /** Chart blue used for info-level logs and similar "neutral / default" - * series. Same hue as categorical `chart-blue` on both brands. */ + * series. Same hue as categorical `chart-blue`. */ export function getChartColorInfo(): string { return getSemanticChartColor('--color-chart-info', 'info'); } diff --git a/packages/app/styles/app.scss b/packages/app/styles/app.scss index 57a4a590ef..c24a952e9e 100644 --- a/packages/app/styles/app.scss +++ b/packages/app/styles/app.scss @@ -1,7 +1,7 @@ /* stylelint-disable-file */ // stylelint adds '}}' to end of file.. not sure why. Disabled for now. -@use '../src/theme/themes/base-tokens'; +@use '../src/theme/base-tokens'; // Bootstrap utilities only (d-flex, flex-column, m-*, p-*, etc.) @use './_bootstrap-utilities'; diff --git a/packages/common-utils/src/types.ts b/packages/common-utils/src/types.ts index aa17728361..8991efe487 100644 --- a/packages/common-utils/src/types.ts +++ b/packages/common-utils/src/types.ts @@ -259,9 +259,9 @@ export const RootValueExpressionSchema = z * number-tile colors, reference lines, and threshold rules. * * Tokens map to CSS variables in - * `packages/app/src/theme/themes/<theme>/_tokens.scss`: - * chart-{hue} -> --color-chart-{hue} (10 hues, unified across themes) - * chart-success/warning/error -> --color-chart-{success|warning|error} (semantic; unified across brands) + * `packages/app/src/theme/_tokens.scss`: + * chart-{hue} -> --color-chart-{hue} (10 hues) + * chart-success/warning/error -> --color-chart-{success|warning|error} (semantic) * * `chart-info` is a render-time CSS variable (defined in the shared * `chart-semantic-tokens` SCSS mixin) but is intentionally *not* in the @@ -269,7 +269,7 @@ export const RootValueExpressionSchema = z * brand-primary (e.g. info-level log series, `getChartColorInfo()`). * * Storing tokens (not hex) lets user choices reflow correctly across - * themes and color modes; see notes/repo-conventions/hyperdx/tile-styling.md. + * color modes; see notes/repo-conventions/hyperdx/tile-styling.md. * * Lives in common-utils because the schema is shared between the app * and the API; the theme-aware CSS resolver (`getColorFromCSSToken`) From c88655e4e447a065db1ae331d0a1dbba535122ed Mon Sep 17 00:00:00 2001 From: Elizabet Oliveira <elizabet.oliveira@clickhouse.com> Date: Wed, 4 Nov 2026 12:48:56 +0000 Subject: [PATCH 2/5] test(app): cover page titles after the brand move usePageTitle had no test once the theme provider tests were removed. The unused font preference stays so older saved preferences still parse. Co-authored-by: Cursor <cursoragent@cursor.com> --- .../src/brand/__tests__/pageTitle.test.tsx | 20 +++++++++++++++++++ packages/app/src/useUserPreferences.tsx | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 packages/app/src/brand/__tests__/pageTitle.test.tsx diff --git a/packages/app/src/brand/__tests__/pageTitle.test.tsx b/packages/app/src/brand/__tests__/pageTitle.test.tsx new file mode 100644 index 0000000000..25d0172138 --- /dev/null +++ b/packages/app/src/brand/__tests__/pageTitle.test.tsx @@ -0,0 +1,20 @@ +jest.mock('next-runtime-env', () => ({ + env: (key: string) => + key === 'NEXT_PUBLIC_INSTANCE_LABEL' ? 'UK' : undefined, +})); + +import { renderHook } from '@testing-library/react'; + +import { usePageTitle } from '@/brand'; + +describe('usePageTitle', () => { + it('is the brand name plus the instance label when no page is given', () => { + const { result } = renderHook(() => usePageTitle()); + expect(result.current).toBe('ClickStack UK'); + }); + + it('prepends the page name', () => { + const { result } = renderHook(() => usePageTitle('Search')); + expect(result.current).toBe('Search - ClickStack UK'); + }); +}); diff --git a/packages/app/src/useUserPreferences.tsx b/packages/app/src/useUserPreferences.tsx index 94fc9f2827..fec9567332 100644 --- a/packages/app/src/useUserPreferences.tsx +++ b/packages/app/src/useUserPreferences.tsx @@ -27,6 +27,11 @@ export type UserPreferences = { timeFormat: '12h' | '24h'; /** Color mode preference (light/dark/system). */ colorMode: ColorModePreference; + /** + * Left in the stored shape so preferences saved before the font picker + * was removed still parse. The UI always uses Inter and does not read this. + * The default stays the historical value so a read does not rewrite storage. + */ font: 'IBM Plex Mono' | 'Roboto Mono' | 'Inter' | 'Roboto'; expandSidebarHeader?: boolean; /** From 3b834d722109f5386f10ea827a12150b381138bd Mon Sep 17 00:00:00 2001 From: Elizabet Oliveira <elizabet.oliveira@clickhouse.com> Date: Wed, 4 Nov 2026 13:19:11 +0000 Subject: [PATCH 3/5] fix(app): keep Storybook on Inter The app no longer lets users pick a UI font, so stories should not either. Co-authored-by: Cursor <cursoragent@cursor.com> --- packages/app/.storybook/preview.tsx | 64 ++++------------------------- packages/app/src/config/fonts.ts | 48 ++-------------------- 2 files changed, 13 insertions(+), 99 deletions(-) diff --git a/packages/app/.storybook/preview.tsx b/packages/app/.storybook/preview.tsx index d33182a0a5..542cc492a4 100644 --- a/packages/app/.storybook/preview.tsx +++ b/packages/app/.storybook/preview.tsx @@ -3,11 +3,7 @@ import { initialize, mswLoader } from 'msw-storybook-addon'; import type { Preview } from '@storybook/nextjs'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { - DEFAULT_FONT_VAR, - FONT_VAR_MAP, - MANTINE_FONT_MAP, -} from '../src/config/fonts'; +import { MANTINE_FONT_MAP } from '../src/config/fonts'; import { ibmPlexMono, inter, roboto, robotoMono } from '../src/fonts'; import { meHandler } from '../src/mocks/handlers'; import { ThemeWrapper } from '../src/ThemeWrapper'; @@ -50,32 +46,10 @@ export const globalTypes = { ], }, }, - font: { - name: 'Font', - description: 'App font family', - defaultValue: 'inter', - toolbar: { - icon: 'typography', - title: 'Font', - items: [ - { value: 'inter', title: 'Inter' }, - { value: 'roboto', title: 'Roboto' }, - { value: 'ibm-plex-mono', title: 'IBM Plex Mono' }, - { value: 'roboto-mono', title: 'Roboto Mono' }, - ], - }, - }, }; initialize(); -const fontMap = { - inter: { nextFont: inter, name: 'Inter' }, - roboto: { nextFont: roboto, name: 'Roboto' }, - 'ibm-plex-mono': { nextFont: ibmPlexMono, name: 'IBM Plex Mono' }, - 'roboto-mono': { nextFont: robotoMono, name: 'Roboto Mono' }, -} as const; - const NEXT_FONT_VARIABLE_CLASSES = [ inter.variable, roboto.variable, @@ -84,26 +58,14 @@ const NEXT_FONT_VARIABLE_CLASSES = [ ]; /** Mirror `_document.tsx` + `_app.tsx`: font CSS vars live on <html> so body - * and portaled overlays (Popover, Tooltip, Modal) inherit the same family. */ -function StorybookFontSync({ - fontName, - fontClassName, -}: { - fontName: string; - fontClassName: string; -}) { + * and portaled overlays (Popover, Tooltip, Modal) inherit the same family. + * The UI font is Inter. Mono faces stay loaded for logs and code. */ +function StorybookFontSync() { React.useEffect(() => { const html = document.documentElement; html.classList.add(...NEXT_FONT_VARIABLE_CLASSES); - html.classList.add(fontClassName); - html.style.setProperty( - '--app-font-family', - FONT_VAR_MAP[fontName] ?? DEFAULT_FONT_VAR, - ); - return () => { - html.classList.remove(fontClassName); - }; - }, [fontName, fontClassName]); + html.style.setProperty('--app-font-family', 'var(--font-inter)'); + }, []); return null; } @@ -123,16 +85,11 @@ const preview: Preview = { (Story, context) => { const [queryClient] = React.useState(() => createQueryClient()); - const selectedFont = context.globals.font || 'inter'; - const font = - fontMap[selectedFont as keyof typeof fontMap] ?? fontMap.inter; - const fontFamily = MANTINE_FONT_MAP[font.name] ?? MANTINE_FONT_MAP.Inter; - const layout = context.parameters.layout ?? 'centered'; return ( <div - className={font.nextFont.className} + className={inter.className} style={ layout === 'fullscreen' ? { minHeight: '100vh' } @@ -145,14 +102,11 @@ const preview: Preview = { : { width: '100%' } } > - <StorybookFontSync - fontName={font.name} - fontClassName={font.nextFont.className} - /> + <StorybookFontSync /> <QueryClientProvider client={queryClient}> <ThemeWrapper colorScheme={context.globals.theme || 'light'} - fontFamily={fontFamily} + fontFamily={MANTINE_FONT_MAP.Inter} > <Story /> </ThemeWrapper> diff --git a/packages/app/src/config/fonts.ts b/packages/app/src/config/fonts.ts index 032f8ae489..5b7229c858 100644 --- a/packages/app/src/config/fonts.ts +++ b/packages/app/src/config/fonts.ts @@ -1,47 +1,7 @@ -type FontConfig = { - variable: string; - fallback: string; -}; - -const FONT_CONFIG: Record<string, FontConfig> = { - 'IBM Plex Mono': { - variable: 'var(--font-ibm-plex-mono)', - fallback: 'monospace', - }, - 'Roboto Mono': { - variable: 'var(--font-roboto-mono)', - fallback: 'monospace', - }, - Inter: { - variable: 'var(--font-inter)', - fallback: 'sans-serif', - }, - Roboto: { - variable: 'var(--font-roboto)', - fallback: 'sans-serif', - }, -}; - -const DEFAULT_FONT_CONFIG = FONT_CONFIG.Inter; - -// Derived maps for convenience -export const FONT_VAR_MAP = Object.entries(FONT_CONFIG).reduce( - (acc, [name, config]) => { - acc[name] = config.variable; - return acc; - }, - {} as Record<string, string>, -); - -export const MANTINE_FONT_MAP = Object.entries(FONT_CONFIG).reduce( - (acc, [name, config]) => { - acc[name] = `${config.variable}, ${config.fallback}`; - return acc; - }, - {} as Record<string, string>, -); - -export const DEFAULT_FONT_VAR = DEFAULT_FONT_CONFIG.variable; +/** UI font. The app does not offer a font picker. */ +export const MANTINE_FONT_MAP = { + Inter: 'var(--font-inter), sans-serif', +} as const; export type ContentFontSize = 'sm' | 'md' | 'lg'; From 6bb31f7971a846c28561fee35a31b8558d845f04 Mon Sep 17 00:00:00 2001 From: Elizabet Oliveira <elizabet.oliveira@clickhouse.com> Date: Wed, 4 Nov 2026 13:19:24 +0000 Subject: [PATCH 4/5] fix(app): use the sidebar icon to collapse the nav The collapse control used a left arrow. It now uses the sidebar glyph and flips when the nav is collapsed. Co-authored-by: Cursor <cursoragent@cursor.com> --- .../src/components/AppNav/AppNav.module.scss | 35 +++++++++++++++--- packages/app/src/components/AppNav/AppNav.tsx | 37 +++++++++++-------- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/packages/app/src/components/AppNav/AppNav.module.scss b/packages/app/src/components/AppNav/AppNav.module.scss index 80415250fb..4be3f59cc6 100644 --- a/packages/app/src/components/AppNav/AppNav.module.scss +++ b/packages/app/src/components/AppNav/AppNav.module.scss @@ -123,14 +123,39 @@ $transition-slow: 0.2s ease; } .collapseButton { - margin-right: -$spacing-xs; - margin-left: -$spacing-xs; + flex-shrink: 0; + display: inline-flex; + align-items: center; + justify-content: center; + margin: 0; + padding: var(--click-button-iconButton-sm-space-y) + var(--click-button-iconButton-sm-space-x); + border: var(--click-button-stroke) solid + var(--click-button-iconButton-color-primary-stroke-default); + border-radius: var(--click-button-iconButton-radii-all); + background: var(--click-button-iconButton-color-primary-background-default); + color: var(--click-button-iconButton-color-primary-text-default); + cursor: pointer; + line-height: 0; + + svg { + width: var(--click-image-sm-size-width); + height: var(--click-image-sm-size-height); + } + + &:hover { + border-color: var(--click-button-iconButton-color-primary-stroke-hover); + background: var(--click-button-iconButton-color-primary-background-hover); + color: var(--click-button-iconButton-color-primary-text-hover); + } + + &:focus-visible { + outline: 2px solid var(--click-global-color-outline-default); + outline-offset: 2px; + } &Collapsed { transform: rotate(180deg); - margin-top: 0; - margin-right: 0; - margin-left: 0; } } diff --git a/packages/app/src/components/AppNav/AppNav.tsx b/packages/app/src/components/AppNav/AppNav.tsx index 04b99f14b9..04937d6fba 100644 --- a/packages/app/src/components/AppNav/AppNav.tsx +++ b/packages/app/src/components/AppNav/AppNav.tsx @@ -6,18 +6,9 @@ import cx from 'classnames'; import { Badge } from '@clickhouse/click-ui'; import HyperDX from '@hyperdx/browser'; import { SavedSearchListApiResponse } from '@hyperdx/common-utils/dist/types'; -import { - ActionIcon, - Anchor, - Collapse, - Flex, - Group, - ScrollArea, - Text, -} from '@mantine/core'; +import { Anchor, Collapse, Flex, Group, ScrollArea, Text } from '@mantine/core'; import { useDisclosure, useLocalStorage } from '@mantine/hooks'; import { - IconArrowBarToLeft, IconBell, IconChartDots, IconDeviceFloppy, @@ -386,17 +377,33 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) { </Group> )} </Link> - <ActionIcon - variant="subtle" - size="sm" + {/* click-ui 0.12 has no sidebar-left icon, so the glyph is + inlined. Chrome matches IconButton type="primary" size="sm". */} + <button + type="button" className={cx(styles.collapseButton, { [styles.collapseButtonCollapsed]: isCollapsed, })} title="Collapse/expand navigation" + aria-label="Collapse/expand navigation" onClick={() => setIsPreferCollapsed((v: boolean) => !v)} > - <IconArrowBarToLeft size={16} /> - </ActionIcon> + <svg + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 24 24" + fill="none" + aria-hidden + > + <path + fill="currentColor" + d="M20.25 5C20.25 4.30921 19.6908 3.75 19 3.75H10.752H9.25195H5C4.30921 3.75 3.75 4.30921 3.75 5V19C3.75 19.6908 4.30921 20.25 5 20.25H9.25195H10.752H19C19.6908 20.25 20.25 19.6908 20.25 19V5ZM21.75 19C21.75 20.5192 20.5192 21.75 19 21.75H5C3.48079 21.75 2.25 20.5192 2.25 19V5C2.25 3.48079 3.48079 2.25 5 2.25H19C20.5192 2.25 21.75 3.48079 21.75 5V19Z" + /> + <path + fill="currentColor" + d="M9.25195 3.75V20.25H10.752V3.75H9.25195Z" + /> + </svg> + </button> </div> </div> <ScrollArea From c91425f859fe04548c58a328df07f0563fef19a2 Mon Sep 17 00:00:00 2001 From: Elizabet Oliveira <elizabet.oliveira@clickhouse.com> Date: Wed, 4 Nov 2026 13:28:49 +0000 Subject: [PATCH 5/5] fix(app): allow Click UI token names in the nav collapse button Stylelint rejects the camelCase custom properties those tokens use. Co-authored-by: Cursor <cursoragent@cursor.com> --- packages/app/src/components/AppNav/AppNav.module.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/app/src/components/AppNav/AppNav.module.scss b/packages/app/src/components/AppNav/AppNav.module.scss index 4be3f59cc6..2d4407490d 100644 --- a/packages/app/src/components/AppNav/AppNav.module.scss +++ b/packages/app/src/components/AppNav/AppNav.module.scss @@ -123,6 +123,8 @@ $transition-slow: 0.2s ease; } .collapseButton { + /* Click UI token names are camelCase. */ + /* stylelint-disable custom-property-pattern */ flex-shrink: 0; display: inline-flex; align-items: center; @@ -157,6 +159,7 @@ $transition-slow: 0.2s ease; &Collapsed { transform: rotate(180deg); } + /* stylelint-enable custom-property-pattern */ } .scrollContainer {