1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/ui/components/component-library/header-base/header-base.stories.tsx
Garrett Bear ed5b78d61b
Feat/add header base component (#18043)
* add header base component

* fix resizing issue

* add center

* add demo

* header base using flexbox

* fix button issue

* header base clean up

* update tests

* add readme description

* add docs

* update snapshot

* add more to readme

* convert to TS

* fix file name

* fix types and colors

* fix classname error

* fix boxprops import

* fix boxprops

* prop fix

* fix errors

* Update ui/components/component-library/header-base/header-base.stories.tsx

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/component-library/header-base/header-base.types.ts

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/component-library/header-base/header-base.types.ts

Co-authored-by: George Marshall <george.marshall@consensys.net>

* headerbase fixes

* fix export

* remove Math.max

* change order for index on storybook to prep build

* revert back to order

* remove type from export

* add type to export

* change export of headerbase function

* export update

* revert back to normal

* add type to export

* Removing interface export from index

---------

Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-03-23 08:24:23 -07:00

294 lines
7.6 KiB
TypeScript

import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import Box from '../../ui/box';
import {
ICON_NAMES,
Button,
ButtonIcon,
BUTTON_ICON_SIZES,
BUTTON_SIZES,
Text,
} from '..';
import {
AlignItems,
BackgroundColor,
TextVariant,
TEXT_ALIGN,
} from '../../../helpers/constants/design-system';
import { HeaderBase } from './header-base';
import README from './README.mdx';
export default {
title: 'Components/ComponentLibrary/HeaderBase',
component: HeaderBase,
parameters: {
docs: {
page: README,
},
},
} as ComponentMeta<typeof HeaderBase>;
const Template: ComponentStory<typeof HeaderBase> = (args) => (
<HeaderBase {...args} />
);
export const DefaultStory = Template.bind({});
DefaultStory.args = {
children: (
<Text variant={TextVariant.headingSm} textAlign={TEXT_ALIGN.CENTER}>
Title is sentence case no period
</Text>
),
startAccessory: (
<ButtonIcon
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.ARROW_LEFT}
ariaLabel="back"
/>
),
endAccessory: (
<ButtonIcon
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.CLOSE}
ariaLabel="close"
/>
),
};
DefaultStory.storyName = 'Default';
export const Children = (args) => {
return (
<HeaderBase {...args}>
<Text variant={TextVariant.headingSm} textAlign={TEXT_ALIGN.CENTER}>
Title is sentence case no period
</Text>
</HeaderBase>
);
};
export const StartAccessory = (args) => {
return (
<HeaderBase
marginBottom={4}
startAccessory={
<ButtonIcon
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.ARROW_LEFT}
ariaLabel="back"
/>
}
{...args}
>
<Text variant={TextVariant.headingSm} textAlign={TEXT_ALIGN.CENTER}>
Title is sentence case no period
</Text>
</HeaderBase>
);
};
export const EndAccessory = (args) => {
return (
<HeaderBase
marginBottom={4}
endAccessory={
<ButtonIcon
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.CLOSE}
ariaLabel="close"
/>
}
{...args}
>
<Text variant={TextVariant.headingSm} textAlign={TEXT_ALIGN.CENTER}>
Title is sentence case no period
</Text>
</HeaderBase>
);
};
export const UseCaseDemos = (args) => (
<>
<Text>children only assigned</Text>
<Box backgroundColor={BackgroundColor.warningAlternative}>
<HeaderBase marginBottom={4} {...args}>
<Text
variant={TextVariant.headingSm}
textAlign={TEXT_ALIGN.CENTER}
backgroundColor={BackgroundColor.primaryAlternative}
>
Title is sentence case no period
</Text>
</HeaderBase>
</Box>
<Text>children and endAccessory assigned </Text>
<Box backgroundColor={BackgroundColor.warningAlternative}>
<HeaderBase
marginBottom={4}
endAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.goerli}
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.CLOSE}
ariaLabel="close"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TEXT_ALIGN.CENTER}
backgroundColor={BackgroundColor.primaryAlternative}
>
Title is sentence case no period
</Text>
</HeaderBase>
</Box>
<Text>children and startAccessory assigned </Text>
<Box backgroundColor={BackgroundColor.warningAlternative}>
<HeaderBase
marginBottom={4}
startAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.successAlternative}
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.ARROW_LEFT}
ariaLabel="back"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TEXT_ALIGN.CENTER}
backgroundColor={BackgroundColor.primaryAlternative}
>
Title is sentence case no period
</Text>
</HeaderBase>
</Box>
<Text>children, startAccessory, and endAccessory assigned </Text>
<Box backgroundColor={BackgroundColor.warningAlternative}>
<HeaderBase
marginBottom={4}
startAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.successAlternative}
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.ARROW_LEFT}
ariaLabel="back"
/>
}
endAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.goerli}
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.CLOSE}
ariaLabel="close"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TEXT_ALIGN.CENTER}
backgroundColor={BackgroundColor.primaryAlternative}
>
Title is sentence case no period
</Text>
</HeaderBase>
</Box>
<Text>children, startAccessory, and endAccessory assigned </Text>
<Box backgroundColor={BackgroundColor.warningAlternative}>
<HeaderBase
marginBottom={4}
startAccessory={
<Button
backgroundColor={BackgroundColor.successAlternative}
style={{ whiteSpace: 'nowrap' }}
size={BUTTON_SIZES.SM}
>
Unlock Now
</Button>
}
endAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.goerli}
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.CLOSE}
ariaLabel="close"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TEXT_ALIGN.CENTER}
backgroundColor={BackgroundColor.primaryAlternative}
>
Title is sentence case no period
</Text>
</HeaderBase>
</Box>
<Text>
children, startAccessory, and endAccessory assigned with prop alignItems=
{AlignItems.center} passed at HeaderBase
</Text>
<Box backgroundColor={BackgroundColor.warningAlternative}>
<HeaderBase
marginBottom={4}
alignItems={AlignItems.center}
startAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.successAlternative}
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.CLOSE}
ariaLabel="close"
/>
}
endAccessory={
<Button
backgroundColor={BackgroundColor.goerli}
size={BUTTON_SIZES.SM}
>
Download
</Button>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TEXT_ALIGN.CENTER}
backgroundColor={BackgroundColor.primaryAlternative}
>
Title is sentence case no period
</Text>
</HeaderBase>
</Box>
<Text>startAccessory and endAccessory assigned </Text>
<Box backgroundColor={BackgroundColor.warningAlternative}>
<HeaderBase
marginBottom={4}
startAccessory={
<Button
backgroundColor={BackgroundColor.successAlternative}
size={BUTTON_SIZES.SM}
>
Unlock
</Button>
}
endAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.goerli}
size={BUTTON_ICON_SIZES.SM}
iconName={ICON_NAMES.CLOSE}
ariaLabel="close"
/>
}
{...args}
></HeaderBase>
</Box>
</>
);