Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.5.0-beta13</Version>
<Version>9.5.0-beta15</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/BootstrapBlazor/Components/Layout/Layout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@
<Tab ClickTabToNavigation="ClickTabToNavigation" AdditionalAssemblies="@AdditionalAssemblies"
ShowExtendButtons="ShowTabExtendButtons" ShowClose="ShowTabItemClose" AllowDrag="AllowDragTab"
DefaultUrl="@TabDefaultUrl" ExcludeUrls="@ExcludeUrls" IsOnlyRenderActiveTab="IsOnlyRenderActiveTab"
TabStyle="TabStyle" ShowToolbar="@ShowToolbar" ToolbarTemplate="@ToolbarTemplate"
ShowRefreshToolbarButton="ShowRefreshToolbarButton" ShowFullscreenToolbarButton="ShowFullscreenToolbarButton"
RefreshToolbarButtonIcon="@RefreshToolbarButtonIcon" FullscreenToolbarButtonIcon="@FullscreenToolbarButtonIcon"
RefreshToolbarTooltipText="@RefreshToolbarTooltipText" FullscreenToolbarTooltipText="@FullscreenToolbarTooltipText"
OnToolbarRefreshCallback="OnToolbarRefreshCallback"
Body="@Main" NotAuthorized="NotAuthorized!" NotFound="NotFound!" NotFoundTabText="@NotFoundTabText">
</Tab>
}
Expand Down
60 changes: 60 additions & 0 deletions src/BootstrapBlazor/Components/Layout/Layout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,66 @@ public partial class Layout : IHandlerException
{
private bool IsSmallScreen { get; set; }

/// <summary>
/// Gets or sets the tab style. Default is <see cref="TabStyle.Default"/>.
/// </summary>
[Parameter]
public TabStyle TabStyle { get; set; }

/// <summary>
/// Gets or sets whether show the toolbar. Default is false.
/// </summary>
[Parameter]
public bool ShowToolbar { get; set; }

/// <summary>
/// Gets or sets the template of the toolbar button. Default is null.
/// </summary>
[Parameter]
public RenderFragment? ToolbarTemplate { get; set; }

/// <summary>
/// Gets or sets whether show the full screen button. Default is true.
/// </summary>
[Parameter]
public bool ShowFullscreenToolbarButton { get; set; } = true;

/// <summary>
/// Gets or sets the full screen toolbar button icon string. Default is null.
/// </summary>
[Parameter]
public string? FullscreenToolbarButtonIcon { get; set; }

/// <summary>
/// Gets or sets the full screen toolbar button tooltip string. Default is null.
/// </summary>
[Parameter]
public string? FullscreenToolbarTooltipText { get; set; }

/// <summary>
/// Gets or sets whether show the full screen button. Default is true.
/// </summary>
[Parameter]
public bool ShowRefreshToolbarButton { get; set; } = true;

/// <summary>
/// Gets or sets the refresh toolbar button icon string. Default is null.
/// </summary>
[Parameter]
public string? RefreshToolbarButtonIcon { get; set; }

/// <summary>
/// Gets or sets the refresh toolbar button tooltip string. Default is null.
/// </summary>
[Parameter]
public string? RefreshToolbarTooltipText { get; set; }

/// <summary>
/// Gets or sets the refresh toolbar button click event callback. Default is null.
/// </summary>
[Parameter]
public Func<Task>? OnToolbarRefreshCallback { get; set; }

/// <summary>
/// 获得/设置 侧边栏状态
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions src/BootstrapBlazor/Components/Tab/Tab.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,10 @@ public void AddTab(string url, string text, string? icon = null, bool active = t

private void AddTabItem(string url)
{
var parameters = new Dictionary<string, object?>();
var parameters = new Dictionary<string, object?>
{
{ nameof(TabItem.Url), url }
};
var context = RouteTableFactory.Create(AdditionalAssemblies, url);
if (context.Handler != null)
{
Expand All @@ -720,7 +723,6 @@ private void AddTabItem(string url)
var menu = GetMenuItem(url) ?? new MenuItem() { Text = url.Split("/").FirstOrDefault() };
SetTabItemParameters(menu.Text, menu.Icon, true, true);
}
parameters.Add(nameof(TabItem.Url), url);

parameters.Add(nameof(TabItem.ChildContent), new RenderFragment(builder =>
{
Expand Down
4 changes: 1 addition & 3 deletions src/BootstrapBlazor/Components/Tab/Tab.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
left: 0;
height: 2px;
background-color: var(--bb-tabs-bar-bg);
z-index: 1;
transition: transform .3s cubic-bezier(.645,.045,.355,1);
list-style: none;
}
Expand Down Expand Up @@ -559,10 +558,9 @@
align-items: flex-end;
flex-shrink: 0;
padding: 0 1rem;
z-index: 1;

&.active {
z-index: 5;
z-index: 1;

.tab-corner {
background-color: var(--bs-body-bg);
Expand Down
36 changes: 36 additions & 0 deletions test/UnitTest/Components/LayoutTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,42 @@ namespace UnitTest.Components;

public class LayoutTest : BootstrapBlazorTestBase
{
[Fact]
public void TabStyle_Ok()
{
var cut = Context.RenderComponent<Layout>(pb =>
{
pb.Add(a => a.UseTabSet, true);
pb.Add(a => a.TabStyle, TabStyle.Default);
pb.Add(a => a.RefreshToolbarButtonIcon, "test-refresh-icon");
pb.Add(a => a.FullscreenToolbarButtonIcon, "test-fullscreen-icon");
pb.Add(a => a.OnToolbarRefreshCallback, () => Task.CompletedTask);
pb.Add(a => a.RefreshToolbarTooltipText, "test-refresh-tooltip");
pb.Add(a => a.FullscreenToolbarTooltipText, "test-fullscreen-tooltip");
});
Assert.DoesNotContain("tabs-chrome", cut.Markup);
Assert.DoesNotContain("tabs-capsule", cut.Markup);

cut.SetParametersAndRender(pb => pb.Add(a => a.TabStyle, TabStyle.Capsule));
Assert.Contains("tabs-capsule", cut.Markup);

cut.SetParametersAndRender(pb => pb.Add(a => a.TabStyle, TabStyle.Chrome));
Assert.Contains("tabs-chrome", cut.Markup);

cut.SetParametersAndRender(pb => pb.Add(a => a.ShowToolbar, true));
Assert.Contains("tabs-nav-toolbar-refresh", cut.Markup);
Assert.Contains("tabs-nav-toolbar-fs", cut.Markup);

cut.SetParametersAndRender(pb => pb.Add(a => a.ShowRefreshToolbarButton, false));
Assert.DoesNotContain("tabs-nav-toolbar-refresh", cut.Markup);

cut.SetParametersAndRender(pb => pb.Add(a => a.ShowFullscreenToolbarButton, false));
Assert.DoesNotContain("tabs-nav-toolbar-fs", cut.Markup);

cut.SetParametersAndRender(pb => pb.Add(a => a.ToolbarTemplate, builder => builder.AddContent(0, "test-toolbar-template")));
Assert.Contains("test-toolbar-template", cut.Markup);
}

[Fact]
public void ShowFooter_OK()
{
Expand Down