Skip to content

Commit

Permalink
Add a sample site that uses the render mode is Auto
Browse files Browse the repository at this point in the history
  • Loading branch information
jsakamoto committed May 30, 2024
1 parent f92cd1f commit 263cf97
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 27 deletions.
3 changes: 0 additions & 3 deletions SampleSites/Server8/Components/Pages/Home.razor

This file was deleted.

6 changes: 0 additions & 6 deletions SampleSites/Server8/Components/Routes.razor

This file was deleted.

4 changes: 4 additions & 0 deletions SampleSites/Web.Client/Pages/Home.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@page "/"
@rendermode InteractiveAuto

<SampleSite.Components.Pages.Index />
4 changes: 4 additions & 0 deletions SampleSites/Web.Client/Pages/InteractiveServerPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@page "/interactive-server"
@rendermode InteractiveServer

<SampleSite.Components.Pages.Index />
9 changes: 9 additions & 0 deletions SampleSites/Web.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Toolbelt.Blazor.Extensions.DependencyInjection;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddSpeechSynthesis();

await builder.Build().RunAsync();
40 changes: 40 additions & 0 deletions SampleSites/Web.Client/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:48194/",
"sslPort": 44385
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5046",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7026;http://localhost:5046",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
19 changes: 19 additions & 0 deletions SampleSites/Web.Client/SampleSite.Web.Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

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

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

<ItemGroup>
<ProjectReference Include="..\Components\SampleSite.Components.csproj" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions SampleSites/Web.Client/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@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.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using SampleSite.Web.Client
@using SampleSite.Components
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<base href="/" />
<link rel="stylesheet" href="data:text/css,%23blazor-error-ui%7Bbackground%3A%23ffffe0%3Bbottom%3A0%3Bbox-shadow%3A0%20-1px%202px%20rgba(0%2C0%2C0%2C.2)%3Bdisplay%3Anone%3Bleft%3A0%3Bpadding%3A.6rem%201.25rem%20.7rem%201.25rem%3Bposition%3Afixed%3Bwidth%3A100%25%3Bz-index%3A1000%7D%23blazor-error-ui%20.dismiss%7Bcursor%3Apointer%3Bposition%3Aabsolute%3Bright%3A.75rem%3Btop%3A.5rem%7D" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
<link rel="stylesheet" href="SampleSite.Server8.styles.css" />
<link rel="stylesheet" href="SampleSite.Web.styles.css" />
<HeadOutlet />
</head>

Expand Down
13 changes: 13 additions & 0 deletions SampleSites/Web/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@inherits LayoutComponentBase

<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/interactive-server">Interactive Server</a></li>
</ul>
</nav>

<main>
@Body
</main>
13 changes: 13 additions & 0 deletions SampleSites/Web/Components/Layout/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ul {
padding: 0;
display: flex;
flex-direction: row;
gap: 12px;
}

li {
list-style: none;
background-color: var(--button-base);
padding: 8px 16px;
border-radius: 4px;
}
4 changes: 4 additions & 0 deletions SampleSites/Web/Components/Pages/About.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@page "/about"

<h1>About Blazor Speech Synthesis</h1>

6 changes: 6 additions & 0 deletions SampleSites/Web/Components/Routes.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new []{ typeof(Client._Imports).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="[autofocus]" />
</Found>
</Router>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using SampleSite.Server8
@using SampleSite.Components
@using SampleSite.Server8.Components
@using SampleSite.Web
@using SampleSite.Web.Components
@using SampleSite.Web.Components.Layout
13 changes: 6 additions & 7 deletions SampleSites/Server8/Program.cs → SampleSites/Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using SampleSite.Server8.Components;
using Toolbelt.Blazor.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

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

builder.Services.AddSpeechSynthesis();

Expand All @@ -28,9 +27,9 @@
app.UseStaticFiles();
app.UseAntiforgery();

app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
//.AddInteractiveWebAssemblyRenderMode()
//.AddAdditionalAssemblies(typeof(BlazorApp1.Client.Components.SpeechRecognitionComponent).Assembly);
app.MapRazorComponents<SampleSite.Web.Components.App>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(SampleSite.Web.Client._Imports).Assembly);

app.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Components\SampleSite.Components.csproj" />
<ProjectReference Include="..\Web.Client\SampleSite.Web.Client.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
19 changes: 13 additions & 6 deletions Toolbelt.Blazor.SpeechSynthesis.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Client", "Sample
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Server", "SampleSites\Server\SampleSite.Server.csproj", "{E48F124D-D559-49E9-98EA-67927D4CE5E0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Server8", "SampleSites\Server8\SampleSite.Server8.csproj", "{BC5E5FF0-26BC-4FFA-AFF0-B283BBFB0987}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Web.Client", "SampleSites\Web.Client\SampleSite.Web.Client.csproj", "{D6916FEF-9736-4292-8772-2CE67C59BBDD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Web", "SampleSites\Web\SampleSite.Web.csproj", "{67855B7A-2B64-4D08-8A45-194B830439F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -48,10 +50,14 @@ Global
{E48F124D-D559-49E9-98EA-67927D4CE5E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E48F124D-D559-49E9-98EA-67927D4CE5E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E48F124D-D559-49E9-98EA-67927D4CE5E0}.Release|Any CPU.Build.0 = Release|Any CPU
{BC5E5FF0-26BC-4FFA-AFF0-B283BBFB0987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC5E5FF0-26BC-4FFA-AFF0-B283BBFB0987}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC5E5FF0-26BC-4FFA-AFF0-B283BBFB0987}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC5E5FF0-26BC-4FFA-AFF0-B283BBFB0987}.Release|Any CPU.Build.0 = Release|Any CPU
{D6916FEF-9736-4292-8772-2CE67C59BBDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6916FEF-9736-4292-8772-2CE67C59BBDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6916FEF-9736-4292-8772-2CE67C59BBDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6916FEF-9736-4292-8772-2CE67C59BBDD}.Release|Any CPU.Build.0 = Release|Any CPU
{67855B7A-2B64-4D08-8A45-194B830439F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67855B7A-2B64-4D08-8A45-194B830439F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67855B7A-2B64-4D08-8A45-194B830439F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67855B7A-2B64-4D08-8A45-194B830439F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -60,7 +66,8 @@ Global
{954BB2D9-1772-4E62-A282-3C37FAD4DD30} = {D5BC12D8-F4C7-4AAA-AEDD-F4F9A024C53A}
{60DDE97F-F614-43DE-A106-5463967995B1} = {D5BC12D8-F4C7-4AAA-AEDD-F4F9A024C53A}
{E48F124D-D559-49E9-98EA-67927D4CE5E0} = {D5BC12D8-F4C7-4AAA-AEDD-F4F9A024C53A}
{BC5E5FF0-26BC-4FFA-AFF0-B283BBFB0987} = {D5BC12D8-F4C7-4AAA-AEDD-F4F9A024C53A}
{D6916FEF-9736-4292-8772-2CE67C59BBDD} = {D5BC12D8-F4C7-4AAA-AEDD-F4F9A024C53A}
{67855B7A-2B64-4D08-8A45-194B830439F9} = {D5BC12D8-F4C7-4AAA-AEDD-F4F9A024C53A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55EFE8E5-C3EB-4128-9592-F27026A30FC6}
Expand Down

0 comments on commit 263cf97

Please sign in to comment.