From 23b2726f539824832191c275a63dc828e1a15ee6 Mon Sep 17 00:00:00 2001 From: Dominique Alexandre Date: Fri, 27 Dec 2024 16:49:41 -0500 Subject: [PATCH] The sidebar in the price overlay can now be resized --- .../Layouts/LayoutTwoColumn.razor | 73 ++++++++++++++++++- src/Sidekick.Common.Ui/wwwroot/css/app.css | 16 ++-- src/Sidekick.Common/Settings/SettingKeys.cs | 1 + .../PoeWikiMapInfo.razor | 2 +- .../Components/Filters/FiltersComponent.razor | 2 +- src/Sidekick.Modules.Trade/Prices.razor | 24 ++++-- 6 files changed, 99 insertions(+), 19 deletions(-) diff --git a/src/Sidekick.Common.Ui/Layouts/LayoutTwoColumn.razor b/src/Sidekick.Common.Ui/Layouts/LayoutTwoColumn.razor index cc1ecb12c..5cc542cdf 100644 --- a/src/Sidekick.Common.Ui/Layouts/LayoutTwoColumn.razor +++ b/src/Sidekick.Common.Ui/Layouts/LayoutTwoColumn.razor @@ -3,7 +3,7 @@ @TopContent
-
+
@LeftContent
@@ -22,6 +22,35 @@
+ + +@inject IJSRuntime jsRuntime + @code { [Parameter] @@ -30,6 +59,9 @@ [Parameter] public RenderFragment? LeftContent { get; set; } + [Parameter] + public int LeftContentWidth { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } @@ -39,4 +71,43 @@ [Parameter] public RenderFragment? BottomContent { get; set; } + [Parameter] + public EventCallback OnLeftContentResize { get; set; } + + private string LeftContentId { get; } = UiUtilities.GenerateId(); + + private string LeftContentClasses + { + get + { + var classes = new List { "relative", "overflow-auto", "min-w-[22em]", }; + + if (HasChildContent) classes.Add("max-w-[35em]"); + else classes.Add("w-full"); + + return string.Join(" ", classes); + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender && HasChildContent && OnLeftContentResize.HasDelegate) + { + try + { + var dotNetReference = DotNetObjectReference.Create(this); + await jsRuntime.InvokeVoidAsync("attachResizeObserver", LeftContentId, nameof(ResizeLeftContent), dotNetReference); + } + catch { } + } + } + + [JSInvokable] + public void ResizeLeftContent(int width) + { + if (width != 0) + { + OnLeftContentResize.InvokeAsync(width); + } + } } diff --git a/src/Sidekick.Common.Ui/wwwroot/css/app.css b/src/Sidekick.Common.Ui/wwwroot/css/app.css index 73072351d..a86b21177 100644 --- a/src/Sidekick.Common.Ui/wwwroot/css/app.css +++ b/src/Sidekick.Common.Ui/wwwroot/css/app.css @@ -1859,10 +1859,6 @@ video { width: 1em; } -.w-\[22em\] { - width: 22em; -} - .w-\[450px\] { width: 450px; } @@ -1908,6 +1904,10 @@ video { min-width: 1em; } +.min-w-\[22em\] { + min-width: 22em; +} + .min-w-full { min-width: 100%; } @@ -1916,6 +1916,10 @@ video { max-width: 15rem; } +.max-w-\[35em\] { + max-width: 35em; +} + .max-w-\[800px\] { max-width: 800px; } @@ -3355,10 +3359,6 @@ video { padding-bottom: 0.5rem; } -.pb-9 { - padding-bottom: 2.25rem; -} - .pb-\[21\.75\%\] { padding-bottom: 21.75%; } diff --git a/src/Sidekick.Common/Settings/SettingKeys.cs b/src/Sidekick.Common/Settings/SettingKeys.cs index c7d2dfd26..14da2fb58 100644 --- a/src/Sidekick.Common/Settings/SettingKeys.cs +++ b/src/Sidekick.Common/Settings/SettingKeys.cs @@ -48,6 +48,7 @@ public static class SettingKeys public const string PriceCheckCurrencyMode = nameof(PriceCheckCurrencyMode); public const string PriceCheckNormalizeValue = nameof(PriceCheckNormalizeValue); public const string PriceCheckCompactMode = nameof(PriceCheckCompactMode); + public const string PriceCheckSidebarWidth = nameof(PriceCheckSidebarWidth); public const string SaveWindowPositions = nameof(SaveWindowPositions); diff --git a/src/Sidekick.Modules.Maps/PoeWikiMapInfo.razor b/src/Sidekick.Modules.Maps/PoeWikiMapInfo.razor index 172612d2c..936c3999f 100644 --- a/src/Sidekick.Modules.Maps/PoeWikiMapInfo.razor +++ b/src/Sidekick.Modules.Maps/PoeWikiMapInfo.razor @@ -37,7 +37,7 @@ else if (Map != null) @if (Map.Screenshot != null) { -
+
@if (Map.AreaTypeTags?.Any() ?? false) {
diff --git a/src/Sidekick.Modules.Trade/Components/Filters/FiltersComponent.razor b/src/Sidekick.Modules.Trade/Components/Filters/FiltersComponent.razor index fbc10214f..1b88d479e 100644 --- a/src/Sidekick.Modules.Trade/Components/Filters/FiltersComponent.razor +++ b/src/Sidekick.Modules.Trade/Components/Filters/FiltersComponent.razor @@ -18,7 +18,7 @@ Influences="PriceCheckService.Item.Influences"/>
-
+
diff --git a/src/Sidekick.Modules.Trade/Prices.razor b/src/Sidekick.Modules.Trade/Prices.razor index 5d24b52b7..e684fe1f9 100644 --- a/src/Sidekick.Modules.Trade/Prices.razor +++ b/src/Sidekick.Modules.Trade/Prices.razor @@ -9,32 +9,32 @@ @inherits Sidekick.Common.Ui.Views.SidekickView - + - + - + - + @if (PriceCheckService.IsFilterLoading) { - + } else { - + } - - + + @@ -55,11 +55,14 @@ public override SidekickViewType ViewType => SidekickViewType.Overlay; + private int LeftContentWidth { get; set; } + protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); PriceCheckService.FilterLoadingChanged += StateHasChanged; CloseOnBlur = await SettingsService.GetBool(SettingKeys.PriceCheckCloseWithMouse); + LeftContentWidth = await SettingsService.GetInt(SettingKeys.PriceCheckSidebarWidth); } protected override async Task OnParametersSetAsync() @@ -74,6 +77,11 @@ await PriceCheckService.Initialize(ItemText.DecodeBase64Url() ?? string.Empty); } + private async Task OnLeftContentResize(int width) + { + await SettingsService.Set(SettingKeys.PriceCheckSidebarWidth, width); + } + public void Dispose() { PriceCheckService.FilterLoadingChanged -= StateHasChanged;