From 05cf33798901c0d72768fc7b8ca48393f065b04f Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 11 May 2022 17:30:50 +0300 Subject: [PATCH] Add Blazor Server seperation to the Customization-Overriding-Components.md --- .../Customization-Overriding-Components.md | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/docs/en/UI/Blazor/Customization-Overriding-Components.md b/docs/en/UI/Blazor/Customization-Overriding-Components.md index e62e0a0ff4..e288a439b0 100644 --- a/docs/en/UI/Blazor/Customization-Overriding-Components.md +++ b/docs/en/UI/Blazor/Customization-Overriding-Components.md @@ -1,5 +1,12 @@ # Blazor UI: Customization / Overriding Components +````json +//[doc-params] +{ + "UI": ["Blazor", "BlazorServer"] +} +```` + This document explains how to override the user interface of a depended [application module](../../Modules/Index.md) or [theme](Theming.md) for Blazor applications. ## Overriding a Razor Component @@ -26,6 +33,30 @@ The next step is to create a razor component, like `MyBranding.razor`, in your a The content of the `MyBranding.razor` is shown below: +{{if UI == "BlazorServer"}} + +````html +@using Volo.Abp.DependencyInjection +@using Volo.Abp.AspNetCore.Components.Server.BasicTheme.Themes.Basic +@inherits Branding +@attribute [ExposeServices(typeof(Branding))] +@attribute [Dependency(ReplaceServices = true)] + + + +```` + +Let's explain the code: + +* `@inherits Branding` line inherits the Branding component defined by the [Basic Theme](Basic-Theme.md) (in the `Volo.Abp.AspNetCore.Components.Server.BasicTheme.Themes.Basic` namespace). +* `@attribute [ExposeServices(typeof(Branding))]` registers this service (component) to [dependency injection](../../Dependency-Injection.md) for the `Branding` service (component). +* `@attribute [Dependency(ReplaceServices = true)]` replaces the `Branding` class (component) with this new `MyBranding` class (component). +* The rest of the code is related the content and styling of the component. + +{{end}} + +{{if UI == "Blazor"}} + ````html @using Volo.Abp.DependencyInjection @using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic @@ -44,6 +75,8 @@ Let's explain the code: * `@attribute [Dependency(ReplaceServices = true)]` replaces the `Branding` class (component) with this new `MyBranding` class (component). * The rest of the code is related the content and styling of the component. +{{end}} + Now, you can run the application to see the result: ![bookstore-added-logo](../../images/bookstore-added-logo.png) @@ -56,6 +89,17 @@ If you prefer to use code-behind file for the C# code of your component, you can **MyBlazor.razor** +{{if UI == "BlazorServer"}} +````html +@using Volo.Abp.AspNetCore.Components.Server.BasicTheme.Themes.Basic +@inherits Branding + + + +```` +{{end}} + +{{if UI == "Blazor"}} ````html @using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic @inherits Branding @@ -63,8 +107,27 @@ If you prefer to use code-behind file for the C# code of your component, you can ```` +{{end}} **MyBlazor.razor.cs** +{{if UI == "BlazorServer"}} + +````csharp +using Volo.Abp.AspNetCore.Components.Server.BasicTheme.Themes.Basic; +using Volo.Abp.DependencyInjection; + +namespace MyProject.Blazor.Components +{ + [ExposeServices(typeof(Branding))] + [Dependency(ReplaceServices = true)] + public partial class MyBranding + { + + } +} +```` +{{end}} +{{if UI == "Blazor"}} ````csharp using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic; @@ -80,6 +143,7 @@ namespace MyProject.Blazor.Components } } ```` +{{end}} ## Theming