[dev-v5] Demo site - Implement static rendering#4969
Draft
dvoituron wants to merge 4 commits into
Draft
Conversation
…d initialize dark mode check in ThemeDesigner after first render
…r message formatting in SampleContainer
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.5%
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the FluentUI demo app to default to static (SSR) rendering and applies interactivity selectively (via @rendermode) to specific UI boundaries (header, navigation, providers/aside, and samples). This improves the demo’s suitability for external tooling by reducing always-interactive rendering.
Changes:
- Switch the app-level routes rendering to static by default and apply
@rendermodeonly where needed. - Introduce
SampleContainerto enable per-sample interactive rendering while still usingDynamicComponent. - Move system dark-mode detection in
ThemeDesignerto first render.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/Tools/FluentUI.Demo.DocViewer/Components/SampleContainer.razor.cs | New wrapper component that resolves a sample component type from a serializable name inside an interactive boundary. |
| examples/Tools/FluentUI.Demo.DocViewer/Components/SampleContainer.razor | Renders the resolved type via DynamicComponent or a not-found message. |
| examples/Tools/FluentUI.Demo.DocViewer/Components/MarkdownViewer.razor.cs | Adds a parameter to pass a render mode through to sample rendering. |
| examples/Tools/FluentUI.Demo.DocViewer/Components/MarkdownViewer.razor | Replaces direct DynamicComponent rendering with SampleContainer and applies @rendermode per sample. |
| examples/Demo/FluentUI.Demo/Components/App.razor | Removes render mode from the whole Routes tree; applies render mode to HeadOutlet via DocViewer.DemoRenderMode. |
| examples/Demo/FluentUI.Demo.Client/Layout/DemoMainLayout.razor.cs | Removes header-related JS logic from the layout code-behind (now handled in DemoHeader). |
| examples/Demo/FluentUI.Demo.Client/Layout/DemoMainLayout.razor | Applies @rendermode to header/nav/aside/providers to keep the rest SSR by default. |
| examples/Demo/FluentUI.Demo.Client/Layout/DemoHeader.razor.cs | New interactive header component containing JS interop for theme/dir switching and external navigation. |
| examples/Demo/FluentUI.Demo.Client/Layout/DemoHeader.razor | New header markup extracted from the main layout. |
| examples/Demo/FluentUI.Demo.Client/DocViewer.razor | Passes a centralized demo render mode into MarkdownViewer and exposes the render mode for other components. |
| examples/Demo/FluentUI.Demo.Client/Documentation/General/Theme/Designer/ThemeDesigner.razor.cs | Defers system dark-mode detection to OnAfterRenderAsync(firstRender). |
Comment on lines
+34
to
+41
| protected override void OnParametersSet() | ||
| { | ||
| _componentType = DocViewerService.ComponentsAssembly? | ||
| .GetTypes() | ||
| .Where(t => t.IsSubclassOf(typeof(ComponentBase)) && !t.IsAbstract) | ||
| .FirstOrDefault(i => i.Name == ComponentName); | ||
| } | ||
| } |
| } | ||
| else | ||
| { | ||
| <div class="component-not-found">⚠ The component {{ @ComponentName }} was not found.</div> |
Comment on lines
24
to
28
| protected override async Task OnInitializedAsync() | ||
| { | ||
| _isDark = await ThemeService.IsSystemDarkAsync(); | ||
|
|
||
| } | ||
|
|
|
|
||
| @code | ||
| { | ||
| public static IComponentRenderMode DemoRenderMode = new InteractiveServerRenderMode(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[dev-v5] Demo site - Implement static rendering
In order to provide documentation that is more easily usable by MCP servers and other external tools, we switche the demo application's default render mode from Interactive Server to Static (SSR), and apply interactivity selectively only where it is actually needed: the navigation, the header, the providers/aside, and all samples.
Previously the whole Routes tree was rendered with
InteractiveServerRenderMode. Now the page is statically rendered by default, and@rendermodeis applied per-component.TODO