Skip to content

Commit ee0129e

Browse files
committed
doc: 更新示例
1 parent 950a339 commit ee0129e

File tree

2 files changed

+47
-20
lines changed

2 files changed

+47
-20
lines changed

src/BootstrapBlazor.Server/Components/Samples/TextAreas.razor

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,63 @@
99
<DemoBlock Title="@Localizer["TextAreaNormalTitle"]"
1010
Introduction="@Localizer["TextAreaNormalIntro"]"
1111
Name="Normal">
12-
<label class="form-label mb-3">@Localizer["TextAreaLabel"]</label>
1312
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" />
1413
</DemoBlock>
1514

1615
<DemoBlock Title="@Localizer["TextAreaDisableTitle"]"
1716
Introduction="@Localizer["TextAreaDisableIntro"]"
1817
Name="IsDisabled">
19-
<label class="form-label mb-3">@Localizer["TextAreaLabel"]</label>
2018
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" IsDisabled="true" />
2119
</DemoBlock>
2220

2321
<DemoBlock Title="@Localizer["TextAreaReadOnlyTitle"]"
2422
Introduction="@Localizer["TextAreaReadOnlyIntro"]"
2523
Name="ReadOnly">
26-
<label class="form-label mb-3">@Localizer["TextAreaLabel"]</label>
27-
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" readonly />
24+
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" readonly />
2825
</DemoBlock>
2926

3027
<DemoBlock Title="@Localizer["TextAreaHeightTitle"]"
3128
Introduction="@Localizer["TextAreaHeightIntro"]"
3229
Name="Rows">
33-
<label class="form-label mb-3">@Localizer["TextAreaLabel"]</label>
34-
35-
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" />
30+
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" />
3631
</DemoBlock>
3732

3833
<DemoBlock Title="@Localizer["TextAreaBindWayTitle"]"
3934
Introduction="@Localizer["TextAreaBindWayIntro"]"
4035
Name="BindValue">
41-
<div class="row g-3">
42-
<div class="col-12">
43-
<label class="form-label">@Localizer["TextAreaLabel"]</label>
44-
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" @bind-Value="@Text"></Textarea>
45-
</div>
36+
<Textarea PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="4" @bind-Value="@Text"></Textarea>
37+
<section ignore class="row g-3">
4638
<div class="col-12">
4739
<label class="form-label">@Localizer["TextAreaBindWayBindValue"]</label>
4840
<div class="form-control textarea-demo">@Text</div>
4941
</div>
50-
</div>
42+
</section>
5143
</DemoBlock>
5244

5345
<DemoBlock Title="@Localizer["TextAreaScrollTitle"]"
5446
Introduction="@Localizer["TextAreaScrollIntro"]"
5547
Name="IsAutoScroll">
5648
<Textarea class="mb-3" PlaceHolder="@Localizer["TextAreaPlaceHolder"]" rows="10" @ref="TextareaElement" @bind-Value="@ChatText" IsAutoScroll="IsAutoScroll" />
49+
<section ignore>
50+
<BootstrapInputGroup>
51+
<Button Text="@Localizer[ChatLocalizerName]" OnClick="MockChat" Icon="fa-fw fas fa-comments" />
52+
<Button Text="@Localizer["TextAreaScrollToTop"]" OnClick="ScrollToTop" />
53+
<Button Text="@Localizer["TextAreaScrollToBottom"]" OnClick="ScrollToBottom" />
54+
<Button Text="@Localizer["TextAreaScrollTo"]" OnClick="ScrollTo20" />
55+
<Button Text="@($"{Localizer["TextAreaAutoScroll"]}{(IsAutoScroll ? " On":" Off")}" )" OnClick="SwitchAutoScroll" />
56+
</BootstrapInputGroup>
57+
</section>
58+
</DemoBlock>
5759

58-
<BootstrapInputGroup>
59-
<Button Text="@Localizer[ChatLocalizerName]" OnClick="MockChat" Icon="fa-fw fas fa-comments" />
60-
<Button Text="@Localizer["TextAreaScrollToTop"]" OnClick="ScrollToTop" />
61-
<Button Text="@Localizer["TextAreaScrollToBottom"]" OnClick="ScrollToBottom" />
62-
<Button Text="@Localizer["TextAreaScrollTo"]" OnClick="ScrollTo20" />
63-
<Button Text="@($"{Localizer["TextAreaAutoScroll"]}{(IsAutoScroll ? " On":" Off")}" )" OnClick="SwitchAutoScroll" />
64-
</BootstrapInputGroup>
60+
<DemoBlock Title="@Localizer["TextAreaKeyUpTitle"]"
61+
Introduction="@Localizer["TextAreaKeyUpIntro"]"
62+
Name="KeyUp">
63+
<Textarea rows="4" autocomplete="off" autocorrect="off" spellcheck="false"
64+
UseInputEvent="true" UseShiftEnter="true" PlaceHolder="@Localizer["TextAreaKeyUpPlaceHolder"]"
65+
@bind-Value="@KeyText"></Textarea>
66+
<section ignore>
67+
<ConsoleLogger @ref="Logger" IsHtml="true" />
68+
</section>
6569
</DemoBlock>
6670

6771
<AttributeTable Items="@GetAttributes()" />

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
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 Microsoft.AspNetCore.Components.Web;
7+
68
namespace BootstrapBlazor.Server.Components.Samples;
79

810
/// <summary>
@@ -15,6 +17,8 @@ public partial class TextAreas
1517

1618
private string? Text { get; set; }
1719

20+
private string? KeyText { get; set; }
21+
1822
private string? ChatText { get; set; }
1923

2024
private int ScrollValue { get; set; }
@@ -88,6 +92,25 @@ private void MockChat()
8892
}
8993
}
9094

95+
[NotNull]
96+
private ConsoleLogger? Logger { get; set; }
97+
98+
private Task<bool> OnKeyDownAsync(KeyboardEventArgs args)
99+
{
100+
var ret = true;
101+
if (args.ShiftKey && args.Key == "Enter")
102+
{
103+
Text += $"{Environment.NewLine}";
104+
Logger.Log("Press <kbd>Shift</kbd> + <kbd>Enter</kbd>");
105+
StateHasChanged();
106+
}
107+
else if (args.Key == "Enter")
108+
{
109+
Logger.Log("Press <kbd>Enter</kbd>: call some method.");
110+
}
111+
return Task.FromResult(ret);
112+
}
113+
91114
/// <summary>
92115
/// Dispose
93116
/// </summary>

0 commit comments

Comments
 (0)