1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/ui/components/component-library/label
Nidhi Kumari c5368c152b
Added storybook check to CI (#17092)
* 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
2023-01-21 00:57:46 +05:30
..
__snapshots__
index.js
label.js
label.scss
label.stories.js Added storybook check to CI (#17092) 2023-01-21 00:57:46 +05:30
label.test.js
README.mdx Added storybook check to CI (#17092) 2023-01-21 00:57:46 +05:30

import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';

import { Text } from '..';

import { Label } from './label';

# Label

The `Label` is a component used to label form inputs

<Canvas>
  <Story id="components-componentlibrary-label--default-story" />
</Canvas>

## Props

The `Label` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props

<ArgsTable of={Label} />

`Label` accepts all [Text](/docs/components-componentlibrary-text--default-story#props) component props

<ArgsTable of={Text} />

### Children

The `children` of the label can be text or a react node

<Canvas>
  <Story id="components-componentlibrary-label--children" />
</Canvas>

```jsx
import { DISPLAY, ALIGN_ITEMS, FLEX_DIRECTION, SIZES, COLORS } from '../../../helpers/constants/design-system';
import { Label, TextField, Icon, ICON_NAMES } from '../../component-library';

<Label>Plain text</Label>
<Label display={DISPLAY.FLEX} alignItems={ALIGN_ITEMS.FLEX_START}>
  Text and icon
  <Icon
    color={COLORS.ICON_ALTERNATIVE}
    name={ICON_NAMES.INFO_FILLED}
    size={SIZES.AUTO}
  />
</Label>
<Label
  display={DISPLAY.INLINE_FLEX}
  flexDirection={FLEX_DIRECTION.COLUMN}
  alignItems={ALIGN_ITEMS.FLEX_START}
>
  Label that wraps an input
  <TextField placeholder="Click label to focus" />
</Label>
```

### Html For

Use the `htmlFor` prop to allow the `Label` to focus on an input with the same id when clicked. The cursor will also change to a `pointer` when the `htmlFor` has a value.

<Canvas>
  <Story id="components-componentlibrary-label--html-for" />
</Canvas>

```jsx
import { Label, TextFieldBase } from '../../component-library';

<Label htmlFor="add-network">Add network</Label>
<TextField id="add-network" placeholder="Enter network name" />
```

### Required

Use the `required` prop to add a required red asterisk next to the `children` of the `Label`. Note the required asterisk will always render after the `children`.

<Canvas>
  <Story id="components-componentlibrary-label--required" />
</Canvas>

```jsx
import { Label } from '../../component-library';

<Label required>Label</Label>;
```

### Disabled

Use the `disabled` prop to set the `Label` in disabled state

<Canvas>
  <Story id="components-componentlibrary-label--disabled" />
</Canvas>

```jsx
import { Label } from '../../component-library';

<Label disabled>Label</Label>;
```