Skip to content

Commit

Permalink
storybook preview (#1359)
Browse files Browse the repository at this point in the history
* feat(storybook): button,link,global,less-var

* chore(storybook): change content

Co-authored-by: zhujiahong <zhujiahong@growingio.com>
  • Loading branch information
zhuzilv and zhujiahong authored Oct 20, 2021
1 parent 06750d0 commit 30ab729
Show file tree
Hide file tree
Showing 127 changed files with 801 additions and 310 deletions.
2 changes: 1 addition & 1 deletion src/alert/demos/Alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AlertProps } from '../interfaces';
import '../style';

export default {
title: 'Feedback/Alert',
title: 'Components/Alert',
component: Alert,
parameters: {
docs: {
Expand Down
10 changes: 5 additions & 5 deletions src/alert/demos/AlertPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ export default function ListPage() {
<Heading>{formatMessage({ defaultMessage: '代码演示' })}</Heading>
<Subheading>{formatMessage({ defaultMessage: 'Icon、标题、正文、关闭按钮' })}</Subheading>
<Canvas>
<Story id="feedback-alert--default" />
<Story id="components-alert--default" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: 'Icon & 标题 & 关闭' })}</Subheading>
<Canvas>
<Story id="feedback-alert--no-description" />
<Story id="components-alert--no-description" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: 'Icon & 正文 & 关闭' })}</Subheading>
<Canvas>
<Story id="feedback-alert--no-title" />
<Story id="components-alert--no-title" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: '标题 & 正文 & 关闭' })}</Subheading>
<Canvas>
<Story id="feedback-alert--no-icon" />
<Story id="components-alert--no-icon" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: 'Icon & 标题 & 正文 ' })}</Subheading>
<Canvas>
<Story id="feedback-alert--no-close" />
<Story id="components-alert--no-close" />
</Canvas>

<Heading>{formatMessage({ defaultMessage: '参数说明' })}</Heading>
Expand Down
2 changes: 1 addition & 1 deletion src/avatar/demos/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../style/demo.stories.less';
import image from '../../assets/images/Avatar.png';

export default {
title: 'Data Display/Avatar',
title: 'Components/Avatar',
component: Avatar,
parameters: {
docs: {
Expand Down
8 changes: 4 additions & 4 deletions src/avatar/demos/AvatarPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function ListPage() {
<Heading>{formatMessage({ defaultMessage: '代码演示' })}</Heading>
<Subheading>{formatMessage({ defaultMessage: '基础头像' })}</Subheading>
<Canvas>
<Story id="data-display-avatar--default" />
<Story id="components-avatar--default" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: '尺寸' })}</Subheading>
Expand All @@ -28,7 +28,7 @@ export default function ListPage() {
})}
</p>
<Canvas>
<Story id="data-display-avatar--size" />
<Story id="components-avatar--size" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: '可展开操作' })}</Subheading>
Expand All @@ -38,7 +38,7 @@ export default function ListPage() {
})}
</p>
<Canvas>
<Story id="data-display-avatar--hover" />
<Story id="components-avatar--hover" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: '重叠展示' })}</Subheading>
Expand All @@ -49,7 +49,7 @@ export default function ListPage() {
})}
</p>
<Canvas>
<Story id="data-display-avatar--group" />
<Story id="components-avatar--group" />
</Canvas>

<Heading>{formatMessage({ defaultMessage: '参数说明' })}</Heading>
Expand Down
2 changes: 1 addition & 1 deletion src/banner/demos/Banner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Docs from './BannerPage';
import '../style';

