Skip to content

Commit 4486fe6

Browse files
author
Tenny
committed
docs: 重构表单
Signed-off-by: Tenny <tenny.shu@foxmail.com>
1 parent 25f3425 commit 4486fe6

File tree

13 files changed

+182
-434
lines changed

13 files changed

+182
-434
lines changed

docs/.vitepress/config.ts

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default defineConfig({
4444
sidebar: [
4545
{
4646
text: '指南',
47-
collapsed: false,
47+
collapsed: true,
4848
items: [
4949
{
5050
text: '快速上手',
@@ -61,45 +61,65 @@ export default defineConfig({
6161
],
6262
},
6363
{
64-
text: '组件',
65-
collapsed: false,
64+
text: '通用',
65+
collapsed: true,
6666
items: [
6767
{ text: 'Container 容器布局', link: '/components/container' },
68-
{ text: 'Directives 指令', link: '/components/directives' },
68+
{ text: 'Polygon 多边形', link: '/components/polygon' },
6969
{ text: 'Icon 图标', link: '/components/icon' },
70+
],
71+
},
72+
{
73+
text: '表单',
74+
collapsed: true,
75+
items: [
7076
{ text: 'Button 按钮', link: '/components/button' },
7177
{ text: 'Input 输入框', link: '/components/input' },
72-
{ text: 'Tooltip 文字提示', link: '/components/tooltip' },
73-
{ text: 'Message 消息提示', link: '/components/message' },
78+
{ text: 'Checkbox 复选框', link: '/components/checkbox' },
79+
{ text: 'Radio 单选框', link: '/components/radio' },
80+
{ text: 'Switch 开关', link: '/components/switch' },
81+
{ text: 'Form 表单', link: '/components/form' },
82+
],
83+
},
84+
{
85+
text: '数据展示',
86+
collapsed: true,
87+
items: [
7488
{ text: 'Card 卡片', link: '/components/card' },
7589
{ text: 'Qrcode 二维码', link: '/components/qrcode' },
7690
{ text: 'Image 图片', link: '/components/image' },
7791
{ text: 'Shadow 阴影', link: '/components/shadow' },
7892
{ text: 'Table 表格', link: '/components/table' },
79-
{ text: 'Checkbox 复选框', link: '/components/checkbox' },
80-
{ text: 'Radio 单选框', link: '/components/radio' },
81-
{ text: 'Switch 开关', link: '/components/switch' },
82-
{ text: 'Polygon 多边形', link: '/components/polygon' },
83-
{ text: 'Form 表单', link: '/components/form' },
8493
{ text: 'Collapse 折叠面板', link: '/components/collapse' },
8594
{ text: 'Progress 进度条', link: '/components/progress' },
86-
{ text: 'Loading 加载', link: '/components/loading' },
8795
{
8896
text: 'DescriptionPanel 简介面板',
8997
link: '/components/descriptionpanel',
9098
},
9199
{
92-
text: 'Tabbar 标签栏',
93-
link: '/components/tabbar',
100+
text: 'List 滚动列表',
101+
link: '/components/list',
94102
},
95103
{
96104
text: 'Tabs 标签页',
97105
link: '/components/tabs',
98106
},
107+
],
108+
},
109+
{
110+
text: '导航',
111+
collapsed: true,
112+
items: [
99113
{
100-
text: 'List 滚动列表',
101-
link: '/components/list',
114+
text: 'Tabbar 标签栏',
115+
link: '/components/tabbar',
102116
},
117+
],
118+
},
119+
{
120+
text: '反馈',
121+
collapsed: true,
122+
items: [
103123
{
104124
text: 'Popover 弹出气泡',
105125
link: '/components/popover',
@@ -108,6 +128,16 @@ export default defineConfig({
108128
text: 'Dialog 对话框',
109129
link: '/components/dialog',
110130
},
131+
{ text: 'Tooltip 文字提示', link: '/components/tooltip' },
132+
{ text: 'Message 消息提示', link: '/components/message' },
133+
],
134+
},
135+
{
136+
text: '自定义指令',
137+
collapsed: true,
138+
items: [
139+
{ text: 'Directives 简单指令', link: '/components/directives' },
140+
{ text: 'Loading 加载', link: '/components/loading' },
111141
],
112142
},
113143
],

docs/.vitepress/theme/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Theme } from 'vitepress';
22
import DefaultTheme from 'vitepress/theme';
33
import '../../../style/icon';
44
import '../../../style/button';
5-
import '../../../style/tooltip';
5+
66
import '../../../style/util/transition.css';
77
import '../../../style/polygon';
88
import '../../../style/vars.css';
@@ -27,6 +27,7 @@ import '../../../style/loading';
2727
import '../../../style/description-panel';
2828
import '../../../style/tabbar';
2929
import '../../../style/popover';
30+
import '../../../style/tooltip';
3031
import '../../../style/util/tabs.css';
3132
import '../../../style/list';
3233
import '../../../style/dialog';

docs/components/image.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,31 @@ const imgs = [
4242
</textarea>
4343
<template #preview>
4444
<div class="grid grid-cols-5">
45-
<Tooltip placement="topStart" title="被替换的内容正好填充元素的内容框。整个对象将完全填充此框。如果对象的宽高比与内容框不相匹配,那么该对象将被拉伸以适应内容框">
45+
<Tooltip content="被替换的内容正好填充元素的内容框。整个对象将完全填充此框。如果对象的宽高比与内容框不相匹配,那么该对象将被拉伸以适应内容框">
4646
<div class="demo-img-item">
4747
<Image src="/neatui-vue/img1.svg" width="100" height="100" fit="fill"></Image>
4848
<span class="mt-15">fill</span>
4949
</div>
5050
</Tooltip>
51-
<Tooltip placement="topStart" title="被替换的内容将被缩放,以在填充元素的内容框时保持其宽高比。整个对象在填充盒子的同时保留其长宽比">
51+
<Tooltip content="被替换的内容将被缩放,以在填充元素的内容框时保持其宽高比。整个对象在填充盒子的同时保留其长宽比">
5252
<div class="demo-img-item">
5353
<Image src="/neatui-vue/img1.svg" width="100" height="100" fit="contain"></Image>
5454
<span class="mt-15">contain</span>
5555
</div>
5656
</Tooltip>
57-
<Tooltip placement="top" title="被替换的内容在保持其宽高比的同时填充元素的整个内容框。如果对象的宽高比与内容框不相匹配,该对象将被剪裁以适应内容框">
57+
<Tooltip content="被替换的内容在保持其宽高比的同时填充元素的整个内容框。如果对象的宽高比与内容框不相匹配,该对象将被剪裁以适应内容框">
5858
<div class="demo-img-item">
5959
<Image src="/neatui-vue/img1.svg" width="100" height="100" fit="cover"></Image>
6060
<span class="mt-15">cover</span>
6161
</div>
6262
</Tooltip>
63-
<Tooltip placement="topEnd" title="被替换的内容将保持其原有的尺寸">
63+
<Tooltip content="被替换的内容将保持其原有的尺寸">
6464
<div class="demo-img-item">
6565
<Image src="/neatui-vue/img1.svg" width="100" height="100" fit="none"></Image>
6666
<span class="mt-15">none</span>
6767
</div>
6868
</Tooltip>
69-
<Tooltip placement="topEnd" title="内容的尺寸与 none 或 contain 中的一个相同,取决于它们两个之间谁得到的对象尺寸会更小一些">
69+
<Tooltip content="内容的尺寸与 none 或 contain 中的一个相同,取决于它们两个之间谁得到的对象尺寸会更小一些">
7070
<div class="demo-img-item">
7171
<Image src="/neatui-vue/img1.svg" width="100" height="100" fit="scale-down"></Image>
7272
<span class="mt-15">scale-down</span>

docs/components/popover.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Popover 弹出起泡
1+
# Popover 弹出气泡
22

33
点击/鼠标移入元素,弹出气泡式的卡片浮层。在内容周围弹出一些隐藏的信息。和 `Tooltip` 的区别是,用户可以对浮层上的元素进行操作,因此它可以承载更复杂的内容,比如链接或按钮等。
44

docs/components/tooltip.md

Lines changed: 16 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,31 @@
11
# Tooltip 文字提示
22

3-
常用于展示鼠标 hover 时的提示信息
3+
常用于展示鼠标悬浮、点击时的提示信息
44

55
可用来代替系统默认的 `title` 提示,通常用于针对一个图标按钮的鼠标悬浮显示简单说明
66

7-
该提示使用纯 `CSS` 实现,所以气泡框位置通常需要手动设置
7+
该提示基于 [popover](/components/popover) 实现,只是对样式进行了简单修改。
88

9-
### 基础用法
10-
11-
使用 `title` 属性来决定 `hover` 时的提示信息。 由 `placement` 属性决定展示位置: `topStart``top[默认]``topEnd``bottomStart``bottom``bottomEnd`
12-
13-
<ClientOnly><CodePreview>
14-
<textarea lang="vue-html">
15-
16-
<div class="flex-between">
17-
<nt-tooltip placement="topStart" title="prompt text">
18-
<nt-button>topStart</nt-button>
19-
</nt-tooltip>
20-
<nt-tooltip placement="top" title="prompt text">
21-
<nt-button>top</nt-button>
22-
</nt-tooltip>
23-
<nt-tooltip placement="topEnd" title="prompt text">
24-
<nt-button>topEnd</nt-button>
25-
</nt-tooltip>
26-
</div>
27-
<div class="flex-between mt-15">
28-
<nt-tooltip placement="bottomStart" title="prompt text">
29-
<nt-button>bottomStart</nt-button>
30-
</nt-tooltip>
31-
<nt-tooltip placement="bottom" title="prompt text">
32-
<nt-button>bottom</nt-button>
33-
</nt-tooltip>
34-
<nt-tooltip placement="bottomEnd" title="prompt text">
35-
<nt-button>bottomEnd</nt-button>
36-
</nt-tooltip>
37-
</div>
38-
</textarea>
39-
</CodePreview></ClientOnly>
40-
41-
### 自定义提示
42-
43-
通过使用 `title` 插槽来渲染自定义的提示; 如果同时传递 `title` 和 插槽,则 `title` 属性为准
9+
## 演示
4410

4511
<script setup>
46-
import { Tooltip, Button } from '../../src'
12+
import { Tooltip } from '../../src'
4713
</script>
4814

49-
<ClientOnly>
50-
<CodePreview>
51-
<textarea lang="vue-html">
52-
<nt-tooltip>
53-
<nt-button>自定义提示</nt-button>
54-
<template v-slot:title>
55-
<span style="color:red;">custome propmt text</span>
56-
</template>
57-
</nt-tooltip>
58-
</textarea>
59-
<template #preview>
60-
<Tooltip>
61-
<Button>自定义提示</Button>
62-
<template #title>
63-
<span style="color:red;">custome propmt text</span>
64-
</template>
65-
</Tooltip>
66-
</template>
67-
</CodePreview>
68-
</ClientOnly>
69-
70-
### 受控模式
71-
72-
通过 `visible` 属性来控制提示框的显示与隐藏
73-
74-
<ClientOnly>
75-
<CodePreview>
76-
<textarea lang="vue-html">
77-
<nt-tooltip :visible="true" title="Content">
78-
<span>受控模式</span>
79-
</nt-tooltip>
80-
</textarea>
81-
<template #preview>
82-
<Tooltip :visible="true" title="Content">
83-
<span>受控模式</span>
84-
</Tooltip>
85-
</template>
86-
</CodePreview>
87-
</ClientOnly>
88-
89-
### 自定义风格
90-
91-
通过 `styleName` 属性来设置提示框的风格名称,然后自定义 `.nt-tooltip--xx` 来定义风格样式,`xx` 就是传递的 `styleName` 的值;例如从 [css-generators](https://css-generators.com/tooltip-speech-bubble/) 复制一段样式,改名称为 `nt-tooltip--demo`
92-
93-
<ClientOnly>
94-
<CodePreview>
95-
<textarea lang="vue">
96-
<template>
97-
<nt-tooltip title="Content" style-name="demo" placement="bottom">
98-
<span>自定义风格</span>
99-
</nt-tooltip>
100-
</template>
101-
<style>
102-
.nt-tooltip--demo {
103-
color: #fff;
104-
font-size: 18px;
105-
max-width: 28ch;
106-
text-align: center;
107-
}
108-
.nt-tooltip--demo {
109-
/* triangle dimension */
110-
--b: 2em; /* base */
111-
--h: 1em; /* height */
112-
--p: 50%; /* triangle position (0%:left 100%:right) */
113-
--r: 1.2em; /* the radius */
114-
--c: #6a4a3c;
115-
padding: 1em;
116-
border-radius: min(var(--r), var(--p) - var(--b) / 2)
117-
min(var(--r), 100% - var(--p) - var(--b) / 2) var(--r) var(--r) / var(--r);
118-
clip-path: polygon(
119-
0 0,
120-
0 100%,
121-
100% 100%,
122-
100% 0,
123-
min(100%, var(--p) + var(--b) / 2) 0,
124-
var(--p) calc(-1 * var(--h)),
125-
max(0%, var(--p) - var(--b) / 2) 0
126-
);
127-
background: var(--c);
128-
border-image: conic-gradient(var(--c) 0 0) fill 0/ 0 calc(
129-
100% - var(--p) - var(--b) / 2
130-
) var(--r) calc(var(--p) - var(--b) / 2) / var(--h) 0 0 0;
131-
}
132-
.nt-tooltip-bottom.nt-tooltip--demo {
133-
top: calc(100% + 20px);
134-
}
135-
</style>
136-
</textarea>
137-
<template #preview>
138-
<Tooltip title="Content" style-name="demo" placement="bottom">
139-
<span>自定义风格</span>
140-
</Tooltip>
141-
</template>
142-
</CodePreview>
143-
</ClientOnly>
144-
145-
> 可以通过配合 `nt-tooltip-top``nt-tooltip-start` 等调整箭头或者提示框的位置
146-
147-
### 触发方式
15+
### 基础用法
14816

149-
默认是悬浮触发,可以通过修改 `trigger` 属性来改变触发方式
17+
传递 `content` 属性为提示内容
15018

15119
<ClientOnly>
15220
<CodePreview>
15321
<textarea lang="vue-html">
154-
<script setup>
155-
</script>
156-
<template>
157-
<hr />
158-
</template>
22+
<nt-tooltip content="提示内容">
23+
<span>显示提示</span>
24+
</nt-tooltip>
15925
</textarea>
16026
<template #preview>
161-
<Tooltip title="prompt text">
162-
<Button>悬浮</Button>
163-
</Tooltip>
164-
<Tooltip title="prompt text" trigger="click" class="ml-10">
165-
<Button>点击</Button>
27+
<Tooltip content="提示内容">
28+
<span>显示提示</span>
16629
</Tooltip>
16730
</template>
16831
</CodePreview>
@@ -172,16 +35,11 @@ import { Tooltip, Button } from '../../src'
17235

17336
### Tooltip Props
17437

175-
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
176-
| -------------- | ------------------------ | --------- | ----------------------------------------------------------------- | --------- |
177-
| `title` | 提示文字 | `string` | - | - |
178-
| `placement` | 提示框出现位置 | `string` | `topStart``top``topEnd``bottomStart``bottom``bottomEnd` | `top` |
179-
| `styleName` | 风格, 可以自定义风格 | `string` | - | `default` |
180-
| `visible` | 是否显示提示框[受控模式] | `boolean` | - | `false` |
181-
| `contentClass` | Tooltip Content 样式 | `string` | - | - |
38+
参数与 [popover-props](/components/popover#popover-props) 一致
18239

18340
### Tooltip Slots
18441

185-
| 参数 | 说明 | 参数 |
186-
| ------- | ---------------------- | ---- |
187-
| `title` | 自定义提示内容以及样式 | `()` |
42+
| 参数 | 说明 |
43+
| --------- | -------------- |
44+
| `default` | 触发提示的元素 |
45+
| `content` | 自定义提示内容 |

0 commit comments

Comments
 (0)