[PR #6827] [CLOSED] feat(theme): add token-based theme customisation with presets and appearance drawer #6468

Closed
opened 2026-11-02 04:08:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6827
Author: @rqzbeh
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: feat/theme-customization


📝 Commits (2)

  • 572643a feat(theme): add token-based theme customisation with presets and appearance drawer
  • 5e3f1f4 fix(theme): use message.useMessage() hook, restore light contrast tokens, and parameterise host cards

📊 Changes

11 files changed (+981 additions, -151 deletions)

View changed files

➕ frontend/src/components/ui/AppearanceDrawer.tsx (+318 -0)
📝 frontend/src/hooks/useTheme.tsx (+118 -147)
📝 frontend/src/layouts/AppSidebar.css (+28 -0)
📝 frontend/src/layouts/AppSidebar.tsx (+22 -0)
➕ frontend/src/lib/themes/engine.ts (+218 -0)
➕ frontend/src/lib/themes/index.ts (+2 -0)
➕ frontend/src/lib/themes/presets.ts (+109 -0)
➕ frontend/src/schemas/forms/theme.ts (+38 -0)
📝 frontend/src/styles/page-cards.css (+4 -4)
➕ frontend/src/test/theme-engine.test.tsx (+84 -0)
➕ frontend/src/test/theme-schema.test.ts (+40 -0)

📄 Description

Summary

Adds a token-based theme customization system driving both Ant Design 5's ConfigProvider and CSS custom properties (--bg-page, --bg-card, --card-radius, --card-shadow, --card-accent-opacity) from a single source of truth. Includes 6 built-in presets (including a "Classic 2.x Inspired" preset), live accent color and border radius adjustments, density toggles, and JSON import/export.

Why

Users moving to 3x-ui v3 often miss the high-density, flat aesthetic of v2.x, or want customized palettes (such as Nord or Dracula) without breaking the panel layout or requiring arbitrary CSS hacks. This provides a strictly validated, token-based presentation layer that keeps all v3 features styled consistently.

Type of change

  • New feature

Areas affected

  • Frontend (UI / panel pages)

How was this tested?

  • Unit tests for Zod schema validation: npx vitest run src/test/theme-schema.test.ts
  • Engine tests for token resolution, compact algorithm stacking, legacy migration, and CSS variable synchronization: npx vitest run src/test/theme-engine.test.tsx
  • Type checking: npm run typecheck (tsc --noEmit passed with 0 errors)
  • Linting: npm run lint (oxlint passed with 0 warnings and 0 errors)
  • Formatting: npm run format:check (oxfmt --check passed)

Screenshots / recordings

N/A (Drawer accessible via the palette icon in the sidebar).

Breaking changes

None. Fully backwards-compatible with existing useTheme() consumers (isDark, isUltra, toggleTheme, toggleUltra, buildAntdThemeConfig). Automatically migrates legacy dark-mode and isUltraDarkThemeEnabled localStorage keys.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6827 **Author:** [@rqzbeh](https://github.com/rqzbeh) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/theme-customization` --- ### 📝 Commits (2) - [`572643a`](https://github.com/MHSanaei/3x-ui/commit/572643a812bcf59fd0511cc311e8c84e20f32db5) feat(theme): add token-based theme customisation with presets and appearance drawer - [`5e3f1f4`](https://github.com/MHSanaei/3x-ui/commit/5e3f1f43d5dcc0fbfa7c1809344152c86865c78a) fix(theme): use message.useMessage() hook, restore light contrast tokens, and parameterise host cards ### 📊 Changes **11 files changed** (+981 additions, -151 deletions) <details> <summary>View changed files</summary> ➕ `frontend/src/components/ui/AppearanceDrawer.tsx` (+318 -0) 📝 `frontend/src/hooks/useTheme.tsx` (+118 -147) 📝 `frontend/src/layouts/AppSidebar.css` (+28 -0) 📝 `frontend/src/layouts/AppSidebar.tsx` (+22 -0) ➕ `frontend/src/lib/themes/engine.ts` (+218 -0) ➕ `frontend/src/lib/themes/index.ts` (+2 -0) ➕ `frontend/src/lib/themes/presets.ts` (+109 -0) ➕ `frontend/src/schemas/forms/theme.ts` (+38 -0) 📝 `frontend/src/styles/page-cards.css` (+4 -4) ➕ `frontend/src/test/theme-engine.test.tsx` (+84 -0) ➕ `frontend/src/test/theme-schema.test.ts` (+40 -0) </details> ### 📄 Description ## Summary Adds a token-based theme customization system driving both Ant Design 5's `ConfigProvider` and CSS custom properties (`--bg-page`, `--bg-card`, `--card-radius`, `--card-shadow`, `--card-accent-opacity`) from a single source of truth. Includes 6 built-in presets (including a "Classic 2.x Inspired" preset), live accent color and border radius adjustments, density toggles, and JSON import/export. ## Why Users moving to 3x-ui v3 often miss the high-density, flat aesthetic of v2.x, or want customized palettes (such as Nord or Dracula) without breaking the panel layout or requiring arbitrary CSS hacks. This provides a strictly validated, token-based presentation layer that keeps all v3 features styled consistently. ## Type of change - [x] New feature ## Areas affected - [x] Frontend (UI / panel pages) ## How was this tested? - Unit tests for Zod schema validation: `npx vitest run src/test/theme-schema.test.ts` - Engine tests for token resolution, compact algorithm stacking, legacy migration, and CSS variable synchronization: `npx vitest run src/test/theme-engine.test.tsx` - Type checking: `npm run typecheck` (`tsc --noEmit` passed with 0 errors) - Linting: `npm run lint` (`oxlint` passed with 0 warnings and 0 errors) - Formatting: `npm run format:check` (`oxfmt --check` passed) ## Screenshots / recordings N/A (Drawer accessible via the palette icon in the sidebar). ## Breaking changes None. Fully backwards-compatible with existing `useTheme()` consumers (`isDark`, `isUltra`, `toggleTheme`, `toggleUltra`, `buildAntdThemeConfig`). Automatically migrates legacy `dark-mode` and `isUltraDarkThemeEnabled` localStorage keys. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:59 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6468
No description provided.