mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 14:15:06 +01:00
c5368c152b
* added storybook test runner * added test runner in ci * updated test for ci and fixed lint error * updated lavamoat policy * updated test command * updated playwright * changed command to storybook;ci * updated command * updated instance for test-storybook * updated playwright * added playwright step * replaced concurrently with start-server-and-test * updated the static storybook directory * replaced first with last * updated lock file * replaced first with last * updated test-storybook with maxworkers * updated .depchechrc * updated yml * removed id from banner base * replaced broken stories with .stories-to-do.js extesnsion * updated token allowance story * removed duplicacies from yarn * fixed lavamoat * removed filename comment * updated links for docs * fixed file extension for stories * updated path for stories.json * updated stories.json path * yarn updated * updated stories * updated yarn * updated wait on
122 lines
3.9 KiB
Plaintext
122 lines
3.9 KiB
Plaintext
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
|
import { BannerBase } from './banner-base';
|
|
|
|
### This is a base component. It should not be used in your feature code directly but as a "base" for other UI components
|
|
|
|
# BannerBase
|
|
|
|
The `BannerBase` is the base component for banners
|
|
|
|
<Canvas style={{ background: 'var(--color-background-alternative)' }}>
|
|
<Story id="components-componentlibrary-bannerbase--default-story" />
|
|
</Canvas>
|
|
|
|
## Props
|
|
|
|
The `BannerBase` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props
|
|
|
|
<ArgsTable of={BannerBase} />
|
|
|
|
### Title
|
|
|
|
Use the `title` prop to pass a string that is sentence case no period. Use the `titleProps` prop to pass additional props to the `Text` component.
|
|
|
|
<Canvas style={{ background: 'var(--color-background-alternative)' }}>
|
|
<Story id="components-componentlibrary-bannerbase--title" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { BannerBase } from '../../component-library';
|
|
|
|
<BannerBase title="Title is sentence case no period">
|
|
Pass only a string through the title prop
|
|
</BannerBase>;
|
|
```
|
|
|
|
### Children
|
|
|
|
The `children` is the description area of the `BannerBase` that can be a text or react node. Description shouldn't repeat title and only 1-3 lines.
|
|
|
|
<Canvas style={{ background: 'var(--color-background-alternative)' }}>
|
|
<Story id="components-componentlibrary-bannerbase--children" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { SIZES } from '../../../helpers/constants/design-system';
|
|
import { BannerBase } from '../../component-library';
|
|
|
|
<BannerBase>
|
|
{`Description shouldn't repeat title. 1-3 lines. Can contain a `}
|
|
<ButtonLink size={SIZES.AUTO} href="https://metamask.io/" target="_blank">
|
|
hyperlink.
|
|
</ButtonLink>
|
|
</BannerBase>;
|
|
```
|
|
|
|
### Action Button Label, onClick, & Props
|
|
|
|
Use the `actionButtonLabel` prop to pass text, `actionButtonOnClick` prop to pass an onClick handler, and `actionButtonProps` prop to pass an object of [ButtonLink props](/docs/components-componentlibrary-buttonlink--default-story) for the action
|
|
|
|
<Canvas style={{ background: 'var(--color-background-alternative)' }}>
|
|
<Story id="components-componentlibrary-bannerbase--action-button" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { BannerBase, ICON_NAMES } from '../../component-library';
|
|
|
|
<BannerBase
|
|
title="Action prop demo"
|
|
actionButtonLabel="Action"
|
|
actionButtonProps={{
|
|
icon: ICON_NAMES.ARROW_2_RIGHT, // TODO: change to iconName
|
|
iconPositionRight: true,
|
|
}}
|
|
actionButtonOnClick={() => console.log('ButtonLink actionButtonOnClick demo')}
|
|
>
|
|
Use actionButtonLabel for action text, actionButtonOnClick for the onClick
|
|
handler, and actionButtonProps to pass any ButtonLink prop types such as
|
|
iconName
|
|
</BannerBase>;
|
|
```
|
|
|
|
### On Close
|
|
|
|
Use the `onClose` prop to pass a function to the close button. The close button will appear when this prop is used.
|
|
|
|
Additional props can be passed to the close button with `closeButtonProps`
|
|
|
|
<Canvas style={{ background: 'var(--color-background-alternative)' }}>
|
|
<Story id="components-componentlibrary-bannerbase--on-close" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { BannerBase } from '../../component-library';
|
|
|
|
<BannerBase
|
|
title="onClose demo"
|
|
onClose={() => console.log('close button clicked')}
|
|
>
|
|
Click the close button icon to hide this notifcation
|
|
</BannerBase>;
|
|
```
|
|
|
|
### Start Accessory
|
|
|
|
Use the `startAccessory` prop to add components such as icons or fox image to the start (default: left) of the `BannerBase` content
|
|
|
|
<Canvas style={{ background: 'var(--color-background-alternative)' }}>
|
|
<Story id="components-componentlibrary-bannerbase--start-accessory" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { SIZES } from '../../../helpers/constants/design-system';
|
|
import { BannerBase, Icon, ICON_NAMES } from '../../component-library';
|
|
|
|
<BannerBase
|
|
title="Start accessory demo"
|
|
startAccessory={<Icon name={ICON_NAMES.INFO_FILLED} size={SIZES.LG} />}
|
|
>
|
|
The info icon on the left is passed through the startAccessory prop
|
|
</BannerBase>;
|
|
```
|