Skip to content

feat: add Press theme families and extensible appearance controls - #623

Merged
Mohamed Mansour (mohamedmansour) merged 5 commits into
mainfrom
mohamedmansour-press-theming-integrations
Oct 30, 2026
Merged

Mohamed Mansour (mohamedmansour) merged 5 commits into
mainfrom
mohamedmansour-press-theming-integrations

Conversation

@mohamedmansour

@mohamedmansour Mohamed Mansour (mohamedmansour) commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Press consumers currently have to duplicate theme CSS generation, pre-paint preference restoration, and header customization to support multiple design families. This adds a shared appearance integration without coupling Press to a particular component library.

Approach

  • Compile independent light/dark theme sources into deterministic shared CSS using a baseline and grouped deltas. Preserve literal initial values, missing-token resets, and consumer stylesheet precedence.
  • Share one document preference owner across pre-paint initialization, controls, and the exported @microsoft/webui-press/appearance.js API. Keep family and System/Light/Dark preferences independent, synchronize OS and cross-tab changes, and use native view transitions for user changes while respecting reduced motion and forced colors.
  • Publish the required initializer as one fingerprinted same-origin static script, loaded synchronously before stylesheet links and hydration. It needs no inline-script exception or per-request nonce; missing or denied required assets remain explicit deployment/CSP errors.
  • Add a palette-triggered native Appearance popover with a customizable native family select and labeled System/sun/moon buttons. Present the same controls inline in a full-height mobile navigation drawer that covers the header, slides in with native CSS transitions, and respects reduced motion. Preserve focus restoration across slotted shadow roots.
  • Add nested header regions with explicit fallback ownership. Replacing a parent suppresses descendant state/scripts/assets; single-family builds omit the family picker and its assets entirely.

Compatibility and migration

Legacy theme configuration remains a single-family integration; do not combine it with appearance. Render metadata is namespaced under webuiPress.appearance to avoid collisions with component properties. Existing data-theme CSS remains usable, and content-only builds continue following the OS without consuming shell preferences or emitting the initializer.

Deploy the generated initialization asset with the rest of the site and authorize it in the site's CSP. The site's other generated scripts still require their own CSP authorization; this does not claim that script-src 'self' alone authorizes all existing inline hydration payloads.

The companion consumer migration must follow a release containing this feature and matching compiler/framework packages. Its local preview package links are not included in this PR.

CSS size

Measured with the same three official theme snapshots and exact token-parity assertions. The previous generator was reconstructed from frozen source rather than a preserved build directory.

Generated theme CSS Previous consumer generator Press integration Reduction
Raw 390,294 B 303,086 B 22.3%
Gzip-9 42,616 B 37,871 B 11.1%

Initialization moves 2,218 bytes into one shared asset (866 bytes gzip), replacing the repeated inline initializer in each page. This adds one cacheable request on a cold load.

Validation

  • cargo xtask check, including documentation and example builds.
  • 126 Press/docs browser and native integration tests covering native controls, responsive layout, full-height drawer geometry and motion, focus, pre-paint/no-JS behavior, storage failures, cross-tab synchronization, token precedence, transitions, and deterministic output.
  • Browser-enforced CSP coverage with no inline-bootstrap authorization: saved preferences, controls, reload, OS changes, delayed initialization, first-paint appearance, and hydration scripts disabled. Genuine initialization-load failures are surfaced explicitly.
  • Cold Rust test execution without generated projection output or TypeScript incremental cache. Pure CSS inventory checks stay in Rust; full-shell build coverage runs in the native integration suite after its JavaScript prerequisites are built.
  • Real MAI consumer integration, including exact token parity across all six family/mode combinations and 15 targeted saved-preference/deferred-hydration regressions against the updated native artifact.
  • Desktop and mobile documentation screenshots remain byte-identical after the initialization delivery change.
  • Updated public documentation and architectural boundaries.

Screenshots

Only this repository's /docs site is shown. It has one configured theme family, so the family select is intentionally omitted while System/Light/Dark controls remain available.

Desktop

This repository's documentation site with the desktop Appearance popover open

Mobile

This repository's documentation site with the full-height mobile drawer covering the header

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@mddinbox mddinbox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target: 6ceba63...8a75fa8 | Coverage: complete; CI: PR Checks, CodeQL, Docs, FFI, E2E (Ubuntu), Test, Build (Linux/macOS/Windows) — success
Challenge: 1 confirmed; Compatibility: strict-script-src deployments lose interactive appearance controls
Action: COMMENT | The CSP initialization failure is detailed inline.

