Skip to content

Commit 067753f

Browse files
committed
docs: add activity,tooltip,skeleton
1 parent 7b67deb commit 067753f

8 files changed

Lines changed: 142 additions & 8 deletions

File tree

docs/components/activity/index.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Activity
2+
3+
当用户有缓存组件的场景,`Activity` 组件可以缓存相应的组件以及 `DOM` 节点
4+
5+
## Playground
6+
7+
<code src="./playground.tsx" />
8+
9+
:::note
10+
切换到 Search List 后,输入框填写内容后,再切换体验效果
11+
:::
12+
13+
## API
14+
15+
| Property | Description | Type | Default Value |
16+
| -------- | ----------- | ----------------------- | ------------- |
17+
| mode | 模式切换 | `"visible" \| "hidden"` | - |
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Activity, Button, Input } from '@shilong/react'
2+
import React from 'react'
3+
4+
const Home = () => {
5+
return 'Home'
6+
}
7+
8+
const SearchList = () => {
9+
return (
10+
<div
11+
style={{
12+
display: 'flex',
13+
justifyContent: 'space-between',
14+
alignItems: 'center',
15+
gap: 10,
16+
}}
17+
>
18+
<Input />
19+
<Button>Search</Button>
20+
</div>
21+
)
22+
}
23+
24+
function App() {
25+
const [route, setRoute] = React.useState('home')
26+
27+
const handleNav = (path: string) => {
28+
setRoute(path)
29+
}
30+
31+
return (
32+
<div>
33+
<div style={{ display: 'flex', gap: 20 }}>
34+
<Button variant="ghost" onClick={() => handleNav('home')}>
35+
Home
36+
</Button>
37+
<Button variant="ghost" onClick={() => handleNav('search')}>
38+
Search List
39+
</Button>
40+
</div>
41+
42+
<Activity mode={route === 'home' ? 'visible' : 'hidden'}>
43+
<Home />
44+
</Activity>
45+
46+
<Activity mode={route === 'search' ? 'visible' : 'hidden'}>
47+
<SearchList />
48+
</Activity>
49+
</div>
50+
)
51+
}
52+
53+
export default App

docs/components/skeleton/index.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Skeleton
2+
3+
用于内容占位等待的场景
4+
5+
## Playground
6+
7+
<code src="./playground.tsx" />
8+
9+
## API
10+
11+
`div` 标签属性相同
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Skeleton } from '@shilong/react'
2+
3+
function App() {
4+
return (
5+
<div>
6+
<Skeleton
7+
style={{ width: 80, height: 80, borderRadius: '50%', margin: '0 auto' }}
8+
/>
9+
<Skeleton style={{ width: '100%', height: 200 }} />
10+
</div>
11+
)
12+
}
13+
14+
export default App

docs/components/tooltip/index.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Tooltip
2+
3+
用于 当既要保持 UI 简洁,同时又需要对不熟悉的人解释 的时候,会使用 `Tooltips` 组件进行内容提示。
4+
5+
## Playground
6+
7+
<code src="./playground.tsx" />
8+
9+
## API
10+
11+
继承自 [Popover](../popover/). 移除了 `floatingArrowProps``offsetHeight` 属性.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Button, Tooltip } from '@shilong/react'
2+
3+
function App() {
4+
return (
5+
<Tooltip
6+
trigger={<Button variant="outline">👋</Button>}
7+
hover
8+
click={false}
9+
arrow
10+
>
11+
这是一个打招呼的表情
12+
</Tooltip>
13+
)
14+
}
15+
16+
export default App

docs/index.mdx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44

55
## 1. 安装依赖
66

7-
```sh
8-
pnpm add @shilong/react
9-
```
7+
import { PackageManagerTabs } from '@theme'
8+
9+
<PackageManagerTabs
10+
command={{
11+
pnpm: 'pnpm add @shilong/react',
12+
npm: 'npm install @shilong/react',
13+
}}
14+
/>
1015

1116
## 2. 加载主题样式
1217

@@ -40,7 +45,7 @@ createRoot(document.querySelector('#app')!).render(
4045

4146
import { Button } from '@shilong/react'
4247

43-
## 3. 使用 <Button variant='link'><a href="/components/button">查看文档</a></Button>
48+
## 3. 使用 <Button variant='link'><a href="/react/components/button">查看文档</a></Button>
4449

4550
```tsx playground
4651
import { Button } from '@shilong/react'

rspress.config.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ export default defineConfig({
1313
},
1414
icon: '/favicon.ico',
1515
themeConfig: {
16+
socialLinks: [
17+
{
18+
icon: 'github',
19+
mode: 'link',
20+
content: 'https://github.com/Onlylonger/react',
21+
},
22+
],
1623
nav: [
1724
{
1825
text: 'Quick Start',
@@ -40,10 +47,10 @@ export default defineConfig({
4047
text: 'Popover',
4148
link: '/components/popover',
4249
},
43-
{
44-
text: 'Input',
45-
link: '/components/input',
46-
},
50+
// {
51+
// text: 'Input',
52+
// link: '/components/input',
53+
// },
4754
{
4855
text: 'Tooltip',
4956
link: '/components/tooltip',

0 commit comments

Comments
 (0)