Skip to content

Commit

Permalink
docs(toggles): add stories and document for toggles component (#764)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack <panjie@growingio.com>
  • Loading branch information
tongchuliu and jack0pan authored Feb 4, 2021
1 parent 5276c59 commit 6f6381d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
36 changes: 36 additions & 0 deletions src/components/toggles/Toggles.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Subtitle, ArgsTable } from '@storybook/addon-docs/blocks';
import Toggles from './toggles';

# Toggles 开关

<Subtitle>需要表示开关状态/两种状态之间的切换时使用。</Subtitle>

## 参数说明

<ArgsTable of={Toggles} />

## 代码演示

### 默认

基础用法

[Example](/?path=/story/basic-components-toggles--default)

### 禁用

Toggles 失效状态

[Example](/?path=/story/basic-components-toggles--disabled)

### 文字

带有文字

[Example](/?path=/story/basic-components-toggles--suffix-content)

### 自定义背景色

可以自定义背景色

[Example](/?path=/story/basic-components-toggles--custom-color)
39 changes: 30 additions & 9 deletions src/components/toggles/Toggles.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
import React from 'react';
import { Story, Meta } from '@storybook/react/types-6-0';

import Toggles from './index'
import { TogglesProps } from './interface'
import './style'
import Docs from './Toggles.mdx';
import Toggles from './index';
import { TogglesProps } from './interface';
import './style';

export default {
title: 'Components/Basic/Toggles',
component: Toggles,
title: 'Basic Components/Toggles',
component: Toggles,
parameters: {
docs: {
page: Docs,
},
},
} as Meta;

const Template : Story<TogglesProps> = (args) => <Toggles {...args} />;
const Template: Story<TogglesProps> = (args) => <Toggles {...args} />;
export const Default = Template.bind({});
Default.args = {
suffixContent: true,
}
className: 'gio-toggles-default',
};

export const Disabled = Template.bind({});
Disabled.args = {
disabled: true,
};

export const suffixContent = Template.bind({});
suffixContent.args = {
suffixContent: true,
};

export const CustomColor = Template.bind({});
CustomColor.args = {
activeColor: '#000',
inactiveColor: '#fff',
};

1 comment on commit 6f6381d

@vercel
Copy link

@vercel vercel bot commented on 6f6381d Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.