export default {
title: 'Functional Components/Banner',
title: 'Components/Banner',
component: Banner,
parameters: {
docs: {
Expand Down
6 changes: 3 additions & 3 deletions src/banner/demos/BannerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export default function ListPage() {
<Heading>{formatMessage({ defaultMessage: '代码演示' })}</Heading>
<Subheading>{formatMessage({ defaultMessage: '信息通知' })}</Subheading>
<Canvas>
<Story id="functional-components-banner--base" />
<Story id="components-banner--base" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: '警告通知' })}</Subheading>
<Canvas>
<Story id="functional-components-banner--alert" />
<Story id="components-banner--alert" />
</Canvas>

<Subheading>{formatMessage({ defaultMessage: '可关闭' })}</Subheading>
<Canvas>
<Story id="functional-components-banner--closeable" />
<Story id="components-banner--closeable" />
</Canvas>

<Heading>{formatMessage({ defaultMessage: '参数说明' })}</Heading>
Expand Down
2 changes: 1 addition & 1 deletion src/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface BreadcrumbInterface extends React.FC<BreadcrumbProps> {
Separator: typeof BreadcrumbSeparator;
}

const Breadcrumb: BreadcrumbInterface = ({
export const Breadcrumb: BreadcrumbInterface = ({
prefixCls: customizePrefixCls,
separator = '/',
style,
Expand Down
7 changes: 6 additions & 1 deletion src/breadcrumb/demos/Breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BreadcrumbProps } from '../interface';
import '../style';

export default {
title: 'Navigation/Breadcrumb',
title: 'Components/Breadcrumb',
component: Breadcrumb,
decorators: [withDesign],
parameters: {
Expand All @@ -20,6 +20,11 @@ export default {
page: Docs,
},
},
argTypes: {
separator: {
control: { type: 'text' },
},
},
} as Meta;

const Template: Story<BreadcrumbProps> = (args) => <Breadcrumb {...args} />;
Expand Down
2 changes: 1 addition & 1 deletion src/breadcrumb/demos/BreadcrumbPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function BreadcrumbPage() {

<Subheading>{formatMessage({ defaultMessage: '默认' })}</Subheading>
<Canvas>
<Story id="navigation-breadcrumb--default" />
<Story id="components-breadcrumb--default" />
</Canvas>

<Heading>{formatMessage({ defaultMessage: '参数说明' })}</Heading>
Expand Down
136 changes: 131 additions & 5 deletions src/button/demos/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,156 @@
import React from 'react';
import { Story, Meta } from '@storybook/react/types-6-0';
import { PlusCircleFilled, FilterOutlined, DeleteOutlined } from '@gio-design/icons';
import { PlusOutlined, FilterOutlined } from '@gio-design/icons';
import { withDesign } from 'storybook-addon-designs';
import Button from '../index';
import IconButton from '../IconButton';
import { ButtonProps, IconButtonProps } from '../interface';
import '../style';
import './index.less';
import Docs from './ButtonPage';

export default {
title: 'Upgraded/Button',
component: Button,
argTypes: {
prefix: {
control: { type: 'text' }, // 不约束react_node会传入对象导致报错
},
suffix: {
control: { type: 'text' },
},
},
decorators: [withDesign],
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/file/J2wZWEocPEb1DbDEj99AgD/Design-System?node-id=373%3A15923',
allowFullscreen: true,
},
docs: {
page: Docs,
},
},
} as Meta;
const Context = [
{ type: 'primary', children: '主要按钮' },
{ type: 'secondary', children: '次要按钮' },
{ type: 'text', children: '文字按钮' },
];

const Template: Story<ButtonProps> = (args) => (
<Button {...args} suffix={<FilterOutlined />} prefix={<PlusCircleFilled />} />
<table>
<tr>
<th>Button Control</th>
<th>描述</th>
{Context.map((item) => (
<th>{item.type}</th>
))}
</tr>
<tr>
<td>Size</td>
<td>拥有两种尺寸:大号为高度36px,小号为高度30px</td>
{Context.map((item: any) => (
<td>
<Button {...args} size="normal" type={item.type} />
<Button {...args} size="small" type={item.type} />
</td>
))}
</tr>
<tr>
<td>Prefix Only</td>
<td>按钮是否只有前缀</td>
{Context.map((item: any) => (
<td>
<Button {...args} prefix={<PlusOutlined />} type={item.type} />
</td>
))}
</tr>
<tr>
<td>Suffix Only</td>
<td>按钮是否只有后缀</td>
{Context.map((item: any) => (
<td>
<Button {...args} suffix={<FilterOutlined />} type={item.type} />
</td>
))}
</tr>

<tr>
<td>Loading</td>
<td>加载样式</td>
{Context.map((item: any) => (
<td>
<Button {...args} type={item.type} loading />
<Button {...args} size="small" type={item.type} loading />
</td>
))}
</tr>
<tr>
<td>Icon Only</td>
<td>按钮是否只有icon</td>
{Context.map((item: any) => (
<td>
<IconButton {...args} type={item.type}>
<FilterOutlined />
</IconButton>
<IconButton {...args} size="small" type={item.type}>
<FilterOutlined />
</IconButton>
</td>
))}
</tr>
<tr>
<td>Disabled</td>
<td>disabled状态的样式</td>
{Context.map((item: any) => (
<td>
<Button {...args} disabled type={item.type} />
</td>
))}
</tr>
<tr>
<td>Prefix+Suffix</td>
<td>前缀和后缀都存在</td>
{Context.map((item: any) => (
<td>
<Button {...args} suffix={<FilterOutlined />} prefix={<PlusOutlined />} type={item.type} />
</td>
))}
</tr>
</table>
);

export const Default = Template.bind({});
export const Demo = Template.bind({});
Demo.args = {
children: 'Button',
};

const ButtonTemplate: Story<ButtonProps> = (args) => <Button {...args} />;
export const Default = ButtonTemplate.bind({});

Default.args = {
children: 'Button',
prefix: <PlusOutlined />,
};
export const Disable = ButtonTemplate.bind({});
Disable.args = {
children: 'Disable',
disabled: true,
};

const IconButtonTemplate: Story<IconButtonProps> = (args) => (
<IconButton {...args}>
<DeleteOutlined />
<FilterOutlined />
</IconButton>
);

export const IconButtonDemo = IconButtonTemplate.bind({});
IconButtonDemo.args = {};

export const BlockButton = ButtonTemplate.bind({});
BlockButton.args = {
children: 'Block',
style: {
width: '100%',
},
};
35 changes: 32 additions & 3 deletions src/button/demos/ButtonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Title, Heading, ArgsTable } from '@storybook/addon-docs';
import { Canvas, Title, Heading, Story, Subheading, ArgsTable } from '@storybook/addon-docs';

import { useIntl } from 'react-intl';
import Button from '../index';

Expand All @@ -11,11 +12,39 @@ export default function ButtonPage() {
<Title>{formatMessage({ defaultMessage: 'Button 按钮' })}</Title>
<p>
{formatMessage({
defaultMessage: '触发后即执行相应操作。按钮通常使用在页面或弹窗等多种场景中,例如新建、删除等。',
defaultMessage: '一个可点击的按钮,可以用在表单或文档其他需要使用简单标准按钮的地方。',
})}
</p>
<p>
<a href="https://www.figma.com/file/J2wZWEocPEb1DbDEj99AgD/Design-System?node-id=21%3A11843">Figma</a>
</p>
<p>Upgrading Guide</p>
<ul>
<li> 支持所有原生html属性</li>
<li> 原 Icon Button 现在需要在children内传入如 &lt;Button&gt;&lt;PlusOutlined /&gt;&lt;/Button&gt;</li>
<li>block参数取消,需在样式表中覆写 display: block,或width: 100%;</li>
</ul>
<Heading>{formatMessage({ defaultMessage: '代码演示' })}</Heading>

<Subheading>{formatMessage({ defaultMessage: '样例展示' })}</Subheading>
<Canvas>
<Story id="upgraded-button--demo" />
</Canvas>
<Subheading>{formatMessage({ defaultMessage: 'default' })}</Subheading>
<Canvas>
<Story id="upgraded-button--default" />
</Canvas>
<Subheading>{formatMessage({ defaultMessage: 'disable' })}</Subheading>
<Canvas>
<Story id="upgraded-button--disable" />
</Canvas>
<Subheading>{formatMessage({ defaultMessage: 'IconButton' })}</Subheading>
<Canvas>
<Story id="upgraded-button--icon-button-demo" />
</Canvas>
<Subheading>{formatMessage({ defaultMessage: 'blockbutton' })}</Subheading>
<Canvas>
<Story id="upgraded-button--block-button" />
</Canvas>
<Heading>{formatMessage({ defaultMessage: '参数说明' })}</Heading>
<ArgsTable of={Button} />
</>
Expand Down
17 changes: 17 additions & 0 deletions src/button/demos/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
table {
border-spacing: 0;
th {
padding: 10px;
font-size: 14px;
text-align: left;
background-color: #f7f8fc;
}
td {
padding: 5px 5px;
font-size: 14px;
border: 1px solid #f7f8fc;
.gio-button {
margin: 4px 8px;
}
}
}
2 changes: 1 addition & 1 deletion src/card/demos/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Table from '../../table';
import Button from '../../legacy/button';

export default {
title: 'Data Display/Card',
title: 'Components/Card',
component: Card,
decorators: [withDesign],
parameters: {
Expand Down
Loading

1 comment on commit 30ab729

@vercel
Copy link

@vercel vercel bot commented on 30ab729 Oct 20, 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.