Browse Source

created MudBlazor theming packages

feat/mudblazor-mix
İsmail ÇAĞDAŞ 3 months ago
parent
commit
76b2d6834a
  1. 36
      framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/AbpAspNetCoreComponentsMauiBlazorThemingMudBlazorModule.cs
  2. 15
      framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/Bundling/MauiBlazorMudBlazorScriptContributor.cs
  3. 16
      framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/Bundling/MauiBlazorMudBlazorStyleContributor.cs
  4. 18
      framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.csproj
  5. 35
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/AbpAspNetCoreComponentsServerThemingMudBlazorModule.cs
  6. 23
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Bundling/BlazorServerMudBlazorScriptContributor.cs
  7. 16
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Bundling/BlazorServerMudBlazorStyleContributor.cs
  8. 14
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Bundling/BlazorStandardBundles.cs
  9. 22
      framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.csproj
  10. 18
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor/Components/PageHeader.razor
  11. 127
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor/Components/PageHeader.razor.cs
  12. 1
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor/_Imports.razor
  13. 36
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/AbpAspNetCoreComponentsWebAssemblyThemingMudBlazorModule.cs
  14. 17
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/Bundling/BlazorWebAssemblyMudBlazorScriptContributor.cs
  15. 16
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/Bundling/BlazorWebAssemblyMudBlazorStyleContributor.cs
  16. 18
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.csproj

36
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/AbpAspNetCoreComponentsMauiBlazorThemingMudBlazorModule.cs

@ -0,0 +1,36 @@
using Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.Bundling;
using Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.Bundling;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor;
using Volo.Abp.AspNetCore.Components.MauiBlazor;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor;
[DependsOn(
typeof(AbpAspNetCoreComponentsMauiBlazorThemingBundlingModule),
typeof(AbpAspNetCoreComponentsWebThemingMudBlazorModule),
typeof(AbpAspNetCoreComponentsMauiBlazorModule)
)]
public class AbpAspNetCoreComponentsMauiBlazorThemingMudBlazorModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpBundlingOptions>(options =>
{
options
.StyleBundles
.Add(MauiBlazorStandardBundles.Styles.Global, bundle =>
{
bundle.AddContributors(typeof(MauiBlazorMudBlazorStyleContributor));
});
options
.ScriptBundles
.Add(MauiBlazorStandardBundles.Scripts.Global, bundle =>
{
bundle.AddContributors(typeof(MauiBlazorMudBlazorScriptContributor));
});
});
}
}

15
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/Bundling/MauiBlazorMudBlazorScriptContributor.cs

@ -0,0 +1,15 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.Bundling;
public class MauiBlazorMudBlazorScriptContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
//TODO@MudBlazor: Do we need this script, check ?
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.js");
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js");
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js");
}
}

16
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/Bundling/MauiBlazorMudBlazorStyleContributor.cs

@ -0,0 +1,16 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.Bundling;
public class MauiBlazorMudBlazorStyleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
//TODO@MudBlazor: Do we need this public font ?
context.Files.AddIfNotContains("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap");
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.css");
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/css/abp.css");
context.Files.AddIfNotContains("_content/Volo.Abp.MudBlazorUI/volo.abp.mudblazorui.css");
}
}

18
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.Bundling\Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.Bundling.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.MauiBlazor\Volo.Abp.AspNetCore.Components.MauiBlazor.csproj" />
</ItemGroup>
</Project>

35
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/AbpAspNetCoreComponentsServerThemingMudBlazorModule.cs

@ -0,0 +1,35 @@
using Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling;
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor;
[DependsOn(
typeof(AbpAspNetCoreComponentsServerModule),
typeof(AbpAspNetCoreMvcUiPackagesModule),
typeof(AbpAspNetCoreComponentsWebThemingMudBlazorModule),
typeof(AbpAspNetCoreMvcUiBundlingModule)
)]
public class AbpAspNetCoreComponentsServerThemingMudBlazorModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpBundlingOptions>(options =>
{
options
.StyleBundles
.Add(BlazorStandardBundles.Styles.Global, bundle =>
{
bundle.AddContributors(typeof(BlazorServerMudBlazorStyleContributor));
});
options
.ScriptBundles
.Add(BlazorStandardBundles.Scripts.Global, bundle =>
{
bundle.AddContributors(typeof(BlazorServerMudBlazorScriptContributor));
});
});
}
}

