Skip to content

Commit

Permalink
feat(Menu): redesign collapse logic (#4672)
Browse files Browse the repository at this point in the history
* refactor: 更改样式名称

* refactor: 更新 Menu 透明样式

* refactor: 精简样式

* test: 更新单元测试
  • Loading branch information
ArgoZhang authored Nov 16, 2024
1 parent 624ade0 commit 9a09c24
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/BootstrapBlazor/Components/Menu/Menu.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public partial class Menu
protected string? ClassString => CssBuilder.Default("menu")
.AddClass("is-bottom", IsBottom)
.AddClass("is-vertical", IsVertical)
.AddClass("is-collapsed", IsVertical && IsCollapsed)
.AddClassFromAttributes(AdditionalAttributes)
.Build();

Expand Down
15 changes: 5 additions & 10 deletions src/BootstrapBlazor/Components/Menu/Menu.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@
transform: rotate(-90deg);
}

.menu .text {
.menu .menu-text {
overflow: hidden;
vertical-align: top;
display: inline-block;
transition: width .3s linear;
opacity: 1;
transition: opacity .3s linear;
}

.menu .nav .nav-link .text {
.menu .nav .nav-link .menu-text {
margin-left: 4px;
}

Expand Down Expand Up @@ -162,7 +163,7 @@
transform: rotate(-90deg);
}

.menu .submenu .nav-link .text,
.menu .submenu .nav-link .menu-text,
.menu .submenu .nav-link .widget {
margin: 0 4px;
}
Expand All @@ -179,12 +180,6 @@
background-image: none;
}

@media (min-width: 768px) {
.layout-side.is-collapsed:not(:hover) .menu.is-collapsed .submenu .text {
width: 0;
}
}

.menu.is-bottom {
position: absolute;
bottom: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Menu/MenuLink.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ else
<NavLink @attributes="@AdditionalAttributes" @onclick:preventDefault="@PreventDefault" class="@ClassString" href="@HrefString" target="@TargetString" Match="@ItemMatch" style="@StyleClassString" aria-expanded="@AriaExpandedString">
<div class="flex-fill">
<i class="@IconString"></i>
<span class="text">@Item.Text</span>
<span class="menu-text">@Item.Text</span>
</div>
@if (Item.Template != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Menu/TopMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{
<i class="@GetIconString(menu.Icon)"></i>
}
<span class="text">@menu.Text</span>
<span class="menu-text">@menu.Text</span>
</a>
@if (!menu.IsDisabled)
{
Expand Down
17 changes: 0 additions & 17 deletions test/UnitTest/Components/MenuTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,6 @@ public void IndentSize_Ok()
Assert.Contains("padding-left: 32px;", cut.Markup);
}

[Fact]
public void IsCollapsed_Ok()
{
var cut = Context.RenderComponent<Menu>(pb =>
{
pb.Add(m => m.Items, Items);
pb.Add(m => m.IsCollapsed, true);
});
Assert.DoesNotContain("is-collapsed", cut.Markup);

cut.SetParametersAndRender(pb =>
{
pb.Add(m => m.IsVertical, true);
});
Assert.Contains("is-collapsed", cut.Markup);
}

[Fact]
public void IsDisabled_Ok()
{
Expand Down

0 comments on commit 9a09c24

Please sign in to comment.