Skip to content

Commit

Permalink
feat: 회원가입, 로그인 페이지 퍼블리싱 (#26)
Browse files Browse the repository at this point in the history
* feat: 회원가입 뷰 퍼블리싱

* feat: 로그인 뷰 퍼블리싱

* rename: 디렉토리명 수정

* rename: 디렉토리명 수정

* fix: 로그인/ 회원가입 버튼 위치 수정 및 오류 해결

---------

Co-authored-by: asdf99245 <asdf99245@naver.com>
  • Loading branch information
bsy1141 and asdf99245 authored Aug 12, 2023
1 parent 44e7bb3 commit b235428
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"react": "18.2.0",
"react-bootstrap": "^2.8.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.45.2",
"tailwind-merge": "^1.13.2",
"tailwind-scrollbar-hide": "^1.1.7",
"tailwindcss": "3.3.2",
Expand Down
9 changes: 9 additions & 0 deletions public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/shared/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type ButtonType = 'button1' | 'button2' | 'button3' | 'button4';
type VariantType = 'primary' | 'secondary' | 'nudge' | 'link' | 'rounded';

interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
variant: VariantType;
variant?: VariantType;
disabled?: boolean;
}

Expand Down
6 changes: 6 additions & 0 deletions src/components/shared/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { useControllableState } from '@/hooks';
import { cn } from '@/utils/cn';

interface Props extends InputHTMLAttributes<HTMLInputElement> {
inputKey?: string;
label?: string;
value?: string;
captionPosition?: 'top' | 'bottom';
caption?: string;
feedback?: string;
defaultValue?: string;
onValueChange?: (value: string) => void;
handleChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
}