23
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Bundling/BlazorServerMudBlazorScriptContributor.cs

@ -0,0 +1,23 @@
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Components.Web;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling;
public class BlazorServerMudBlazorScriptContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpAspNetCoreComponentsWebOptions>>().Value;
if (!options.IsBlazorWebApp)
{
context.Files.AddIfNotContains("/_framework/blazor.server.js");
}
//TODO@MudBlazor: Do we need this script, check ?
context.Files.AddIfNotContains("/_content/MudBlazor/MudBlazor.min.js");
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js");
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/authentication-state-listener.js");
}
}

16
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Bundling/BlazorServerMudBlazorStyleContributor.cs

@ -0,0 +1,16 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling;
public class BlazorServerMudBlazorStyleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
//TODO@MudBlazor: Do we need this public font ?
context.Files.AddIfNotContains("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap");
context.Files.AddIfNotContains("/_content/MudBlazor/MudBlazor.min.css");
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/css/abp.css");
context.Files.AddIfNotContains("/_content/Volo.Abp.MudBlazorUI/volo.abp.mudblazorui.css");
}
}

14
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Bundling/BlazorStandardBundles.cs

@ -0,0 +1,14 @@
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling;
public class BlazorStandardBundles
{
public static class Styles
{
public static string Global = "Blazor.Global";
}
public static class Scripts
{
public static string Global = "Blazor.Global";
}
}

22
framework/src/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor/Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.csproj

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Server\Volo.Abp.AspNetCore.Components.Server.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Packages\Volo.Abp.AspNetCore.Mvc.UI.Packages.csproj" />
</ItemGroup>
</Project>

18
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor/Components/PageHeader.razor

@ -1,9 +1,6 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.Extensions.Options
@using Volo.Abp.Ui.Branding
@inject IOptions<PageHeaderOptions> Options
@inject IBrandingProvider BrandingProvider
@inject PageLayout PageLayout
<MudGrid Class="entry-row">
@if (PageLayout.Title.IsNullOrEmpty())
@ -64,19 +61,4 @@
}
</MudGrid>
@code {
[Parameter]
public bool BreadcrumbShowHome { get; set; } = true;
[Parameter]
public bool BreadcrumbShowCurrent { get; set; } = true;
[Parameter]
public RenderFragment ChildContent { get; set; } = default!;
[Parameter]
public PageToolbar? Toolbar { get; set; }
protected List<RenderFragment> ToolbarItemRenders { get; } = new();
}

127
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor/Components/PageHeader.razor.cs

