Skip to content

Commit

Permalink
[Developer] Updated the demo project to run as wasm
Browse files Browse the repository at this point in the history
Closes #16
  • Loading branch information
Alex Knijf authored and Aaltuj committed Jan 9, 2021
1 parent 156a951 commit ce3da14
Show file tree
Hide file tree
Showing 59 changed files with 1,232 additions and 12 deletions.
17 changes: 16 additions & 1 deletion FormGeneratorDemo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30104.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FormGeneratorDemo", "Demo\FormGeneratorDemo.csproj", "{93087E84-D125-415E-822A-9805A48C473B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGeneratorDemo.Server", "VxFormGeneratorDemo.Server\VxFormGeneratorDemo.Server.csproj", "{93087E84-D125-415E-822A-9805A48C473B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGenerator.Core", "VxFormGenerator.Core\VxFormGenerator.Core.csproj", "{EDEF4FEC-5088-4DF5-B057-2CDA074505EC}"
EndProject
Expand All @@ -13,13 +13,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGenerator.Components.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{793D7184-2846-4E6D-A4C4-7B93D5EB276E}"
ProjectSection(SolutionItems) = preProject
changlog.bat = changlog.bat
README.md = README.md
run.cmd = run.cmd
run.sh = run.sh
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGenerator.Core.Tests", "VxFormGenerator.Core.Tests\VxFormGenerator.Core.Tests.csproj", "{73AE376A-E7AA-4C7B-972C-6CAD787364D3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGeneratorDemoData", "VxFormGeneratorDemoData\VxFormGeneratorDemoData.csproj", "{17AC6DF2-4B77-4463-9EB8-D445A858C2F7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGeneratorDemo.Wasm", "VxFormGeneratorDemo.Wasm\VxFormGeneratorDemo.Wasm.csproj", "{D7388958-7877-4F05-A372-9639EEDF1C76}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VxFormGeneratorDemo.Shared", "VxFormGeneratorDemo.Shared\VxFormGeneratorDemo.Shared.csproj", "{EFD74D8B-C011-4464-B0DC-FDE5EFA1559E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -50,6 +57,14 @@ Global
{17AC6DF2-4B77-4463-9EB8-D445A858C2F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17AC6DF2-4B77-4463-9EB8-D445A858C2F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17AC6DF2-4B77-4463-9EB8-D445A858C2F7}.Release|Any CPU.Build.0 = Release|Any CPU
{D7388958-7877-4F05-A372-9639EEDF1C76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7388958-7877-4F05-A372-9639EEDF1C76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7388958-7877-4F05-A372-9639EEDF1C76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7388958-7877-4F05-A372-9639EEDF1C76}.Release|Any CPU.Build.0 = Release|Any CPU
{EFD74D8B-C011-4464-B0DC-FDE5EFA1559E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFD74D8B-C011-4464-B0DC-FDE5EFA1559E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFD74D8B-C011-4464-B0DC-FDE5EFA1559E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFD74D8B-C011-4464-B0DC-FDE5EFA1559E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public static void AddVxFormGenerator(this IServiceCollection services, Core.Lay
repository ?? new VxComponentsRepository(),
options ?? new VxFormOptions());
}

}
}
File renamed without changes.
5 changes: 4 additions & 1 deletion Demo/App.razor → VxFormGeneratorDemo.Server/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Router AppAssembly="@typeof(Program).Assembly">
@using VxFormGeneratorDemo.Shared.Navigation

<Router AppAssembly="@typeof(Program).Assembly"
AdditionalAssemblies="new[] { typeof(VxFormGeneratorDemo.Shared._Imports).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/"
@namespace FormGeneratorDemo.Pages
@namespace VxFormGeneratorDemo.Server.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
Expand Down
2 changes: 1 addition & 1 deletion Demo/Program.cs → VxFormGeneratorDemo.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace FormGeneratorDemo
namespace VxFormGeneratorDemo.Server
{
public class Program
{
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Demo/Startup.cs → VxFormGeneratorDemo.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@



namespace FormGeneratorDemo
namespace VxFormGeneratorDemo.Server
{
public class Startup
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
<ItemGroup>
<ProjectReference Include="..\VxFormGenerator.Components.Bootstrap\VxFormGenerator.Components.Bootstrap.csproj" />
<ProjectReference Include="..\VxFormGenerator.Components.Plain\VxFormGenerator.Components.Plain.csproj" />
<ProjectReference Include="..\VxFormGeneratorDemo.Shared\VxFormGeneratorDemo.Shared.csproj" />
<ProjectReference Include="..\VxFormGeneratorDemoData\VxFormGeneratorDemoData.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Shared\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using FormGeneratorDemo
@using FormGeneratorDemo.Shared
@using VxFormGeneratorDemo
@using VxFormGeneratorDemo.Server

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@inherits LayoutComponentBase
@namespace VxFormGeneratorDemo.Shared.Navigation

@inherits LayoutComponentBase

<div class="sidebar">
<NavMenu />
Expand Down
70 changes: 70 additions & 0 deletions VxFormGeneratorDemo.Shared/Shared/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

.main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
}

.top-row a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}

.top-row.auth {
justify-content: space-between;
}

.top-row a, .top-row .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.main > div {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class="top-row pl-4 navbar navbar-dark">
@namespace VxFormGeneratorDemo.Shared.Navigation

<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">VxFormGenerator Demo</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
Expand Down
62 changes: 62 additions & 0 deletions VxFormGeneratorDemo.Shared/Shared/NavMenu.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}

.top-row {
height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}

.navbar-brand {
font-size: 1.1rem;
}

.oi {
width: 2rem;
font-size: 1.1rem;
vertical-align: text-top;
top: -2px;
}

.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}

.nav-item:first-of-type {
padding-top: 1rem;
}

.nav-item:last-of-type {
padding-bottom: 1rem;
}

.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}

.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25);
color: white;
}

