Skip to content

Commit eac7530

Browse files
authored
doc(RadioListGeneric): update sample code (#4912)
* doc(Safari): 更新标题栏颜色设置 * refactor: 精简代码 * refactor: 重构代码消除警告信息 * doc: 精简代码 * doc: 更新宽度 * doc: 格式化代码 * doc: 更新资源文件 * refactor: 更新示例代码
1 parent 72398af commit eac7530

File tree

7 files changed

+27
-32
lines changed

7 files changed

+27
-32
lines changed

src/BootstrapBlazor.Server/Components/App.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<html lang="en" data-bs-theme='light'>
77

88
<head>
9+
<meta name="theme-color" content="#712cf9">
910
<meta charset="utf-8" />
1011
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
1112
<meta http-equiv="X-UA-Compatible" content="IE=edge">

src/BootstrapBlazor.Server/Components/Samples/Radios.razor.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6-
using DocumentFormat.OpenXml.Office2010.Excel;
7-
using DocumentFormat.OpenXml.Wordprocessing;
8-
96
namespace BootstrapBlazor.Server.Components.Samples;
107

118
/// <summary>
@@ -58,8 +55,7 @@ private Task OnSelectedChanged(IEnumerable<SelectedItem> values, string val)
5855
[NotNull]
5956
private IEnumerable<SelectedItem<Foo>>? GenericItems { get; set; }
6057

61-
[NotNull]
62-
private Foo? _selectedFoo = default;
58+
private Foo _selectedFoo = new() { Id = 1 };
6359

6460
/// <summary>
6561
/// OnInitialized 方法
@@ -80,11 +76,11 @@ protected override void OnInitialized()
8076
new("2", Localizer["RadiosItem2"]) { IsDisabled = true }
8177
};
8278

83-
Items = new SelectedItem[]
84-
{
79+
Items =
80+
[
8581
new("1", Localizer["RadiosAdd1"]),
8682
new("2", Localizer["RadiosAdd2"])
87-
};
83+
];
8884

8985
IconDemoValues = new List<IconSelectedItem>()
9086
{
@@ -95,14 +91,13 @@ protected override void OnInitialized()
9591
Model = Foo.Generate(LocalizerFoo);
9692
FooItems = Foo.GetCompleteItems(LocalizerFoo);
9793

98-
GenericItems = new List<SelectedItem<Foo>>()
94+
_selectedFoo.Name = LocalizerFoo["Foo.Name", "001"];
95+
GenericItems = new List<SelectedItem<Foo>>
9996
{
100-
new() { Text = Localizer["item1"], Value = new Foo() { Id = 1, Name = LocalizerFoo["Foo.Name", "001"] } },
101-
new() { Text = Localizer["item2"], Value = new Foo() { Id = 2, Name = LocalizerFoo["Foo.Name", "002"] } },
102-
new() { Text = Localizer["item3"], Value = new Foo() { Id = 3, Name = LocalizerFoo["Foo.Name", "003"] } },
97+
new() { Text = Localizer["Item1"], Value = _selectedFoo },
98+
new() { Text = Localizer["Item2"], Value = new Foo { Id = 2, Name = LocalizerFoo["Foo.Name", "002"] } },
99+
new() { Text = Localizer["Item3"], Value = new Foo { Id = 3, Name = LocalizerFoo["Foo.Name", "003"] } },
103100
};
104-
105-
_selectedFoo = new Foo() { Id = 1, Name = LocalizerFoo["Foo.Name", "001"] };
106101
}
107102

108103
private Task OnItemChanged(IEnumerable<SelectedItem> values, SelectedItem val)
@@ -112,10 +107,9 @@ private Task OnItemChanged(IEnumerable<SelectedItem> values, SelectedItem val)
112107
return Task.CompletedTask;
113108
}
114109

115-
116110
class IconSelectedItem : SelectedItem
117111
{
118-
public string? Icon { get; set; }
112+
public string? Icon { get; init; }
119113
}
120114