@ -0,0 +1,127 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Components.Web.Theming;
using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars;
using Volo.Abp.BlazoriseUI;
namespace Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components;
public partial class PageHeader : ComponentBase, IDisposable
{
protected List<RenderFragment> ToolbarItemRenders { get; set; }
[Inject]
public IPageToolbarManager PageToolbarManager { get; set; } = default!;
[Inject]
public PageLayout PageLayout { get; private set; } = default!;
[Inject]
public IOptions<PageHeaderOptions> Options { get; set; } = default!;
[Parameter]
public string? Title { get => PageLayout.Title; set => PageLayout.Title = value; }
[Parameter]
public bool BreadcrumbShowHome { get; set; } = true;
[Parameter]
public bool BreadcrumbShowCurrent { get; set; } = true;
[Parameter]
public RenderFragment ChildContent { get; set; } = default!;
[Parameter]
public List<BreadcrumbItem> BreadcrumbItems
{
get => PageLayout.BreadcrumbItems.ToList();
set
{
PageLayout.BreadcrumbItems.Clear();
if (value != null)
{
foreach (var item in value)
{
PageLayout.BreadcrumbItems.Add(item);
}
}
}
}
[Parameter]
public PageToolbar? Toolbar { get; set; }
public PageHeader()
{
ToolbarItemRenders = new List<RenderFragment>();
}
protected async override Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
if (Toolbar != null)
{
var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar);
if (!ShouldRenderToolbarItems(toolbarItems))
{
return;
}
ToolbarItemRenders.Clear();
if (!Options.Value.RenderToolbar)
{
PageLayout.ToolbarItems.Clear();
foreach (var item in toolbarItems)
{
PageLayout.ToolbarItems.Add(item);
}
return;
}
foreach (var item in toolbarItems)
{
var sequence = 0;
ToolbarItemRenders.Add(builder =>
{
builder.OpenComponent(sequence, item.ComponentType);
if (item.Arguments != null)
{
foreach (var argument in item.Arguments)
{
sequence++;
builder.AddAttribute(sequence, argument.Key, argument.Value);
}
}
builder.CloseComponent();
});
}
}
}
protected virtual bool ShouldRenderToolbarItems(PageToolbarItem[] items)
{
if (items.Length != PageLayout.ToolbarItems.Count)
{
return true;
}
return items.Where((t, i) => t.ComponentType != PageLayout.ToolbarItems[i].ComponentType).Any();
}
protected async override Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}
public void Dispose()
{
PageLayout.Reset();
ToolbarItemRenders.Clear();
}
}

1
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor/_Imports.razor

@ -2,4 +2,5 @@
@using Volo.Abp.AspNetCore.Components.Web.Theming
@using Volo.Abp.AspNetCore.Components.Web.Theming.Layout
@using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars
@using Volo.Abp.BlazoriseUI

36
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/AbpAspNetCoreComponentsWebAssemblyThemingMudBlazorModule.cs

@ -0,0 +1,36 @@
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor;
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling;
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.Bundling;
using Volo.Abp.AspNetCore.Components.WebAssembly;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor;
[DependsOn(
typeof(AbpAspNetCoreComponentsWebAssemblyThemingBundlingModule),
typeof(AbpAspNetCoreComponentsWebThemingMudBlazorModule),
typeof(AbpAspNetCoreComponentsWebAssemblyModule)
)]
public class AbpAspNetCoreComponentsWebAssemblyThemingMudBlazorModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpBundlingOptions>(options =>
{
options
.StyleBundles
.Add(BlazorWebAssemblyStandardBundles.Styles.Global, bundle =>
{
bundle.AddContributors(typeof(BlazorWebAssemblyMudBlazorStyleContributor));
});
options
.ScriptBundles
.Add(BlazorWebAssemblyStandardBundles.Scripts.Global, bundle =>
{
bundle.AddContributors(typeof(BlazorWebAssemblyMudBlazorScriptContributor));
});
});
}
}

17
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/Bundling/BlazorWebAssemblyMudBlazorScriptContributor.cs

@ -0,0 +1,17 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.Bundling;
public class BlazorWebAssemblyMudBlazorScriptContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js");
//TODO@MudBlazor: Do we need this script, check ?
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.js");
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js");
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js");
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/authentication-state-listener.js");
}
}

16
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/Bundling/BlazorWebAssemblyMudBlazorStyleContributor.cs

@ -0,0 +1,16 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.Bundling;
public class BlazorWebAssemblyMudBlazorStyleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
//TODO@MudBlazor: Do we need this public font ?
context.Files.AddIfNotContains("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap");
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.css");
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/css/abp.css");
context.Files.AddIfNotContains("_content/Volo.Abp.MudBlazorUI/volo.abp.mudblazorui.css");
}
}

18
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.WebAssembly\Volo.Abp.AspNetCore.Components.WebAssembly.csproj" />
</ItemGroup>
</Project>
Loading…
Cancel
Save