Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 71fa20e

Browse files
authored
docs: 重构整个文档,提升用户体验,使用户能更好的查看示例和API (#312)
2 parents 4edb676 + 8894472 commit 71fa20e

127 files changed

Lines changed: 1485 additions & 1180 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/TDesign.Docs.ServerSide/TDesign.xml

Lines changed: 132 additions & 157 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
@{
2+
var parameters = ApiDoc.GetParameterApiDoc(ComponentType);
3+
if ( parameters.Any() )
4+
{
5+
<h2>@(Name) 的参数</h2>
6+
<table class="t-table" style="margin-bottom:40px">
7+
<thead>
8+
<tr>
9+
<th width="10%">名称</th>
10+
<th width="15%">数据类型</th>
11+
<th width="5%">默认值</th>
12+
<th>说明</th>
13+
<th width="100px">必填</th>
14+
</tr>
15+
</thead>
16+
<tbody>
17+
@foreach ( var param in parameters )
18+
{
19+
<tr>
20+
<td style="font-weight:bolder;">@param.name</td>
21+
<td>
22+
@if ( string.IsNullOrEmpty(param.type) )
23+
{
24+
<TTag Theme="Theme.Danger">Unkonw</TTag>
25+
}
26+
else
27+
{
28+
<code style="color:darkred">@param.type</code>
29+
}
30+
</td>
31+
<td>
32+
@param.defaultValue
33+
</td>
34+
<td>@param.comment</td>
35+
<td>
36+
@if ( param.requried )
37+
{
38+
<TTag Theme="Theme.Danger">Y</TTag>
39+
}
40+
else
41+
{
42+
<TTag Type="TagType.Outline">N</TTag>
43+
}
44+
</td>
45+
</tr>
46+
}
47+
</tbody>
48+
</table>
49+
}
50+
51+
var methods = ApiDoc.GetMethodApiDoc(ComponentType);
52+
if ( methods.Any() )
53+
{
54+
<h2 style="margin-top:40px">@(Name) 的方法</h2>
55+
<table class="t-table">
56+
<thead>
57+
<tr>
58+
<th width="40%">方法</th>
59+
<th>说明</th>
60+
</tr>
61+
</thead>
62+
<tbody>
63+
@foreach ( var item in methods )
64+
{
65+
<tr>
66+
<td style="font-weight:bolder;">
67+
@($"{item.returnType} {item.name}({item.parameters})")
68+
</td>
69+
<td>@item.comment</td>
70+
</tr>
71+
}
72+
</tbody>
73+
</table>
74+
}
75+
}
76+
77+
78+
@code {
79+
[EditorRequired][Parameter] public Type ComponentType { get; set; }
80+
81+
[Parameter]public string? Title{ get; set; }
82+
83+
string Name => Title ?? ComponentType.Name;
84+
}

doc/TDesign.Docs.Shared/Components/ComponentAPI.razor

Lines changed: 0 additions & 231 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
<div style="margin-50px;">
3+
<h1 style="font-size:36px;margin-bottom:20px; margin-top:40px; display:block;">@Title</h1>
4+
<p style="color:gray">
5+
@Description
6+
</p>
7+
<TTab>
8+
<TTabItem Title="示例">
9+
<TLayout style="height:75vh;overflow-y:auto">
10+
<RightSideContent>
11+
@if ( Anchors is not null )
12+
{
13+
<div style="width:20vw;padding:10px;">
14+
<TAnchor style="position: fixed;" Container="#page">
15+
@foreach ( var item in Anchors )
16+
{
17+
<TAnchorItem Title="@item" Href="@("#"+item)"></TAnchorItem>
18+
}
19+
</TAnchor>
20+
</div>
21+
}
22+
</RightSideContent>
23+
<ChildContent>
24+
@ChildContent
25+
</ChildContent>
26+
</TLayout>
27+
</TTabItem>
28+
<TTabItem Title="API">
29+
<div style="height:75vh;overflow-y:auto">
30+
@if(ComponentType is not null)
31+
{
32+
<ApiDocument ComponentType="@ComponentType"/>
33+
}else{
34+
@ApiContent
35+
}
36+
</div>
37+
</TTabItem>
38+
</TTab>
39+
</div>
40+
41+
@code {
42+
[Parameter] public string? Title { get; set; }
43+
[Parameter] public string? Description { get; set; }
44+
[Parameter] public RenderFragment? ChildContent { get; set; }
45+
[Parameter] public RenderFragment? ApiContent { get; set; }
46+
[Parameter] public string[]? Anchors { get; set; }
47+
[Parameter]public Type? ComponentType{ get; set; }
48+
}

doc/TDesign.Docs.Shared/Pages/Components/Basic/ButtonPage.razor

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@page "/components/button"
2-
<LayoutContent AnchorItems="@(new[]{"示例","幽灵按钮","图标按钮","Block 按钮","不同颜色主题按钮","不同状态的按钮","不同尺寸的按钮","不同形状的按钮","OnClick 点击事件","自定义渲染元素","API"})">
3-
<PageHeader Title="Button 按钮">
4-
按钮用于开启一个闭环的操作任务,如“删除”对象、“购买”商品等。
5-
</PageHeader>
62

3+
4+
<PageLayout Title="Button 按钮" Description="按钮用于开启一个闭环的操作任务,如“删除”对象、“购买”商品等。"
5+
ComponentType="typeof(TButton)"
6+
Anchors="@(new[]{"示例","幽灵按钮","图标按钮","Block 按钮","不同颜色主题按钮","不同状态的按钮","不同尺寸的按钮","不同形状的按钮","OnClick 点击事件","自定义渲染元素"})">
77
<Example Title="示例">
88
<RunContent>
99
<TButton>普通按钮</TButton>
@@ -420,7 +420,5 @@
420420
")
421421
</CodeContent>
422422
</Example>
423-
<div id="API"></div>
424-
<ComponentAPI Component="typeof(TButton)"></ComponentAPI>
425-
</LayoutContent>
423+
</PageLayout>
426424
@inject IJSRuntime JS

0 commit comments

Comments
 (0)