Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Segmented): update style for segmented item #2898

Merged
merged 5 commits into from
Feb 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public abstract class PopConfirmButtonBase : ButtonBase
/// 获得/设置 点击确认弹窗前回调方法 返回真时弹出弹窗 返回假时不弹出 默认 null
/// </summary>
[Parameter]
[NotNull]
public Func<Task<bool>>? OnBeforeClick { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Modal/ModalDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public partial class ModalDialog : IHandlerException
public RenderFragment? HeaderTemplate { get; set; }

/// <summary>
/// 获得/设置 保存按钮回调委托
/// 获得/设置 保存按钮回调委托 返回 true 并且设置 <see cref="IsAutoCloseAfterSave"/> true 时自动关闭弹窗
/// </summary>
[Parameter]
public Func<Task<bool>>? OnSaveAsync { get; set; }
Expand Down
6 changes: 4 additions & 2 deletions src/BootstrapBlazor/Components/Segmented/Segmented.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@

.segmented-item {
padding: var(--bb-segmented-item-padding);
text-align: center;
cursor: pointer;
border-radius: var(--bb-segmented-item-border-radius);
line-height: var(--bb-segmented-item-height);
font-size: var(--bb-segmented-item-font-size);
position: relative;
transition: color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
white-space: nowrap;
display: flex;
align-items: center;
justify-content: center;

&.mask {
background-color: var(--bb-segmented-item-selected-bg);
Expand Down Expand Up @@ -111,5 +113,5 @@
}

[data-bs-theme='dark'] .segmented {
--bb-segmented-item-selected-bg: rgba(var(--bs-body-color-rgb),.12);
--bb-segmented-item-selected-bg: rgba(var(--bs-body-color-rgb),.12);
}
9 changes: 2 additions & 7 deletions src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,8 @@ public static async Task ShowSaveDialog<TComponent>(this DialogService service,
ShowSaveButton = true,
OnSaveAsync = saveCallback
};
Dictionary<string, object?>? parameters = null;
if (parametersFactory != null)
{
parameters = [];
parametersFactory.Invoke(parameters);
}
var parameters = new Dictionary<string, object?>();
parametersFactory?.Invoke(parameters);
option.Component = BootstrapDynamicComponent.CreateComponent<TComponent>(parameters);
configureOption?.Invoke(option);
await service.Show(option, dialog);
Expand All @@ -238,7 +234,6 @@ public static async Task ShowCloseDialog<TComponent>(this DialogService service,
parametersFactory?.Invoke(parameters);
option.Component = BootstrapDynamicComponent.CreateComponent<TComponent>(parameters);
configureOption?.Invoke(option);

await service.Show(option, dialog);
}

Expand Down
14 changes: 7 additions & 7 deletions test/UnitTest/Components/DisplayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public void FormatterAsync_Ok()
{
var cut = Context.RenderComponent<Display<string>>(pb =>
{
pb.Add(a => a.FormatterAsync, new Func<string, Task<string>>(v =>
pb.Add(a => a.FormatterAsync, new Func<string, Task<string?>>(v =>
{
return Task.FromResult("FormattedValue");
return Task.FromResult<string?>("FormattedValue");
}));
});
Assert.Contains("FormattedValue", cut.Markup);
Expand Down Expand Up @@ -56,20 +56,20 @@ public void LookupService_Ok()
[Fact]
public void TypeResolver_Ok()
{
var cut = Context.RenderComponent<Display<DisplayTest.Fish[]>>(pb =>
var cut = Context.RenderComponent<Display<Fish[]>>(pb =>
{
pb.Add(a => a.Value, new DisplayTest.Fish[] { new DisplayTest.Fish() { Value = "1" } });
pb.Add(a => a.TypeResolver, new Func<Assembly, string, bool, Type>((assembly, typeName, ignoreCase) => typeof(DisplayTest.Fish)));
pb.Add(a => a.Value, new Fish[] { new() { Value = "1" } });
pb.Add(a => a.TypeResolver, new Func<Assembly, string, bool, Type>((assembly, typeName, ignoreCase) => typeof(Fish)));
});
Assert.Equal("<div class=\"form-control is-display\">1</div>", cut.Markup);
}

[Fact]
public void TypeResolver_Null()
{
var cut = Context.RenderComponent<Display<DisplayTest.Fish[]>>(pb =>
var cut = Context.RenderComponent<Display<Fish[]>>(pb =>
{
pb.Add(a => a.Value, new DisplayTest.Fish[] { new DisplayTest.Fish() { Value = "1" } });
pb.Add(a => a.Value, new Fish[] { new() { Value = "1" } });
});
Assert.Equal("<div class=\"form-control is-display\"></div>", cut.Markup);
}
Expand Down
4 changes: 2 additions & 2 deletions test/UnitTest/Components/TableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6949,9 +6949,9 @@ public void Value_Formatter()
var col = cut.FindComponent<TableColumn<Foo, int>>();
col.SetParametersAndRender(pb =>
{
pb.Add(a => a.Formatter, new Func<object?, Task<string>>(obj =>
pb.Add(a => a.Formatter, new Func<object?, Task<string?>>(obj =>
{
return Task.FromResult("test-formatter");
return Task.FromResult<string?>("test-formatter");
}));
});
var table = cut.FindComponent<MockTable>();
Expand Down
3 changes: 2 additions & 1 deletion test/UnitTest/Extensions/ITableColumnExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public void CopyValue_Ok()
FormatString = "test-format",
Formatter = obj =>
{
return Task.FromResult("test-formatter");
var ret = "test-formatter";
return Task.FromResult<string?>(ret);
},
HeaderTemplate = new RenderFragment<ITableColumn>(col => builder => builder.AddContent(0, "test-header")),
OnCellRender = args => { },
Expand Down
Loading