Skip to content

Commit

Permalink
refactor: fix error layout
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-shirbandi committed Nov 17, 2024
1 parent ef47f7b commit bc2aeea
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 100 deletions.
33 changes: 13 additions & 20 deletions src/1-Libraries/Web.Blazor.Server/Components/Error.razor
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@


<div class="@(WrapperClass)">

<div class="card bg-form shadow mb-5 min-height-20rem width-xs-90 width-sm-40 width-md-40">
<div class="card-header text-center text-@Type h2 p-3">@Title</div>
<div class="card-body p-3 text-center text-white-50">
<p>
@Message
</p>
<i class="bi bi-exclamation-triangle-fill opacity-30" style="font-size:8rem;"></i>
</div>
@if (ShowIndexLink)
{
<div class="card-footer">
<a href="/" class="btn btn-warning d-block">@Localizer[BlazorResource.Error_Page_Home_Btn]</a>
</div>
}
<div class="card bg-form shadow mb-5 min-height-20rem width-xs-90 width-sm-40 width-md-40">
<div class="card-header text-center text-@Type h2 p-3">@Title</div>
<div class="card-body p-3 text-center text-white-50">
<p>
@Message
</p>
<i class="bi bi-exclamation-triangle-fill opacity-30" style="font-size:8rem;"></i>
</div>

@if (ShowIndexLink)
{
<div class="card-footer">
<a href="/" class="btn btn-warning d-block">@Localizer[BlazorResource.Error_Page_Home_Btn]</a>
</div>
}
</div>


