-
Notifications
You must be signed in to change notification settings - Fork 1
[feat] add header userInfo #13
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
6cf6c4b
5d7f72c
d34e36f
c4311a7
ab405fc
eb01929
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 |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import type { NextConfig } from "next"; | ||
| import type { NextConfig } from 'next'; | ||
|
|
||
| const nextConfig: NextConfig = { | ||
| /* config options here */ | ||
| images: { | ||
| domains: ['sprint-fe-project.s3.ap-northeast-2.amazonaws.com'], | ||
| }, | ||
| }; | ||
|
|
||
| export default nextConfig; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function Page() { | ||
| return <div>dashboard page</div>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| font-size: 14px; | ||
| font-weight: 600; | ||
| color: var(--white); | ||
| white-space: nowrap; | ||
|
Collaborator
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. ์ด๊ฑฐ ๋ฒํผ ๊ธ์ ๋ง์์ง๋ฉด(?) ์ค๋ฐ๊ฟ ๋๋๋ผ๊ตฌ์ |
||
| } | ||
|
|
||
| .button:disabled { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,91 @@ | ||
| .header { | ||
| padding: 16px; | ||
| border-bottom: 1px solid var(--gray-300); | ||
| display: flex; | ||
| justify-content: space-around; | ||
| align-items: center; | ||
| gap: 16px; | ||
| } | ||
|
|
||
| .title { | ||
| flex: 1; | ||
| color: var(--black-100); | ||
| font-size: 16px; | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| .buttonContainer { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| gap: 6px; | ||
| } | ||
|
|
||
| .button { | ||
| padding: 6px 12px; | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 8px; | ||
| background-color: transparent; | ||
| border-radius: 6px; | ||
| border: 1px solid var(--gray-300); | ||
| color: var(--gray-500); | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| .icon { | ||
| display: none; | ||
| } | ||
|
|
||
| .userInfoContainer { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .userInfoContainer::before { | ||
| content: ''; | ||
| border: 0.5px solid var(--gray-300); | ||
| height: 34px; | ||
| } | ||
|
|
||
| .userInfoWrapper { | ||
| margin-left: 16px; | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| @media screen and (min-width: 768px) { | ||
| .header { | ||
| padding-left: 40px; | ||
| padding-right: 30px; | ||
| gap: 36px; | ||
| } | ||
|
|
||
| .title { | ||
| font-size: 20px; | ||
| } | ||
|
|
||
| .buttonContainer { | ||
| gap: 16px; | ||
| } | ||
|
|
||
| .button { | ||
| padding: 10px 16px; | ||
| font-size: 16px; | ||
| } | ||
|
|
||
| .userInfoWrapper { | ||
| margin-left: 36px; | ||
| } | ||
| } | ||
|
|
||
| @media screen and (min-width: 1199px) { | ||
| .header { | ||
| padding-right: 80px; | ||
| } | ||
|
|
||
| .icon { | ||
| display: block; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,52 @@ | ||
| 'use client'; | ||
| import { usePathname } from 'next/navigation'; | ||
| import Image from 'next/image'; | ||
| import Button from './Button'; | ||
| import UserInfo from './UserInfo'; | ||
| import styles from './Header.module.css'; | ||
| import type { User } from '@/app/(with-header-sidebar)/mydashboard/types/user'; | ||
|
|
||
| const user: User = { | ||
| id: 1, | ||
| email: '[email protected]', | ||
| nickname: 'heejin', | ||
| profileImageUrl: null, | ||
| createdAt: '2024-11-15T14:29:07.482Z', | ||
| }; | ||
| interface HeaderProps { | ||
| component: React.ComponentType; | ||
| } | ||
|
|
||
| export default function Header() { | ||
| export default function Header({ component: Component }: HeaderProps) { | ||
|
Collaborator
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. ํค๋์ ๋ณด๋ฉด ๋์๋ณด๋์ชฝ์๋ง ์ฌ๋๋ค์์ด์ฝ..? ์๋๊ฒ ์์ด์ |
||
| const pathname = usePathname(); | ||
|
|
||
| const { nickname, profileImageUrl } = user; | ||
|
|
||
| return <header className={styles.header}>๋ด ๋์๋ณด๋</header>; | ||
| return ( | ||
| <header className={styles.header}> | ||
| <span className={styles.title}>๋ด ๋์๋ณด๋</span> | ||
|
Collaborator
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. h2 ์ฐ๋๊ฒ ์ข์๋ณด์ด๋ค์ ์ถํ ์์ ใฑใฑ (์ ํ ์ฝ๋๋ฆฌ๋ทฐ..ใ ใ ใ ใ ใ ใ ) |
||
| <div className={styles.buttonContainer}> | ||
| <Button className={styles.button}> | ||
| <Image | ||
| src="/icons/settings.svg" | ||
| alt="๊ด๋ฆฌ" | ||
| width={20} | ||
| height={20} | ||
| className={styles.icon} | ||
| /> | ||
| ๊ด๋ฆฌ | ||
| </Button> | ||
| <Button className={styles.button}> | ||
| <Image | ||
| src="/icons/add_box.svg" | ||
| alt="์ด๋ํ๊ธฐ" | ||
| width={20} | ||
| height={20} | ||
| className={styles.icon} | ||
| /> | ||
| ์ด๋ํ๊ธฐ | ||
| </Button> | ||
| </div> | ||
| {Component && ( | ||
| <div> | ||
| <Component /> | ||
| </div> | ||
| )} | ||
| <div className={styles.userInfoContainer}> | ||
| <div className={styles.userInfoWrapper}> | ||
| <UserInfo /> | ||
| </div> | ||
|
Owner
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. userInfoContainer, userInfoWrapper ๋๋ค display: flex;
align-items: center;์ด ์์ฑ์ ๊ฐ์ง๊ณ ์๋๋ฐ ์ด๋ ๊ฒ ํ์ ์ด์ ๊ฐ ๋ญ๊ฐ์?
Collaborator
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. @najitwo ์ด๊ฒ.. ์ ๊ฐ ํ์ดํ๋ผ์ธ ์ ๊ฑฐ๋ฅผ ๋ฐ๋ก ํ๊ทธ์์ ์ถ๊ฐ์ํ๊ณ before ๊ฐ์ํด๋์ค ์ฌ์ฉํด์ ํ์๋ฅผ ํ๊ณ ์ถ์๋๋ฐ
Owner
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. ์ค... ์ง์ ํ๋๊ฑฐ ์๋๋ฉด ๊ฐ์ด ์์กํ๋ค์ ใ
ใ
ใ
ใ
|
||
| </div> | ||
| </header> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| .image { | ||
| border-radius: 50%; | ||
| object-fit: cover; | ||
| } | ||
|
|
||
| .userInfo { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 15px; | ||
| } | ||
|
|
||
| .userIcon { | ||
| width: 30px; | ||
| height: 30px; | ||
| border-radius: 50%; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .nickname { | ||
| color: var(--black-100); | ||
| font-size: 16px; | ||
| font-weight: 500; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| 'use client'; | ||
|
|
||
| import type { User } from '@/app/(with-header-sidebar)/mydashboard/types/user'; | ||
| import styles from './UserInfo.module.css'; | ||
|
Collaborator
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. ์ ๋ ์๋ก๊ฐ๋ค.. ๋ด์ ๋์ค์ ๋ด๋ฆด๊ฒ์~! |
||
| import Image from 'next/image'; | ||
| import useWindowSize from '@/app/(with-header-sidebar)/mydashboard/hooks/useWindowSize'; | ||
| import { useState, useEffect } from 'react'; | ||
| import UserInfoSkeleton from './skeleton/UserInfoSkeleton'; | ||
|
|
||
| const user: User = { | ||
| id: 1, | ||
| email: '[email protected]', | ||
| nickname: 'heejin', | ||
| // profileImageUrl: | ||
| // 'https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/taskify/profile_image/10-1_4804_1731757528194.jpeg', | ||
| profileImageUrl: null, | ||
| createdAt: '2024-11-15T14:29:07.482Z', | ||
| }; | ||
|
|
||
| export default function UserInfo() { | ||
| const { email, nickname, profileImageUrl } = user; | ||
| const { isMobile } = useWindowSize(); | ||
|
|
||
| const [colors, setColors] = useState<{ | ||
| randomColor: string; | ||
| invertedColor: string; | ||
| } | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| const { randomColor, invertedColor } = getRandomColor(); | ||
| setColors({ randomColor, invertedColor }); | ||
| }, []); | ||
|
|
||
| if (!colors) { | ||
| return <UserInfoSkeleton />; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| {profileImageUrl ? ( | ||
| <Image | ||
| src={profileImageUrl} | ||
| alt="ํ๋กํ ์ด๋ฏธ์ง" | ||
| width={30} | ||
| height={30} | ||
| className={styles.image} | ||
| /> | ||
| ) : ( | ||
| <div className={styles.userInfo}> | ||
| <div | ||
| style={{ | ||
| backgroundColor: colors.randomColor, | ||
| color: colors.invertedColor, | ||
| }} | ||
| className={styles.userIcon} | ||
| > | ||
| <span>{email[0].toUpperCase()}</span> | ||
| </div> | ||
| {!isMobile && <span className={styles.nickname}>{nickname}</span>} | ||
| </div> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| function getRandomColor() { | ||
| const randomColor = `#${Math.floor(Math.random() * 16777215).toString(16)}`; | ||
|
|
||
| const r = parseInt(randomColor.slice(1, 3), 16); | ||
| const g = parseInt(randomColor.slice(3, 5), 16); | ||
| const b = parseInt(randomColor.slice(5, 7), 16); | ||
|
|
||
| const invertedColor = `rgb(${255 - r}, ${255 - g}, ${255 - b})`; | ||
|
|
||
| return { randomColor, invertedColor }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| .userIcon { | ||
| width: 30px; | ||
| height: 30px; | ||
| border-radius: 50%; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| background-color: var(--gray-300); | ||
| } | ||
|
|
||
| @media screen and (min-width: 768px) { | ||
| .userInfo { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 15px; | ||
| } | ||
|
|
||
| .nickname { | ||
| background-color: var(--gray-300); | ||
| width: 45px; | ||
| height: 20px; | ||
| } | ||
| } |
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.
@21ow ์ง์ค๋ ์ด๊ฑฐ ์ ๊ฐ ์ถ๊ฐํด๋์๊ฒ์ ์์ง ๋์๋ณด๋์ชฝ์์ ์ํ์ ๊ฒ๊ฐ์์
์ผ์ชฝ ์์ด์ฝ ๋๋ฅด๋ฉด ๋์๋ณด๋ ํ๋ฉด ์๋จ๋ ํ ์คํธ์ฉ์ผ๋ก ๋ก์ปฌ์์๋ง ์ผ์๋๋ฐ ์๊ฑฐ ๊ฐ์ ธ๋ค ์ฐ์๋ฉด ๋ ๊ฒ๊ฐ์ต๋๋ค!