-
Notifications
You must be signed in to change notification settings - Fork 2
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
[feature/#1/header] - 헤더 컴포넌트 구현 #18
Changes from all commits
3efb91e
debfc77
4355d96
db171d3
8ced2b3
9a8b788
1da70b8
ebaa9fa
56301ee
e1dcbb9
0e6053c
18f5d9e
cb367dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { IoSearch } from "react-icons/io5" | ||
|
||
import { | ||
Box, | ||
Center, | ||
Flex, | ||
Icon, | ||
Input, | ||
InputGroup, | ||
InputRightElement, | ||
Spacer, | ||
} from "@chakra-ui/react" | ||
|
||
import HeaderLogo from "./components/HeaderLogo" | ||
import Menu from "./components/Menu" | ||
|
||
const Header = () => { | ||
return ( | ||
<Center | ||
w="100%" | ||
position="fixed" | ||
bg="white" | ||
boxShadow="md"> | ||
<Flex | ||
flex="1" | ||
h="headerHeight" | ||
maxW="1280px" | ||
align="center" | ||
gap="1.6rem" | ||
px="1.6rem"> | ||
{/* 로고 */} | ||
<Box> | ||
<HeaderLogo /> | ||
</Box> | ||
{/* 검색창 */} | ||
<Box | ||
pl="1.5rem" | ||
alignSelf="end" | ||
pb="2rem"> | ||
<InputGroup> | ||
<InputRightElement> | ||
<Icon | ||
as={IoSearch} | ||
w="2rem" | ||
h="2rem" | ||
/> | ||
</InputRightElement> | ||
<Input | ||
size="lg" | ||
variant="flushed" | ||
placeholder="검색어를 입력하세요" | ||
/> | ||
</InputGroup> | ||
</Box> | ||
Comment on lines
+36
to
+54
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. 이런건 하나의 컴포넌트로 묶어도 될 것 같은데, 어떻게 생각하시나요..? 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. 아 이건 일단 나중에 검색창 컴포넌트로 대체하려고 대충 만든거긴한데 |
||
<Spacer /> | ||
{/* 메뉴 */} | ||
<Box> | ||
<Menu /> | ||
</Box> | ||
</Flex> | ||
</Center> | ||
) | ||
} | ||
|
||
export default Header |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Link as ReactRouterLink } from "react-router-dom" | ||
|
||
import { Image, Link } from "@chakra-ui/react" | ||
|
||
import SidePeekLogoSVG from "@assets/svgs/sidepeek_logo.svg" | ||
|
||
const HeaderLogo = () => { | ||
return ( | ||
<Link | ||
as={ReactRouterLink} | ||
to="/"> | ||
<Image | ||
src={SidePeekLogoSVG} | ||
alt="side peek logo" | ||
/> | ||
</Link> | ||
) | ||
} | ||
|
||
export default HeaderLogo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { FaRegBell } from "react-icons/fa" | ||
|
||
import { Avatar, HStack, Icon, IconButton } from "@chakra-ui/react" | ||
|
||
import NotificationPopover from "./NotificationPopover" | ||
import ProfilePopover from "./ProfilePopover" | ||
|
||
const Menu = () => { | ||
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. P3 : 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. Chakra UI에 이미 있는거군요;; |
||
return ( | ||
<HStack spacing="1.6rem"> | ||
<NotificationPopover | ||
NotificationIconButton={ | ||
<IconButton | ||
aria-label="notification popover" | ||
icon={ | ||
<Icon | ||
as={FaRegBell} | ||
w="3rem" | ||
h="3rem" | ||
/> | ||
} | ||
bg={"transparent"} | ||
_before={{ | ||
content: "''", | ||
position: "absolute", | ||
top: "5%", | ||
right: "10%", | ||
width: "1rem", | ||
height: "1rem", | ||
bg: "red", | ||
borderRadius: "full", | ||
}} | ||
/> | ||
} | ||
/> | ||
<ProfilePopover | ||
ProfileButton={ | ||
<Avatar | ||
as="button" | ||
size="md" | ||
aria-label="profile popover" | ||
transition="all 0.2s" | ||
_hover={{ filter: "brightness(90%)" }} | ||
/> | ||
} | ||
/> | ||
</HStack> | ||
) | ||
} | ||
|
||
export default Menu |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ReactNode } from "react" | ||
|
||
import { | ||
Divider, | ||
Heading, | ||
Popover, | ||
PopoverArrow, | ||
PopoverBody, | ||
PopoverCloseButton, | ||
PopoverContent, | ||
PopoverHeader, | ||
PopoverTrigger, | ||
} from "@chakra-ui/react" | ||
|
||
interface NotificationPopoverProps { | ||
NotificationIconButton: ReactNode | ||
} | ||
|
||
const NotificationPopover = ({ | ||
NotificationIconButton, | ||
}: NotificationPopoverProps) => { | ||
return ( | ||
<Popover> | ||
<PopoverTrigger>{NotificationIconButton}</PopoverTrigger> | ||
<PopoverContent> | ||
<PopoverArrow /> | ||
<PopoverCloseButton /> | ||
<PopoverHeader> | ||
<Heading size="md">알림</Heading> | ||
</PopoverHeader> | ||
<Divider /> | ||
<PopoverBody>이쪽에 알림 목록을 넣을 예정입니다</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
) | ||
} | ||
|
||
export default NotificationPopover |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ReactNode } from "react" | ||
|
||
import { | ||
Divider, | ||
Heading, | ||
Popover, | ||
PopoverArrow, | ||
PopoverBody, | ||
PopoverCloseButton, | ||
PopoverContent, | ||
PopoverHeader, | ||
PopoverTrigger, | ||
} from "@chakra-ui/react" | ||
|
||
interface ProfilePopoverProps { | ||
ProfileButton: ReactNode | ||
} | ||
|
||
const ProfilePopover = ({ ProfileButton }: ProfilePopoverProps) => { | ||
return ( | ||
<Popover> | ||
<PopoverTrigger>{ProfileButton}</PopoverTrigger> | ||
<PopoverContent> | ||
<PopoverArrow /> | ||
<PopoverCloseButton /> | ||
<PopoverHeader> | ||
<Heading size="md">프로필</Heading> | ||
</PopoverHeader> | ||
<Divider /> | ||
<PopoverBody>이쪽에 프로필 팝오버 목록을 넣을 예정입니다</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
) | ||
} | ||
|
||
export default ProfilePopover |
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.
저는 뭔가 Header의 의미 상 들어가는 컴포넌트들을 (대부분 차크라에서 제공하는 컴포넌트를 사용했어도) 하나의 커스텀 컴포넌트로 만들어도 좋을 것 같습니다
예를 들어
이런걸 Logo 컴포넌트로 만든다던지.. 해서 Header에서는 최대한 깔끔한? return문을 유지하면 나중에 요소 추가하기도 쉽지 않을까..싶습니다
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.
오... 맞는 말씀이에요
의미상으로 중요한 UI들이 딱히 특별한 로직이 없더라도
가독성 차원에서 컴포넌트로 구분해 놓으면
다른 분들이 읽을 때 훨씬 수월하겠네요!
너무 좋은 조언 감사합니다~! 👍👍