Skip to content

Commit

Permalink
initial mudblazor setup
Browse files Browse the repository at this point in the history
  • Loading branch information
iammukeshm committed Jun 6, 2024
1 parent 7485e98 commit 277b27c
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 51 deletions.
1 change: 1 addition & 0 deletions apps/blazor/client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6" />
<PackageReference Include="MudBlazor" Version="6.20.0" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions apps/blazor/client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor.Services;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services.AddMudServices();

await builder.Build().RunAsync();
2 changes: 2 additions & 0 deletions apps/blazor/client/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using FSH.Blazor.Client
@using MudBlazor
@using MudBlazor.Services
8 changes: 5 additions & 3 deletions apps/blazor/server/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="FSH.Blazor.styles.css" />

<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />

<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
</head>

<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
</body>

</html>
36 changes: 18 additions & 18 deletions apps/blazor/server/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<MudThemingProvider />
<MudLayout>
<MudAppBar Elevation="1">
<MudText Typo="Typo.h5" Class="ml-3">Application</MudText>
</MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Always" Elevation="2">
<NavMenu />
</div>
</MudDrawer>
<MudMainContent Class="mt-16 pa-4">
@Body
</MudMainContent>
</MudLayout>

<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>
@code {
private bool _drawerOpen = true;

<article class="content px-4">
@Body
</article>
</main>
</div>

<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
private void DrawerToggle()
{
_drawerOpen = !_drawerOpen;
}
}
35 changes: 5 additions & 30 deletions apps/blazor/server/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">FSH.Blazor</a>
</div>
</div>

<input type="checkbox" title="Navigation menu" class="navbar-toggler" />

<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
</NavLink>
</div>
</nav>
</div>

<MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>
<MudNavLink Href="weather" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Weather</MudNavLink>
</MudNavMenu>
2 changes: 2 additions & 0 deletions apps/blazor/server/Components/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
@using FSH.Blazor
@using FSH.Blazor.Client
@using FSH.Blazor.Server.Components
@using MudBlazor
@using MudBlazor.Services
3 changes: 3 additions & 0 deletions apps/blazor/server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using FSH.Blazor.Server.Components;
using MudBlazor.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveWebAssemblyComponents();

builder.Services.AddMudServices();

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand Down

0 comments on commit 277b27c

Please sign in to comment.