Skip to content

docs(demo): add a MudBlazor / Fluent UI adapter selector to the top bar (#490) - #491

Merged
phmatray merged 7 commits into
devfrom
docs/490-demo-adapter-selector
Sep 25, 2026
Merged

phmatray merged 7 commits into
devfrom
docs/490-demo-adapter-selector

Conversation

@phmatray

@phmatray phmatray commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Implements #490.

Closes #490.

Executing the implementation plan task-by-task; the checklist below — and the plan on the issue — are
ticked as each task lands. Opened as a draft — will be marked ready after the final task and a
code-review pass.

Plan

  • Task 1: Fluent brand tokens with an AA contrast guard
  • Task 2: Pre-boot attribute and the AdapterPreference service
  • Task 3: The top-bar selector and the honesty note
  • Task 4: Home install line and setup steps follow the adapter
  • Task 5: Getting Started carries both adapters' setup
  • Task 6: Full verification pass

What shipped

  • Selector: a MudBlazor | Fluent UI segmented control (aria-pressed buttons in a labelled group) in the top bar. It is persisted in localStorage["fc-adapter"] through window.fcAdapter, and every access is in try/catch. A scoped AdapterPreference service shares it app-wide.
  • Accent: :root[data-adapter="fluentui"] in tokens.css overrides all eight accent tokens with Fluent 2's brand ramp (the Spec's starting values, all AA). An inline pre-boot script in index.html sets the attribute, so the first frame is never violet.
  • Snippets:
    • The Home hero install line (and its copy button) plus setup step 2 switch to the Fluent UI package and registration.
    • getting-started.md wraps Install / Services / References in ::: adapter-mudblazor / ::: adapter-fluentui containers, shown or hidden by CSS.
  • Honesty note: under the nav when Fluent UI is selected. The live forms stay MudBlazor.

Deviations from the plan

  • demo.css: the plan asked for color-mix(… 25% …), but the original alpha was .3. I used 30%, so the MudBlazor rendering doesn't change.
  • Home.razor: each setup step is @key'd on its source, and the page highlights again after an adapter change. code.js rewrites the <code> it highlights, so without the key Blazor could not update step 2's text. The browser pass caught this: step 2 stayed on MudBlazor.
  • shell.css: .fc-adapter-note gets width: 100%, because as a flex item of .fc-shell the auto margins shrank it off-centre. .fc-nav .fc-btn--sm gets white-space: nowrap, because at 1440 px the added control made "Get started" wrap.

Verification

  • dotnet build -c Release: 0 warnings, 0 errors. dotnet test -c Release: 2150/2150 passed. ./build.sh Format: succeeded.
  • DemoAdapterThemeTests (12 tests): the Fluent block covers every accent token and the five AC7 pairs are ≥ 4.5:1. The pre-boot script runs before blazor.webassembly.js, uses try and only accepts the literal 'fluentui'. Getting Started has exactly one closed container per adapter per section, with the real Fluent UI surface.
  • Real-browser pass (Playwright + Chrome, 57 checks, all passing) at 1440 and 390 px:
    • AC1: keyboard toggle with a yellow focus ring and aria-pressed; no horizontal scroll at 390 px. The accessible names stay "MudBlazor" / "Fluent UI" while the visible labels are "Mud" / "Fluent".
    • AC2: the accent switches both ways with no reload.
    • AC3: after a reload, the data-adapter attribute and --fc-violet: #0F6CBD are already set at DOMContentLoaded.
    • AC4: the hero copy button copies dotnet add package FormCraft.ForFluentUI, and step 2 shows the Fluent calls.
    • AC5: Getting Started shows only the selected adapter's blocks, and the code blocks still get their copy bar.
    • AC8: with localStorage throwing, the page loads in MudBlazor colours and still switches for the session.
    • AC9: the honesty note is visible, and the /simplified demo still renders MudBlazor components.
    • AC10: no console errors on Home, /simplified or getting-started under either adapter.

@phmatray
phmatray marked this pull request as ready for review September 25, 2026 08:51
@phmatray
phmatray merged commit 35c92e1 into dev Sep 25, 2026
4 checks passed
@phmatray
phmatray deleted the docs/490-demo-adapter-selector branch September 25, 2026 08:56
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.

Add a MudBlazor / Fluent UI adapter selector to the demo site's top bar

1 participant