Skip to content

Commit 9a4a26f

Browse files
committed
doc: 更新 Tooltip 示例
1 parent f383f47 commit 9a4a26f

File tree

6 files changed

+55
-2
lines changed

6 files changed

+55
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<i class="fa-solid fa-flag" style="cursor: pointer;" @onclick="ToggleShow" />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.Components;
7+
8+
/// <summary>
9+
/// TooltipContent 组件用于显示 Tooltip 的内容
10+
/// </summary>
11+
public partial class TooltipContent
12+
{
13+
[CascadingParameter]
14+
private Tooltip? Tooltip { get; set; }
15+
16+
private async Task ToggleShow()
17+
{
18+
if (Tooltip == null)
19+
{
20+
return;
21+
}
22+
23+
await Tooltip.Toggle();
24+
}
25+
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,21 @@
8888
</Tooltip>
8989
</DemoBlock>
9090

91+
<DemoBlock Title="@Localizer["TooltipsManualTitle"]"
92+
Introduction="@Localizer["TooltipsManualIntro"]"
93+
Name="Manual">
94+
<section ignore>
95+
<ul class="ul-demo">
96+
<li>@((MarkupString)Localizer["TooltipsManualDescLI1"].Value)</li>
97+
<li>@((MarkupString)Localizer["TooltipsManualDescLI2"].Value)</li>
98+
</ul>
99+
</section>
100+
<Tooltip Title="Cascading tooltip" Trigger="manual">
101+
<TooltipContent></TooltipContent>
102+
</Tooltip>
103+
<Tooltip Title="OnClick tooltip" Trigger="manual" OnClick="ToggleShow">
104+
<i class="fa-solid fa-flag" style="cursor: pointer;" />
105+
</Tooltip>
106+
</DemoBlock>
107+
91108
<AttributeTable Items="@GetAttributes()" />

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public partial class Tooltips
2020

2121
private static string HtmlString => "This is <a href=\"www.blazor.zone\">Blazor</a> tooltip";
2222

23+
private static Task ToggleShow(IToggle toggle) => toggle.Toggle();
24+
2325
/// <summary>
2426
/// 获得属性方法
2527
/// </summary>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@
108108
"TooltipsCustomClassIntro": "Set the custom style by setting the <code>CustomClass</code> parameter",
109109
"BootstrapTooltipIntro": "Try to make a new component that is more comfortable to use, you can use it early, the name of the component may be changed later",
110110
"BootstrapTooltipTips1": "Wrap other components or <code>HTML</code> elements through <code>BootstrapTooltip</code> so that the wrapped object has the function of <code>Tooltip</code>",
111-
"BootstrapTooltipTips2": "In this example, an icon is wrapped by <code>BootstrapTooltip</code>. When the mouse moves over the icon, the default <code>Tooltip</code> is displayed, which is easier and faster to use."
111+
"BootstrapTooltipTips2": "In this example, an icon is wrapped by <code>BootstrapTooltip</code>. When the mouse moves over the icon, the default <code>Tooltip</code> is displayed, which is easier and faster to use.",
112+
"TooltipsManualTitle": "Manual",
113+
"TooltipsManualIntro": "Use code to control the tooltip state by setting <code>Trigger=\"manual\"</code>",
114+
"TooltipsManualDescLI1": "The child component uses the cascade parameters to get the <code>Tooltip</code> instance and then calls its methods <code>Show</code> <code>Hide</code> <code>Toggle</code>",
115+
"TooltipsManualDescLI2": "Call its method in the callback through the <code>Tooltip</code> parameter <code>OnClick</code>"
112116
},
113117
"BootstrapBlazor.Server.Components.Samples.Toasts": {
114118
"ToastsTitle": "Toast Lightweight Popup",

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@
108108
"TooltipsCustomClassIntro": "通过设置 <code>CustomClass</code> 参数进行自定义样式设置",
109109
"BootstrapTooltipIntro": "尝试新做一个用起来比较舒服的组件,可尝鲜使用,后期组件名字可能会更改",
110110
"BootstrapTooltipTips1": "通过 <code>BootstrapTooltip</code> 对其他组件或者 <code>HTML</code> 元素进行包裹,使其被包裹对象具有 <code>Tooltip</code> 功能",
111-
"BootstrapTooltipTips2": "本例中通过 <code>BootstrapTooltip</code> 包裹一个图标,鼠标移动到图标上时,显示预设 <code>Tooltip</code> 使用更简单快捷"
111+
"BootstrapTooltipTips2": "本例中通过 <code>BootstrapTooltip</code> 包裹一个图标,鼠标移动到图标上时,显示预设 <code>Tooltip</code> 使用更简单快捷",
112+
"TooltipsManualTitle": "手动控制状态",
113+
"TooltipsManualIntro": "通过设置 <code>Trigger=\"manual\"</code> 使用代码控制提示栏状态",
114+
"TooltipsManualDescLI1": "子组件使用级联参数得到 <code>Tooltip</code> 实例,然后调用其相应方法 <code>Show</code> <code>Hide</code> <code>Toggle</code>",
115+
"TooltipsManualDescLI2": "通过 <code>Tooltip</code> 参数 <code>OnClick</code> 在回调中调用其对应方法"
112116
},
113117
"BootstrapBlazor.Server.Components.Samples.Toasts": {
114118
"ToastsTitle": "Toast 轻量弹窗",

0 commit comments

Comments
 (0)