Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
e76509a5
Commit
e76509a5
authored
Nov 08, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update header menu style in mobile view
parent
4499f45b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
76 deletions
+69
-76
Header.tsx
web/src/components/Header.tsx
+23
-60
HeaderDrawer.tsx
web/src/components/HeaderDrawer.tsx
+37
-0
MobileHeader.tsx
web/src/components/MobileHeader.tsx
+4
-2
Root.tsx
web/src/layouts/Root.tsx
+3
-1
layout.ts
web/src/store/module/layout.ts
+1
-4
layout.ts
web/src/store/reducer/layout.ts
+1
-9
No files found.
web/src/components/Header.tsx
View file @
e76509a5
import
classNames
from
"classnames"
;
import
classNames
from
"classnames"
;
import
{
useEffect
}
from
"react"
;
import
{
useEffect
}
from
"react"
;
import
{
NavLink
,
useLocation
}
from
"react-router-dom"
;
import
{
NavLink
}
from
"react-router-dom"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
{
useLayoutStore
}
from
"@/store/module"
;
import
{
useInboxStore
}
from
"@/store/v1"
;
import
{
useInboxStore
}
from
"@/store/v1"
;
import
{
Inbox_Status
}
from
"@/types/proto/api/v2/inbox_service"
;
import
{
Inbox_Status
}
from
"@/types/proto/api/v2/inbox_service"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
resolution
}
from
"@/utils/layout"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
import
UserBanner
from
"./UserBanner"
;
import
UserBanner
from
"./UserBanner"
;
...
@@ -19,11 +17,8 @@ interface NavLinkItem {
...
@@ -19,11 +17,8 @@ interface NavLinkItem {
const
Header
=
()
=>
{
const
Header
=
()
=>
{
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
location
=
useLocation
();
const
layoutStore
=
useLayoutStore
();
const
user
=
useCurrentUser
();
const
user
=
useCurrentUser
();
const
inboxStore
=
useInboxStore
();
const
inboxStore
=
useInboxStore
();
const
showHeader
=
layoutStore
.
state
.
showHeader
;
const
hasUnreadInbox
=
inboxStore
.
inboxes
.
some
((
inbox
)
=>
inbox
.
status
===
Inbox_Status
.
UNREAD
);
const
hasUnreadInbox
=
inboxStore
.
inboxes
.
some
((
inbox
)
=>
inbox
.
status
===
Inbox_Status
.
UNREAD
);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -42,22 +37,6 @@ const Header = () => {
...
@@ -42,22 +37,6 @@ const Header = () => {
};
};
},
[]);
},
[]);
useEffect
(()
=>
{
const
handleWindowResize
=
()
=>
{
if
(
window
.
innerWidth
<
resolution
.
sm
)
{
layoutStore
.
setHeaderStatus
(
false
);
}
else
{
layoutStore
.
setHeaderStatus
(
true
);
}
};
handleWindowResize
();
window
.
addEventListener
(
"resize"
,
handleWindowResize
);
return
()
=>
{
window
.
removeEventListener
(
"resize"
,
handleWindowResize
);
};
},
[
location
]);
const
homeNavLink
:
NavLinkItem
=
{
const
homeNavLink
:
NavLinkItem
=
{
id
:
"header-home"
,
id
:
"header-home"
,
path
:
"/"
,
path
:
"/"
,
...
@@ -119,22 +98,7 @@ const Header = () => {
...
@@ -119,22 +98,7 @@ const Header = () => {
:
[
exploreNavLink
,
signInNavLink
];
:
[
exploreNavLink
,
signInNavLink
];
return
(
return
(
<
div
<
header
className=
{
`w-full h-full overflow-auto flex flex-col justify-start items-start py-4 z-30`
}
>
className=
{
`fixed sm:sticky top-0 left-0 w-full sm:w-56 h-screen shrink-0 pointer-events-none sm:pointer-events-auto z-10 ${
showHeader && "pointer-events-auto"
}`
}
>
<
div
className=
{
`fixed top-0 left-0 w-full h-full max-h-screen opacity-0 pointer-events-none transition-opacity duration-300 sm:!hidden ${
showHeader && "opacity-60 pointer-events-auto"
}`
}
onClick=
{
()
=>
layoutStore
.
setHeaderStatus
(
false
)
}
></
div
>
<
header
className=
{
`relative w-56 sm:w-full h-full max-h-screen border-r sm:border-none dark:border-r-zinc-700 overflow-auto hide-scrollbar flex flex-col justify-start items-start py-4 z-30 bg-zinc-100 dark:bg-zinc-800 sm:bg-transparent sm:shadow-none transition-all duration-300 -translate-x-full sm:translate-x-0 ${
showHeader && "translate-x-0 shadow-2xl"
}`
}
>
<
UserBanner
/>
<
UserBanner
/>
<
div
className=
"w-full px-2 py-2 flex flex-col justify-start items-start shrink-0 space-y-2"
>
<
div
className=
"w-full px-2 py-2 flex flex-col justify-start items-start shrink-0 space-y-2"
>
{
navLinks
.
map
((
navLink
)
=>
(
{
navLinks
.
map
((
navLink
)
=>
(
...
@@ -156,7 +120,6 @@ const Header = () => {
...
@@ -156,7 +120,6 @@ const Header = () => {
))
}
))
}
</
div
>
</
div
>
</
header
>
</
header
>
</
div
>
);
);
};
};
...
...
web/src/components/HeaderDrawer.tsx
0 → 100644
View file @
e76509a5
import
{
Drawer
,
IconButton
}
from
"@mui/joy"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useLocation
}
from
"react-router-dom"
;
import
Header
from
"./Header"
;
import
Icon
from
"./Icon"
;
const
HeaderDrawer
=
()
=>
{
const
location
=
useLocation
();
const
[
open
,
setOpen
]
=
useState
(
false
);
useEffect
(()
=>
{
setOpen
(
false
);
},
[
location
.
pathname
]);
const
toggleDrawer
=
(
inOpen
:
boolean
)
=>
(
event
:
React
.
KeyboardEvent
|
React
.
MouseEvent
)
=>
{
if
(
event
.
type
===
"keydown"
&&
((
event
as
React
.
KeyboardEvent
).
key
===
"Tab"
||
(
event
as
React
.
KeyboardEvent
).
key
===
"Shift"
))
{
return
;
}
setOpen
(
inOpen
);
};
return
(
<
div
>
<
IconButton
onClick=
{
toggleDrawer
(
true
)
}
>
<
Icon
.
Menu
className=
"w-5 h-auto dark:text-gray-200"
/>
</
IconButton
>
<
Drawer
anchor=
"left"
open=
{
open
}
onClose=
{
toggleDrawer
(
false
)
}
>
<
div
className=
"w-full px-4"
>
<
Header
/>
</
div
>
</
Drawer
>
</
div
>
);
};
export
default
HeaderDrawer
;
web/src/components/MobileHeader.tsx
View file @
e76509a5
import
{
useState
}
from
"react"
;
import
{
useState
}
from
"react"
;
import
{
useLayoutStore
}
from
"@/store/module"
;
import
{
useLayoutStore
}
from
"@/store/module"
;
import
HeaderDrawer
from
"./HeaderDrawer"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
interface
Props
{
interface
Props
{
...
@@ -14,12 +15,13 @@ const MobileHeader = (props: Props) => {
...
@@ -14,12 +15,13 @@ const MobileHeader = (props: Props) => {
return
(
return
(
<
div
className=
"sticky top-0 pt-4 sm:pt-1 pb-1 mb-1 backdrop-blur bg-zinc-100 dark:bg-zinc-800 bg-opacity-70 flex @lg:hidden flex-row justify-between items-center w-full h-auto flex-nowrap shrink-0 z-2"
>
<
div
className=
"sticky top-0 pt-4 sm:pt-1 pb-1 mb-1 backdrop-blur bg-zinc-100 dark:bg-zinc-800 bg-opacity-70 flex @lg:hidden flex-row justify-between items-center w-full h-auto flex-nowrap shrink-0 z-2"
>
<
div
className=
"flex flex-row justify-start items-center mr-2 shrink-0 overflow-hidden"
>
<
div
className=
"flex flex-row justify-start items-center mr-2 shrink-0 overflow-hidden"
>
<
div
{
/*
<div
className="flex sm:hidden flex-row justify-center items-center w-6 h-6 mr-1 shrink-0 bg-transparent"
className="flex sm:hidden flex-row justify-center items-center w-6 h-6 mr-1 shrink-0 bg-transparent"
onClick={() => layoutStore.setHeaderStatus(true)}
onClick={() => layoutStore.setHeaderStatus(true)}
>
>
<Icon.Menu className="w-5 h-auto dark:text-gray-200" />
<Icon.Menu className="w-5 h-auto dark:text-gray-200" />
</
div
>
</div> */
}
<
HeaderDrawer
/>
<
span
<
span
className=
"font-bold text-lg leading-10 mr-1 text-ellipsis shrink-0 cursor-pointer overflow-hidden text-gray-700 dark:text-gray-200"
className=
"font-bold text-lg leading-10 mr-1 text-ellipsis shrink-0 cursor-pointer overflow-hidden text-gray-700 dark:text-gray-200"
onClick=
{
()
=>
location
.
reload
()
}
onClick=
{
()
=>
location
.
reload
()
}
...
...
web/src/layouts/Root.tsx
View file @
e76509a5
...
@@ -9,7 +9,9 @@ function Root() {
...
@@ -9,7 +9,9 @@ function Root() {
<
DemoBanner
/>
<
DemoBanner
/>
</
div
>
</
div
>
<
div
className=
"w-full max-w-6xl mx-auto flex flex-row justify-center items-start sm:px-4"
>
<
div
className=
"w-full max-w-6xl mx-auto flex flex-row justify-center items-start sm:px-4"
>
<
div
className=
"hidden sm:block sticky top-0 left-0 w-56"
>
<
Header
/>
<
Header
/>
</
div
>
<
main
className=
"w-full min-h-screen sm:max-w-[calc(100%-14rem)] flex-grow shrink flex flex-col justify-start items-start"
>
<
main
className=
"w-full min-h-screen sm:max-w-[calc(100%-14rem)] flex-grow shrink flex flex-col justify-start items-start"
>
<
Outlet
/>
<
Outlet
/>
</
main
>
</
main
>
...
...
web/src/store/module/layout.ts
View file @
e76509a5
import
store
,
{
useAppSelector
}
from
".."
;
import
store
,
{
useAppSelector
}
from
".."
;
import
{
setH
eaderStatus
,
setH
omeSidebarStatus
}
from
"../reducer/layout"
;
import
{
setHomeSidebarStatus
}
from
"../reducer/layout"
;
export
const
useLayoutStore
=
()
=>
{
export
const
useLayoutStore
=
()
=>
{
const
state
=
useAppSelector
((
state
)
=>
state
.
layout
);
const
state
=
useAppSelector
((
state
)
=>
state
.
layout
);
...
@@ -8,9 +8,6 @@ export const useLayoutStore = () => {
...
@@ -8,9 +8,6 @@ export const useLayoutStore = () => {
getState
:
()
=>
{
getState
:
()
=>
{
return
store
.
getState
().
tag
;
return
store
.
getState
().
tag
;
},
},
setHeaderStatus
:
(
showHeader
:
boolean
)
=>
{
store
.
dispatch
(
setHeaderStatus
(
showHeader
));
},
setHomeSidebarStatus
:
(
showHomeSidebar
:
boolean
)
=>
{
setHomeSidebarStatus
:
(
showHomeSidebar
:
boolean
)
=>
{
store
.
dispatch
(
setHomeSidebarStatus
(
showHomeSidebar
));
store
.
dispatch
(
setHomeSidebarStatus
(
showHomeSidebar
));
},
},
...
...
web/src/store/reducer/layout.ts
View file @
e76509a5
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
interface
State
{
interface
State
{
showHeader
:
boolean
;
showHomeSidebar
:
boolean
;
showHomeSidebar
:
boolean
;
}
}
const
layoutSlice
=
createSlice
({
const
layoutSlice
=
createSlice
({
name
:
"layout"
,
name
:
"layout"
,
initialState
:
{
initialState
:
{
showHeader
:
false
,
showHomeSidebar
:
false
,
showHomeSidebar
:
false
,
}
as
State
,
}
as
State
,
reducers
:
{
reducers
:
{
setHeaderStatus
:
(
state
,
action
:
PayloadAction
<
boolean
>
)
=>
{
return
{
...
state
,
showHeader
:
action
.
payload
,
};
},
setHomeSidebarStatus
:
(
state
,
action
:
PayloadAction
<
boolean
>
)
=>
{
setHomeSidebarStatus
:
(
state
,
action
:
PayloadAction
<
boolean
>
)
=>
{
return
{
return
{
...
state
,
...
state
,
...
@@ -27,6 +19,6 @@ const layoutSlice = createSlice({
...
@@ -27,6 +19,6 @@ const layoutSlice = createSlice({
},
},
});
});
export
const
{
setH
eaderStatus
,
setH
omeSidebarStatus
}
=
layoutSlice
.
actions
;
export
const
{
setHomeSidebarStatus
}
=
layoutSlice
.
actions
;
export
default
layoutSlice
.
reducer
;
export
default
layoutSlice
.
reducer
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment