From ad1552e3431e3bd10d02288a3eb5e0ac2ec909c5 Mon Sep 17 00:00:00 2001 From: Neil Brommer Date: Thu, 16 Dec 2021 21:26:53 -0800 Subject: [PATCH] Move the containter list into it's own component --- .../Client/Components/BookmarkContainer.razor | 2 +- Start/Client/Components/ContainerList.razor | 77 ++++++++++++++++++ Start/Client/Pages/Index.razor | 80 ++----------------- Start/Client/Sass/app.scss | 27 +++++++ 4 files changed, 112 insertions(+), 74 deletions(-) create mode 100644 Start/Client/Components/ContainerList.razor diff --git a/Start/Client/Components/BookmarkContainer.razor b/Start/Client/Components/BookmarkContainer.razor index ea79e0c..69c68d0 100644 --- a/Start/Client/Components/BookmarkContainer.razor +++ b/Start/Client/Components/BookmarkContainer.razor @@ -7,7 +7,7 @@ @inject IDispatcher dispatch @inject IState state -
+
@if (this.state.Value.CurrentContainerState.ErrorMessage != null) { diff --git a/Start/Client/Components/ContainerList.razor b/Start/Client/Components/ContainerList.razor new file mode 100644 index 0000000..a9b3fb6 --- /dev/null +++ b/Start/Client/Components/ContainerList.razor @@ -0,0 +1,77 @@ +@using Fluxor +@using Start.Client.Store.State +@using Start.Client.Store.Features.CurrentContainer +@using Start.Client.Store.Features.CreateContainer +@using Start.Client.Store.Features.DeleteContainer +@using Start.Client.Store.Features.Sidebar + +@inherits Fluxor.Blazor.Web.Components.FluxorComponent + +@inject Blazored.LocalStorage.ILocalStorageService localStorage +@inject IState state +@inject IDispatcher dispatch + +
+ +
    + @foreach (BookmarkContainerDto container in this.state.Value.ContainerListState.Containers) + { + string itemClasses = "tab-item"; + if (container.BookmarkContainerId == this.state.Value.CurrentContainerState.Container?.BookmarkContainerId) + itemClasses += " active"; + + + } + @if (this.state.Value.EditMode) + { +
  • + +
  • + } +
+
+ +@code { + protected void ShowSidebar() + { + dispatch.Dispatch(new ShowSidebarAction()); + } + + protected void OnContainerClicked(int bookmarkContainerId) { + dispatch.Dispatch(new LoadCurrentContainerAction(bookmarkContainerId)); + } + + protected void OnCreateContainerClicked() + { + dispatch.Dispatch(new ShowCreateContainerFormAction()); + } + + protected void OnDeleteContainerClicked(int bookmarkContainerId) + { + BookmarkContainerDto? bookmarkContainerToDelete = this.state.Value.ContainerListState + .Containers + ?.FirstOrDefault(bc => bc.BookmarkContainerId == bookmarkContainerId); + + if (bookmarkContainerToDelete == null) + return; + + this.dispatch.Dispatch(new ShowDeleteContainerFormAction( + bookmarkContainerToDelete.BookmarkContainerId, bookmarkContainerToDelete.Title)); + } +} diff --git a/Start/Client/Pages/Index.razor b/Start/Client/Pages/Index.razor index 96a793e..1457eb4 100644 --- a/Start/Client/Pages/Index.razor +++ b/Start/Client/Pages/Index.razor @@ -1,18 +1,13 @@ @page "/" +@using Start.Client.Components +@using Start.Client.Store.State +@using Microsoft.AspNetCore.Authorization +@using Fluxor + @inherits Fluxor.Blazor.Web.Components.FluxorComponent -@using System.Linq -@using Start.Client.Components -@using Start.Client.Store.State -@using Start.Client.Store.Features.CurrentContainer -@using Start.Client.Store.Features.CreateContainer -@using Start.Client.Store.Features.DeleteContainer -@using Start.Client.Store.Features.Sidebar -@using Fluxor - -@* Distinguish from Refit.Authorize *@ -@attribute [Microsoft.AspNetCore.Authorization.Authorize] +@attribute [Authorize] @inject Blazored.LocalStorage.ILocalStorageService localStorage @inject IState state @@ -37,42 +32,7 @@ else { -
- -
    - @foreach (BookmarkContainerDto container in this.state.Value.ContainerListState.Containers) - { - string itemClasses = "tab-item"; - if (container.BookmarkContainerId == this.state.Value.CurrentContainerState.Container?.BookmarkContainerId) - itemClasses += " active"; - -
  • - - @container.Title - @if (this.state.Value.EditMode) - { - - } - -
  • - } - @if (this.state.Value.EditMode) - { -
  • - -
  • - } -
-
- + @* Data management forms *@ @@ -90,31 +50,5 @@ else @code { - protected void ShowSidebar() - { - dispatch.Dispatch(new ShowSidebarAction()); - } - protected void OnContainerSelected(int bookmarkContainerId) - { - dispatch.Dispatch(new LoadCurrentContainerAction(bookmarkContainerId)); - } - - protected void OnDeleteContainerClicked(int bookmarkContainerId) - { - BookmarkContainerDto? bookmarkContainerToDelete = this.state.Value.ContainerListState - .Containers - ?.FirstOrDefault(bc => bc.BookmarkContainerId == bookmarkContainerId); - - if (bookmarkContainerToDelete == null) - return; - - this.dispatch.Dispatch(new ShowDeleteContainerFormAction( - bookmarkContainerToDelete.BookmarkContainerId, bookmarkContainerToDelete.Title)); - } - - protected void OnCreateContainerClicked() - { - dispatch.Dispatch(new ShowCreateContainerFormAction()); - } } diff --git a/Start/Client/Sass/app.scss b/Start/Client/Sass/app.scss index 7538403..7ba3075 100644 --- a/Start/Client/Sass/app.scss +++ b/Start/Client/Sass/app.scss @@ -41,6 +41,33 @@ } +.tab li.tab-item:not(.tab-action) { + display: flex; + flex-direction: row; + align-items: center; + margin-right: 0.4rem; + + a { + flex: 1; + margin-right: 0; + } + + .btn-clear { + margin-top: 0; + margin-right: 0.4rem; + } + + &.active { + border-bottom: solid 0.1rem $primary-color; + + a { + border-bottom: none; + margin-right: 0; + } + } +} + + /* Spectre's default is no padding */ .container { padding: 0.4rem;