123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import React, { MouseEvent } from 'react';
- import { storiesOf } from '@storybook/react';
- import { action } from '@storybook/addon-actions';
- import { withInfo } from "@storybook/addon-info";
- import { withKnobs, number, boolean, select } from "@storybook/addon-knobs";
- import { addReadme } from 'storybook-readme';
-
- import ConsumeListView from '@/components/Payment/ConsumeListView';
- import ConsumeListViewDoc from '@components/Payment/ConsumeListView/README.md';
- import PayPlatFormOptions, { PAY_CHANNEL } from '@/components/Payment/PayPlatformOptions';
- import PayPlatFormOptionsDoc from '@components/Payment/PayPlatformOptions/README.md';
- import PriceOptions from '@/components/Payment/PriceOptions';
- import PriceOptionsDoc from '@components/Payment/PriceOptions/README.md';
- import WaitPayInfoView from '@/components/Payment/WaitPayInfoView';
- import WaitPayInfoViewDoc from '@components/Payment/WaitPayInfoView/README.md';
-
- import { consumeList as consumeData} from './data/consumeList.json';
-
- const stories = storiesOf('Payment', module);
- stories.addDecorator((storyFn) => <div style={{padding: "0px 40px"}}>{storyFn()}</div>)
- stories.addDecorator(withKnobs);
- stories.addDecorator(withInfo);
- stories.addDecorator(addReadme);
-
- stories.add(
- 'ConsumeListView',
- () => {
- const [toggle, setToggle] = React.useState(false);
- return <ConsumeListView
- isToggle={toggle}
- onToggleChange={() => setToggle(!toggle)}
- onConsumeItemClick={(e: MouseEvent, clickData: any) => { console.log(clickData); }}
- dataSource={consumeData}
- listLength={consumeData.length}
- showLength={number("showLength", 5)}
- />
- },
- {
- info: {
- inline: true,
- text: `
- ~~~typescript
- <ConsumeListView
- isToggle={toggle}
- onToggleChange={() => setToggle(!toggle)}
- dataSource={consumeData}
- listLength={consumeData.length}
- showLength={number("showLength", 5)}
- />
- ~~~
- `,
- // TableComponent: (props: TableComponentOptionProps) => {
- // const { propDefinitions } = props;
- // return propDefinitions.map(i => {
- // return (
- // <div>
- // {i.defaultValue}
- // </div>
- // )
- // })
- // },
- source: false,
- maxPropStringLength: 500,
- },
- notes: 'A very simple example of addon notes',
- readme: {
- sidebar: ConsumeListViewDoc,
- }
- }
- );
-
- stories.add(
- 'PayPlatFormOptions',
- () => {
- const [payChannel, setPayChannel] = React.useState(PAY_CHANNEL.PAYPAL);
- return (
- <PayPlatFormOptions
- payChannel={payChannel}
- onPayChannelChange={(value) => {
- action(`PayItemChange: ${value}`);
- setPayChannel(value);
- }}
- isMobile={boolean("isMobile", false)}
- size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
- withTitle={boolean("withTitle", false)}
- locale={select("locale", { ZH: 'zh', EN: 'en' }, "zh")}
- />
- )
- },
- {
- info: {
- inline: true,
- text: ``,
- source: false,
- maxPropStringLength: 500,
- },
- notes: 'A very simple example of addon notes',
- readme: {
- sidebar: PayPlatFormOptionsDoc,
- }
- }
- );
-
- stories.add(
- 'PriceOptions',
- () => {
- const [price, setPrice] = React.useState(0);
- const refInput = React.useRef(null);
- return (
- <PriceOptions
- price={price}
- onPriceChange={(v) => setPrice(v)}
- size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
- withTitle={boolean("withTitle", false)}
- focusScroll={boolean("focusScroll", false)}
- inputRef={refInput}
- />
- )
- },
- {
- info: {
- inline: true,
- text: ``,
- source: false,
- maxPropStringLength: 500,
- },
- notes: 'A very simple example of addon notes',
- readme: {
- sidebar: PriceOptionsDoc,
- }
- }
- )
-
- stories.add(
- 'WaitPayInfoView',
- () => {
- return (
- <WaitPayInfoView />
- )
- },
- {
- info: { inline: true, text: ``, source: false, maxPropStringLength: 500 },
- notes: 'A very simple example of addon notes',
- readme: {
- sidebar: WaitPayInfoViewDoc,
- }
- }
- )
|