Skip to content

Commit ae7d396

Browse files
committed
U
1 parent 07966e7 commit ae7d396

14 files changed

Lines changed: 99 additions & 22 deletions

File tree

docs/components/button/index.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@
77
<code src="./playground.tsx" />
88

99
## API
10+
11+
Extended from `button`
12+
13+
| Property | Description | Type | Default Value |
14+
| -------- | ----------- | ------------------------------------------------------------------------------------------ | ------------- |
15+
| variant | 变体类型 | `"link" \| "default" \| "destructive" \| "outline" \| "secondary" \| "ghost" \| undefined` | `undefined` |
16+
| size | 大小 | `"default" \| "sm" \| "lg" \| "icon" \| undefined` | `undefined` |
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { Button } from '@shilong/react'
2+
import React from 'react'
23

34
function App() {
4-
return <Button onClick={() => alert('Ooops')}>Click Me!</Button>
5+
const [variant] = React.useState()
6+
const [size] = React.useState()
7+
8+
return (
9+
<Button variant={variant} size={size} onClick={() => alert('Ooops')}>
10+
Click Me!
11+
</Button>
12+
)
513
}
614

715
export default App

docs/components/popover/index.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Popover
2+
3+
用户在某个参考元素上,动态显示某个弹框元素. 基于 [floating-ui](https://github.com/floating-ui/floating-ui)
4+
5+
## Playground
6+
7+
<code src="./playground.tsx" />
8+
9+
## API
10+
11+
| Property | Description | Type | Default Value |
12+
| ------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- |
13+
| trigger | 触发元素 | `React.ReactElement` | - |
14+
| dismiss | 是否打开键盘`esc`和弹窗外 点击关闭 | `boolean` | `true` |
15+
| hover | 是否开启 `hover` 打开弹窗 | `boolean` | `false` |
16+
| click | 是否开启 `click` 打开弹窗 | `boolean` | `true` |
17+
| arrow | 是否开启 弹窗箭头 | `boolean` | `false` |
18+
| offsetHeight | `trigger元素` 与 弹窗 距离 | `number` | `0` |
19+
| floatingArrowProps | 箭头额外属性 | Omit\<[FloatingArrowProps](https://floating-ui.com/docs/floatingarrow), 'context'\> | `{}` |
20+
| children | | `React.ReactElement` | - |
21+
| onOpenChange | 打开弹窗时回调函数 | `((open: boolean, event?: Event, reason?: OpenChangeReason) => void) \| undefined` | - |
22+
| placement | 弹窗位置 | `"top" \| "right" \| "bottom" \| "left"\|"top-start" \| "top-end" \| "right-start" \| "right-end" \| "bottom-start" \| "bottom-end" \| "left-start" \| "left-end"` | `bottom` |
23+
| open | 弹窗打开状态 | `boolean` | `-` |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Button, Popover } from '@shilong/react'
2+
3+
function App() {
4+
return (
5+
<Popover trigger={<Button variant="outline">Click && Hover</Button>} hover>
6+
<div style={{ border: '1px solid black' }}>nihao</div>
7+
</Popover>
8+
)
9+
}
10+
11+
export default App

docs/components/toast.mdx

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/components/toast/index.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Toast
2+
3+
当有信息反馈的时候,可以使用 `Toaster` + `toast` 方法动态提供反馈实时信息给到用户。
4+
当前是使用的 [sonner](https://github.com/emilkowalski/sonner) 库.
5+
6+
## Playground
7+
8+
<code src="./playground.tsx" />
9+
10+
## API
11+
12+
请查阅 [sonner](https://sonner.emilkowal.ski/getting-started)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Button, toast, Toaster } from '@shilong/react'
2+
import ReactDom from 'react-dom'
3+
4+
function App() {
5+
return (
6+
<>
7+
<Button onClick={() => toast('nihao')}>Show Toast!</Button>
8+
{/* createPortal is optional. Use it when your layers are incorrect and cannot be easily modified. */}
9+
{ReactDom.createPortal(<Toaster position="top-center" />, document.body)}
10+
</>
11+
)
12+
}
13+
14+
export default App

docs/index.mdx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pnpm add @shilong/react
99
```
1010

11-
## 2. 加载主题样式.
11+
## 2. 加载主题样式
1212

1313
```tsx "title=index.tsx" {5}
1414
import { StrictMode } from 'react'
@@ -38,18 +38,17 @@ createRoot(document.querySelector('#app')!).render(
3838

3939
:::
4040

41-
## 3. 使用
41+
import { Button } from '@shilong/react'
4242

43-
```tsx preview
44-
import { Button, Toaster, toast } from '@shilong/react'
43+
## 3. 使用 <Button variant='link'><a href="/components/button">查看文档</a></Button>
44+
45+
```tsx playground
46+
import { Button } from '@shilong/react'
4547

4648
function App() {
4749
return (
4850
<div>
49-
<Button variant="outline">Hello World</Button>
50-
&nbsp;&nbsp;
51-
<Button onClick={() => toast('Hi!')}>Toast</Button>
52-
<Toaster position="bottom-center" />
51+
<Button>Hi 👋</Button>
5352
</div>
5453
)
5554
}

docs/theme/global.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
table thead,
2+
tbody {
3+
width: 100%;
4+
}

docs/theme/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Theme from 'rspress/theme'
22
import '@shilong/react/style.css'
3+
import './global.css'
34

45
export default {
56
...Theme,

0 commit comments

Comments
 (0)