1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/component-library/header-base/header-base.stories.tsx
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

290 lines
7.4 KiB
TypeScript

import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import {
IconName,
Button,
ButtonSize,
ButtonIcon,
ButtonIconSize,
Text,
Box,
} from '..';
import {
AlignItems,
BackgroundColor,
TextVariant,
TextAlign,
} 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 Meta<typeof HeaderBase>;
const Template: StoryFn<typeof HeaderBase> = (args) => <HeaderBase {...args} />;
export const DefaultStory = Template.bind({});
DefaultStory.args = {
children: (
<Text variant={TextVariant.headingSm} textAlign={TextAlign.Center}>
Title is sentence case no period
</Text>
),
startAccessory: (
<ButtonIcon
size={ButtonIconSize.Sm}
iconName={IconName.ArrowLeft}
ariaLabel="back"
/>
),
endAccessory: (
<ButtonIcon
size={ButtonIconSize.Sm}
iconName={IconName.Close}
ariaLabel="close"
/>
),
};
DefaultStory.storyName = 'Default';
export const Children = (args) => {
return (
<HeaderBase {...args}>
<Text variant={TextVariant.headingSm} textAlign={TextAlign.Center}>
Title is sentence case no period
</Text>
</HeaderBase>
);
};
export const StartAccessory = (args) => {
return (
<HeaderBase
marginBottom={4}
startAccessory={
<ButtonIcon
size={ButtonIconSize.Sm}
iconName={IconName.ArrowLeft}
ariaLabel="back"
/>
}
{...args}
>
<Text variant={TextVariant.headingSm} textAlign={TextAlign.Center}>
Title is sentence case no period
</Text>
</HeaderBase>
);
};
export const EndAccessory = (args) => {
return (
<HeaderBase
marginBottom={4}
endAccessory={
<ButtonIcon
size={ButtonIconSize.Sm}
iconName={IconName.Close}
ariaLabel="close"
/>
}
{...args}
>
<Text variant={TextVariant.headingSm} textAlign={TextAlign.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={TextAlign.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={ButtonIconSize.Sm}
iconName={IconName.Close}
ariaLabel="close"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TextAlign.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={ButtonIconSize.Sm}
iconName={IconName.ArrowLeft}
ariaLabel="back"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TextAlign.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={ButtonIconSize.Sm}
iconName={IconName.ArrowLeft}
ariaLabel="back"
/>
}
endAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.goerli}
size={ButtonIconSize.Sm}
iconName={IconName.Close}
ariaLabel="close"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TextAlign.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={ButtonSize.Sm}
>
Unlock Now
</Button>
}
endAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.goerli}
size={ButtonIconSize.Sm}
iconName={IconName.Close}
ariaLabel="close"
/>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TextAlign.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={ButtonIconSize.Sm}
iconName={IconName.Close}
ariaLabel="close"
/>
}
endAccessory={
<Button backgroundColor={BackgroundColor.goerli} size={ButtonSize.Sm}>
Download
</Button>
}
{...args}
>
<Text
variant={TextVariant.headingSm}
textAlign={TextAlign.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={ButtonSize.Sm}
>
Unlock
</Button>
}
endAccessory={
<ButtonIcon
backgroundColor={BackgroundColor.goerli}
size={ButtonIconSize.Sm}
iconName={IconName.Close}
ariaLabel="close"
/>
}
{...args}
></HeaderBase>
</Box>
</>
);