Skip to content

Commit 1e36561

Browse files
committed
doc: 更新示例文档
1 parent 3e77c2f commit 1e36561

File tree

4 files changed

+156
-17
lines changed

4 files changed

+156
-17
lines changed
Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
@page "/typed"
2+
@inject IStringLocalizer<Typeds> Localizer
23

3-
<div>
4-
<Button Text="Update" OnClick="OnUpdate"></Button>
5-
</div>
4+
<h3>@Localizer["TypedTitle"]</h3>
65

7-
<div>
8-
<TypedJs Options="_options"></TypedJs>
9-
</div>
6+
<h4>@Localizer["TypedIntro"]</h4>
107

11-
@code {
12-
private TypedOptions _options = new();
8+
<DemoBlock Title="@Localizer["NormalTitle"]"
9+
Introduction="@Localizer["NormalIntro"]"
10+
Name="Normal">
11+
<div class="row g-3">
12+
<div class="col-12">
13+
<Typed Text="<code>BootstrapBlazor</code> is an enterprise-level UI component library"></Typed>
14+
</div>
15+
</div>
16+
</DemoBlock>
1317

14-
private void OnUpdate()
15-
{
16-
//_options = new() { TypeSpeed = 70 };
17-
_options.Text = ["Bootstrap Blazor is an enterprise-level UI component library", "BB 组件库你可以试试看"];
18-
_options.TypeSpeed = 70;
19-
_options.BackSpeed = 30;
20-
_options.Loop = true;
21-
}
22-
}
18+
<DemoBlock Title="@Localizer["TypedOptionsTitle"]"
19+
Introduction="@Localizer["TypedOptionsIntro"]"
20+
Name="Options">
21+
<div class="row g-3">
22+
<div class="col-12 col-sm-6">
23+
<Typed Options="_options"></Typed>
24+
</div>
25+
<div class="col-12 col-sm-6">
26+
<Button Text="Update" OnClick="OnUpdate"></Button>
27+
</div>
28+
</div>
29+
</DemoBlock>
30+
31+
<AttributeTable Items="@TypedAttributes" Title="@Localizer["TypedAttribute"]"></AttributeTable>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Server.Components.Samples;
7+
8+
/// <summary>
9+
/// Typed 组件示例
10+
/// </summary>
11+
public partial class Typeds
12+
{
13+
private readonly TypedOptions _options = new();
14+
15+
private void OnUpdate()
16+
{
17+
_options.Text = ["<code>BootstrapBlazor</code> is an enterprise-level UI component library", "你可以试试看 <b>Blazor</b> 框架"];
18+
_options.TypeSpeed = 70;
19+
_options.BackSpeed = 30;
20+
_options.Loop = true;
21+
}
22+
23+
private static AttributeItem[] TypedAttributes =>
24+
[
25+
new()
26+
{
27+
Name = nameof(TypedOptions.Text),
28+
Description = "strings strings to be typed",
29+
Type = "List<string>",
30+
ValueList = " — ",
31+
DefaultValue = " — "
32+
},
33+
new()
34+
{
35+
Name = nameof(TypedOptions.TypeSpeed),
36+
Description = "typeSpeed type speed in milliseconds",
37+
Type = "int",
38+
ValueList = " — ",
39+
DefaultValue = " — "
40+
},
41+
new()
42+
{
43+
Name = nameof(TypedOptions.BackSpeed),
44+
Description = "backSpeed backspacing speed in milliseconds",
45+
Type = "int",
46+
ValueList = " — ",
47+
DefaultValue = " — "
48+
},
49+
new()
50+
{
51+
Name = nameof(TypedOptions.BackDelay),
52+
Description = "backDelay time before backspacing in milliseconds",
53+
Type = "int",
54+
ValueList = " — ",
55+
DefaultValue = " — "
56+
},
57+
new()
58+
{
59+
Name = nameof(TypedOptions.SmartBackspace),
60+
Description = "smartBackspace only backspace what doesn't match the previous string default true",
61+
Type = "bool",
62+
ValueList = "true|false",
63+
DefaultValue = "false"
64+
},
65+
new()
66+
{
67+
Name = nameof(TypedOptions.Shuffle),
68+
Description = "shuffle the strings",
69+
Type = "bool",
70+
ValueList = "true|false",
71+
DefaultValue = "false"
72+
},
73+
new()
74+
{
75+
Name = nameof(TypedOptions.Loop),
76+
Description = "loop loop strings default false",
77+
Type = "bool",
78+
ValueList = "true|false",
79+
DefaultValue = "false"
80+
},
81+
new()
82+
{
83+
Name = nameof(TypedOptions.LoopCount),
84+
Description = "loopCount amount of loops default Infinity",
85+
Type = "int",
86+
ValueList = " — ",
87+
DefaultValue = " — ",
88+
},
89+
new()
90+
{
91+
Name = nameof(TypedOptions.ShowCursor),
92+
Description = "showCursor show cursor",
93+
Type = "bool",
94+
ValueList = "true|false",
95+
DefaultValue = "true"
96+
},
97+
new()
98+
{
99+
Name = nameof(TypedOptions.CursorChar),
100+
Description = "cursorChar character for cursor",
101+
Type = "string",
102+
ValueList = " — ",
103+
DefaultValue = "|"
104+
},
105+
new()
106+
{
107+
Name = nameof(TypedOptions.ContentType),
108+
Description = "contentType 'html' or 'null' for plaintext",
109+
Type = "string",
110+
ValueList = "html|null",
111+
DefaultValue = "html"
112+
}
113+
];
114+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6942,5 +6942,13 @@
69426942
"CacheListDelete": "Delete",
69436943
"CacheListDeleteAll": "Clear",
69446944
"CacheListCount": "Total {0} Entry"
6945+
},
6946+
"BootstrapBlazor.Server.Components.Samples.Typeds": {
6947+
"TypedTitle": "Typed",
6948+
"TypedIntro": "Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set.",
6949+
"NormalTitle": "Text",
6950+
"NormalIntro": "Set the text to be displayed by setting the <code>Text</code> parameter",
6951+
"TypedOptionsTitle": "TypedOptions",
6952+
"TypedOptionsIntro": "Customize typing speed, delay, and other settings by setting the properties of the <code>TypedOptions</code> parameter"
69456953
}
69466954
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6942,5 +6942,13 @@
69426942
"CacheListDelete": "删除",
69436943
"CacheListDeleteAll": "清除全部",
69446944
"CacheListCount": "共 {0} 个键值"
6945+
},
6946+
"BootstrapBlazor.Server.Components.Samples.Typeds": {
6947+
"TypedTitle": "Typed 打字机效果",
6948+
"TypedIntro": "输入任意字符串,它会按照你设置的速度输入,输入的内容会退格,然后根据你设置的字符串数量开始一个新句子。",
6949+
"NormalTitle": "Text",
6950+
"NormalIntro": "通过设置 <code>Text</code> 参数设置要显示的文本",
6951+
"TypedOptionsTitle": "TypedOptions",
6952+
"TypedOptionsIntro": "通过设置 <code>TypedOptions</code> 参数的属性自定义打字速度、延时等设定"
69456953
}
69466954
}

0 commit comments

Comments
 (0)