diff --git a/code/ui/components/src/new/Button/Button.stories.tsx b/code/ui/components/src/new/Button/Button.stories.tsx
index 443d62d53839..e318d2e26bac 100644
--- a/code/ui/components/src/new/Button/Button.stories.tsx
+++ b/code/ui/components/src/new/Button/Button.stories.tsx
@@ -65,15 +65,11 @@ export const Sizes: Story = {
}>
Small Button
- } iconOnly>
- Small Button
-
+ } iconOnly />
}>
Medium Button
- } iconOnly>
- Medium Button
-
+ } iconOnly />
),
};
@@ -91,24 +87,12 @@ export const IconOnly: Story = {
},
render: () => (
<>
- }>
- Primary
-
- }>
- Secondary
-
- }>
- Tertiary
-
- }>
- Primary
-
- }>
- Secondary
-
- }>
- Tertiary
-
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
>
),
decorators: [
@@ -119,24 +103,12 @@ export const IconOnly: Story = {
export const IconOnlyActive: Story = {
render: () => (
- } active>
- Primary
-
- } active>
- Secondary
-
- } active>
- Tertiary
-
- } active>
- Primary
-
- } active>
- Secondary
-
- } active>
- Tertiary
-
+ } active />
+ } active />
+ } active />
+ } active />
+ } active />
+ } active />
),
};
diff --git a/code/ui/components/src/new/Button/Button.tsx b/code/ui/components/src/new/Button/Button.tsx
index a769bdf079e2..204d99180652 100644
--- a/code/ui/components/src/new/Button/Button.tsx
+++ b/code/ui/components/src/new/Button/Button.tsx
@@ -4,18 +4,30 @@ import { styled } from '@storybook/theming';
import { darken, lighten, rgba, transparentize } from 'polished';
import type { PropsOf } from '../utils/types';
-export interface ButtonProps {
+interface CommonProps {
as?: T;
- children: string;
size?: 'small' | 'medium';
variant?: 'primary' | 'secondary' | 'tertiary';
- icon?: ReactNode;
- iconOnly?: boolean;
onClick?: () => void;
disabled?: boolean;
active?: boolean;
}
+type ButtonIconOnlyProps = {
+ iconOnly: true;
+ icon: ReactNode;
+ children?: never;
+};
+
+type ButtonWithTextProps = {
+ iconOnly?: false;
+ icon?: ReactNode;
+ children: string;
+};
+
+type ButtonProps = CommonProps &
+ (ButtonIconOnlyProps | ButtonWithTextProps);
+
export const Button: {
(
props: ButtonProps & Omit, keyof ButtonProps>