-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from JECT-Study/feature/design-system
[TASK-44, 45] style: 공용 Input, Button 구현
- Loading branch information
Showing
26 changed files
with
813 additions
and
117 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/app/ReactQueryProvider.tsx → src/app/providers/ReactQueryProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { CategoryButtonProps } from '@/types'; | ||
|
||
import { FC } from 'react'; | ||
|
||
const CategoryButton: FC<CategoryButtonProps> = ({ | ||
backgroundColor = 'bg-gray-800', | ||
textColor = 'text-gray-300', | ||
textSize, | ||
children, | ||
|
||
onClick, | ||
ariaLabel, | ||
}) => { | ||
return ( | ||
<button | ||
onClick={onClick} | ||
aria-label={ariaLabel} | ||
className={` | ||
inline-flex items-center justify-center rounded-full | ||
px-[56px] py-[17px] h-[69px] | ||
${backgroundColor} ${textColor} ${textSize} | ||
hover:bg-opacity-80 active:bg-opacity-60 active:scale-95 | ||
transition-all duration-300 ease-in-out | ||
`} | ||
> | ||
{children} | ||
</button> | ||
); | ||
}; | ||
|
||
export default CategoryButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use client'; | ||
|
||
import { FC, useState } from 'react'; | ||
|
||
import { FollowButtonProps } from '@/types/buttons/FollowButtonProps'; | ||
|
||
import Icon from '../Icon/Icon'; | ||
|
||
const FollowButton: FC<FollowButtonProps> = ({ | ||
backgroundColor = 'bg-gray-900', | ||
textColor = 'text-white', | ||
textSize = 'button-s', | ||
|
||
onClick, | ||
ariaLabel, | ||
}) => { | ||
const [isFollowing, setIsFollowing] = useState(false); | ||
|
||
const toggleFollow = () => { | ||
setIsFollowing((prev) => !prev); | ||
|
||
// 외부에서 전달받은 onClick 함수 실행 | ||
if (onClick) { | ||
onClick(); | ||
} | ||
}; | ||
|
||
return ( | ||
<button | ||
onClick={toggleFollow} | ||
aria-label={ariaLabel} | ||
className={` | ||
flex items-center justify-center rounded-full | ||
w-[95px] h-[37px] gap-[3px] | ||
${backgroundColor} ${textColor} ${textSize} | ||
${ | ||
isFollowing | ||
? 'border border-gray-900 text-gray-900 bg-white' | ||
: 'bg-gray-900 text-white' | ||
} | ||
hover:bg-opacity-80 active:bg-opacity-60 active:scale-95 | ||
transition-all duration-300 ease-in-out | ||
`} | ||
> | ||
{isFollowing ? ( | ||
<> | ||
<Icon name='Check' size='s' /> | ||
<span>팔로잉</span> | ||
</> | ||
) : ( | ||
<> | ||
<Icon name='Plus' size='s' /> | ||
<span>팔로우</span> | ||
</> | ||
)} | ||
</button> | ||
); | ||
}; | ||
|
||
export default FollowButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { SquareButtonLProps } from '@/types'; | ||
|
||
import { FC } from 'react'; | ||
|
||
const SquareButtonL: FC<SquareButtonLProps> = ({ | ||
backgroundColor = 'bg-gray-800', | ||
textColor = 'text-white', | ||
textSize, | ||
children, | ||
|
||
onClick, | ||
ariaLabel, | ||
disabled = false, | ||
loading = false, | ||
icon, | ||
iconPosition, | ||
type = 'button', | ||
}) => { | ||
return ( | ||
<button | ||
type={type} | ||
onClick={onClick} | ||
disabled={disabled || loading} | ||
aria-label={ariaLabel} | ||
className={` | ||
flex items-center justify-center rounded-md | ||
w-[420px] h-[70px] gap-2 | ||
${backgroundColor} ${textColor} ${textSize} | ||
${disabled ? 'text-gray-700 cursor-not-allowed' : ''} | ||
hover:bg-opacity-80 active:bg-opacity-60 active:scale-95 | ||
transition-all duration-300 ease-in-out | ||
`} | ||
> | ||
{loading && <span>로딩중...</span>} | ||
{icon && iconPosition === 'left' && <span>{icon}</span>} | ||
{children} | ||
{icon && iconPosition === 'right' && <span>{icon}</span>} | ||
</button> | ||
); | ||
}; | ||
|
||
export default SquareButtonL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,63 +2,48 @@ | |
|
||
import { Input } from '@nextui-org/react'; | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
import Icon from '../Icon/Icon'; | ||
|
||
export interface EmailInputProps { | ||
interface EmailInputProps { | ||
mode: 'sign-up' | 'sign-in'; | ||
} | ||
|
||
const EmailInput = ({ mode }: EmailInputProps) => { | ||
const [value, setValue] = useState(''); | ||
const [message, setMessage] = useState(''); | ||
const [messageColor, setMessageColor] = useState(''); | ||
const [email, setEmail] = useState(''); | ||
const [validationMessage, setValidationMessage] = useState(''); | ||
const [validationMessageColor, setValidationMessageColor] = useState(''); | ||
|
||
const validateEmail = (email: string) => | ||
/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(email); | ||
const isEmailInvalid = (email: string) => | ||
email !== '' && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(email); | ||
|
||
const checkEmailStatus = (email: string) => { | ||
// TODO: 여기에 이메일 상태를 확인하는 API 호출 로직 추가 | ||
const clearEmailField = () => { | ||
setEmail(''); | ||
}; | ||
|
||
if (mode === 'sign-up') { | ||
if (email === '[email protected]') { | ||
setMessage('이미 가입된 계정입니다.'); | ||
setMessageColor('text-system-error'); | ||
} else { | ||
setMessage('사용 가능한 이메일입니다.'); | ||
setMessageColor('text-system-success'); | ||
} | ||
} else if (mode === 'sign-in') { | ||
const checkEmailStatus = (email: string) => { | ||
// TODO: 이메일 상태 확인 (API 호출 로직 추가) | ||
if (mode === 'sign-in') { | ||
if (email === '[email protected]') { | ||
setMessage(''); | ||
setValidationMessage(''); | ||
} else { | ||
setMessage('가입되어 있지 않은 이메일입니다.'); | ||
setMessageColor('text-system-error'); | ||
setValidationMessage('가입되어 있지 않은 이메일입니다.'); | ||
setValidationMessageColor('text-system-error'); | ||
} | ||
} | ||
}; | ||
|
||
const isInvalid = React.useMemo(() => { | ||
if (value === '') return false; | ||
|
||
return !validateEmail(value); | ||
}, [value]); | ||
|
||
useEffect(() => { | ||
if (isInvalid) { | ||
setMessage('올바른 이메일 형식으로 입력해주세요.'); | ||
setMessageColor('text-system-error'); | ||
} else if (value) { | ||
checkEmailStatus(value); | ||
if (isEmailInvalid(email)) { | ||
setValidationMessage('올바른 이메일 형식으로 입력해주세요.'); | ||
setValidationMessageColor('text-system-error'); | ||
} else if (email) { | ||
checkEmailStatus(email); | ||
} else { | ||
setMessage(''); | ||
setValidationMessage(''); | ||
} | ||
}, [value, isInvalid, mode]); | ||
|
||
const handleEmailFieldClear = () => { | ||
setValue(''); | ||
}; | ||
}, [email]); | ||
|
||
return ( | ||
<> | ||
|
@@ -67,20 +52,21 @@ const EmailInput = ({ mode }: EmailInputProps) => { | |
label='이메일' | ||
labelPlacement='outside' | ||
placeholder='이메일을 입력해주세요.' | ||
value={value} | ||
onValueChange={(newValue) => setValue(newValue)} | ||
value={email} | ||
onValueChange={(newEmail) => setEmail(newEmail)} | ||
isInvalid={false} | ||
className='w-80' | ||
className='w-78.25' | ||
classNames={{ | ||
label: 'custom-label', | ||
input: 'placeholder:text-gray-700', | ||
inputWrapper: ['bg-gray-900', 'rounded-md'], | ||
}} | ||
onClear={handleEmailFieldClear} | ||
onClear={clearEmailField} | ||
/> | ||
{message && ( | ||
|
||
{validationMessage && ( | ||
<div className='flex items-center mt-2'> | ||
{messageColor === 'text-system-success' ? ( | ||
{validationMessageColor === 'text-system-success' ? ( | ||
<Icon | ||
name='CheckCircleFilled' | ||
size='s' | ||
|
@@ -93,7 +79,9 @@ const EmailInput = ({ mode }: EmailInputProps) => { | |
className='text-system-error mr-2' | ||
/> | ||
)} | ||
<p className={`button-s ${messageColor}`}>{message}</p> | ||
<p className={`button-s ${validationMessageColor}`}> | ||
{validationMessage} | ||
</p> | ||
</div> | ||
)} | ||
</> | ||
|
Oops, something went wrong.