.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}

@media (min-width: 641px) {
.navbar-toggler {
display: none;
}

.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
}
21 changes: 21 additions & 0 deletions VxFormGeneratorDemo.Shared/VxFormGeneratorDemo.Shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>VxFormGeneratorDemo.Shared</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\VxFormGenerator.Components.Bootstrap\VxFormGenerator.Components.Bootstrap.csproj" />
<ProjectReference Include="..\VxFormGenerator.Components.Plain\VxFormGenerator.Components.Plain.csproj" />
<ProjectReference Include="..\VxFormGeneratorDemoData\VxFormGeneratorDemoData.csproj" />
</ItemGroup>



</Project>
7 changes: 7 additions & 0 deletions VxFormGeneratorDemo.Shared/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@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 Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
14 changes: 14 additions & 0 deletions VxFormGeneratorDemo.Wasm/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

@using VxFormGeneratorDemo.Shared.Navigation;

<Router AppAssembly="@typeof(Program).Assembly"
AdditionalAssemblies="new[] { typeof(VxFormGeneratorDemo.Shared._Imports).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
32 changes: 32 additions & 0 deletions VxFormGeneratorDemo.Wasm/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
#if BOOTSTRAP
using VxFormGenerator.Settings.Bootstrap;
#else
using VxFormGenerator.Settings.Plain;
#endif

namespace VxFormGeneratorDemo.Wasm
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");

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

builder.Services.AddVxFormGenerator();

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

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\VxFormGenerator.Components.Bootstrap\VxFormGenerator.Components.Bootstrap.csproj" />
<ProjectReference Include="..\VxFormGeneratorDemo.Shared\VxFormGeneratorDemo.Shared.csproj" />
<ProjectReference Include="..\VxFormGeneratorDemoData\VxFormGeneratorDemoData.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions VxFormGeneratorDemo.Wasm/_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 Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
Loading

0 comments on commit ce3da14

Please sign in to comment.