mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
c92d7380df
* Converted file extension from .js to .tsx * Updated README docs to match the enums. Resolved type errors * Updated AvatarBaseSizes enum values to string literals * Added TEXT_TRANSFORM.UPPERCASE as default value of textTransform in base file * lint fix * Solved liniting errors in avatar-base * Made enum more consistent, added desc for AvatarBaseProps * Updated snapshots of AvatarBase and exported AvatarBaseProps in index.ts * Made textTransform property accept right values in avatar-base.tsx * Adding temporary changed extensions * Reverted files back to tsx and resolved conflicts * Solved linting errors * AvatarBaseProps now extends TextProps * Changing extension to resolve conflict * Reverted extensions back to tsx after resolving conflicts * Added forwardRef in AvatarBase * Updated import name of AvatarBaseSize in README.mdx. Removed empty children attribute from AvatarBase storybook file --------- Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com>
154 lines
3.6 KiB
TypeScript
154 lines
3.6 KiB
TypeScript
import { ComponentMeta } from '@storybook/react';
|
|
import React from 'react';
|
|
import {
|
|
AlignItems,
|
|
DISPLAY,
|
|
TextColor,
|
|
BackgroundColor,
|
|
BorderColor,
|
|
IconColor,
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import Box from '../../ui/box/box';
|
|
|
|
import { Icon, IconName } from '..';
|
|
import README from './README.mdx';
|
|
import { AvatarBase } from './avatar-base';
|
|
import { AvatarBaseProps, AvatarBaseSize } from './avatar-base.types';
|
|
|
|
const marginSizeKnobOptions = [
|
|
0,
|
|
1,
|
|
2,
|
|
3,
|
|
4,
|
|
5,
|
|
6,
|
|
7,
|
|
8,
|
|
9,
|
|
10,
|
|
11,
|
|
12,
|
|
'auto',
|
|
];
|
|
|
|
export default {
|
|
title: 'Components/ComponentLibrary/AvatarBase',
|
|
|
|
component: AvatarBase,
|
|
parameters: {
|
|
docs: {
|
|
page: README,
|
|
},
|
|
},
|
|
argTypes: {
|
|
size: {
|
|
control: 'select',
|
|
options: Object.values(AvatarBaseSize),
|
|
},
|
|
color: {
|
|
options: Object.values(TextColor),
|
|
control: 'select',
|
|
},
|
|
backgroundColor: {
|
|
options: Object.values(BackgroundColor),
|
|
control: 'select',
|
|
},
|
|
borderColor: {
|
|
options: Object.values(BorderColor),
|
|
control: 'select',
|
|
},
|
|
display: {
|
|
options: Object.values(DISPLAY),
|
|
control: 'select',
|
|
table: { category: 'box props' },
|
|
},
|
|
marginTop: {
|
|
options: marginSizeKnobOptions,
|
|
control: 'select',
|
|
table: { category: 'box props' },
|
|
},
|
|
marginRight: {
|
|
options: marginSizeKnobOptions,
|
|
control: 'select',
|
|
table: { category: 'box props' },
|
|
},
|
|
marginBottom: {
|
|
options: marginSizeKnobOptions,
|
|
control: 'select',
|
|
table: { category: 'box props' },
|
|
},
|
|
marginLeft: {
|
|
options: marginSizeKnobOptions,
|
|
control: 'select',
|
|
table: { category: 'box props' },
|
|
},
|
|
},
|
|
args: {
|
|
size: AvatarBaseSize.Md,
|
|
color: TextColor.textDefault,
|
|
backgroundColor: BackgroundColor.backgroundAlternative,
|
|
borderColor: BorderColor.borderDefault,
|
|
children: 'B',
|
|
},
|
|
} as ComponentMeta<typeof AvatarBase>;
|
|
|
|
export const DefaultStory = (args: AvatarBaseProps) => <AvatarBase {...args} />;
|
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
export const Size = (args: AvatarBaseProps) => (
|
|
<Box display={DISPLAY.FLEX} alignItems={AlignItems.baseline} gap={1}>
|
|
<AvatarBase {...args} size={AvatarBaseSize.Xs} />
|
|
<AvatarBase {...args} size={AvatarBaseSize.Sm} />
|
|
<AvatarBase {...args} size={AvatarBaseSize.Md} />
|
|
<AvatarBase {...args} size={AvatarBaseSize.Lg} />
|
|
<AvatarBase {...args} size={AvatarBaseSize.Xl} />
|
|
</Box>
|
|
);
|
|
|
|
export const Children = (args: AvatarBaseProps) => (
|
|
<Box display={DISPLAY.FLEX} gap={1}>
|
|
<AvatarBase {...args}>
|
|
<img src="./images/eth_logo.png" />
|
|
</AvatarBase>
|
|
<AvatarBase {...args}>
|
|
<img width="100%" src="./images/arbitrum.svg" />
|
|
</AvatarBase>
|
|
<AvatarBase {...args}>
|
|
<img width="100%" src="./images/avax-token.png" />
|
|
</AvatarBase>
|
|
<AvatarBase {...args}>A</AvatarBase>
|
|
<AvatarBase
|
|
{...args}
|
|
backgroundColor={BackgroundColor.infoMuted}
|
|
borderColor={BorderColor.infoMuted}
|
|
>
|
|
<Icon name={IconName.User} color={IconColor.infoDefault} />
|
|
</AvatarBase>
|
|
</Box>
|
|
);
|
|
|
|
export const ColorBackgroundColorAndBorderColor = (args: AvatarBaseProps) => (
|
|
<Box display={DISPLAY.FLEX} gap={1}>
|
|
<AvatarBase {...args}>B</AvatarBase>
|
|
<AvatarBase
|
|
{...args}
|
|
backgroundColor={BackgroundColor.goerli}
|
|
borderColor={BorderColor.goerli}
|
|
color={TextColor.primaryInverse}
|
|
>
|
|
G
|
|
</AvatarBase>
|
|
<AvatarBase
|
|
{...args}
|
|
backgroundColor={BackgroundColor.sepolia}
|
|
borderColor={BorderColor.sepolia}
|
|
color={TextColor.primaryInverse}
|
|
>
|
|
S
|
|
</AvatarBase>
|
|
</Box>
|
|
);
|