1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/ui/components/component-library/header-base
Garrett Bear 4e1a96b4ef
Feat/18308/ds popover header component (#18489)
* add popover component

popperjs init

popperjs hook init

popper arrow styles

fix popover story

add popover positions constant

story testing

popover structure

popper placement

make forwardref

fix popover with TS updates

modifiers

createPortal

add useClickAway hook

newer popover component build

simplifed popperjs with toggle to show/hide

toggle popover

modal version

popover progress 65%

add hover functionality

hide folder

storybook demo

add close button props

working popover with arrow

title prop breaking

popover TS conversion

TS updates

update test

add test

add arrow test

add stories

remove unused hook

fix docs

add popoverheader

types fix

Fix typo: detetcted-tokens-link -> detected-tokens-link (#18408)

Typography to text (#18382)

* Typography to text

* Update README.md

* Update README.md

* minor changes in custom file

* minor change

* Resolved Conflict issues

---------

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>

fix: Pass correct optimism chain id to gas estimation (#18478)

removes unnecessary images (#18484)

Fix firsttimeloaded logic (#18344)

* use session storage, instead of chrome.runtime.onStartup and globalThis, for firstTimeLoaded architecture

* Ensure account tracker accounts remain defined upon service worker restart

* lint fix

* Simplify code

* Only call browser.storage.session in mv3

* Only call browser.storage.session.set after resetStates in mv3

* fix metamask controller reset states unit tests

* fix test

* fix test

* Actually fix tests

* lint fix

[FLASK] More Snaps E2E Optimization and Delay Reductions (#18245)

* bip32 delay reduction

* asserts changed to waitFors in 32/44

* scrollTo change

* replaced delay for firefox flake

* more reduced delays

* more delay reductions and changes

* raise paralellism to 4 for snaps tests

* additional delay changes

* fixed update code

* removed comment

* removed another comment

Fix switch-ethereum-chain handler by passing configuration id to setA… (#18483)

* Fix switch-ethereum-chain handler by passing configuration id to setActiveNetwork

* fix e2e test

* Fix e2e tests

* Update test/e2e/tests/switch-custom-network.spec.js

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>

* Revert "Update test/e2e/tests/switch-custom-network.spec.js"

This reverts commit be533ff7f25e1fd42e951d9b817b8438035ae256.

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>

Bumping notification id's to 18 & 19 (#18460)

* Popover header update with TS ButtonIcon

* update PopoverHeader types

* update using new Text enums

* readme fix

* direct file import

* remove forwardRef and add action argtypes

* remove console.logs

* add arg types and fix TS on HeaderBase

* george nits

* popover header snapshot update

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2023-04-19 10:36:01 -07:00
..
__snapshots__
header-base.stories.tsx Feat/18308/ds popover header component (#18489) 2023-04-19 10:36:01 -07:00
header-base.test.tsx
header-base.tsx
header-base.types.ts
index.ts
README.mdx update ButtonIcon to TS (#18448) 2023-04-12 08:55:24 -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

The `HeaderBase` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component 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 {
  TEXT_ALIGN,
  TextVariant,
} from '../../../helpers/constants/design-system';

<HeaderBase>
  <Text variant={TextVariant.headingSm} textAlign={TEXT_ALIGN.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 {
  TEXT_ALIGN,
  TextVariant,
} from '../../../helpers/constants/design-system';

<HeaderBase
  startAccessory={
    <ButtonIcon
      size={ButtonIconSize.Sm}
      iconName={IconName.ArrowLeft}
      ariaLabel="back"
    />
  }
>
  <Text variant={TextVariant.headingSm} textAlign={TEXT_ALIGN.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 {
  TEXT_ALIGN,
  TextVariant,
} from '../../../helpers/constants/design-system';

<HeaderBase
  endAccessory={
    <ButtonIcon
      size={ButtonIconSize.Sm}
      iconName={IconName.Close}
      ariaLabel="close"
    />
  }
>
  <Text variant={TextVariant.headingSm} textAlign={TEXT_ALIGN.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>