Skip to content

Commit

Permalink
refactor: add and configure the client project
Browse files Browse the repository at this point in the history
  • Loading branch information
djoufson committed Dec 29, 2024
1 parent 6481b54 commit 2aca068
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 4 deletions.
19 changes: 19 additions & 0 deletions app.client/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@page "/counter"
@rendermode InteractiveWebAssembly

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
5 changes: 5 additions & 0 deletions app.client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

await builder.Build().RunAsync();
8 changes: 8 additions & 0 deletions app.client/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
15 changes: 15 additions & 0 deletions app.client/app.client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions app.client/wwwroot/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
8 changes: 8 additions & 0 deletions app.client/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
6 changes: 4 additions & 2 deletions app/Components/Components/NavBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
<NavLink href="/events" data-enhance-nav="false" class="py-2 md:text-slate-300 md:hover:text-white transition-all">Events</NavLink>
</li>
<li class="flex">
<NavLink href="/dotnet-conf-2024" data-enhance-nav="false"
class="py-2 md:text-slate-300 md:hover:text-white transition-all">.NET Conf 2024</NavLink>
<NavLink href="/dotnet-conf-2024" data-enhance-nav="false" class="py-2 md:text-slate-300 md:hover:text-white transition-all">.NET Conf 2024</NavLink>
</li>
<li class="flex">
<NavLink href="/counter" data-enhance-nav="false" class="py-2 md:text-slate-300 md:hover:text-white transition-all">Counter</NavLink>
</li>
@* <li class="flex">
<NavLink href="/about" class="py-2 md:text-slate-300 md:hover:text-white transition-all">About</NavLink>
Expand Down
4 changes: 3 additions & 1 deletion app/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public static IServiceCollection AddServices(
IHostEnvironment environment)
{
services.AddRazorComponents()
.AddInteractiveServerComponents();
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();

if (environment.IsProduction())
{
services.AddApplicationInsightsTelemetry(configuration);
Expand Down
4 changes: 3 additions & 1 deletion app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
app.MapHangfireJobs();

app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(app.client._Imports).Assembly);

app.Run();
2 changes: 2 additions & 0 deletions app/app.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\dotnet-ef-seeder\dotnet-ef-seeder.csproj" />
<ProjectReference Include="..\app.business\app.business.csproj" />
<ProjectReference Include="..\app.infrastructure\app.infrastructure.csproj" />
<ProjectReference Include="..\app.client\app.client.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions dotnetcameroon.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "app.shared", "app.shared\ap
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "app.domain", "app.domain\app.domain.csproj", "{93EB2875-B349-48BC-8509-86F7365BC945}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "app.client", "app.client\app.client.csproj", "{6E22DCB4-CB51-4976-BB72-3554504B9D59}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -48,5 +50,9 @@ Global
{93EB2875-B349-48BC-8509-86F7365BC945}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93EB2875-B349-48BC-8509-86F7365BC945}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93EB2875-B349-48BC-8509-86F7365BC945}.Release|Any CPU.Build.0 = Release|Any CPU
{6E22DCB4-CB51-4976-BB72-3554504B9D59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E22DCB4-CB51-4976-BB72-3554504B9D59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E22DCB4-CB51-4976-BB72-3554504B9D59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E22DCB4-CB51-4976-BB72-3554504B9D59}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit 2aca068

Please sign in to comment.