Skip to content

Commit

Permalink
[Feat/#37] Input 컴포넌트 구현 (#38)
Browse files Browse the repository at this point in the history
* feat: input 컴포넌트 구현

* feat: input 컴포넌트 스토리북 구현

* chore: git merge develop 후 후순위 이슈로 잠정적 중단

* chore: pr fail 해결

* feat: input 컴포넌트 80% 완성

* input 컴포넌트 완성

* App.tsx 파일 최신화

* chore: 코드리뷰 반영

* feat: input 완성

* chore: base 폰트 추가

* chore: 트렌지션 수정
  • Loading branch information
zzz-myam authored Jan 17, 2025
1 parent 391415c commit 6335715
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 9 deletions.
6 changes: 0 additions & 6 deletions public/svg/ic_arrow_right_24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/svg/ic_form_dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/svg/ic_form_dotdot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { useState } from 'react';
import { createBrowserRouter, RouterProvider } from 'react-router-dom';

import { Input } from '@components';
import { ToastProvider } from '@contexts';
import { pageRoutes } from '@routes';

Expand All @@ -12,10 +14,22 @@ import '@styles/global.css';
const router = createBrowserRouter(pageRoutes);

const App = () => {
const [inputValue, setInputValue] = useState('');

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value);
};

return (
<QueryClientProvider client={queryClient}>
<ToastProvider>
<RouterProvider router={router} />
<Input
inputLabel={'성함/연락처'}
value={inputValue}
onChange={handleInputChange}
placeholder={'입력하세요'}
/>
</ToastProvider>
<div style={{ fontSize: '16px' }}>
<ReactQueryDevtools />
Expand Down
12 changes: 12 additions & 0 deletions src/assets/svgs/IcFormDot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { SVGProps } from 'react';
const SvgIcFormDot = (props: SVGProps<SVGSVGElement>) => (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 20 20"
{...props}
>
<circle cx={10} cy={10} r={1.5} fill="#454545" />
</svg>
);
export default SvgIcFormDot;
13 changes: 13 additions & 0 deletions src/assets/svgs/IcFormDotdot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { SVGProps } from 'react';
const SvgIcFormDotdot = (props: SVGProps<SVGSVGElement>) => (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 10 20"
{...props}
>
<circle cx={5} cy={7} r={1} fill="#454545" />
<circle cx={5} cy={13} r={1} fill="#454545" />
</svg>
);
export default SvgIcFormDotdot;
8 changes: 5 additions & 3 deletions src/assets/svgs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ export { default as IcArrowUp20 } from './IcArrowUp20';
export { default as IcCheck } from './IcCheck';
export { default as IcFillLikeOff36 } from './IcFillLikeOff36';
export { default as IcFillLikeOn36 } from './IcFillLikeOn36';
export { default as IcFormDot } from './IcFormDot';
export { default as IcFormDotdot } from './IcFormDotdot';
export { default as IcGpsmarkerOff } from './IcGpsmarkerOff';
export { default as IcGpsmarkerOn } from './IcGpsmarkerOn';
export { default as IcKakao } from './IcKakao';
export { default as IcLineLikeOff20 } from './IcLineLikeOff20';
export { default as IcLineLikeOn20 } from './IcLineLikeOn20';
export { default as IcLocation } from './IcLocation';
export { default as IcMy } from './IcMy';
export { default as IcMypageArrowRight24 } from './IcMypageArrowRight24';
export { default as IcSavedOff24 } from './IcSavedOff24';
export { default as IcSavedOn24 } from './IcSavedOn24';
export { default as IcSearchCategoryAnivUnactivate } from './IcSearchCategoryAnivUnactivate';
Expand All @@ -19,12 +23,10 @@ export { default as IcSearchCategoryCheerUnactivate } from './IcSearchCategoryCh
export { default as IcSearchCategorySeasonUnactivate } from './IcSearchCategorySeasonUnactivate';
export { default as IcToastCheck } from './IcToastCheck';
export { default as IcToastError } from './IcToastError';
export { default as IcLocation } from './IcLocation';
export { default as ImgLogo } from './ImgLogo';
export { default as ImgMypageProfileLogin } from './ImgMypageProfileLogin';
export { default as ImgStore11Cm } from './ImgStore11Cm';
export { default as ImgStore13Cm } from './ImgStore13Cm';
export { default as ImgStore16Cm } from './ImgStore16Cm';
export { default as ImgStore19Cm } from './ImgStore19Cm';
export { default as ImgStore22Cm } from './ImgStore22Cm';
export { default as ImgMypageProfileLogin } from './ImgMypageProfileLogin';
export { default as IcMypageArrowRight24 } from './IcMypageArrowRight24';
49 changes: 49 additions & 0 deletions src/components/common/Input/Input.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';

import { flexGenerator } from '@styles/generator.css';
import { vars } from '@styles/theme.css';

export const inputContainer = style([
flexGenerator('column', 'center', 'flex-start'),
{
gap: '0.4rem',
},
]);

export const inputTitle = style([
flexGenerator(),
vars.fonts.body05_m_14,
{
color: vars.colors.gray700,
},
]);

export const inputStyle = recipe({
base: [
vars.fonts.body07_r_14,
{
width: '100%',
backgroundColor: vars.colors.white,
border: `1px solid ${vars.colors.gray300}`,
borderRadius: '8px',
padding: '1.4rem 2rem',
selectors: {
'&:focus': {
border: `1px solid ${vars.colors.gray500}`,
},
},
},
],
variants: {
state: {
default: { color: vars.colors.gray400 },
active: {
color: vars.colors.gray900,
},
},
},
defaultVariants: {
state: 'default',
},
});
31 changes: 31 additions & 0 deletions src/components/common/Input/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { IcFormDot, IcFormDotdot } from '@svgs';

import { inputTitle, inputContainer, inputStyle } from './Input.css';

type InputProps = {
inputLabel?: string;
value: string;
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
placeholder?: string;
};

const Input = ({ inputLabel, value, onChange, placeholder }: InputProps) => {
return (
<div className={inputContainer}>
<label htmlFor={value} className={inputTitle}>
<IcFormDot width={20} height={20} />
{inputLabel} <IcFormDotdot width={10} height={20} />
</label>
<input
className={inputStyle({ state: value ? 'active' : 'default' })}
type="text"
id={value}
value={value}
onChange={onChange}
placeholder={placeholder}
/>
</div>
);
};

export default Input;
2 changes: 2 additions & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FilteringButton from './FilteringButton/FilteringButton';
import Header from './Header/Header';
import IconButton from './IconButton/IconButton';
import Image from './Image/Image';
import Input from './Input/Input';
import Label from './Label/Label';
import Modal from './Modal/Modal';
import SocialLoginButton from './SocialLoginButton/SocialLoginButton';
Expand All @@ -30,4 +31,5 @@ export {
BottomSheet,
DesignCard,
Toast,
Input,
};
30 changes: 30 additions & 0 deletions src/stories/Input.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Input } from '@components';

import type { Meta, StoryObj } from '@storybook/react';

const meta: Meta<typeof Input> = {
title: 'Components/Input',
component: Input,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {
inputLabel: { control: 'text' },
value: { control: 'text' },
onChange: { action: 'changed' },
placeholder: { control: 'text' },
},
};

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

export const Default: Story = {
args: {
inputLabel: '픽업 날짜/요일/시간(30분 단위로)',
value: '',
onChange: () => {},
placeholder: '예: 01.03/금/16:30',
},
};

0 comments on commit 6335715

Please sign in to comment.