From 77a4f4881c191c20678210c24505b58da17fd0f2 Mon Sep 17 00:00:00 2001 From: wonjin-dev Date: Sat, 16 Dec 2023 01:00:56 +0900 Subject: [PATCH 01/31] =?UTF-8?q?feat:=20alias=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsconfig.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index cfddc22b..c1080dfd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,12 @@ "jsx": "preserve", "incremental": true, "paths": { - "@/*": ["./*"] + "@/*": ["./*"], + "@components/*": ["./src/components/*"], + "@feature/*": ["./src/feature/*"], + "@hooks/*": ["./src/hooks/*"], + "@styles/*": ["./src/styles/*"], + "@utils/*": ["./src/utils/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], From 82ab4004563d12f71fc43e95072cee54eaac132d Mon Sep 17 00:00:00 2001 From: wonjin-dev Date: Sat, 16 Dec 2023 01:06:17 +0900 Subject: [PATCH 02/31] =?UTF-8?q?feat:=20=EC=8A=A4=ED=86=A0=EB=A6=AC?= =?UTF-8?q?=EB=B6=81=20=EC=B4=88=EC=95=88=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .storybook/main.ts | 2 +- .storybook/stories/BaseInput.stories.tsx | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .storybook/stories/BaseInput.stories.tsx diff --git a/.storybook/main.ts b/.storybook/main.ts index 0d315412..b7913244 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,7 +1,7 @@ import type { StorybookConfig } from '@storybook/nextjs'; const config: StorybookConfig = { - stories: ['./**/*.stories.@(js|jsx|mjs|ts|tsx)'], + stories: ['./stories/*.stories.@(js|jsx|mjs|ts|tsx)'], addons: [ '@storybook/addon-links', '@storybook/addon-essentials', diff --git a/.storybook/stories/BaseInput.stories.tsx b/.storybook/stories/BaseInput.stories.tsx new file mode 100644 index 00000000..e71e3773 --- /dev/null +++ b/.storybook/stories/BaseInput.stories.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import BaseInput from '../../src/components/Input/BaseInput'; +import { type Meta } from '@storybook/react'; + +const meta: Meta = { + title: 'BaseInput', + component: BaseInput, +}; + +export default meta; + +export function Default() { + return {} }} />; +} From 5809aaaf3f4d9038b9edf300dc19d3e9e737a934 Mon Sep 17 00:00:00 2001 From: wonjin-dev Date: Sat, 16 Dec 2023 01:06:27 +0900 Subject: [PATCH 03/31] =?UTF-8?q?feat:=20useInput=20=EC=B4=88=EC=95=88=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 6 ++++-- src/components/Input/BaseInput.tsx | 15 +++++++++++++++ src/hooks/useInput.ts | 13 +++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/components/Input/BaseInput.tsx create mode 100644 src/hooks/useInput.ts diff --git a/.eslintrc.json b/.eslintrc.json index 67210252..d33b811e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,8 +3,7 @@ "next/core-web-vitals", "prettier", "eslint:recommended", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended" + "plugin:react-hooks/recommended" ], "parser": "@typescript-eslint/parser", "plugins": [ @@ -16,6 +15,9 @@ "rules": { "import/first": "error", "import/newline-after-import": "error", + "plugin:jsx-a11y/recommended": { + "some": ["nesting", "id"] + }, "import/no-useless-path-segments": [ "error", { diff --git a/src/components/Input/BaseInput.tsx b/src/components/Input/BaseInput.tsx new file mode 100644 index 00000000..52fed367 --- /dev/null +++ b/src/components/Input/BaseInput.tsx @@ -0,0 +1,15 @@ +import { UseInputReturn } from '@hooks/useInput'; + +interface BaseInputProps extends Omit { + controlledInputProps: UseInputReturn; +} + +const BaseInput = ({ id, controlledInputProps }: BaseInputProps) => { + return ( + + ); +}; + +export default BaseInput; diff --git a/src/hooks/useInput.ts b/src/hooks/useInput.ts new file mode 100644 index 00000000..59806b5e --- /dev/null +++ b/src/hooks/useInput.ts @@ -0,0 +1,13 @@ +import { ChangeEvent, useState } from 'react'; + +export const useInput = () => { + const [value, setValue] = useState(''); + + const onChange = (e: ChangeEvent) => { + setValue(e.currentTarget.value); + }; + + return { value, onChange }; +}; + +export type UseInputReturn = ReturnType; From 71718b28f303a4495a21903dd7f8e9e48524f365 Mon Sep 17 00:00:00 2001 From: wonjin-dev Date: Sat, 16 Dec 2023 01:08:45 +0900 Subject: [PATCH 04/31] =?UTF-8?q?refactor:=20=ED=8E=B8=EC=9D=98=EB=A5=BC?= =?UTF-8?q?=20=EC=9C=84=ED=95=B4=20@/=20alias=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index c1080dfd..0237a7f8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,10 +14,10 @@ "jsx": "preserve", "incremental": true, "paths": { - "@/*": ["./*"], "@components/*": ["./src/components/*"], "@feature/*": ["./src/feature/*"], "@hooks/*": ["./src/hooks/*"], + "@pages": ["./pages/*"], "@styles/*": ["./src/styles/*"], "@utils/*": ["./src/utils/*"] } From 523dcf360750a791032a3552597a165703c8537c Mon Sep 17 00:00:00 2001 From: wonjin-dev Date: Sat, 16 Dec 2023 01:23:45 +0900 Subject: [PATCH 05/31] =?UTF-8?q?feat:=20=EC=A0=9C=EC=96=B4=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20BaseInput=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/_app.tsx | 2 +- pages/index.tsx | 6 +++++- src/components/Input/BaseInput.tsx | 32 +++++++++++++++++++++++++----- src/hooks/useInput.ts | 4 ++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index 22f77394..bdd8ae21 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,5 +1,5 @@ import type { AppProps } from 'next/app'; -import '@/src/styles/global.css'; +import '@styles/global.css'; const App = ({ Component, pageProps }: AppProps) => { return ; diff --git a/pages/index.tsx b/pages/index.tsx index 2a7ba008..8cb5b886 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,7 +1,11 @@ +import BaseInput from '@components/Input/BaseInput'; +import { useInput } from '@hooks/useInput'; import type { NextPage } from 'next'; const HomePage: NextPage = () => { - return <>; + const testInputProps = useInput('test'); + + return ; }; export default HomePage; diff --git a/src/components/Input/BaseInput.tsx b/src/components/Input/BaseInput.tsx index 52fed367..558a0fcf 100644 --- a/src/components/Input/BaseInput.tsx +++ b/src/components/Input/BaseInput.tsx @@ -1,13 +1,35 @@ import { UseInputReturn } from '@hooks/useInput'; +import { FocusEventHandler, ReactNode } from 'react'; -interface BaseInputProps extends Omit { - controlledInputProps: UseInputReturn; +interface BaseInputProps { + inputProps: UseInputReturn; + + labelClassName?: string; + inputClassName?: string; + postfix?: ReactNode; + + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; } -const BaseInput = ({ id, controlledInputProps }: BaseInputProps) => { +const BaseInput = ({ + inputProps, + labelClassName, + inputClassName, + postfix, + onFocus, + onBlur, +}: BaseInputProps) => { return ( -