-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1387 from nervosnetwork/develop
Merge develop into testnet
- Loading branch information
Showing
13 changed files
with
5,109 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { StorybookConfig } from '@storybook/react-webpack5' | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
addons: [ | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@storybook/preset-create-react-app', | ||
'@storybook/addon-onboarding', | ||
'@storybook/addon-interactions', | ||
'@storybook/addon-storysource', | ||
], | ||
framework: { | ||
name: '@storybook/react-webpack5', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: true, | ||
}, | ||
staticDirs: ['../public'], | ||
} | ||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'antd/dist/antd.css' | ||
// This should be after all third-party library styles so that it can override them. | ||
import '../src/index.css' | ||
import '../src/utils/i18n' | ||
import type { Preview } from '@storybook/react' | ||
import { MINIMAL_VIEWPORTS, INITIAL_VIEWPORTS } from '@storybook/addon-viewport' | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
viewport: { | ||
viewports: { ...MINIMAL_VIEWPORTS, ...INITIAL_VIEWPORTS }, | ||
}, | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.border { | ||
border: 1px solid #000; | ||
box-sizing: content-box; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import AddressText from '.' | ||
import styles from './index.stories.module.scss' | ||
import { useForkedState } from '../../utils/hook' | ||
|
||
const meta = { | ||
component: AddressText, | ||
argTypes: { | ||
children: { | ||
// In React 17, `FC<P>` is wrapped in `PropsWithChildren<P>`, causing the type of `children` to be unrecognizable by Storybook. | ||
description: 'This item will be used as text when text is empty.', | ||
type: 'string', | ||
}, | ||
}, | ||
} satisfies Meta<typeof AddressText> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
const addressHash = 'ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqflz4emgssc6nqj4yv3nfv2sca7g9dzhscgmg28x' | ||
|
||
export const Primary: Story = { | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'mobile2', | ||
}, | ||
}, | ||
args: { | ||
children: addressHash, | ||
}, | ||
} | ||
|
||
export const UseTextWidthForPlaceholderWidth: Story = { | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'tablet', | ||
}, | ||
}, | ||
args: { | ||
children: addressHash, | ||
useTextWidthForPlaceholderWidth: true, | ||
className: styles.border, | ||
}, | ||
render: function Render(args) { | ||
const [useTextWidthForPlaceholderWidth, setUseTextWidthForPlaceholderWidth] = useForkedState( | ||
args.useTextWidthForPlaceholderWidth, | ||
) | ||
|
||
return ( | ||
<div> | ||
<AddressText {...args} useTextWidthForPlaceholderWidth={useTextWidthForPlaceholderWidth} /> | ||
<button | ||
type="button" | ||
onClick={() => setUseTextWidthForPlaceholderWidth(value => !value)} | ||
style={{ marginTop: 16 }} | ||
> | ||
toggle useTextWidthForPlaceholderWidth | ||
</button> | ||
</div> | ||
) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import EllipsisMiddle from '.' | ||
import { useForkedState } from '../../utils/hook' | ||
|
||
const meta = { | ||
component: EllipsisMiddle, | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'tablet', | ||
}, | ||
}, | ||
argTypes: { | ||
children: { | ||
// In React 17, `FC<P>` is wrapped in `PropsWithChildren<P>`, causing the type of `children` to be unrecognizable by Storybook. | ||
description: 'This item will be used as text when text is empty.', | ||
type: 'string', | ||
}, | ||
}, | ||
} satisfies Meta<typeof EllipsisMiddle> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
function getSentence(count: number) { | ||
return new Array(count) | ||
.fill(null) | ||
.map((_, idx) => `This is a sentence ${idx}.`) | ||
.join(' ') | ||
} | ||
|
||
export const ShortSentence: Story = { | ||
args: { | ||
children: getSentence(1), | ||
}, | ||
} | ||
|
||
export const LongSentence: Story = { | ||
args: { | ||
children: getSentence(10), | ||
}, | ||
} | ||
|
||
export const MinStartLen: Story = { | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'mobile1', | ||
}, | ||
}, | ||
args: { | ||
minStartLen: 40, | ||
children: getSentence(10), | ||
}, | ||
} | ||
|
||
export const UseTextWidthForPlaceholderWidth: Story = { | ||
args: { | ||
children: getSentence(1), | ||
useTextWidthForPlaceholderWidth: true, | ||
style: { border: '1px solid #000', boxSizing: 'content-box' }, | ||
}, | ||
render: function Render(args) { | ||
const [useTextWidthForPlaceholderWidth, setUseTextWidthForPlaceholderWidth] = useForkedState( | ||
args.useTextWidthForPlaceholderWidth, | ||
) | ||
|
||
return ( | ||
<div> | ||
<EllipsisMiddle {...args} useTextWidthForPlaceholderWidth={useTextWidthForPlaceholderWidth} /> | ||
<button | ||
type="button" | ||
onClick={() => setUseTextWidthForPlaceholderWidth(value => !value)} | ||
style={{ marginTop: 16 }} | ||
> | ||
toggle useTextWidthForPlaceholderWidth | ||
</button> | ||
</div> | ||
) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.