121115
private AttributeItem[] GetAttributes() =>

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,9 +2376,7 @@
23762376
"StatusText2": "Not selected",
23772377
"StatusText3": "Indeterminate",
23782378
"Checkbox2Text": "Two-way binding",
2379-
"Checkbox3Text": "Handwritten labels",
2380-
"RadioListGenericTitle": "Generic List",
2381-
"RadioListGenericIntro": "Enable generic support through <code>SelectedItem&lt;TValue&gt;</code>"
2379+
"Checkbox3Text": "Handwritten labels"
23822380
},
23832381
"BootstrapBlazor.Server.Components.Samples.CheckboxLists": {
23842382
"Title": "CheckboxList",
@@ -2390,13 +2388,13 @@
23902388
"NormalTips3": "Get the changed item instance through the <code>onSelectedChanged</code> callback method",
23912389
"NormalTips4": "Enable label tooltip by <code>ShowLabelTooltip=\"true\"</code>",
23922390
"ValidateFormTitle": "Client Validation",
2393-
"ValidateFormIntro": "Built in validateform",
2391+
"ValidateFormIntro": "Built in <code>ValidateForm</code>",
23942392
"ValidateFormTips1": "You can experience adaptive layout by changing the window size",
23952393
"ValidateFormTips2": "In this example, the <code>Name</code> field of the binding model <code>binditem</code> is automatically changed by checking the option",
23962394
"ValidateFormTips3": "Because it is built into the <code>ValidateForm</code> form, in this example, <code>RequiredAttribute</code> required for verification is added. When all options are cancelled, the verification result will be prompted",
23972395
"ShowLabelTitle": "Bidirectional binding collection",
23982396
"ShowLabelIntro": "Binding values are collections",
2399-
"ShowLabelTip": "Tvalue is set to <code>IEnumerable&lt;int&gt;</code> generic collection, the <Code>ValueField</Code> specified field of the bound collection must be consistent with the generic type",
2397+
"ShowLabelTip": "<code>TValue</code> is set to <code>IEnumerable&lt;int&gt;</code> generic collection, the <Code>ValueField</Code> specified field of the bound collection must be consistent with the generic type",
24002398
"EnumTitle": "Bidirectional binding enumeration",
24012399
"EnumIntro": "The binding value is enumeration",
24022400
"EnumTip": "When <code>CheckboxList</code> binds an enumeration set, <code>Items</code> does not need to be specified, <code>Items</code> will be automatically set to all values in the enumeration. If you need to bind some values, please provide the enumeration set <code>Items</code>",
@@ -2428,7 +2426,9 @@
24282426
"MaxSelectedCountIntro": "Control the maximum number of selectable items by setting the <code>MaxSelectedCount</code> property, and handle the logic through the <code>OnMaxSelectedCountExceed</code> callback",
24292427
"MaxSelectedCountDesc": "When more than 2 nodes are selected, a <code>Toast</code> prompt bar will pop up",
24302428
"OnMaxSelectedCountExceedTitle": "Maximum Info",
2431-
"OnMaxSelectedCountExceedContent": "You can select at most {0} items"
2429+
"OnMaxSelectedCountExceedContent": "You can select at most {0} items",
2430+
"CheckboxListGenericTitle": "Generic List",
2431+
"CheckboxListGenericIntro": "Enable generic support by using the <code>RadioListGeneric</code> component with <code>SelectedItem&lt;TValue&gt;</code>"
24322432
},
24332433
"BootstrapBlazor.Server.Components.Samples.ColorPickers": {
24342434
"Title": "ColorPicker",
@@ -2912,7 +2912,7 @@
29122912
"MultiSelectIsSingleLineDescription": "When there are too many candidates, the component is laid out horizontally, and a horizontal scroll bar is displayed when the mouse is hovering over the component for data scrolling.",
29132913
"MultiSelectBindingStringTitle": "A two-way binding value string",
29142914
"MultiSelectBindingStringIntro": "Bind a comma string-splitting string",
2915-
"MultiSelectBindingStringDescription": "<div>The <code>mutltiSelect</code> component data source <code>Items</code> and <b>selected values</b> the <code>SelectItemsValue</code> support bidirectional binding;In this example, the <code>SelectItemsValue</code> variable by binding bidirectionally, and chooses to change its value through the drop-down box. </div>",
2915+
"MultiSelectBindingStringDescription": "<div>The <code>MultiSelect</code> component data source <code>Items</code> and <b>selected values</b> the <code>SelectItemsValue</code> support bidirectional binding;In this example, the <code>SelectItemsValue</code> variable by binding bidirectionally, and chooses to change its value through the drop-down box. </div>",
29162916
"MultiSelectBindingCollectionTitle": "A collection of bidirectional binding values",
29172917
"MultiSelectBindingCollectionIntro": "Bind a generic <code>a collection of IEnumerable<T></code>",
29182918
"MultiSelectBindingCollectionDescription": "In this example, the <code>SelectArrayValues</code> collection variable by binding bidirectionally, and selects to change its value through the drop-down box",
@@ -3028,7 +3028,7 @@
30283028
"RadiosAdd1": "Beijing",
30293029
"RadiosAdd2": "Shanghai",
30303030
"RadioListGenericTitle": "Generic List",
3031-
"RadioListGenericIntro": "Enable generic support through <code>SelectedItem&lt;TValue&gt;</code>"
3031+
"RadioListGenericIntro": "Enable generic support by using the <code>RadioListGeneric</code> component with <code>SelectedItem&lt;TValue&gt;</code>"
30323032
},
30333033
"BootstrapBlazor.Server.Components.Samples.Rates": {
30343034
"RatesTitle": "Rate",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,13 +2388,13 @@
23882388
"NormalTips3": "通过 <code>OnSelectedChanged</code> 回调方法获取改变项实例",
23892389
"NormalTips4": "通过 <code>ShowLabelTooltip=\"true\"</code> 开启标签提示功能",
23902390
"ValidateFormTitle": "客户端验证",
2391-
"ValidateFormIntro": "内置于 ValidateForm 中使用",
2391+
"ValidateFormIntro": "内置于 <code>ValidateForm</code> 中使用",
23922392
"ValidateFormTips1": "可以通过改变窗口大小,体验自适应布局",
23932393
"ValidateFormTips2": "本例中绑定模型 <code>BindItem</code> 的 <code>Name</code> 字段,通过勾选项自动更改模型数据",
23942394
"ValidateFormTips3": "由于内置于 <code>ValidateForm</code> 表单内,本例中增加了 <code>RequiredAttribute</code> 必选要求验证,当取消所有选项后提示验证结果",
23952395
"ShowLabelTitle": "双向绑定集合",
23962396
"ShowLabelIntro": "绑定值为集合",
2397-
"ShowLabelTip": "TValue 设置为 <code>IEnumerable&lt;int&gt;</code> 泛型集合,绑定集合的 <code>ValueField</code> 指定字段必须与泛型类型一致",
2397+
"ShowLabelTip": "<code>TValue</code> 设置为 <code>IEnumerable&lt;int&gt;</code> 泛型集合,绑定集合的 <code>ValueField</code> 指定字段必须与泛型类型一致",
23982398
"EnumTitle": "双向绑定枚举",
23992399
"EnumIntro": "绑定值为枚举",
24002400
"EnumTip": "当 <code>CheckboxList</code> 绑定一个枚举集合时,<code>Items</code> 不需要指定,<code>Items</code> 会被自动设置成枚举里面所有的值,如果需要绑定部分值时,请自行提供枚举集合 <code>Items</code>",
@@ -2428,7 +2428,7 @@
24282428
"OnMaxSelectedCountExceedTitle": "可选最大数量提示",
24292429
"OnMaxSelectedCountExceedContent": "最多只能选择 {0} 项",
24302430
"CheckboxListGenericTitle": "泛型支持",
2431-
"CheckboxListGenericIntro": "通过 <code>SelectedItem&lt;TValue&gt;</code> 开启泛型支持"
2431+
"CheckboxListGenericIntro": "通过 <code>CheckboxListGeneric</code> 组件和 <code>SelectedItem&lt;TValue&gt;</code> 开启泛型支持"
24322432
},
24332433
"BootstrapBlazor.Server.Components.Samples.ColorPickers": {
24342434
"Title": "ColorPicker 颜色拾取器",
@@ -2912,7 +2912,7 @@
29122912
"MultiSelectIsSingleLineDescription": "候选项过多时,组件横向布局,鼠标悬浮组件上时显示横向滚动条进行数据滚动",
29132913
"MultiSelectBindingStringTitle": "双向绑定值字符串",
29142914
"MultiSelectBindingStringIntro": "绑定一个逗号字符串分割的字符串",
2915-
"MultiSelectBindingStringDescription": "<div><code>MutltiSelect</code> 组件数据源 <code>Items</code> 与 <b>选中值</b> <code>SelectedItemsValue</code> 均支持双向绑定;本例中通过双向绑定 <code>SelectedItemsValue</code> 变量,通过下拉框选择更改其值</div>",
2915+
"MultiSelectBindingStringDescription": "<div><code>MultiSelect</code> 组件数据源 <code>Items</code> 与 <b>选中值</b> <code>SelectedItemsValue</code> 均支持双向绑定;本例中通过双向绑定 <code>SelectedItemsValue</code> 变量,通过下拉框选择更改其值</div>",
29162916
"MultiSelectBindingCollectionTitle": "双向绑定值集合",
29172917
"MultiSelectBindingCollectionIntro": "绑定一个泛型 <code>IEnumerable<T></code> 集合",
29182918
"MultiSelectBindingCollectionDescription": "本例中通过双向绑定 <code>SelectedArrayValues</code> 集合变量,通过下拉框选择更改其值",
@@ -3028,7 +3028,7 @@
30283028
"RadiosAdd1": "北京",
30293029
"RadiosAdd2": "上海",
30303030
"RadioListGenericTitle": "泛型支持",
3031-
"RadioListGenericIntro": "通过 <code>SelectedItem&lt;TValue&gt;</code> 开启泛型支持"
3031+
"RadioListGenericIntro": "通过使用 <code>RadioListGeneric</code> 组件配合 <code>SelectedItem&lt;TValue&gt;</code> 开启泛型支持"
30323032
},
30333033
"BootstrapBlazor.Server.Components.Samples.Rates": {
30343034
"RatesTitle": "Rate 评分",

src/BootstrapBlazor.Server/wwwroot/css/site.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ code {
304304
@media (min-width: 768px) {
305305
:root {
306306
--bs-header-height: 50px;
307-
--bb-header-select-width: 130px;
307+
--bb-header-select-width: 196px;
308308
--bb-header-search-margin-bottom: 0;
309309
}
310310

src/BootstrapBlazor/Components/Radio/RadioListGeneric.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected override void OnParametersSet()
139139
/// <summary>
140140
/// 点击选择框方法
141141
/// </summary>
142-
private async Task OnClick(SelectedItem<TValue?> item)
142+
private async Task OnClick(SelectedItem<TValue> item)
143143
{
144144
if (!IsDisabled)
145145
{

src/BootstrapBlazor/Components/Table/TableColumn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public class TableColumn<TItem, TType> : BootstrapComponentBase, ITableColumn
322322
get => Template == null ? null : new RenderFragment<object>(context => builder =>
323323
{
324324
// 此处 context 为行数据
325-
if (this is TableTemplateColumn<TItem> col)
325+
if (this is TableTemplateColumn<TItem>)
326326
{
327327
builder.AddContent(0, Template.Invoke(new TableColumnContext<TItem, TType?>((TItem)context, default)));
328328
}

0 commit comments

Comments
 (0)