Skip to content

Commit

Permalink
feat: update button props
Browse files Browse the repository at this point in the history
  • Loading branch information
okorie2 committed Aug 29, 2024
1 parent 75a8705 commit b91d896
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 1 addition & 8 deletions src/components/buttons/button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@ import type { Meta, StoryObj } from "@storybook/react";
import { fn, userEvent, within, expect } from "@storybook/test";
import Button from "./button";

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
title: "Example/Button",
component: Button,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: "centered",
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ["autodocs"],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
argTypes: {
backgroundColor: { control: "color" },
},
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
args: { onClick: fn() },
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Filled: Story = {
args: {
filled: true,
Expand All @@ -37,7 +31,6 @@ export const Filled: Story = {
const canvas = within(canvasElement);
const user = userEvent.setup();
expect(canvas.getByRole("button")).toBeInTheDocument();
// await user.click(canvas.getByRole("button"));
// expect(meta.args.onClick).toHaveBeenCalled();
await user.click(canvas.getByRole("button"));
},
};
14 changes: 13 additions & 1 deletion src/components/buttons/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export default function Button(props: ButtonProps) {
sharp: "5px",
circle: "50%",
};
const buttonWidth = {
small: "100px",
medium: "200px",
large: "300px",
};
const buttonHeight = {
small: "30px",
medium: "40px",
large: "50px",
};
return (
<button
css={css`
Expand All @@ -40,8 +50,10 @@ export default function Button(props: ButtonProps) {
justify-content: center;
flex-direction: ${icon?.position === "left" ? "row" : "row-reverse"};
cursor: pointer;
color: ${color};
color: ${filled ? color : backgroundColor};
gap: 5px;
width: ${buttonWidth[size!]};
height: ${buttonHeight[size!]};
&:hover {
color: ${color};
}
Expand Down

0 comments on commit b91d896

Please sign in to comment.