-
Notifications
You must be signed in to change notification settings - Fork 1
✨Feat: header components 구현 #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ad65dc5
2e78b74
f68187f
02b693e
65579d9
5813236
aa6dcf9
7330b43
d41e808
02bbcb7
2085078
c3c916e
5c6f604
a7cf7b4
1dc2915
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||||||
| import { Icon } from '@/shared/icons'; | ||||||||||
| import { cn } from '@/shared/lib'; | ||||||||||
| import { cva } from 'class-variance-authority'; | ||||||||||
|
|
||||||||||
| interface ControlBarProps { | ||||||||||
| isLoggedIn: boolean; | ||||||||||
| onLogin: () => void; | ||||||||||
| userName: string; | ||||||||||
| className?: string; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const rightStyle = cva('flex items-center gap-[0.6rem] transition w-[7.8rem]', { | ||||||||||
| variants: { | ||||||||||
| state: { | ||||||||||
| loggedIn: 'text-mint-600', | ||||||||||
| guest: 'text-gray-400 hover:text-gray-600', | ||||||||||
| }, | ||||||||||
| }, | ||||||||||
| defaultVariants: { state: 'guest' }, | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| const ControlBar = ({ | ||||||||||
| onLogin, | ||||||||||
| isLoggedIn, | ||||||||||
| userName = '글다', | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. userName 기본값이 의미상 적절하지 않습니다. 사용자 이름의 기본값으로 다음 중 하나로 수정하는 것을 권장합니다: - userName = '글다',
+ userName = '사용자',또는 기본값 없이 빈 문자열로 처리: - userName = '글다',
+ userName = '',📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 우리 서비스명이 '글다'여서 기본 사용자이름이 글다면 좋을것 같아 설정해두었습니다
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jjangminii, 이해했습니다! 서비스명을 기본 사용자이름으로 사용하는 것이 의도된 디자인이었군요. 설명해주셔서 감사합니다. 제안을 철회하겠습니다. 😊 ✏️ Learnings added
|
||||||||||
| className, | ||||||||||
| }: ControlBarProps) => { | ||||||||||
| const rightState = isLoggedIn ? 'loggedIn' : ('guest' as const); | ||||||||||
| const iconColor = isLoggedIn ? 'mint-600' : ('gray-400' as const); | ||||||||||
|
|
||||||||||
| return ( | ||||||||||
| <header className={cn('bg-none w-full h-[5.4rem]', className)} role='group'> | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
다음과 같이 수정하세요: - <header className={cn('bg-none w-full h-[5.4rem]', className)} role='group'>
+ <header className={cn('bg-none w-full h-[5.4rem]', className)}>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| <div className='h-full grid grid-cols-[auto_1fr_auto] items-center gap-[1.2rem]'> | ||||||||||
| <div | ||||||||||
| className='w-[7.8rem] h-[5.4rem] rounded-[0.6rem] bg-gray-200' | ||||||||||
| aria-hidden | ||||||||||
| /> | ||||||||||
|
|
||||||||||
| <h1 className='justify-self-center text-headline-sm-serif font-[400] leading-[2.4rem] tracking-[0.015rem] text-gray-900'> | ||||||||||
| 글다 | ||||||||||
| </h1> | ||||||||||
| {isLoggedIn ? ( | ||||||||||
| <div className={cn(rightStyle({ state: rightState }), 'min-w-0')}> | ||||||||||
| <Icon name='User' size={24} color={iconColor} /> | ||||||||||
| <span | ||||||||||
| className='text-body-md w-[5.3rem] truncate block' | ||||||||||
| aria-label={`${userName}님`} | ||||||||||
| > | ||||||||||
| {userName}님 | ||||||||||
| </span> | ||||||||||
| </div> | ||||||||||
| ) : ( | ||||||||||
| <button | ||||||||||
| type='button' | ||||||||||
| onClick={(e) => { | ||||||||||
| e.stopPropagation(); | ||||||||||
| onLogin?.(); | ||||||||||
| }} | ||||||||||
| className={rightStyle({ state: rightState })} | ||||||||||
| aria-label='Log In' | ||||||||||
| > | ||||||||||
| <Icon name='User' size={24} color={iconColor} /> | ||||||||||
| <span className='text-body-md'>Log In</span> | ||||||||||
| </button> | ||||||||||
| )} | ||||||||||
| </div> | ||||||||||
| </header> | ||||||||||
| ); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| export default ControlBar; | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Icon } from '@/shared/icons'; | ||
| import { cn } from '@/shared/lib'; | ||
| import { cva, type VariantProps } from 'class-variance-authority'; | ||
|
|
||
| interface HeaderProps { | ||
| title: string; | ||
| onClick: () => void; | ||
| className?: string; | ||
| color?: VariantProps<typeof headerStyle>['color']; | ||
| } | ||
|
|
||
| const headerStyle = cva( | ||
| 'w-full h-[11.8rem] px-[1.6rem] pb-[1.8rem] pt-[7.6rem] fixed top-0 left-0 right-0 z-[100]', | ||
| { | ||
| variants: { | ||
| color: { | ||
| mint300: 'bg-mint-300', | ||
| mint50: 'bg-mint-50', | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| color: 'mint300', | ||
| }, | ||
| }, | ||
| ); | ||
|
Comment on lines
+12
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 고정 헤더로 인한 콘텐츠 겹침 문제가 발생할 수 있습니다. 헤더가 예를 들어, 이 Header를 사용하는 페이지의 main 컨텐츠에 🤖 Prompt for AI Agents |
||
|
|
||
| const Header = ({ title, onClick, color, className }: HeaderProps) => { | ||
| return ( | ||
| <header className={cn(headerStyle({ color }), className)}> | ||
| <div className='mx-auto h-[2.4rem] grid grid-cols-[auto_1fr_auto] items-center text-mint-900'> | ||
| <button | ||
| type='button' | ||
| aria-label='뒤로가기' | ||
| onClick={onClick} | ||
| className='grid place-items-center w-[2.4rem] h-[2.4rem]' | ||
| > | ||
| <Icon name='Caret' size={24} color='mint-900' /> | ||
| </button> | ||
|
|
||
| <h1 | ||
| className={cn( | ||
| 'justify-self-center', | ||
| 'text-title-md font-[600] leading-[2.4rem] tracking-[0.015rem]', | ||
| )} | ||
| > | ||
| {title} | ||
| </h1> | ||
|
|
||
| <div aria-hidden className='w-[2.4rem] h-[2.4rem]' /> | ||
| </div> | ||
| </header> | ||
| ); | ||
| }; | ||
|
|
||
| export default Header; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { default as Header } from './header/Header'; | ||
| export { default as ControlBar } from './header/ControlBar'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인터페이스와 기본값 불일치를 수정하세요.
isLoggedIn이 인터페이스에서는 필수 prop(boolean)으로 정의되어 있지만, 컴포넌트에서는 기본값(false)을 제공합니다. 인터페이스에서도 선택적으로 변경해야 일관성이 유지됩니다.다음과 같이 수정하세요:
interface ControlBarProps { - isLoggedIn: boolean; + isLoggedIn?: boolean; onLogin?: () => void; userName?: string; className?: string; }📝 Committable suggestion
🤖 Prompt for AI Agents