-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Slider): support Range attribute (#2553)
* feat: 增加扩展方法 GetRange * feat: 支持 RangeAttribute * doc: 更新示例代码 * test: 增加单元测试 * chore: bump version 8.0.6-beta02
- Loading branch information
Showing
11 changed files
with
204 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/BootstrapBlazor.Server/Components/Samples/Sliders.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
namespace BootstrapBlazor.Server.Components.Samples; | ||
|
||
/// <summary> | ||
/// Slider 组件示例 | ||
/// </summary> | ||
public partial class Sliders | ||
{ | ||
private string DisplayText { get; set; } = "Range"; | ||
|
||
private double MaxValue { get; set; } = 100; | ||
|
||
private double MinValue { get; set; } = -100; | ||
|
||
private double CurrentValue { get; set; } = 0; | ||
|
||
private double Step { get; set; } = 20; | ||
|
||
private bool IsDisabled { get; set; } | ||
|
||
private bool UseInput { get; set; } | ||
|
||
private bool UseGroup { get; set; } | ||
|
||
private bool ShowLabel { get; set; } = true; | ||
|
||
[NotNull] | ||
private ConsoleLogger? Logger { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[Range(10, 100)] | ||
public int RangeValue { get; set; } = 20; | ||
|
||
private Task OnRangeSliderValueChanged(double value) | ||
{ | ||
Logger.Log($"RangeSlider: Bind Value: {value}"); | ||
return Task.CompletedTask; | ||
} | ||
|
||
/// <summary> | ||
/// 获得属性方法 | ||
/// </summary> | ||
/// <returns></returns> | ||
private AttributeItem[] GetAttributes() => | ||
[ | ||
new() | ||
{ | ||
Name = "IsDisabled", | ||
Description = Localizer["SlidersIsDisabled"], | ||
Type = "bool", | ||
ValueList = " — ", | ||
DefaultValue = "false" | ||
}, | ||
new() | ||
{ | ||
Name = "Value", | ||
Description = Localizer["SlidersValue"], | ||
Type = "int", | ||
ValueList = " — ", | ||
DefaultValue = " — " | ||
}, | ||
]; | ||
|
||
/// <summary> | ||
/// 获得事件方法 | ||
/// </summary> | ||
/// <returns></returns> | ||
private EventItem[] GetEvents() => | ||
[ | ||
new() | ||
{ | ||
Name = "ValueChanged", | ||
Description = Localizer["SlidersValueChanged"], | ||
Type ="EventCallback<int>" | ||
} | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters