Skip to content

Commit

Permalink
Implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomodo committed May 10, 2024
1 parent a7d9977 commit d7cde7d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<MudPopover Open="true" Style="my-custom-style:3px"
MaxHeight="@MaxHeight"
Paper="Paper"
DropShadow=@DropShadow
Elevation="Elevation"
Square="Square"
Fixed="Fixed"
Expand All @@ -31,4 +32,5 @@
[Parameter] public bool RelativeWidth { get; set; } = false;
[Parameter] public OverflowBehavior OverflowBehavior { get; set; } = OverflowBehavior.FlipNever;
[Parameter] public double Duration { get; set; } = 251;
[Parameter] public bool DropShadow { get; set; } = true; // Default
}
12 changes: 12 additions & 0 deletions src/MudBlazor.UnitTests/Components/PopoverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ public void MudPopover_DefaultValues()

popover.MaxHeight.Should().BeNull();
popover.Paper.Should().BeTrue();
popover.DropShadow.Should().BeTrue();
popover.Elevation.Should().Be(8);
popover.Square.Should().BeFalse();
popover.Open.Should().BeFalse();
Expand Down Expand Up @@ -1032,6 +1033,17 @@ public void MudPopover_Property_OverflowBehavior(OverflowBehavior overflowBehavi
popoverElement.ClassList.Should().Contain(new[] { "mud-popover-open", $"mud-popover-overflow-{expectedClass}", "my-custom-class" });
}

[Test]
public void MudPopover_Property_DropShadow_False_NoElevation()
{
var comp = Context.RenderComponent<PopoverPropertyTest>(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()
{
Expand Down
15 changes: 10 additions & 5 deletions src/MudBlazor/Components/Popover/MudPopover.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components;
using MudBlazor.Utilities;

namespace MudBlazor
Expand All @@ -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();
Expand Down Expand Up @@ -58,12 +56,19 @@ internal Direction ConvertDirection(Direction direction)
[Category(CategoryTypes.Popover.Appearance)]
public bool Paper { get; set; } = true;

/// <summary>
/// Determines whether the popover has a drop-shadow. Default is true.
/// </summary>
[Parameter]
[Category(CategoryTypes.Menu.Appearance)]
public bool DropShadow { get; set; } = true;

/// <summary>
/// The higher the number, the heavier the drop-shadow.
/// </summary>
[Parameter]
[Category(CategoryTypes.Popover.Appearance)]
public int Elevation { set; get; } = 8;
public int Elevation { set; get; } = MudGlobal.Popover.Elevation;

/// <summary>
/// If true, border-radius is set to 0.
Expand Down
8 changes: 8 additions & 0 deletions src/MudBlazor/Services/MudGlobal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ private static void OnDefaultExceptionHandler(Exception ex)
{
Console.Write(ex);
}

public static class Popover
{
/// <summary>
/// The default elevation level for <see cref="MudPopover"/>.
/// </summary>
public static int Elevation { get; set; } = 8;
}
}

0 comments on commit d7cde7d

Please sign in to comment.