2022-10-04 18:55:51 +02:00
|
|
|
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
|
|
|
import { ButtonBase } from './button-base';
|
|
|
|
|
|
|
|
### This is a base component. It should not be used in your feature code directly but as a "base" for other UI components
|
|
|
|
|
|
|
|
# ButtonBase
|
|
|
|
|
|
|
|
The `ButtonBase` is the base component for buttons.
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--default-story" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
## Props
|
|
|
|
|
|
|
|
The `ButtonBase` accepts all props below as well as all [Box](/docs/ui-components-ui-box-box-stories-js--default-story#props) component props
|
|
|
|
|
|
|
|
<ArgsTable of={ButtonBase} />
|
|
|
|
|
|
|
|
### Size
|
|
|
|
|
|
|
|
Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-system.js`
|
|
|
|
to change the size of `ButtonBase`. Defaults to `SIZES.MD`
|
|
|
|
|
2022-11-03 19:41:16 +01:00
|
|
|
Optional: `BUTTON_BASE_SIZES` from `./button-base` object can be used instead of `SIZES`.
|
2022-10-04 18:55:51 +02:00
|
|
|
|
|
|
|
Possible sizes include:
|
|
|
|
|
|
|
|
- `SIZES.AUTO` inherits the font-size of the parent element.
|
|
|
|
- `SIZES.SM` 32px
|
|
|
|
- `SIZES.MD` 40px
|
|
|
|
- `SIZES.LG` 48px
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--size" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { SIZES } from '../../../helpers/constants/design-system';
|
|
|
|
import { ButtonBase } from '../ui/component-library';
|
|
|
|
|
|
|
|
<ButtonBase size={SIZES.AUTO} />
|
|
|
|
<ButtonBase size={SIZES.SM} />
|
|
|
|
<ButtonBase size={SIZES.MD} />
|
|
|
|
<ButtonBase size={SIZES.LG} />
|
|
|
|
```
|
|
|
|
|
|
|
|
### Block
|
|
|
|
|
|
|
|
Use boolean `block` prop to quickly enable a full width block button
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--block" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { DISPLAY } from '../../../helpers/constants/design-system';
|
|
|
|
import { ButtonBase } from '../ui/component-library';
|
|
|
|
|
|
|
|
<ButtonBase>Default Button</ButtonBase>
|
|
|
|
<ButtonBase block>Block Button</ButtonBase>
|
|
|
|
```
|
|
|
|
|
|
|
|
### As
|
|
|
|
|
|
|
|
Use the `as` box prop to change the element of `ButtonBase`. Defaults to `button`.
|
|
|
|
|
2022-10-14 00:39:22 +02:00
|
|
|
When an `href` prop is passed it will change the element to an anchor(`a`) tag.
|
|
|
|
|
2022-10-04 18:55:51 +02:00
|
|
|
Button `as` options:
|
|
|
|
|
|
|
|
- `button`
|
|
|
|
- `a`
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--as" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { ButtonBase } from '../ui/component-library';
|
|
|
|
|
|
|
|
|
|
|
|
<ButtonBase as="button">Button Element</ButtonBase>
|
|
|
|
<ButtonBase as="a" href="#">
|
|
|
|
Anchor Element
|
|
|
|
</ButtonBase>
|
|
|
|
```
|
|
|
|
|
2022-11-03 19:41:16 +01:00
|
|
|
### Href
|
|
|
|
|
|
|
|
When an `href` prop is passed it will change the element to an anchor(`a`) tag.
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--href" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { ButtonBase } from '../ui/component-library';
|
|
|
|
|
|
|
|
<ButtonBase href="/metamask">Anchor Element</ButtonBase>;
|
|
|
|
```
|
|
|
|
|
2022-10-04 18:55:51 +02:00
|
|
|
### Disabled
|
|
|
|
|
|
|
|
Use the boolean `disabled` prop to disable button
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--disabled" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { ButtonBase } from '../ui/component-library';
|
|
|
|
|
|
|
|
<ButtonBase disabled>Disabled Button</ButtonBase>;
|
|
|
|
```
|
|
|
|
|
|
|
|
### Loading
|
|
|
|
|
|
|
|
Use the boolean `loading` prop to set loading spinner
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--loading" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { ButtonBase } from '../ui/component-library';
|
|
|
|
|
|
|
|
<ButtonBase loading>Loading Button</ButtonBase>;
|
|
|
|
```
|
|
|
|
|
|
|
|
### Icon
|
|
|
|
|
|
|
|
Use the `icon` prop and the `ICON_NAMES` object from `./ui/components/component-library/icon` to select icon.
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="ui-components-component-library-button-base-button-base-stories-js--icon" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { ButtonBase } from '../ui/component-library';
|
|
|
|
import { ICON_NAMES } from '../icon';
|
|
|
|
|
|
|
|
<ButtonBase icon={ICON_NAMES.ADD_SQUARE_FILLED}>Button</ButtonBase>;
|
|
|
|
```
|