From c962fe9669ee3d0ae904f73774702af84bb59fe1 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Thu, 28 Nov 2024 16:10:33 +0330 Subject: [PATCH 01/11] 1st commit --- .../Components/NavPanel/BitNavPanel.razor | 75 ++++++++++++++++++ .../Components/NavPanel/BitNavPanel.razor.cs | 15 ++++ .../Components/NavPanel/BitNavPanel.scss | 78 +++++++++++++++++++ .../Extras/NavPanel/BitNavPanelDemo.razor | 19 +++++ .../Extras/NavPanel/BitNavPanelDemo.razor.cs | 42 ++++++++++ .../NavPanel/BitNavPanelDemo.razor.scss | 0 6 files changed, 229 insertions(+) create mode 100644 src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor create mode 100644 src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs create mode 100644 src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss create mode 100644 src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor create mode 100644 src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.cs create mode 100644 src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.scss diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor new file mode 100644 index 0000000000..ac7a9ab08e --- /dev/null +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor @@ -0,0 +1,75 @@ +@namespace Bit.BlazorUI + +@if (isMenuOpen) +{ + +} + +@{ + var isToggled = !isMenuOpen && isMenuToggled; +} + +
+ + + + + + + + + + + @if (isToggled) + { + + } + + @if (filteredNavItems.Count == 0) + { + if (isToggled is false) + { + @Localizer[nameof(AppStrings.NothingFound)] + } + } + else + { + + } + + + + + @(isToggled ? "" : Localizer[nameof(AppStrings.SignOut)]) + + + +
\ No newline at end of file diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs new file mode 100644 index 0000000000..872236bee1 --- /dev/null +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs @@ -0,0 +1,15 @@ +using System.Diagnostics.CodeAnalysis; + +namespace Bit.BlazorUI; + +public partial class BitNavPanel : IDisposable +{ + private bool _disposed; + + public void Dispose() + { + if (_disposed) return; + + _disposed = true; + } +} diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss new file mode 100644 index 0000000000..efe31928b9 --- /dev/null +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss @@ -0,0 +1,78 @@ +.bit-npn { +} + +section { + top: 0; + padding: 1rem; + position: sticky; + overflow: hidden auto; + height: var(--app-height); + min-width: var(--nav-menu-width); + max-width: var(--nav-menu-width); + + &::-webkit-scrollbar { + width: 0; + } + + @include lt-md { + z-index: 3; + padding: 0; + position: fixed; + height: unset !important; + top: var(--app-inset-top); + bottom: var(--app-inset-bottom); + + &.closed { + display: none; + } + } +} + +.bit-macos { + section { + height: -webkit-fill-available; + + ::deep .panel { + height: -webkit-fill-available; + } + } +} + +.menu-overlay { + inset: 0; + z-index: 2; + width: 100%; + height: 100%; + position: fixed; + min-height: 100vh; + + @include gt-sm { + display: none; + } +} + +::deep { + .panel { + width: auto; + display: flex; + padding: 0.5rem; + min-height: 100%; + height: fit-content; + flex-direction: column; + background-color: $bit-color-background-secondary; + + @include lt-md { + padding: 1rem; + } + } + + .toggle-btn { + @include lt-md { + display: none; + } + } + + a { + text-decoration: none; + } +} diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor new file mode 100644 index 0000000000..58feadaa03 --- /dev/null +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor @@ -0,0 +1,19 @@ +@page "/components/navpanel" + +@inherits AppComponentBase + + + + + + + + + + \ No newline at end of file diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.cs new file mode 100644 index 0000000000..674e5e3275 --- /dev/null +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.cs @@ -0,0 +1,42 @@ + +namespace Bit.BlazorUI.Demo.Client.Core.Pages.Components.Extras.NavPanel; + +public partial class BitNavPanelDemo +{ + private readonly List componentParameters = + [ + new() + { + Name = "CanvasClass", + Type = "string?", + DefaultValue = "null", + Description = "The CSS class of the canvas element(s).", + }, + ]; + + private readonly List componentSubClasses = + [ + new() + { + Id = "pdf-reader-config", + Title = "BitPdfReaderConfig", + Parameters= + [ + new() + { + Name = "Id", + Type = "string", + DefaultValue = "Guid.NewGuid().ToString()", + Description = "The id of the pdf reader instance and its canvas element(s).", + }, + ] + } + ]; + + + + private readonly string example1RazorCode = @" +"; + private readonly string example1CsharpCode = @" +"; +} diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.scss b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.scss new file mode 100644 index 0000000000..e69de29bb2 From b13e8dc9032d202096cba1cea7ab65f3a055de43 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Wed, 4 Dec 2024 00:14:07 +0330 Subject: [PATCH 02/11] 2nd --- .../Components/NavPanel/BitNavPanel.razor | 22 ++-- .../Components/NavPanel/BitNavPanel.razor.cs | 95 ++++++++++++++++-- .../fabric.mdl2.bit.blazoui.extras.scss | 9 ++ .../FabMDL2.4.66.bit.BlazorUI.Extras.woff2 | Bin 1696 -> 1580 bytes .../Components/App.razor | 2 +- .../wwwroot/index.html | 2 +- 6 files changed, 107 insertions(+), 23 deletions(-) diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor index ac7a9ab08e..593eaa7884 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor @@ -21,24 +21,25 @@ Size="BitSize.Large" OnClick="ToggleNavPanel" Variant="BitVariant.Text" - Color="BitColor.TertiaryBackground" - IconName="@BitIconName.ColumnRightTwoThirds" /> + IconName="ColumnRightTwoThirds" + Color="BitColor.TertiaryBackground" /> @if (isToggled) { - } @@ -46,7 +47,7 @@ { if (isToggled is false) { - @Localizer[nameof(AppStrings.NothingFound)] + Nothing found! } } else @@ -62,14 +63,7 @@ - - @(isToggled ? "" : Localizer[nameof(AppStrings.SignOut)]) - + @*
*@ \ No newline at end of file diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs index 872236bee1..c680eb91fa 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs @@ -1,15 +1,96 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Bit.BlazorUI; +namespace Bit.BlazorUI; public partial class BitNavPanel : IDisposable { - private bool _disposed; + private bool disposed; + private bool isMenuOpen; + private bool isMenuToggled; + private bool isSignOutConfirmOpen; + private List allNavItems = []; + private Action unsubOpenNavPanel = default!; + private BitSearchBox searchBoxRef = default!; + private Action unsubUserDataChange = default!; + private List flatNavItemList = []; + private List filteredNavItems = []; - public void Dispose() + + protected override async Task OnInitializedAsync() + { + //CreateNavItems(); + flatNavItemList = Flatten(allNavItems).ToList().FindAll(link => !string.IsNullOrEmpty(link.Url)); + + SearchNavItems(null); + + //unsubOpenNavPanel = PubSubService.Subscribe(ClientPubSubMessages.OPEN_NAV_PANEL, async _ => + //{ + // isMenuOpen = true; + // StateHasChanged(); + //}); + } + + + private async Task ShowSignOutConfirm() { - if (_disposed) return; + isSignOutConfirmOpen = true; + await CloseMenu(); + } + + private async Task HandleNavItemClick(BitNavItem item) + { + if (string.IsNullOrEmpty(item.Url)) return; + + filteredNavItems = allNavItems; + + await CloseMenu(); + } + + private async Task CloseMenu() + { + isMenuOpen = false; + } - _disposed = true; + private async Task ToggleNavPanel() + { + isMenuToggled = !isMenuToggled; + if (isMenuToggled) + { + SearchNavItems(null); + } + } + + private async Task ToggleForSearch() + { + isMenuToggled = false; + await Task.Delay(1); + await searchBoxRef.FocusAsync(); + } + + private void SearchNavItems(string? searchText) + { + filteredNavItems = allNavItems; + if (searchText is null) return; + + filteredNavItems = allNavItems; + if (string.IsNullOrEmpty(searchText)) return; + + var mainItems = flatNavItemList + .FindAll(item => searchText.Split(' ') + .Where(t => string.IsNullOrEmpty(t) is false) + .Any(t => $"{item.Text} {item.Description}".Contains(t, StringComparison.InvariantCultureIgnoreCase))); + + var subItems = flatNavItemList + .FindAll(item => searchText.Split(' ') + .Where(t => string.IsNullOrEmpty(t) is false) + .Any(t => item.Data?.ToString()?.Contains(t, StringComparison.InvariantCultureIgnoreCase) ?? false)); + + filteredNavItems = [.. mainItems, .. subItems]; + } + + private static IEnumerable Flatten(IEnumerable e) => e.SelectMany(c => Flatten(c.ChildItems)).Concat(e); + + + public void Dispose() + { + disposed = true; } } diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Styles/fabric.mdl2.bit.blazoui.extras.scss b/src/BlazorUI/Bit.BlazorUI.Extras/Styles/fabric.mdl2.bit.blazoui.extras.scss index e372997a9a..7b869b44bc 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Styles/fabric.mdl2.bit.blazoui.extras.scss +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Styles/fabric.mdl2.bit.blazoui.extras.scss @@ -5,3 +5,12 @@ font-family: 'Fabric MDL2 bit BlazorUI Extras'; src: url('../fonts/FabMDL2.4.66.bit.BlazorUI.Extras.woff2') format("woff2"); } + +.bit-icon { + font-style: normal; + font-weight: normal; + display: inline-block; + font-family: 'Fabric MDL2 bit BlazorUI' !important; +} + +.bit-icon--ColumnRightTwoThirds:before { content: "\F1D7"; } \ No newline at end of file diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/fonts/FabMDL2.4.66.bit.BlazorUI.Extras.woff2 b/src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/fonts/FabMDL2.4.66.bit.BlazorUI.Extras.woff2 index ff7084633725716df6f84de435e5092b75a83e44..8f5238872665196110a36472d618e6e446427b31 100644 GIT binary patch delta 1564 zcmV+%2IKjl4Xg|pcTYw#00961000Io01yBG000oI000Hhkr*U@LI^4ef>{v^3Uq-8 z3km=MHUcCA5Ck9vlpO~$41rS{m=7Zn_G)kv1N_B-?T7}IqJqu2f^`)I$$qyTDa~Ox zPfjFDa4{S~ynm3h@AE()aVb}iH;}R@W#g!5utn9wEJ>nsW&0?NOws)xQpz=dU zvZg%Oh?mQM)b;;=<}{6<;IG;8+s!h8RIaEI@+wNC^Z zqd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ds^7nUGT}H}LuX zarM^VJg8y0PBB3$T*9woh;|e*Zx6fC$b9` z_g8RPJqKsPgZo;{Wlt)VV{`0irtKHipHp#X8F-f-FYBFET4Lc$C9J;ErB$|6s4M}d z`#H<)V}j4sGUouS(uS2Oa>EHD2^5P(;GZbKI^3Uu!q5n27z#W_fE>;Va%5+JlQ5%H zD0F$WNI<3-->;$MM=*}`d3Ju{9OqnxBWq{ppgU1aR2yPZKDJP3K&y|w@0^xyCVo!Q za6FtaQ1OgXPpS)3w!|FuqI=Vuo8M8l6r*@!QY6-*`73yQ>RWt;tpPHtaaxiADR+$d zHV$~A7SjRy6%5C9bo4Fi0--H`sx9Ez9VoiNlzXaN=Cx@n_S<+Op>ETr*M+AK zo6+>4YVdA;A#8)#gG1q6)MIc-8({I{>9dVsxJr-ffy(CBaM2#0R+b)rc2hsRX*=GH zJwmi-avr#_H6UI+jarJFG`igWzdlWW&;TBz$0all=L3Qg zC0a~y(b=apEt)g8+ib~j!sfu{dB6o7)7UCmYMN}#W*hIyzVWP~6%(-2cIBKjP&>1x z&q;3Fx_EMxle~sS)5erI$)7&HrZm?{!RX48eCwnzKQ}8dyr@BaN5$@*b9-keuuI5G bO45>%JWGFcl@v%;$|}9JM1pCKRV@Gjhz%V7 diff --git a/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor b/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor index 8d494028ae..ac4edc5dad 100644 --- a/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor +++ b/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor @@ -47,9 +47,9 @@ Microsoft Clarity --> + - diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/wwwroot/index.html b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/wwwroot/index.html index 0076c2e05e..01cbb664c3 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/wwwroot/index.html +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/wwwroot/index.html @@ -19,9 +19,9 @@ + - From 3686db99dbac1c979127c33bf326dfd475352ec3 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Wed, 4 Dec 2024 11:08:42 +0330 Subject: [PATCH 03/11] 3rd --- .../Components/NavPanel/BitNavPanel.razor | 23 +++++++++---------- .../Components/NavPanel/BitNavPanel.razor.cs | 4 ++-- .../Components/NavPanel/BitNavPanel.scss | 5 +--- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor index 593eaa7884..313b72d0b4 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor @@ -1,16 +1,15 @@ @namespace Bit.BlazorUI -@if (isMenuOpen) -{ - -} - @{ - var isToggled = !isMenuOpen && isMenuToggled; + var isToggled = !isPanelOpen && isMenuToggled; } -
- +
+ @if (isPanelOpen) + { +
+ } +
@@ -33,7 +32,7 @@ @if (isToggled) { - *@ - -
\ No newline at end of file + + \ No newline at end of file diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs index c680eb91fa..3edc7b1b70 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs @@ -3,7 +3,7 @@ public partial class BitNavPanel : IDisposable { private bool disposed; - private bool isMenuOpen; + private bool isPanelOpen; private bool isMenuToggled; private bool isSignOutConfirmOpen; private List allNavItems = []; @@ -46,7 +46,7 @@ private async Task HandleNavItemClick(BitNavItem item) private async Task CloseMenu() { - isMenuOpen = false; + isPanelOpen = false; } private async Task ToggleNavPanel() diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss index efe31928b9..5df77e85e8 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.scss @@ -1,7 +1,4 @@ .bit-npn { -} - -section { top: 0; padding: 1rem; position: sticky; @@ -38,7 +35,7 @@ section { } } -.menu-overlay { +.bit-npn-ovl { inset: 0; z-index: 2; width: 100%; From 2bd1c4a58fd306fdf2fdc0cdbedba4c50cd49f3f Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Sun, 22 Dec 2024 12:20:43 +0330 Subject: [PATCH 04/11] stuff --- .../Components/NavPanel/BitNavPanel.razor | 16 ++-- .../Components/NavPanel/BitNavPanel.razor.cs | 82 ++++++++++++------- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor index 313b72d0b4..f2a0049e18 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor @@ -1,11 +1,13 @@ @namespace Bit.BlazorUI +@inherits BitComponentBase +@typeparam TItem @{ - var isToggled = !isPanelOpen && isMenuToggled; + var isToggled = !_isPanelOpen && _isMenuToggled; } -
- @if (isPanelOpen) +
+ @if (_isPanelOpen) {
} @@ -24,7 +26,7 @@ Color="BitColor.TertiaryBackground" /> - } - @if (filteredNavItems.Count == 0) + @if (_filteredNavItems.Count == 0) { if (isToggled is false) { @@ -53,9 +55,9 @@ { } diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs index 3edc7b1b70..a64d46d835 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs @@ -1,23 +1,34 @@ -namespace Bit.BlazorUI; +using Microsoft.Extensions.Options; -public partial class BitNavPanel : IDisposable +namespace Bit.BlazorUI; + +public partial class BitNavPanel : BitComponentBase, IDisposable where TItem : class { - private bool disposed; - private bool isPanelOpen; - private bool isMenuToggled; - private bool isSignOutConfirmOpen; + private bool _disposed; + private bool _isPanelOpen; + private bool _isMenuToggled; private List allNavItems = []; - private Action unsubOpenNavPanel = default!; - private BitSearchBox searchBoxRef = default!; - private Action unsubUserDataChange = default!; - private List flatNavItemList = []; - private List filteredNavItems = []; + private BitSearchBox _searchBoxRef = default!; + private List _flatNavItemList = []; + private List _filteredNavItems = []; + + + + /// + /// A collection of item to display in the navigation bar. + /// + [Parameter] + [CallOnSet(nameof(OnSetItems))] + public IList Items { get; set; } = []; + + protected override string RootElementClass => "bit-nav"; + protected override async Task OnInitializedAsync() { //CreateNavItems(); - flatNavItemList = Flatten(allNavItems).ToList().FindAll(link => !string.IsNullOrEmpty(link.Url)); + _flatNavItemList = Flatten(allNavItems).ToList().FindAll(link => !string.IsNullOrEmpty(link.Url)); SearchNavItems(null); @@ -28,31 +39,24 @@ protected override async Task OnInitializedAsync() //}); } - - private async Task ShowSignOutConfirm() - { - isSignOutConfirmOpen = true; - await CloseMenu(); - } - private async Task HandleNavItemClick(BitNavItem item) { if (string.IsNullOrEmpty(item.Url)) return; - filteredNavItems = allNavItems; + _filteredNavItems = allNavItems; await CloseMenu(); } private async Task CloseMenu() { - isPanelOpen = false; + _isPanelOpen = false; } private async Task ToggleNavPanel() { - isMenuToggled = !isMenuToggled; - if (isMenuToggled) + _isMenuToggled = !_isMenuToggled; + if (_isMenuToggled) { SearchNavItems(null); } @@ -60,37 +64,53 @@ private async Task ToggleNavPanel() private async Task ToggleForSearch() { - isMenuToggled = false; + _isMenuToggled = false; await Task.Delay(1); - await searchBoxRef.FocusAsync(); + await _searchBoxRef.FocusAsync(); } private void SearchNavItems(string? searchText) { - filteredNavItems = allNavItems; + _filteredNavItems = allNavItems; if (searchText is null) return; - filteredNavItems = allNavItems; + _filteredNavItems = allNavItems; if (string.IsNullOrEmpty(searchText)) return; - var mainItems = flatNavItemList + var mainItems = _flatNavItemList .FindAll(item => searchText.Split(' ') .Where(t => string.IsNullOrEmpty(t) is false) .Any(t => $"{item.Text} {item.Description}".Contains(t, StringComparison.InvariantCultureIgnoreCase))); - var subItems = flatNavItemList + var subItems = _flatNavItemList .FindAll(item => searchText.Split(' ') .Where(t => string.IsNullOrEmpty(t) is false) .Any(t => item.Data?.ToString()?.Contains(t, StringComparison.InvariantCultureIgnoreCase) ?? false)); - filteredNavItems = [.. mainItems, .. subItems]; + _filteredNavItems = [.. mainItems, .. subItems]; } private static IEnumerable Flatten(IEnumerable e) => e.SelectMany(c => Flatten(c.ChildItems)).Concat(e); + private void OnSetItems() + { + if (ChildContent is not null || Options is not null || Items == _oldItems) return; + + _items = Items?.ToList() ?? []; + _oldItems = Items; + } + public void Dispose() { - disposed = true; + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing is false || _disposed) return; + + _disposed = true; } } From 0ee4417bedbef64b62e0e47167759370ecb90f63 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Sun, 22 Dec 2024 13:39:42 +0330 Subject: [PATCH 05/11] improve stuff --- .../Components/NavPanel/BitNavPanel.razor | 101 ++++++++++-------- .../Components/NavPanel/BitNavPanel.razor.cs | 77 ++++++------- .../Components/NavPanel/BitNavPanel.scss | 74 +++++++------ .../NavPanel/BitNavPanelClassStyles.cs | 9 ++ .../Extensions/LinqExtensions.cs | 49 +++++++++ .../Components/Navs/Nav/BitNav.razor.cs | 24 ++++- .../Extensions/StringExtensions.cs | 3 +- 7 files changed, 219 insertions(+), 118 deletions(-) create mode 100644 src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanelClassStyles.cs create mode 100644 src/BlazorUI/Bit.BlazorUI.Extras/Extensions/LinqExtensions.cs diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor index f2a0049e18..33a1040784 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor @@ -3,68 +3,83 @@ @typeparam TItem @{ - var isToggled = !_isPanelOpen && _isMenuToggled; + var isToggled = !_isPanelOpen && _isPanelToggled; } -
+