From d7cde7d7d87fbaad5e70a567f0dde9e63203214f Mon Sep 17 00:00:00 2001 From: Yomodo Date: Fri, 10 May 2024 10:26:26 +0200 Subject: [PATCH] Implemented --- .../Popover/PopoverPropertyTest.razor | 2 ++ .../Components/PopoverTests.cs | 12 ++++++++++++ .../Components/Popover/MudPopover.razor.cs | 15 ++++++++++----- src/MudBlazor/Services/MudGlobal.cs | 8 ++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/MudBlazor.UnitTests.Viewer/TestComponents/Popover/PopoverPropertyTest.razor b/src/MudBlazor.UnitTests.Viewer/TestComponents/Popover/PopoverPropertyTest.razor index 53459bfc6f7d..af870085b7df 100644 --- a/src/MudBlazor.UnitTests.Viewer/TestComponents/Popover/PopoverPropertyTest.razor +++ b/src/MudBlazor.UnitTests.Viewer/TestComponents/Popover/PopoverPropertyTest.razor @@ -5,6 +5,7 @@ (p => p.Add( + x => x.DropShadow, false)); + + var popoverElement = comp.Find(".test-popover-content").ParentElement; + + popoverElement.ClassList.Should().NotContain("mud-elevation-8"); + } + [Test] public async Task MudPopover_WithDynamicContent() { diff --git a/src/MudBlazor/Components/Popover/MudPopover.razor.cs b/src/MudBlazor/Components/Popover/MudPopover.razor.cs index 4ea3bd645c41..29b121c742df 100644 --- a/src/MudBlazor/Components/Popover/MudPopover.razor.cs +++ b/src/MudBlazor/Components/Popover/MudPopover.razor.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components; using MudBlazor.Utilities; namespace MudBlazor @@ -18,7 +16,7 @@ public partial class MudPopover : MudPopoverBase .AddClass($"mud-popover-relative-width", RelativeWidth) .AddClass($"mud-paper", Paper) .AddClass($"mud-paper-square", Paper && Square) - .AddClass($"mud-elevation-{Elevation}", Paper) + .AddClass($"mud-elevation-{Elevation}", Paper && DropShadow) .AddClass($"overflow-y-auto", MaxHeight != null) .AddClass(Class) .Build(); @@ -58,12 +56,19 @@ internal Direction ConvertDirection(Direction direction) [Category(CategoryTypes.Popover.Appearance)] public bool Paper { get; set; } = true; + /// + /// Determines whether the popover has a drop-shadow. Default is true. + /// + [Parameter] + [Category(CategoryTypes.Menu.Appearance)] + public bool DropShadow { get; set; } = true; + /// /// The higher the number, the heavier the drop-shadow. /// [Parameter] [Category(CategoryTypes.Popover.Appearance)] - public int Elevation { set; get; } = 8; + public int Elevation { set; get; } = MudGlobal.Popover.Elevation; /// /// If true, border-radius is set to 0. diff --git a/src/MudBlazor/Services/MudGlobal.cs b/src/MudBlazor/Services/MudGlobal.cs index 836adbe58f98..7b561678f460 100644 --- a/src/MudBlazor/Services/MudGlobal.cs +++ b/src/MudBlazor/Services/MudGlobal.cs @@ -96,4 +96,12 @@ private static void OnDefaultExceptionHandler(Exception ex) { Console.Write(ex); } + + public static class Popover + { + /// + /// The default elevation level for . + /// + public static int Elevation { get; set; } = 8; + } }