Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebFront
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebFront
Commits
3f31ecaf
Commit
3f31ecaf
authored
5 months ago
by
석찬 윤
Browse files
Options
Downloads
Patches
Plain Diff
feat: 로그인 상태에 따른 헤딩바 변형 (
#10
)
parent
628a44e1
No related branches found
No related tags found
1 merge request
!8
[#10] 로그인 페이지 개발
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/layout/HeaderLogoBar.jsx
+13
-1
13 additions, 1 deletion
src/components/layout/HeaderLogoBar.jsx
src/components/layout/HeaderNav.jsx
+25
-17
25 additions, 17 deletions
src/components/layout/HeaderNav.jsx
src/store/authStore.js
+1
-0
1 addition, 0 deletions
src/store/authStore.js
with
39 additions
and
18 deletions
src/components/layout/HeaderLogoBar.jsx
+
13
−
1
View file @
3f31ecaf
import
React
from
"
react
"
;
import
LogoIcon
from
"
../icons/LogoIcon
"
;
import
useAuthStore
from
"
../../store/authStore
"
;
const
HeaderLogoBar
=
()
=>
{
const
{
user
}
=
useAuthStore
();
// Zustand에서 user 상태 가져오기
return
(
<
div
className
=
"flex items-center justify-start w-full h-16 px-4 bg-white"
>
<
div
className
=
"flex items-center justify-between w-full h-16 px-4 bg-white"
>
{
/* 왼쪽: 로고와 앱 이름 */
}
<
div
className
=
"flex items-center"
>
<
LogoIcon
width
=
{
32
}
height
=
{
32
}
/>
<
span
className
=
"title-1"
>
YANAWA
</
span
>
</
div
>
{
/* 오른쪽: 사용자 이름 */
}
<
div
className
=
"flex items-center"
>
<
span
className
=
"text-gray-600 label-1"
>
{
user
?
`
${
user
.
name
}
`
:
"
guest
"
}
님
</
span
>
</
div
>
</
div
>
);
};
...
...
This diff is collapsed.
Click to expand it.
src/components/layout/HeaderNav.jsx
+
25
−
17
View file @
3f31ecaf
...
...
@@ -2,10 +2,12 @@ import React, { useState, useEffect } from "react";
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
Button
from
"
../Button
"
;
import
LogoIcon
from
"
../icons/LogoIcon
"
;
import
useAuthStore
from
"
../../store/authStore
"
;
export
default
function
HeaderNav
()
{
const
navigate
=
useNavigate
();
const
[
isMobile
,
setIsMobile
]
=
useState
(
false
);
const
{
user
}
=
useAuthStore
();
// Zustand에서 user 상태 가져오기
useEffect
(()
=>
{
const
checkMobile
=
()
=>
setIsMobile
(
window
.
innerWidth
<=
768
);
...
...
@@ -18,6 +20,7 @@ export default function HeaderNav() {
const
navigateToHome
=
()
=>
navigate
(
"
/
"
);
const
navigateToChattingList
=
()
=>
navigate
(
"
/chattinglist
"
);
const
navigateToLogin
=
()
=>
navigate
(
"
/login
"
);
const
navigateToMyPage
=
()
=>
navigate
(
"
/mypage
"
);
return
(
<
header
className
=
"bg-white shadow-md"
>
...
...
@@ -47,20 +50,14 @@ export default function HeaderNav() {
size
=
"icon"
theme
=
"black"
icon
=
{
<
LogoIcon
fillColor
=
"#ffffff"
/>
}
onClick
=
{
navigateToLogin
}
onClick
=
{
user
?
navigateToMyPage
:
navigateToLogin
}
// 조건부 이동
/>
</>
)
:
(
<>
<
Button
size
=
"icon"
theme
=
"pink"
icon
=
{
<
LogoIcon
fillColor
=
"#ffffff"
/>
}
onClick
=
{
navigateToHome
}
/>
<
Button
size
=
"lg"
theme
=
"p
urple
"
theme
=
"p
ink
"
icon
=
{
<
LogoIcon
fillColor
=
"#ffffff"
/>
}
onClick
=
{
navigateToHome
}
>
...
...
@@ -68,7 +65,7 @@ export default function HeaderNav() {
</
Button
>
<
Button
size
=
"lg"
theme
=
"
indigo
"
theme
=
"
purple
"
icon
=
{
<
LogoIcon
fillColor
=
"#ffffff"
/>
}
onClick
=
{
navigateToTimeTable
}
>
...
...
@@ -82,14 +79,25 @@ export default function HeaderNav() {
>
번개채팅방
</
Button
>
<
Button
size
=
"lg"
theme
=
"black"
icon
=
{
<
LogoIcon
fillColor
=
"#ffffff"
/>
}
onClick
=
{
navigateToLogin
}
>
로그인
</
Button
>
{
user
?
(
<
Button
size
=
"lg"
theme
=
"black"
icon
=
{
<
LogoIcon
fillColor
=
"#ffffff"
/>
}
onClick
=
{
navigateToMyPage
}
>
마이페이지
</
Button
>
)
:
(
<
Button
size
=
"lg"
theme
=
"black"
icon
=
{
<
LogoIcon
fillColor
=
"#ffffff"
/>
}
onClick
=
{
navigateToLogin
}
>
로그인
</
Button
>
)
}
</>
)
}
</
div
>
...
...
This diff is collapsed.
Click to expand it.
src/store/authStore.js
+
1
−
0
View file @
3f31ecaf
...
...
@@ -3,6 +3,7 @@ import { getSessionInfo, logout } from "../api/auth";
const
useAuthStore
=
create
((
set
)
=>
({
user
:
null
,
// 사용자 정보
// user: { name: "윤석찬", email: "ysc0731@ajou.ac.kr" }, // 사용자 정보
// 세션 정보 가져오기
fetchSession
:
async
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment