4.0 KiB
4.0 KiB
kind, name, category, scope, source_files
| kind | name | category | scope | source_files | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| frontend_style | WPF/Avalonia XAML Theme System with Design Tokens | frontend_style |
|
|
ClassicAssist uses a dual-frontend architecture (WPF + Avalonia) that shares a consistent dark-themed visual style through XAML Resource Dictionaries and design tokens. The styling system is built around centralized color palettes, component-level control templates, and theme-aware brushes rather than CSS or SCSS.
System overview
- WPF frontend (
ClassicAssist/) defines the primary theme inResources/DarkTheme.xaml, which mergesColours.xamlfor design tokens and provides full control templates for TreeView, ListBox, ListView, TabControl, Button, ComboBox, CheckBox, ScrollBar, GridView, TextBlock, and custom controls likeEditTextBlock. A thinResourceDictionary.xamlaggregates the theme for consumption by views. - Avalonia frontend (
ClassicAssist.Avalonia/) mirrors the same dark aesthetic viaApp.axaml'sRequestedThemeVariant="Dark", inline application resources, and selector-based styles. It includesAvaloniaEditSimple theme, DataGrid Simple theme, and a customGroupBox.Theme.xamlcontrol template. - Both shells reference shared icons and assets from their respective
Assets//Resources/folders (PNGs, fonts, syntax highlighting files).
Design tokens
Colours.xamldeclares a palette ofBackgroundColor1..6,ForegroundColor1..5,SelectionColor1/2(with emphasized variants), andRedColor, then exposes them asSolidColorBrushkeys suffixed withBrush. Semantic brushes such asThemeBackgroundBrush,ThemeForegroundBrush,ThemeBorderBrush,ThemeInnerControlBackgroundBrush,ThemeTabBackgroundBrush, andIconForegroundBrushare defined at the bottom of the file and consumed by all control templates.- Token naming follows a strict
<Component><State>Brushconvention (e.g.,ButtonHoverBackgroundBrush,ComboBoxNonEditableDisabledBorderBrush,TreeViewSelectecBackgroudBrush).
Architecture & conventions
- Styles are organized per-component inside one large
DarkTheme.xaml; there is no CSS-in-JS, Tailwind, or SCSS pipeline — zero.css/.scss/tailwind.config.*files exist in the repo. - Control templates override default WPF chrome (CheckBox, ComboBox, ScrollBar, TreeViewItem, etc.) to use the token brushes, ensuring every state (hover, pressed, disabled, selected, inactive selection) maps to a specific brush key.
- Views bind UI elements to these tokens via
{DynamicResource ...}so the entire palette can be swapped by replacing the merged dictionary. - Avalonia uses its own
Styles/StyleSelectorsyntax inApp.axamlandControls/GroupBox.Theme.xaml, but reuses the same semantic color names (ThemeForegroundBrush,ThemeBorderMidBrush, etc.) so both frontends look identical. - Custom reusable controls live under
UI/Controls(WPF) andControls(Avalonia) and ship paired.xaml/.csfiles; they consume the same token brushes rather than hard-coding colors.
Rules developers should follow
- Never hard-code hex colors in views or control templates; always reference a named brush from
Colours.xaml(or the Avalonia equivalent). Add new tokens toColours.xamlbefore using them. - When adding a new state to a control template (hover, focus, disabled, selected), define the corresponding
<Component><State>Brushtoken first. - Keep WPF and Avalonia control templates aligned: if you customize a control's look in one shell, mirror the change in the other so both frontends stay visually consistent.
- Place new reusable visuals in the appropriate
Controls/folder and expose them as a single.xamlresource dictionary merged into the app's root resources. - Avoid CSS/SCSS entirely — this project has no web stack and no build step for preprocessors.