Skip to content

Commit

Permalink
🚧 feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Dec 25, 2023
1 parent 991e01c commit 51dc6cd
Show file tree
Hide file tree
Showing 213 changed files with 381 additions and 258 deletions.
12 changes: 0 additions & 12 deletions Masa.Blazor.Pro/App.razor

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ public CookieStorage(IJSRuntime jsRuntime)

public async Task<string> GetAsync(string key)
{
return await _jsRuntime.InvokeAsync<string>(JsInteropConstants.GetCookie, key);
try
{
return await _jsRuntime.InvokeAsync<string>(JsInteropConstants.GetCookie, key);
}
catch (JSDisconnectedException)
{
// ignore
return string.Empty;
}
}

public async void SetAsync<T>(string key, T? value)
Expand All @@ -22,9 +30,9 @@ public async void SetAsync<T>(string key, T? value)
{
await _jsRuntime.InvokeVoidAsync(JsInteropConstants.SetCookie, key, value?.ToString());
}
catch
catch (JSDisconnectedException)
{
// ignored
// ignore
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Microsoft.Extensions.DependencyInjection
using System.Net.Http.Json;

namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Shared
namespace Masa.Blazor.Pro.Client.Layout
{
public partial class Favorite
{
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Login />
</div>
<div class="default-app-bar__nav @PageModeClass">
@if (_pageTab == PageModes.PageTab)
@if (GlobalConfig.PageMode == PageModes.PageTab)
{
<PageTabs @ref="_pageTabs" SelfPatterns="@s_selfPatterns" />
}
Expand All @@ -30,7 +30,7 @@

<MMain Class="fill-lighten-1">
<div class="pa-6">
@if (_pageTab == PageModes.PageTab)
@if (GlobalConfig.PageMode == PageModes.PageTab)
{
<PPageContainer PageTabs="@_pageTabs?.PPageTabs" SelfPatterns="@s_selfPatterns">
@Body
Expand All @@ -42,11 +42,17 @@
}
</div>
</MMain>
<Settings @bind-PageModel="_pageTab" @bind-Show=_showSetting />
<Settings @bind-Show=_showSetting />
</CascadingValue>
</PPageTabsProvider>
</MApp>

<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>

@code {

private static readonly string[] s_selfPatterns =
Expand All @@ -56,11 +62,9 @@

private bool? _showSetting;

private string? _pageTab;

private PageTabs? _pageTabs;

private string PageModeClass => _pageTab == PageModes.PageTab ? "page-mode--tab" : "page-mode--breadcrumb";
private string PageModeClass => GlobalConfig.PageMode == PageModes.PageTab ? "page-mode--tab" : "page-mode--breadcrumb";

protected override async Task OnAfterRenderAsync(bool firstRender)
{
Expand All @@ -69,6 +73,7 @@
if (firstRender)
{
await GlobalConfig.InitFromStorage();
StateHasChanged();
}
}

Expand Down
19 changes: 19 additions & 0 deletions Masa.Blazor.Pro/Masa.Blazor.Pro.Client/Layout/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#blazor-error-ui {
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}

#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,21 @@
[Parameter]
public EventCallback<bool?> ShowChanged { get; set; }

[Parameter]
public string PageModel { get; set; } = PageModes.PageTab;

[Parameter]
public string NavigationStyle { get; set; } = NavigationStyles.Flat;

[Parameter]
public EventCallback<string> PageModelChanged { get; set; }

[Parameter]
public EventCallback<string> NavigationBarStyleChanged { get; set; }

protected override async Task OnInitializedAsync()
{
if (PageModelChanged.HasDelegate)
await PageModelChanged.InvokeAsync(GlobalConfig.PageMode);
if (NavigationBarStyleChanged.HasDelegate)
await NavigationBarStyleChanged.InvokeAsync(GlobalConfig.NavigationStyle);
}

async Task PageModeChanged(string value)
void PageModeChanged(string value)
{
GlobalConfig.PageMode = value;
if (PageModelChanged.HasDelegate)
await PageModelChanged.InvokeAsync(value);
else PageModel = value;
}

async Task NavigationStyleChanged(string value)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

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

<ItemGroup>
<!-- <PackageReference Include="Masa.Blazor" Version="1.3.0-beta.5" />-->
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Masa.Blazor\src\Masa.Blazor\Masa.Blazor.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.ECommerce.Shop
namespace Masa.Blazor.Pro.Client.Pages.App.ECommerce.Shop
{
public partial class Shop : ProComponentBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.ECommerce.Shop;
namespace Masa.Blazor.Pro.Client.Pages.App.ECommerce.Shop;

public class ShopPage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,4 @@
</MCol>
</MRow>

<Masa.Blazor.Pro.Pages.App.Invoice.Components.AddPayment @bind-Show="_showAddPayment" />
<Masa.Blazor.Pro.Client.Pages.App.Invoice.Components.AddPayment @bind-Show="_showAddPayment" />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.Invoice
namespace Masa.Blazor.Pro.Client.Pages.App.Invoice
{
public partial class Add : ProComponentBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.Invoice.Components;
namespace Masa.Blazor.Pro.Client.Pages.App.Invoice.Components;

public partial class InvoiceList
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/app/invoice/list"

<Masa.Blazor.Pro.Client.Pages.App.Invoice.Components.InvoiceList />
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,5 @@
</MCol>
</MRow>

<Masa.Blazor.Pro.Pages.App.Invoice.Components.SendInvoice @bind-Show="_showSendInvoice" />
<Masa.Blazor.Pro.Pages.App.Invoice.Components.AddPayment @bind-Show="_showAddPayment" />
<Masa.Blazor.Pro.Client.Pages.App.Invoice.Components.SendInvoice @bind-Show="_showSendInvoice" />
<Masa.Blazor.Pro.Client.Pages.App.Invoice.Components.AddPayment @bind-Show="_showAddPayment" />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.Invoice
namespace Masa.Blazor.Pro.Client.Pages.App.Invoice
{
public partial class Preview
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.Invoice;
namespace Masa.Blazor.Pro.Client.Pages.App.Invoice;

public class InvoicePage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.Todo
namespace Masa.Blazor.Pro.Client.Pages.App.Todo
{
public partial class Todo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components.Forms;

namespace Masa.Blazor.Pro.Pages.App.Todo;
namespace Masa.Blazor.Pro.Client.Pages.App.Todo;

public partial class TodoDetail
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.User
namespace Masa.Blazor.Pro.Client.Pages.App.User
{
public partial class List
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
</MCol>
</MRow>

<Masa.Blazor.Pro.Pages.App.Invoice.Components.InvoiceList />
<Masa.Blazor.Pro.Client.Pages.App.Invoice.Components.InvoiceList />

@code {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.App.User;
namespace Masa.Blazor.Pro.Client.Pages.App.User;

public class UserPage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components.Web;

namespace Masa.Blazor.Pro.Pages.Authentication.Components;
namespace Masa.Blazor.Pro.Client.Pages.Authentication.Components;

public partial class Login
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@layout EmptyLayout

<div class="d-flex align-center" style="height:calc(100% - 96px)">
<Masa.Blazor.Pro.Pages.Authentication.Components.Login />
<Masa.Blazor.Pro.Client.Pages.Authentication.Components.Login />
</div>

<MFooter Padless Height=96 Style="background:transparent;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
</MCol>
<MCol Md=8 Sm=12 Class="fill-lighten-1 block-center">
<Masa.Blazor.Pro.Pages.Authentication.Components.Login
<Masa.Blazor.Pro.Client.Pages.Authentication.Components.Login
HideLogo
Elevation="0"
Width="500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,5 +431,5 @@
</MRow>

<div class="mt-7">
<Masa.Blazor.Pro.Pages.App.Invoice.Components.InvoiceList />
<Masa.Blazor.Pro.Client.Pages.App.Invoice.Components.InvoiceList />
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.Dashboard
namespace Masa.Blazor.Pro.Client.Pages.Dashboard
{
public partial class Analytics : ProComponentBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Masa.Blazor.Pro.Pages.Dashboard
namespace Masa.Blazor.Pro.Client.Pages.Dashboard
{
public partial class ECommerce : ProComponentBase
{
Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions Masa.Blazor.Pro/Masa.Blazor.Pro.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Services.AddMasaBlazor(options =>
{
options.ConfigureTheme(theme =>
{
theme.Themes.Light.Primary = "#4318FF";
theme.Themes.Light.Accent = "#4318FF";
});
});
// .AddI18nForWasmAsync($"{builder.HostEnvironment.BaseAddress}/i18n");

await builder.Services.AddGlobalForWasmAsync(builder.HostEnvironment.BaseAddress);

await builder.Build().RunAsync();
6 changes: 6 additions & 0 deletions Masa.Blazor.Pro/Masa.Blazor.Pro.Client/Routes.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
</Router>
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@
global using System.ComponentModel.DataAnnotations;
global using System.Reflection;
global using System.Text.Json;

Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using Masa.Blazor.Pro
@using Masa.Blazor.Pro.Shared
@using Masa.Blazor.Pro.Client.Layout
@using BlazorComponent
@using BlazorComponent.I18n
@using Masa.Blazor.Presets
@using Masa.Blazor.Pro.Pages
@using Masa.Blazor.Pro.Client.Pages
@using Masa.Blazor.Pro.Global
@using Masa.Blazor.Pro.Data
@using System.Diagnostics.CodeAnalysis
@using System.Diagnostics
@using Microsoft.AspNetCore.Components.Rendering
@using System.Globalization

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Loading

0 comments on commit 51dc6cd

Please sign in to comment.