mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-01-30 10:26:29 +00:00
105 lines
2.5 KiB
Text
105 lines
2.5 KiB
Text
import { Meta, Story, Props, Canvas } from '@storybook/addon-docs/blocks'
|
|
import { config, withDesign } from 'storybook-addon-designs'
|
|
import { action } from '@storybook/addon-actions'
|
|
import { useArgs } from '@storybook/client-api'
|
|
|
|
import Radio from '@baserow/modules/core/components/Radio'
|
|
|
|
<Meta
|
|
title="Baserow/Form Elements/Radio/Radio"
|
|
component={Radio}
|
|
parameters={{
|
|
backgrounds: {
|
|
default: 'white',
|
|
values: [
|
|
{ name: 'white', value: '#ffffff' },
|
|
{ name: 'light', value: '#eeeeee' },
|
|
{ name: 'dark', value: '#222222' },
|
|
],
|
|
},
|
|
}}
|
|
decorators={[
|
|
withDesign,
|
|
(story, context) => {
|
|
const [_, updateArgs] = useArgs()
|
|
return story({ ...context, updateArgs })
|
|
},
|
|
]}
|
|
argTypes={{
|
|
default: {
|
|
control: 'text',
|
|
description: 'Slot content',
|
|
defaultValue: 'Label',
|
|
},
|
|
modelValue: {
|
|
control: {
|
|
type: 'text',
|
|
},
|
|
defaultValue: '',
|
|
},
|
|
value: {
|
|
control: {
|
|
type: 'text',
|
|
},
|
|
defaultValue: 'option1',
|
|
},
|
|
disabled: {
|
|
control: {
|
|
type: 'boolean',
|
|
options: [true, false],
|
|
},
|
|
defaultValue: false,
|
|
},
|
|
loading: {
|
|
control: {
|
|
type: 'boolean',
|
|
options: [true, false],
|
|
},
|
|
defaultValue: false,
|
|
},
|
|
}}
|
|
/>
|
|
|
|
# Radio
|
|
|
|
The radio component is a basic native radio input. It can be used to select a single option from a list.
|
|
|
|
export const Template = (args, { argTypes, updateArgs }) => ({
|
|
methods: {
|
|
action,
|
|
handleInput(value) {
|
|
const modelValue = value
|
|
updateArgs({ ...args, modelValue })
|
|
action('handleInput')(modelValue)
|
|
},
|
|
},
|
|
components: { Radio },
|
|
props: Object.keys(argTypes),
|
|
template: `<Radio v-bind="$props" @input="handleInput">${args.default}</Radio>`,
|
|
})
|
|
|
|
export const designConfig = {
|
|
type: 'figma',
|
|
url: 'https://www.figma.com/file/W7R2rQW7ohsZMeHRfEcPFW/Design-Library?node-id=53%3A1852&mode=dev',
|
|
}
|
|
|
|
<Canvas>
|
|
<Story
|
|
name="Radio"
|
|
parameters={{
|
|
design: config(designConfig),
|
|
}}
|
|
>
|
|
{Template.bind({})}
|
|
</Story>
|
|
</Canvas>
|
|
|
|
## Example
|
|
|
|
```javascript
|
|
<Radio></Radio>
|
|
```
|
|
|
|
## Props
|
|
|
|
<Props of={Radio} />
|