Skip to content

Commit

Permalink
Merge pull request #6 from zimmerman-team/feat/add-input-component
Browse files Browse the repository at this point in the history
feat: add Input component
  • Loading branch information
okorie2 authored Sep 1, 2024
2 parents 9bc51b8 + 86c4298 commit 9e444e7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/buttons/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ButtonProps = {
radius: "rounded" | "sharp" | "circle";
};

export default function MyButton(props: ButtonProps) {
export default function MyButton(props: Readonly<ButtonProps>) {
const { filled, backgroundColor, size, label, onClick, icon, color, radius } =
props;
const radiusSize = {
Expand Down
1 change: 1 addition & 0 deletions src/components/input/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Input } from "./input";
31 changes: 31 additions & 0 deletions src/components/input/input.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Meta, StoryObj } from "@storybook/react";
import { fn, userEvent, within, expect } from "@storybook/test";
import Input from "./input";

const meta = {
title: "Example/Input",
component: Input,
parameters: {
layout: "centered",
},
tags: ["autodocs"],
argTypes: {
backgroundColor: { control: "color" },
},
args: { backgroundColor: "yellow" },
} satisfies Meta<typeof Input>;

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

export const Basic: Story = {
args: {
backgroundColor: "yellow",
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const user = userEvent.setup();
expect(canvas.getByRole("textbox")).toBeInTheDocument();
await user.type(canvas.getByRole("textbox"), "Hello, World!");
},
};
30 changes: 30 additions & 0 deletions src/components/input/input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @jsxImportSource @emotion/react */
import { css } from "@emotion/react";
import React from "react";

export default function Input({
backgroundColor,
}: {
backgroundColor: string;
}) {
return (
<div>
<input
type="text"
css={css`
display: flex;
width: 236px;
height: 32px;
padding: 4px 8px;
align-items: center;
align-content: center;
gap: 8px;
flex-wrap: wrap;
border-radius: 5px;
background: ${backgroundColor ?? "#ebebeb"};
border: none;
`}
/>
</div>
);
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./components/buttons";
export * from "./components/input";

0 comments on commit 9e444e7

Please sign in to comment.