/**
Expand All @@ -29,6 +31,7 @@ interface Props extends InputHTMLAttributes<HTMLInputElement> {
export const Input = forwardRef<HTMLInputElement, Props>(
(
{
inputKey,
id: idFromProps,
label,
value: valueFromProps,
Expand All @@ -38,6 +41,7 @@ export const Input = forwardRef<HTMLInputElement, Props>(
defaultValue = '',
maxLength,
onValueChange,
handleChange,
className,
...restProps
},
Expand All @@ -55,6 +59,7 @@ export const Input = forwardRef<HTMLInputElement, Props>(
return;
}
setValue(e.target.value);
handleChange?.(e);
};

return (
Expand All @@ -75,6 +80,7 @@ export const Input = forwardRef<HTMLInputElement, Props>(
</div>
)}
<input
name={inputKey}
ref={ref}
id={idFromProps ?? id}
value={value}
Expand Down
58 changes: 58 additions & 0 deletions src/pages/signin/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Image from 'next/image';
import { useRouter } from 'next/router';
import { useForm } from 'react-hook-form';
import { Button, Input } from '@/components/shared';

export default function SignInPage() {
const router = useRouter();
const {
formState: { isValid },
register,
handleSubmit,
} = useForm();

const onSubmit = (data: object) => {
// NOTE: 로그인 API 연결
const uuid = 1111;
router.push(`/user/${uuid}`);
};

const { ref: idRef, onChange: onIdChange } = register('id', { required: true });
const { ref: pwRef, onChange: onPwChange } = register('password', { required: true, minLength: 4 });

return (
<div className='tw-relative tw-flex tw-h-[100vh] tw-w-full tw-flex-col tw-bg-white tw-px-5 tw-py-8'>
<div className='mb-10 tw-mb-11 tw-flex tw-items-center tw-gap-2'>
<Image alt='logo' src='/logo.svg' width={32} height={32} />
<h1 className='tw-text-logo'>Grafi</h1>
</div>
<form onSubmit={handleSubmit(onSubmit)} className='tw-flex tw-flex-1 tw-flex-col tw-justify-between'>
<div className='tw-flex tw-flex-col tw-gap-10'>
<Input
inputKey='id'
label='아이디'
caption='영문 소문자, 숫자만 입력 가능'
placeholder='아이디를 입력해주세요'
maxLength={15}
ref={idRef}
handleChange={onIdChange}
/>
<Input
type='password'
inputKey='password'
label='비밀번호'
caption='숫자만 입력 가능'
placeholder='비밀번호 4자리를 입력해주세요'
maxLength={4}
ref={pwRef}
handleChange={onPwChange}
/>
</div>

<Button disabled={!isValid} className='tw-w-full tw-justify-center'>
로그인하기
</Button>
</form>
</div>
);
}
72 changes: 72 additions & 0 deletions src/pages/signup/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import Image from 'next/image';
import { useRouter } from 'next/router';
import { useForm } from 'react-hook-form';
import { isString } from '@/utils';
import { Button, Input } from '@/components/shared';

export default function SignUpPage() {
const router = useRouter();
const {
formState: { isValid, errors },
register,
handleSubmit,
setError,
} = useForm();

// NOTE: ID 체크 API 연결 예정
const checkValidID = () => {
return false;
};

const onSubmit = (data: object) => {
const isValidID = checkValidID();
if (isValidID) {
// NOTE : 회원가입 요청 API 후 uuid값 리턴받음
const uuid = '1111';
router.push(`/user/${uuid}`);
return;
}
setError('id', { message: '이미 사용 중인 아이디입니다' }, { shouldFocus: true });
};

const { ref: idRef, onChange: onIdChange } = register('id', { required: true });
const { ref: pwRef, onChange: onPwChange } = register('password', { required: true, minLength: 4 });

return (
<div className='tw-relative tw-flex tw-h-[100vh] tw-w-full tw-flex-col tw-bg-white tw-px-5 tw-py-8'>
<div className='mb-10 tw-mb-11 tw-flex tw-items-center tw-gap-2'>
<Image alt='logo' src='/logo.svg' width={32} height={32} />
<h1 className='tw-text-logo'>Grafi</h1>
</div>
<form onSubmit={handleSubmit(onSubmit)} className='tw-flex tw-flex-1 tw-flex-col tw-justify-between'>
<div className='tw-flex tw-flex-col tw-gap-10'>
<Input
inputKey='id'
label='아이디'
captionPosition='top'
caption='영문 소문자, 숫자만 입력 가능'
feedback={isString(errors.id?.message) ? errors.id?.message : ''}
placeholder='아이디를 입력해주세요'
maxLength={15}
ref={idRef}
handleChange={onIdChange}
/>
<Input
type='password'
inputKey='password'
label='비밀번호'
captionPosition='top'
caption='숫자만 입력 가능'
placeholder='비밀번호 4자리를 입력해주세요'
maxLength={4}
ref={pwRef}
handleChange={onPwChange}
/>
</div>
<Button disabled={!isValid} className='tw-w-full tw-justify-center'>
회원가입
</Button>
</form>
</div>
);
}
3 changes: 3 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export function isString(str: unknown): str is string {
return typeof str === 'string';
}
export const convertImageToBase64 = (file : File) => {
const mediaType = file?.type;
return new Promise((resolve, reject) => {
Expand Down
6 changes: 6 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ module.exports = {
fontWeight: '600',
lineHeight: '1',
},
'.text-logo': {
fontFamily: theme('fontFamily.montserrat'),
fontSize: '1.75rem',
fontWeight: '600',
lineHeight: '1',
},
'.text-button-eng': {
fontFamily: theme('fontFamily.montserrat'),
fontSize: '1.5rem',
Expand Down
31 changes: 24 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1018,13 +1018,20 @@
resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==

"@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7":
"@babel/runtime@^7.20.7", "@babel/runtime@^7.8.4":
version "7.22.6"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438"
integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==
dependencies:
regenerator-runtime "^0.13.11"

"@babel/runtime@^7.21.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.8.7":
version "7.22.10"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.10.tgz#ae3e9631fd947cb7e3610d3e9d8fef5f76696682"
integrity sha512-21t/fkKLMZI4pqP2wlmsQAWnYW1PDyKyyUV4vCi+B25ydmdaYTKXPwCj0BzSUnZf4seIiYvSA3jcZ3gdsMFkLQ==
dependencies:
regenerator-runtime "^0.14.0"

"@babel/template@^7.22.5":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.5.tgz#0c8c4d944509875849bd0344ff0050756eefc6ec"
Expand Down Expand Up @@ -1272,9 +1279,9 @@
integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==

"@react-aria/ssr@^3.5.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@react-aria/ssr/-/ssr-3.7.0.tgz#7eda2964ab792dc1c3a1fdacbf5bfb185590e9a5"
integrity sha512-bfufjg4ESE5giN+Fxj1XIzS5f/YIhqcGc+Ve+vUUKU8xZ8t/Xtjlv8F3kjqDBQdk//n3mluFY7xG1wQVB9rMLQ==
version "3.7.1"
resolved "https://registry.yarnpkg.com/@react-aria/ssr/-/ssr-3.7.1.tgz#11d0fac17e50028459aad325c2d093dbb2960f68"
integrity sha512-ovVPSD1WlRpZHt7GI9DqJrWG3OIYS+NXQ9y5HIewMJpSe+jPQmMQfyRmgX4EnvmxSlp0u04Wg/7oItcoSIb/RA==
dependencies:
"@swc/helpers" "^0.5.0"

Expand Down Expand Up @@ -1513,9 +1520,9 @@
csstype "^3.0.2"

"@types/react@>=16.9.11":
version "18.2.17"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.17.tgz#baa565b17ddb649c2dac85b5eaf9e9a1fe0f3b4e"
integrity sha512-u+e7OlgPPh+aryjOm5UJMX32OvB2E3QASOAqVMY6Ahs90djagxwv2ya0IctglNbNTexC12qCSMZG47KPfy1hAA==
version "18.2.20"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.20.tgz#1605557a83df5c8a2cc4eeb743b3dfc0eb6aaeb2"
integrity sha512-WKNtmsLWJM/3D5mG4U84cysVY31ivmyw85dE84fOCk5Hx78wezB/XEjVPWl2JTZ5FkEeaTJf+VgUAUn3PE7Isw==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
Expand Down Expand Up @@ -3963,6 +3970,11 @@ react-dom@18.2.0:
loose-envify "^1.1.0"
scheduler "^0.23.0"

react-hook-form@^7.45.2:
version "7.45.2"
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.45.2.tgz#c757f3d5e633ccb186443d57c10fc511df35721a"
integrity sha512-9s45OdTaKN+4NSTbXVqeDITd/nwIg++nxJGL8+OD5uf1DxvhsXQ641kaYHk5K28cpIOTYm71O/fYk7rFaygb3A==

react-is@^16.13.1, react-is@^16.3.2:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
Expand Down Expand Up @@ -4021,6 +4033,11 @@ regenerator-runtime@^0.13.11:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==

regenerator-runtime@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45"
integrity sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==

regenerator-transform@^0.15.1:
version "0.15.1"
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.15.1.tgz#f6c4e99fc1b4591f780db2586328e4d9a9d8dc56"
Expand Down

0 comments on commit b235428

Please sign in to comment.