1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00
metamask-extension/ui/components/component-library/header-base
Garrett Bear 66292330fe
Feat/18890/button ts update (#20492)
* button to TS migration

working demo

style props

broken mapping - need switch

working types file

working types

fix dependent imports of Button

variant mapping

working types

fix lint

fix test

fix ButtonSize issue on QuizContent

box fix

test if this works

fix button being used on QuizContent

fix button_variant import

readme fix

* fix button import

* fix primary button as anchor hover

* deprecated

* button to TS migration

fix lint

fix test

* fix rebase issue

* fix rebase issue

* lint fix
2023-08-28 14:42:00 -07:00
..
__snapshots__ migration of HeaderBase to use TS Box version (#20250) 2023-08-01 17:36:55 -07:00
header-base.stories.tsx Feat/18890/button ts update (#20492) 2023-08-28 14:42:00 -07:00
header-base.test.tsx Migrating Icon to typescript and deprecating JS component (#18431) 2023-04-04 09:48:04 -07:00
header-base.tsx migration of HeaderBase to use TS Box version (#20250) 2023-08-01 17:36:55 -07:00
header-base.types.ts migration of HeaderBase to use TS Box version (#20250) 2023-08-01 17:36:55 -07:00
index.ts migration of HeaderBase to use TS Box version (#20250) 2023-08-01 17:36:55 -07:00
README.mdx Removing Box props description from TS component docs (#20451) 2023-08-16 10:34:08 -07:00

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

### This is a base component. It should not be used in your feature code directly but as a "base" for other UI components

# HeaderBase

The `HeaderBase` component is a reusable UI component for displaying a header with optional startAccessory, children (title) and endAccessory content areas. It is designed to be flexible and customizable for various use cases to keep a visually balanced appearance.

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

## Props

<ArgsTable of={HeaderBase} />

### Children

Wrapping content in the `HeaderBase` component will be rendered in the center of the header.

Use the `childrenWrapperProps` prop to customize the wrapper element around the `children` content.

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

```jsx
import { HeaderBase, Text } from '../../component-library';
import {
  TextAlign,
  TextVariant,
} from '../../../helpers/constants/design-system';

<HeaderBase>
  <Text variant={TextVariant.headingSm} textAlign={TextAlign.Center}>
    Title is sentence case no period
  </Text>
</HeaderBase>;
```

### startAccessory

Using the `startAccessory` prop will render the content in the start (left) side of the header.

Use the `startAccessoryWrapperProps` prop to customize the wrapper element around the `startAccessory` content.

<Canvas>
  <Story id="components-componentlibrary-headerbase--start-accessory" />
</Canvas>

```jsx
import {
  HeaderBase,
  Text,
  ButtonIcon,
  ButtonIconSize,
  IconName,
} from '../../component-library';
import {
  TextAlign,
  TextVariant,
} from '../../../helpers/constants/design-system';

<HeaderBase
  startAccessory={
    <ButtonIcon
      size={ButtonIconSize.Sm}
      iconName={IconName.ArrowLeft}
      ariaLabel="back"
    />
  }
>
  <Text variant={TextVariant.headingSm} textAlign={TextAlign.Center}>
    Title is sentence case no period
  </Text>
</HeaderBase>;
```

### endAccessory

Using the `endAccessory` prop will render the content in the end (right) side of the header.

Use the `endAccessoryWrapperProps` prop to customize the wrapper element around the `endAccessory` content.

<Canvas>
  <Story id="components-componentlibrary-headerbase--end-accessory" />
</Canvas>

```jsx
import {
  ButtonIcon,
  ButtonIconSize,
  HeaderBase,
  IconName,
  Text,
} from '../../component-library';
import {
  TextAlign,
  TextVariant,
} from '../../../helpers/constants/design-system';

<HeaderBase
  endAccessory={
    <ButtonIcon
      size={ButtonIconSize.Sm}
      iconName={IconName.Close}
      ariaLabel="close"
    />
  }
>
  <Text variant={TextVariant.headingSm} textAlign={TextAlign.Center}>
    Title is sentence case no period
  </Text>
</HeaderBase>;
```

### Use Case Demos

Some examples of how the `HeaderBase` component can be used in various use cases with background colors set for visual aid.

<Canvas>
  <Story id="components-componentlibrary-headerbase--use-case-demos" />
</Canvas>