Skip to content

Commit

Permalink
Merge pull request #12 from MARU-EGG/atom-component-refactor
Browse files Browse the repository at this point in the history
[USER]: Feat Text-input component
  • Loading branch information
swgvenghy authored Jul 24, 2024
2 parents 0633589 + 9f1d0c1 commit ef07043
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ui/components/atom/icon/icon-button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { Meta, StoryObj } from '@storybook/react';
import IconButton from './icon-button';
import { ReactComponent as MenuIcon } from '../../../../../public/Menu.svg';
import { ReactComponent as SendIcon } from '../../../../../public/Send.svg';
import { ReactComponent as XIcon } from '../../../../../public/X.svg';
import { ReactComponent as RefreshIcon } from '../../../../../public/Refresh.svg';
import { ReactComponent as MenuIcon } from '../../../../assets/Menu.svg';
import { ReactComponent as SendIcon } from '../../../../assets/Send.svg';
import { ReactComponent as XIcon } from '../../../../assets/X.svg';
import { ReactComponent as RefreshIcon } from '../../../../assets/Refresh.svg';

const meta = {
title: 'Example/IconButton',
Expand Down
36 changes: 36 additions & 0 deletions src/ui/components/atom/text-input/text-input.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Meta, StoryObj } from '@storybook/react';
import TextArea from './text-input';

const meta = {
title: 'Example/TextArea',
component: TextArea,
tags: ['autodocs'],
parameters: {
layout: 'centered',
},
args: {
onValueChange: (value: string) => console.log(value),
},
} satisfies Meta<typeof TextArea>;

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

export const Default: Story = {
args: {
placeholder: 'Enter text here...',
},
};

export const Disabled: Story = {
args: {
placeholder: 'Enter text here...',
disabled: true,
},
};

export const WithValue: Story = {
args: {
value: '마루에그에게 물어보고싶어요',
},
};
30 changes: 30 additions & 0 deletions src/ui/components/atom/text-input/text-input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { cn } from '../../../../utils/style';

export interface TextInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
value?: string;
onValueChange?: (value: string) => void;
disabled?: boolean;
defaultValue?: string;
}

const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(function TextArea(
{ disabled = false, placeholder, onValueChange, defaultValue, value },
ref,
) {
return (
<input
ref={ref}
type="text"
className={cn(`w-full rounded-2xl bg-transparent px-5 py-2 text-body3`, `placeholder:text-[#72777A]`)}
value={value}
placeholder={placeholder}
disabled={disabled}
onChange={(e) => {
onValueChange?.(e.target.value);
}}
/>
);
});

export default TextInput;

0 comments on commit ef07043

Please sign in to comment.