Skip to content

Commit

Permalink
MainFooter added to StoryBook
Browse files Browse the repository at this point in the history
  • Loading branch information
dyatlov-a committed Oct 24, 2024
1 parent 31b86b0 commit de26926
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@attribute [Stories("Features/MainFooter")]

<Stories TComponent="MainFooter" Layout="typeof(LightLayout)">
<Story Name="Default">
<Template>
<MainFooter />
</Template>
</Story>
</Stories>
1 change: 1 addition & 0 deletions src/Inc.TeamAssistant.Stories/Features/_Imports.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Inc.TeamAssistant.WebUI.Features.Main
@using Inc.TeamAssistant.WebUI.Features.Map
@using Inc.TeamAssistant.WebUI.Features.Layouts
@using Inc.TeamAssistant.CheckIn.Model.Queries.GetLocations
82 changes: 3 additions & 79 deletions src/Inc.TeamAssistant.WebUI/Features/Layouts/MainFooter.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@inject IRenderContext RenderContext
@inject NavRouter NavRouter
@inject IStringLocalizer<LayoutResources> Localizer
@inject MainFooterLinksFactory MainFooterLinksFactory

<div class="footer">
<div class="footer__container">
<div class="footer__content">
@foreach (var group in _links)
@foreach (var group in MainFooterLinksFactory.Create())
{
<div class="footer-group">
<span class="footer-group__header">@Localizer[group.Key]</span>
Expand All @@ -19,79 +18,4 @@
}
</div>
</div>
</div>

@code {
private IReadOnlyDictionary<string, IReadOnlyCollection<FooterLink>> _links = new Dictionary<string, IReadOnlyCollection<FooterLink>>();

protected override void OnInitialized() => Load();

private void Load()
{
const bool external = true;

_links = new Dictionary<string, IReadOnlyCollection<FooterLink>>
{
["GroupNavigation"] =
[
new FooterLink(
Localizer["LinkMain"],
NavRouter.CreateRoute(null),
!external),
new FooterLink(
Localizer["LinkConstructor"],
NavRouter.CreateRoute("constructor"),
!external),
new FooterLink(
Localizer["LinkDashboard"],
NavRouter.CreateRoute("dashboard"),
!external)
],
["GroupTech"] =
[
new FooterLink(
"DotNet",
"https://dotnet.microsoft.com/",
external),
new FooterLink(
"Blazor",
"https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor",
external),
new FooterLink(
"Nuke",
"https://nuke.build/",
external)
],
["GroupStorage"] =
[
new FooterLink(
"Postgres",
"https://www.postgresql.org/",
external),
new FooterLink(
"Npgsql",
"https://www.npgsql.org/",
external),
new FooterLink(
"FluentMigrator",
"https://fluentmigrator.github.io/",
external)
],
["GroupTools"] =
[
new FooterLink(
"Telegram.Bot",
"https://github.com/TelegramBots/Telegram.Bot",
external),
new FooterLink(
"FluentValidator",
"https://docs.fluentvalidation.net/",
external),
new FooterLink(
"GitHub",
"https://github.com/dyatlov-a/Inc.TeamAssistant",
external)
]
};
}
}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Inc.TeamAssistant.WebUI.Routing;
using Microsoft.Extensions.Localization;

namespace Inc.TeamAssistant.WebUI.Features.Layouts;

internal sealed class MainFooterLinksFactory
{
private readonly IStringLocalizer<LayoutResources> _localizer;
private readonly NavRouter _navRouter;

public MainFooterLinksFactory(IStringLocalizer<LayoutResources> localizer, NavRouter navRouter)
{
_localizer = localizer ?? throw new ArgumentNullException(nameof(localizer));
_navRouter = navRouter ?? throw new ArgumentNullException(nameof(navRouter));
}

public IReadOnlyDictionary<string, IReadOnlyCollection<FooterLink>> Create()
{
return new Dictionary<string, IReadOnlyCollection<FooterLink>>
{
["GroupNavigation"] =
[
new FooterLink(
_localizer["LinkMain"],
_navRouter.CreateRoute(null),
External: false),
new FooterLink(
_localizer["LinkConstructor"],
_navRouter.CreateRoute("constructor"),
External: false),
new FooterLink(
_localizer["LinkDashboard"],
_navRouter.CreateRoute("dashboard"),
External: false)
],
["GroupTech"] =
[
new FooterLink(
"DotNet",
"https://dotnet.microsoft.com/",
External: true),
new FooterLink(
"Blazor",
"https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor",
External: true),
new FooterLink(
"Nuke",
"https://nuke.build/",
External: true)
],
["GroupStorage"] =
[
new FooterLink(
"Postgres",
"https://www.postgresql.org/",
External: true),
new FooterLink(
"Npgsql",
"https://www.npgsql.org/",
External: true),
new FooterLink(
"FluentMigrator",
"https://fluentmigrator.github.io/",
External: true)
],
["GroupTools"] =
[
new FooterLink(
"Telegram.Bot",
"https://github.com/TelegramBots/Telegram.Bot",
External: true),
new FooterLink(
"FluentValidator",
"https://docs.fluentvalidation.net/",
External: true),
new FooterLink(
"GitHub",
"https://github.com/dyatlov-a/Inc.TeamAssistant",
External: true)
]
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Inc.TeamAssistant.WebUI.Features.Constructor.Stages.Stage4;
using Inc.TeamAssistant.WebUI.Features.Dashboard.Appraiser;
using Inc.TeamAssistant.WebUI.Features.Dashboard.Settings;
using Inc.TeamAssistant.WebUI.Features.Layouts;
using Inc.TeamAssistant.WebUI.Routing;
using Inc.TeamAssistant.WebUI.Services.ClientCore;
using Inc.TeamAssistant.WebUI.Services.Clients;
Expand Down Expand Up @@ -55,6 +56,7 @@ public static IServiceCollection AddIsomorphicServices(this IServiceCollection s
.AddScoped<AuthenticationStateProvider, AuthStateProvider>()
.AddScoped<FeaturesFactory>()
.AddScoped<DateSelectorFactory>()
.AddScoped<MainFooterLinksFactory>()
.AddScoped<RequestProcessor>()
.AddScoped<NavRouter>()
.AddScoped(typeof(DragAndDropService<>))
Expand Down

0 comments on commit de26926

Please sign in to comment.