Skip to content

Commit

Permalink
sparkle very basic input
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanierh committed Sep 7, 2023
1 parent 8878dd0 commit 1a562f8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sparkle/src/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export { Avatar };
import Spinner from "./components/Spinner";
export { Spinner };

import Input from "./components/Input";
export { Input };

import {
LogoHorizontalColor as LogoHorizontalColorLogo,
LogoHorizontalDark as LogoHorizontalDarkLogo,
Expand Down
38 changes: 38 additions & 0 deletions sparkle/src/components/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React, { HTMLInputTypeAttribute, InputHTMLAttributes } from "react";

export interface InputProps {
disabled?: boolean;
type: HTMLInputTypeAttribute;
name?: string;
id?: string;
className?: string;
value?: InputHTMLAttributes<HTMLInputElement>["value"];
placeholder?: string;
onChange?: InputHTMLAttributes<HTMLInputElement>["onChange"];
}

const Input: React.FC<InputProps> = ({
disabled,
type,
name,
id,
className,
value,
placeholder,
onChange,
}) => {
return (
<input
disabled={disabled}
type={type}
name={name}
id={id}
className={className}
value={value}
placeholder={placeholder}
onChange={onChange}
/>
);
};

export default Input;
29 changes: 29 additions & 0 deletions sparkle/src/stories/Input.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { Meta, StoryObj } from "@storybook/react";
import React from "react";

import { Input } from "../index_with_tw_base";

const meta = {
title: "Atoms/Input",
component: Input,
} satisfies Meta<typeof Input>;

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

export const InputExample = () => (
<div>
<Input
type="text"
placeholder="Enter your name"
className="border border-gray-300 rounded-md p-2"
/>
</div>
);

export const ItemDefault: Story = {
args: {
type: "text",
placeholder: "Enter your name",
},
};

0 comments on commit 1a562f8

Please sign in to comment.