Skip to content

Commit 9a09c24

Browse files
authored
feat(Menu): redesign collapse logic (#4672)
* refactor: 更改样式名称 * refactor: 更新 Menu 透明样式 * refactor: 精简样式 * test: 更新单元测试
1 parent 624ade0 commit 9a09c24

File tree

5 files changed

+7
-30
lines changed

5 files changed

+7
-30
lines changed

src/BootstrapBlazor/Components/Menu/Menu.razor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public partial class Menu
1616
protected string? ClassString => CssBuilder.Default("menu")
1717
.AddClass("is-bottom", IsBottom)
1818
.AddClass("is-vertical", IsVertical)
19-
.AddClass("is-collapsed", IsVertical && IsCollapsed)
2019
.AddClassFromAttributes(AdditionalAttributes)
2120
.Build();
2221

src/BootstrapBlazor/Components/Menu/Menu.razor.scss

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,15 @@
9999
transform: rotate(-90deg);
100100
}
101101

102-
.menu .text {
102+
.menu .menu-text {
103103
overflow: hidden;
104104
vertical-align: top;
105105
display: inline-block;
106-
transition: width .3s linear;
106+
opacity: 1;
107+
transition: opacity .3s linear;
107108
}
108109

109-
.menu .nav .nav-link .text {
110+
.menu .nav .nav-link .menu-text {
110111
margin-left: 4px;
111112
}
112113

@@ -162,7 +163,7 @@
162163
transform: rotate(-90deg);
163164
}
164165

165-
.menu .submenu .nav-link .text,
166+
.menu .submenu .nav-link .menu-text,
166167
.menu .submenu .nav-link .widget {
167168
margin: 0 4px;
168169
}
@@ -179,12 +180,6 @@
179180
background-image: none;
180181
}
181182

182-
@media (min-width: 768px) {
183-
.layout-side.is-collapsed:not(:hover) .menu.is-collapsed .submenu .text {
184-
width: 0;
185-
}
186-
}
187-
188183
.menu.is-bottom {
189184
position: absolute;
190185
bottom: 0;

src/BootstrapBlazor/Components/Menu/MenuLink.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ else
1313
<NavLink @attributes="@AdditionalAttributes" @onclick:preventDefault="@PreventDefault" class="@ClassString" href="@HrefString" target="@TargetString" Match="@ItemMatch" style="@StyleClassString" aria-expanded="@AriaExpandedString">
1414
<div class="flex-fill">
1515
<i class="@IconString"></i>
16-
<span class="text">@Item.Text</span>
16+
<span class="menu-text">@Item.Text</span>
1717
</div>
1818
@if (Item.Template != null)
1919
{

src/BootstrapBlazor/Components/Menu/TopMenu.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{
1212
<i class="@GetIconString(menu.Icon)"></i>
1313
}
14-
<span class="text">@menu.Text</span>
14+
<span class="menu-text">@menu.Text</span>
1515
</a>
1616
@if (!menu.IsDisabled)
1717
{

test/UnitTest/Components/MenuTest.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,6 @@ public void IndentSize_Ok()
216216
Assert.Contains("padding-left: 32px;", cut.Markup);
217217
}
218218

219-
[Fact]
220-
public void IsCollapsed_Ok()
221-
{
222-
var cut = Context.RenderComponent<Menu>(pb =>
223-
{
224-
pb.Add(m => m.Items, Items);
225-
pb.Add(m => m.IsCollapsed, true);
226-
});
227-
Assert.DoesNotContain("is-collapsed", cut.Markup);
228-
229-
cut.SetParametersAndRender(pb =>
230-
{
231-
pb.Add(m => m.IsVertical, true);
232-
});
233-
Assert.Contains("is-collapsed", cut.Markup);
234-
}
235-
236219
[Fact]
237220
public void IsDisabled_Ok()
238221
{

0 commit comments

Comments
 (0)