Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/buttonbase ts update #20060

Merged
merged 16 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

203 changes: 0 additions & 203 deletions ui/components/component-library/button-base/button-base.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
user-select: none;

&--block {
display: block;
width: 100%;
}

Expand Down Expand Up @@ -45,6 +44,10 @@
}
}

a.mm-button-base:hover {
color: var(--color-text-default);
}



@keyframes spinner {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import {
AlignItems,
Color,
DISPLAY,
FLEX_DIRECTION,
Size,
BackgroundColor,
Display,
FlexDirection,
TextColor,
} from '../../../helpers/constants/design-system';
import Box from '../../ui/box/box';
import { TextDirection, IconName } from '..';

import { BUTTON_BASE_SIZES } from './button-base.constants';
import { Box, TextDirection, IconName } from '..';
import { ButtonBaseSize } from './button-base.types';
import { ButtonBase } from './button-base';
import README from './README.mdx';

Expand Down Expand Up @@ -70,7 +69,7 @@ export default {
},
size: {
control: 'select',
options: Object.values(BUTTON_BASE_SIZES),
options: Object.values(ButtonBaseSize),
},
marginTop: {
options: marginSizeControlOptions,
Expand All @@ -96,27 +95,29 @@ export default {
args: {
children: 'Button Base',
},
};
} as Meta<typeof ButtonBase>;

export const DefaultStory = (args) => <ButtonBase {...args} />;
export const DefaultStory: StoryFn<typeof ButtonBase> = (args) => (
<ButtonBase {...args} />
);

DefaultStory.storyName = 'Default';

export const SizeStory = (args) => (
export const SizeStory: StoryFn<typeof ButtonBase> = (args) => (
<>
<Box
display={DISPLAY.FLEX}
display={Display.Flex}
alignItems={AlignItems.baseline}
gap={1}
marginBottom={2}
>
<ButtonBase {...args} size={Size.SM}>
<ButtonBase {...args} size={ButtonBaseSize.Sm}>
Button SM
</ButtonBase>
<ButtonBase {...args} size={Size.MD}>
<ButtonBase {...args} size={ButtonBaseSize.Md}>
Button MD
</ButtonBase>
<ButtonBase {...args} size={Size.LG}>
<ButtonBase {...args} size={ButtonBaseSize.Lg}>
Button LG
</ButtonBase>
</Box>
Expand All @@ -125,7 +126,7 @@ export const SizeStory = (args) => (

SizeStory.storyName = 'Size';

export const Block = (args) => (
export const Block: StoryFn<typeof ButtonBase> = (args) => (
<>
<ButtonBase {...args} marginBottom={2}>
Default Button
Expand All @@ -136,22 +137,24 @@ export const Block = (args) => (
</>
);

export const As = (args) => (
<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.ROW} gap={2}>
export const As: StoryFn<typeof ButtonBase> = (args) => (
<Box display={Display.Flex} flexDirection={FlexDirection.Row} gap={2}>
<ButtonBase {...args}>Button Element</ButtonBase>
<ButtonBase as="a" href="#" {...args}>
Anchor Element
</ButtonBase>
</Box>
);

export const Href = (args) => <ButtonBase {...args}>Anchor Element</ButtonBase>;
export const Href: StoryFn<typeof ButtonBase> = (args) => (
<ButtonBase {...args}>Anchor Element</ButtonBase>
);

Href.args = {
href: '/metamask',
};

export const ExternalLink = (args) => (
export const ExternalLink: StoryFn<typeof ButtonBase> = (args) => (
<ButtonBase {...args}>Anchor element with external link</ButtonBase>
);

Expand All @@ -160,36 +163,36 @@ ExternalLink.args = {
externalLink: true,
};

export const Disabled = (args) => (
export const Disabled: StoryFn<typeof ButtonBase> = (args) => (
<ButtonBase {...args}>Disabled Button</ButtonBase>
);

Disabled.args = {
disabled: true,
};

export const Loading = (args) => (
export const Loading: StoryFn<typeof ButtonBase> = (args) => (
<ButtonBase {...args}>Loading Button</ButtonBase>
);

Loading.args = {
loading: true,
};

export const StartIconName = (args) => (
export const StartIconName: StoryFn<typeof ButtonBase> = (args) => (
<ButtonBase {...args} startIconName={IconName.AddSquare}>
Button
</ButtonBase>
);

export const EndIconName = (args) => (
export const EndIconName: StoryFn<typeof ButtonBase> = (args) => (
<ButtonBase {...args} endIconName={IconName.Arrow2Right}>
Button
</ButtonBase>
);

export const Rtl = (args) => (
<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.COLUMN} gap={2}>
export const Rtl: StoryFn<typeof ButtonBase> = (args) => (
<Box display={Display.Flex} flexDirection={FlexDirection.Column} gap={2}>
<ButtonBase
{...args}
startIconName={IconName.AddSquare}
Expand All @@ -208,10 +211,14 @@ export const Rtl = (args) => (
</Box>
);

export const Ellipsis = (args) => (
<Box backgroundColor={Color.iconMuted} style={{ width: 150 }}>
export const Ellipsis: StoryFn<typeof ButtonBase> = (args) => (
<Box backgroundColor={BackgroundColor.primaryMuted} style={{ width: 150 }}>
<ButtonBase {...args}>Example without ellipsis</ButtonBase>
<ButtonBase {...args} ellipsis>
<ButtonBase
{...args}
ellipsis
textProps={{ color: TextColor.errorDefault }}
>
Example with ellipsis
</ButtonBase>
</Box>
Expand Down
Loading
Loading