diff --git a/src/components/Button/Button.stories.tsx b/src/components/Button/Button.stories.tsx index 641f408c..848e825d 100644 --- a/src/components/Button/Button.stories.tsx +++ b/src/components/Button/Button.stories.tsx @@ -20,6 +20,11 @@ import { Meta, StoryFn } from "@storybook/react"; import { Button as ButtonComponent } from "./Button"; import VisibilityOnIcon from "@vector-im/compound-design-tokens/icons/visibility-on.svg"; +type Props = { + kind?: "primary" | "secondary" | "tertiary" | "destructive"; + size?: "sm" | "lg"; +}; + export default { title: "Button", component: ButtonComponent, @@ -29,13 +34,20 @@ export default { control: { type: "inline-radio" }, }, }, - args: {}, + args: { + size: "sm", + }, } as Meta; -const Template: StoryFn = (args) => ( +const Template: StoryFn = ({ kind, size }: Props) => (
- Click me! - + + Click me! + + + Click me! + + Click me!
diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 0cf84cd4..06359673 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -15,15 +15,25 @@ limitations under the License. */ import classNames from "classnames"; -import React, { ComponentType, PropsWithChildren } from "react"; +import React, { + ComponentType, + PropsWithChildren, + forwardRef, + ForwardedRef, + Ref, +} from "react"; import styles from "./Button.module.css"; -type ButtonProps = { - /** - * The underlying HTML element to use. Can be a button or a link. - * @default "button" - */ - as?: C; +interface ButtonComponent { + // With the explicit `as` prop + ( + props: { as: C } & ButtonPropsFor, + ): React.ReactElement; + // Without the explicit `as` prop, defaulting to a