@code {
[Parameter]
public string WrapperClass { get; set; } = "d-flex flex-column min-height-90 justify-content-center align-items-center";

[Parameter]
public string Type { get; set; } = "warning";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/1-Libraries/Web.Blazor.Server/Resources/BlazorResource.fa.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,16 @@
<data name="Connection_State_Reload_Btn" xml:space="preserve">
<value>رفرش کردن صفحه</value>
</data>
<data name="Error_NotFound_Title" xml:space="preserve">
<value>صفحه ی مورد نظر پیدا نشد!</value>
</data>
<data name="Error_Authorization_Message" xml:space="preserve">
<value>شما به تازگی به سیستم وارد شدی، کمی زمان نیاز داریم که این موضوع رو بررسی کنیم</value>
</data>
<data name="Error_Authorization_Title" xml:space="preserve">
<value>در حال احراز هویت ...</value>
</data>
<data name="Error_NotFound_Message" xml:space="preserve">
<value>متاسفیم! صفحه ای که دنبالش بودی پیدا نشد.</value>
</data>
</root>
12 changes: 12 additions & 0 deletions src/1-Libraries/Web.Blazor.Server/Resources/BlazorResource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,16 @@
<data name="Connection_State_Reload_Btn" xml:space="preserve">
<value>Reload</value>
</data>
<data name="Error_NotFound_Title" xml:space="preserve">
<value>Page not found!</value>
</data>
<data name="Error_Authorization_Message" xml:space="preserve">
<value>We are authorizing, please wait.</value>
</data>
<data name="Error_Authorization_Title" xml:space="preserve">
<value>Authorizing ...</value>
</data>
<data name="Error_NotFound_Message" xml:space="preserve">
<value>Sorry! It seems the page that you are looking for, does not exist.</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/1-Libraries/Web.Blazor.Server/Web.Blazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyName>CodeBlock.DevKit.Web.Blazor.Server</AssemblyName>
<RootNamespace>CodeBlock.DevKit.Web.Blazor.Server</RootNamespace>
<Description>CodeBlock Development Kit</Description>
<VersionPrefix>1.1.3</VersionPrefix>
<VersionPrefix>1.1.5</VersionPrefix>
<Authors>Hamed Shirbandi</Authors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>CodeBlock.DevKit.Web.Blazor.Server</PackageId>
Expand Down
12 changes: 8 additions & 4 deletions src/4-Examples/BlazorServerApp/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
<Error ShowIndexLink=false Title="@Localizer[BlazorServerAppResource.Error_Authorization_Title]" Message="@Localizer[BlazorServerAppResource.Error_Authorization_Message]" />
<LayoutView Layout="@typeof(SimpleLayout)">
<Error ShowIndexLink=false Title="@AppLocalizer[BlazorResource.Error_Authorization_Title]" Message="@AppLocalizer[BlazorResource.Error_Authorization_Message]" />
</LayoutView>
</Authorizing>
<NotAuthorized>
<RedirectToLogin />
<LayoutView Layout="@typeof(SimpleLayout)">
<RedirectToLogin />
</LayoutView>
</NotAuthorized>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<Error Title="@Localizer[BlazorServerAppResource.Error_NotFound_Title]" Message="@Localizer[BlazorServerAppResource.Error_NotFound_Message]" />
<LayoutView Layout="@typeof(SimpleLayout)">
<Error Title="@BlazorLocalizer[BlazorResource.Error_NotFound_Title]" Message="@AppLocalizer[BlazorResource.Error_NotFound_Message]" />
</LayoutView>
</NotFound>
</Router>
Expand Down
2 changes: 1 addition & 1 deletion src/4-Examples/BlazorServerApp/Pages/Home/Index.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/"

<h1>@Localizer[BlazorServerAppResource.Home_Page_Welcome]</h1>
<h1>@AppLocalizer[BlazorServerAppResource.Home_Page_Welcome]</h1>


4 changes: 2 additions & 2 deletions src/4-Examples/BlazorServerApp/Pages/Home/Roles.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@page "/roles"
@using CodeBlock.DevKit.Authorization.UI.Pages.Roles

<PageTitle>@Localizer[BlazorServerAppResource.Nav_Menu_Roles]</PageTitle>
<PageTitle>@AppLocalizer[BlazorServerAppResource.Nav_Menu_Roles]</PageTitle>

<h1>@Localizer[BlazorServerAppResource.Nav_Menu_Roles]</h1>
<h1>@AppLocalizer[BlazorServerAppResource.Nav_Menu_Roles]</h1>


<RolesList />
Expand Down
4 changes: 2 additions & 2 deletions src/4-Examples/BlazorServerApp/Pages/Home/Users.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@page "/users"
@using CodeBlock.DevKit.Authorization.UI.Pages.Users

<PageTitle>@Localizer[BlazorServerAppResource.Nav_Menu_Users]</PageTitle>
<PageTitle>@AppLocalizer[BlazorServerAppResource.Nav_Menu_Users]</PageTitle>

<h1>@Localizer[BlazorServerAppResource.Nav_Menu_Users]</h1>
<h1>@AppLocalizer[BlazorServerAppResource.Nav_Menu_Users]</h1>

<UsersList />

Expand Down
2 changes: 0 additions & 2 deletions src/4-Examples/BlazorServerApp/Pages/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
<div class="top-row px-4">

<SelectLanguage />


<NavLink class="nav-link" href="logout">
<span class="bi bi-power" aria-hidden="true"></span>
</NavLink>
Expand Down
10 changes: 5 additions & 5 deletions src/4-Examples/BlazorServerApp/Pages/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">@Localizer[BlazorServerAppResource.App_Name]</a>
<a class="navbar-brand" href="">@AppLocalizer[BlazorServerAppResource.App_Name]</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
Expand All @@ -11,25 +11,25 @@
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-fill p-1" aria-hidden="true"></span> @Localizer[BlazorServerAppResource.Nav_Menu_Home]
<span class="bi bi-house-fill p-1" aria-hidden="true"></span> @AppLocalizer[BlazorServerAppResource.Nav_Menu_Home]
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="/users">
<span class="bi bi-people-fill p-1" aria-hidden="true"></span> @Localizer[BlazorServerAppResource.Nav_Menu_Users]
<span class="bi bi-people-fill p-1" aria-hidden="true"></span> @AppLocalizer[BlazorServerAppResource.Nav_Menu_Users]
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="/roles">
<span class="bi bi-command p-1" aria-hidden="true"></span> @Localizer[BlazorServerAppResource.Nav_Menu_Roles]
<span class="bi bi-command p-1" aria-hidden="true"></span> @AppLocalizer[BlazorServerAppResource.Nav_Menu_Roles]
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="/logout">
<span class="bi bi-power p-1" aria-hidden="true"></span> @Localizer[BlazorServerAppResource.Nav_Menu_Logout]
<span class="bi bi-power p-1" aria-hidden="true"></span> @AppLocalizer[BlazorServerAppResource.Nav_Menu_Logout]
</NavLink>
</div>
</nav>
Expand Down
16 changes: 16 additions & 0 deletions src/4-Examples/BlazorServerApp/Pages/Shared/SimpleLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@using Blazored.Toast
@using Blazored.Toast.Configuration
@inherits LayoutComponentBase

<div class="bg-primary">
<div class="fixed-top background-none p-0 h1">
<div class="card-body">
<SelectLanguage BtnClass="btn btn-outline-primary text-white" />
</div>
</div>


<div class="d-flex flex-column min-height-100 justify-content-center align-items-center">
@Body
</div>
</div>
9 changes: 7 additions & 2 deletions src/4-Examples/BlazorServerApp/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
</head>
<body class="bg-primary" style="font-family: @LocalizationSettings.GetCurrentLanguageFont() !important">

<partial name="_SelectLanguage" model="@("btn btn-danger")" />
<div class="fixed-top background-none p-0 h1">
<div class="card-body">
<partial name="_SelectLanguage" model="@("btn btn-outline-primary text-white")" />
</div>
</div>


<div class="d-flex flex-column min-height-90 justify-content-center align-items-center">
<div class="d-flex flex-column min-height-100 justify-content-center align-items-center">
@RenderBody()
</div>

Expand Down
3 changes: 3 additions & 0 deletions src/4-Examples/BlazorServerApp/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
@using CodeBlock.DevKit.Web.Localization
@using Microsoft.AspNetCore.Components.Web
@inject LocalizationSettings LocalizationSettings
@{
Layout = null;
}

<!DOCTYPE html>
<html dir="@LocalizationSettings.GetCurrentLanguageDirection()" lang="@LocalizationSettings.GetCurrentLanguageCode()" style="font-family: @LocalizationSettings.GetCurrentLanguageFont() !important">
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Error_Authorization_Title" xml:space="preserve">
<value>در حال احراز هویت ...</value>
</data>
<data name="Error_Authorization_Message" xml:space="preserve">
<value>شما به تازگی به سیستم وارد شدی، کمی زمان نیاز داریم که این موضوع رو بررسی کنیم</value>
</data>
<data name="Error_NotFound_Message" xml:space="preserve">
<value>متاسفیم! صفحه ای که دنبالش بودی پیدا نشد.</value>
</data>
<data name="Error_NotFound_Title" xml:space="preserve">
<value>صفحه ی مورد نظر پیدا نشد!</value>
</data>
<data name="Nav_Menu_Users" xml:space="preserve">
<value>کاربرها</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Error_Authorization_Title" xml:space="preserve">
<value>Authorizing ...</value>
</data>
<data name="Error_Authorization_Message" xml:space="preserve">
<value>We are authorizing, please wait.</value>
</data>
<data name="Error_NotFound_Message" xml:space="preserve">
<value>Sorry! It seems the page that you are looking for, does not exist.</value>
</data>
<data name="Error_NotFound_Title" xml:space="preserve">
<value>Page not found!</value>
</data>
<data name="Nav_Menu_Users" xml:space="preserve">
<value>Users</value>
</data>
Expand Down
4 changes: 3 additions & 1 deletion src/4-Examples/BlazorServerApp/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@using CodeBlock.DevKit.Core.Extensions
@using CodeBlock.DevKit.Web.Blazor.Server.Extensions
@using CodeBlock.DevKit.Web.Blazor.Server.Components
@using CodeBlock.DevKit.Web.Blazor.Server.Resources
@using Microsoft.Extensions.Localization
@using BlazorServerApp.Resources

Expand All @@ -24,4 +25,5 @@
@inject IModalService ModalService
@inject IBus Bus

@inject IStringLocalizer<BlazorServerAppResource> Localizer
@inject IStringLocalizer<BlazorServerAppResource> AppLocalizer
@inject IStringLocalizer<BlazorResource> BlazorLocalizer

0 comments on commit bc2aeea

Please sign in to comment.