mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-02-06 13:50:10 +00:00
106 lines
2.6 KiB
Text
106 lines
2.6 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 Checkbox from '@baserow/modules/core/components/Checkbox'
|
|
|
|
<Meta
|
|
title="Baserow/Form Elements/Checkbox"
|
|
component={Checkbox}
|
|
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={{
|
|
checked: {
|
|
control: {
|
|
type: 'boolean',
|
|
options: [true, false],
|
|
},
|
|
defaultValue: false,
|
|
},
|
|
disabled: {
|
|
control: {
|
|
type: 'boolean',
|
|
options: [true, false],
|
|
},
|
|
defaultValue: false,
|
|
},
|
|
error: {
|
|
control: {
|
|
type: 'boolean',
|
|
options: [true, false],
|
|
},
|
|
defaultValue: false,
|
|
},
|
|
indeterminate: {
|
|
control: {
|
|
type: 'boolean',
|
|
options: [true, false],
|
|
},
|
|
defaultValue: false,
|
|
},
|
|
}}
|
|
/>
|
|
|
|
# Checbkox
|
|
|
|
The checkbox component replaces the default browser checkbox with a custom styled one. It has an additional indeterminate state.
|
|
|
|
export const Template = (args, { argTypes, updateArgs }) => ({
|
|
methods: {
|
|
action,
|
|
handleInput(checkboxValue) {
|
|
const checked = checkboxValue
|
|
updateArgs({ ...args, checked })
|
|
action('handleInput')(checkboxValue)
|
|
},
|
|
},
|
|
components: { Checkbox },
|
|
props: Object.keys(argTypes),
|
|
template: `<Checkbox v-bind="$props" @input="handleInput">${args.default}</Checkbox>`,
|
|
})
|
|
|
|
export const designConfig = {
|
|
type: 'figma',
|
|
url: 'https://www.figma.com/file/W7R2rQW7ohsZMeHRfEcPFW/Design-Library?node-id=54%3A919&mode=dev',
|
|
}
|
|
|
|
<Canvas>
|
|
<Story
|
|
name="Checkbox"
|
|
args={{
|
|
checked: true,
|
|
default: 'Label',
|
|
}}
|
|
parameters={{
|
|
design: config(designConfig),
|
|
}}
|
|
>
|
|
{Template.bind({})}
|
|
</Story>
|
|
</Canvas>
|
|
|
|
## Example
|
|
|
|
```javascript
|
|
<Checkbox>Label</Checkbox>
|
|
```
|
|
|
|
## Props
|
|
|
|
<Props of={Checkbox} />
|