docs(slider): add event example

This commit is contained in:
unix
2020-04-20 22:51:15 +08:00
parent 82277c4bd6
commit 4f516a9d3c
2 changed files with 41 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { Layout, Playground, Attributes } from 'lib/components'
import { Slider, Row, Spacer } from 'components'
import { useState } from 'react'
export const meta = {
title: 'Slider',
@@ -47,6 +48,26 @@ Display the current value and an inputable range.
</div>
`} />
<Playground
title="Event"
desc="Get event when slide."
scope={{ Slider, Row, useState }}
code={`
() => {
const [value, setValue] = useState()
const handler = val => {
console.log(val)
setValue(val)
}
return (
<Row style={{ width: '75%' }}>
<Slider value={value} onChange={handler} />
</Row>
)
}
`} />
<Attributes edit="/pages/en-us/components/slider.mdx">
<Attributes.Title>Slider.Props</Attributes.Title>

View File

@@ -1,5 +1,6 @@
import { Layout, Playground, Attributes } from 'lib/components'
import { Slider, Row, Spacer } from 'components'
import { useState } from 'react'
export const meta = {
title: '滑动输入 Slider',
@@ -47,6 +48,25 @@ export const meta = {
</div>
`} />
<Playground
title="事件"
desc="在滑动时获取值的变化。"
scope={{ Slider, Row, useState }}
code={`
() => {
const [value, setValue] = useState()
const handler = val => {
console.log(val)
setValue(val)
}
return (
<Row style={{ width: '75%' }}>
<Slider value={value} onChange={handler} />
</Row>
)
}
`} />
<Attributes edit="/pages/zh-cn/components/slider.mdx">
<Attributes.Title>Slider.Props</Attributes.Title>