Comment thread crates/webui-press/src/appearance.rs Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Collect inline script hashes from a script-disabled, network-blocked browser document instead of matching HTML with a regular expression. Cover whitespace-terminated end tags, quoted attributes, external scripts, inert JSON, and bootstrap exclusion.
@mohamedmansour
Mohamed Mansour (mohamedmansour) merged commit 48d8b9e into main Oct 30, 2026
41 checks passed
@mohamedmansour
Mohamed Mansour (mohamedmansour) deleted the mohamedmansour-press-theming-integrations branch October 30, 2026 22:58
Mohamed Mansour (mohamedmansour) added a commit that referenced this pull request Oct 31, 2026
## Release

Bumps WebUI to `3.0.5`.

Previous release tag: `v3.0.4`

## Changes since `v3.0.4`

Features:

- Press supports reusable, per-page outlines with responsive navigation
(feat: redesign the docs site and add reusable page outlines #613 by
@mohamedmansour).
- Press tabs can synchronize categories and persist selections;
package-manager preferences now follow readers across documentation
pages and reloads (feat: persist package-manager tabs and simplify
documentation #620 by @mohamedmansour).
- Press adds independent theme families, shared appearance preferences,
System/Light/Dark controls, and extensible header regions with a
cacheable pre-paint initializer (feat: add Press theme families and
extensible appearance controls #623 by @mohamedmansour).

Fixes:

- Hydrate conditional and repeated SSR ranges in place, avoiding
unnecessary custom-element disconnect/reconnect cycles and correcting
trailing formatting whitespace (fix: hydrate SSR block ranges in place
#619 by @mohamedmansour).
- Preserve pending development-server file events by retargeting the
existing watcher instead of replacing it after rebuilds (fix: retarget
the dev-server watcher instead of replacing it #622 by @mohamedmansour).
- Remove unapproved transitive TLS/WebSocket crypto dependencies while
retaining HTTP/2 support. The commerce example now serves HTTP/1.1 and
h2c behind a TLS-terminating ingress; its direct TLS flags are removed
(fix: remove unapproved crypto dependencies #596 by @mohamedmansour).

Docs:

- Redesign the documentation homepage and reading experience, organize
guides into Start/Learn/Build/Reference with legacy redirects, and
simplify installation and package-manager instructions (feat: redesign
the docs site and add reusable page outlines #613 by @mohamedmansour,
chore: clarify the homepage and organize documentation #617 by
@mohamedmansour, feat: persist package-manager tabs and simplify
documentation #620 by @mohamedmansour).
- Refresh benchmark previews, methodology, and downloadable results
around the uniform 15-case official WebUI 3.0.4 campaign, including
provenance and unavailable memory-sample disclosures (docs: support the
uniform 15-case official benchmark campaign #614 by @mohamedmansour).
- Update source-build requirements, Rust writer guidance, and Press
appearance configuration and deployment documentation (chore: upgrade
Rust to 1.99.1 #612 by @mohamedmansour, perf: reduce renderer output
allocations #615 by @mohamedmansour, feat: add Press theme families and
extensible appearance controls #623 by @mohamedmansour).

Maintenance:

- Reduce renderer allocation churn by writing escaped values directly
into output buffers, reusing attribute buffers, and borrowing quoted
condition text (perf: reduce renderer output allocations #615 by
@mohamedmansour).
- Share eligible Link stylesheets across component mounts within a
document, preserving native first-use loading and avoiding repeated
parsing on subsequent uses (perf: share Link stylesheets across
component mounts #621 by @mohamedmansour).
- Align development and release toolchains on Rust 1.99.1; consumers
building from source now require Rust 1.99.1 or newer (chore: upgrade
Rust to 1.99.1 #612 by @mohamedmansour).

## Validation

- `cargo xtask check` passed, including lint, protocol drift, dependency
audit, tests, native/WASM builds, examples, benchmark validation, and
docs.
- Used `WEBUI_PRESS_BINARY_PATH` to select the freshly built workspace
Press 3.0.5 binary instead of an older global installation.
- Refreshed the standalone Tauri lockfile with Cargo; all 45 changed
files contain only `3.0.4` to `3.0.5` substitutions.
Mohamed Mansour (mohamedmansour) added a commit that referenced this pull request Oct 31, 2026
…etargeting (#622)

No textual conflicts. Cargo.lock, DESIGN.md, docs/ai.md, the Press bundler
and the Press package manifest auto-merged; this branch's explicit
runtime.js/styles.js entry imports and main's appearance plugin and alias
are independent.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 90a93005-7b2a-4ea4-bce5-902f79da872d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants