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
0ea06452
Commit
0ea06452
authored
Nov 10, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add use reponsive width
parent
9227ca5b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
11 deletions
+33
-11
HomeSidebarDrawer.tsx
web/src/components/HomeSidebarDrawer.tsx
+2
-2
MobileHeader.tsx
web/src/components/MobileHeader.tsx
+3
-1
NavigationDrawer.tsx
web/src/components/NavigationDrawer.tsx
+2
-2
useResponsiveWidth.ts
web/src/hooks/useResponsiveWidth.ts
+18
-0
Home.tsx
web/src/pages/Home.tsx
+8
-6
No files found.
web/src/components/HomeSidebarDrawer.tsx
View file @
0ea06452
...
@@ -21,7 +21,7 @@ const HomeSidebarDrawer = () => {
...
@@ -21,7 +21,7 @@ const HomeSidebarDrawer = () => {
};
};
return
(
return
(
<
div
className=
"md:hidden"
>
<>
<
IconButton
onClick=
{
toggleDrawer
(
true
)
}
>
<
IconButton
onClick=
{
toggleDrawer
(
true
)
}
>
<
Icon
.
Search
className=
"w-5 h-auto dark:text-gray-200"
/>
<
Icon
.
Search
className=
"w-5 h-auto dark:text-gray-200"
/>
</
IconButton
>
</
IconButton
>
...
@@ -30,7 +30,7 @@ const HomeSidebarDrawer = () => {
...
@@ -30,7 +30,7 @@ const HomeSidebarDrawer = () => {
<
HomeSidebar
/>
<
HomeSidebar
/>
</
div
>
</
div
>
</
Drawer
>
</
Drawer
>
</
div
>
</>
);
);
};
};
...
...
web/src/components/MobileHeader.tsx
View file @
0ea06452
import
{
useState
}
from
"react"
;
import
{
useState
}
from
"react"
;
import
useResponsiveWidth
from
"@/hooks/useResponsiveWidth"
;
import
NavigationDrawer
from
"./NavigationDrawer"
;
import
NavigationDrawer
from
"./NavigationDrawer"
;
interface
Props
{
interface
Props
{
...
@@ -7,12 +8,13 @@ interface Props {
...
@@ -7,12 +8,13 @@ interface Props {
const
MobileHeader
=
(
props
:
Props
)
=>
{
const
MobileHeader
=
(
props
:
Props
)
=>
{
const
{
children
}
=
props
;
const
{
children
}
=
props
;
const
{
sm
}
=
useResponsiveWidth
();
const
[
titleText
]
=
useState
(
"MEMOS"
);
const
[
titleText
]
=
useState
(
"MEMOS"
);
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 md: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 md: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"
>
<
NavigationDrawer
/>
{
!
sm
&&
<
NavigationDrawer
/>
}
<
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/components/NavigationDrawer.tsx
View file @
0ea06452
...
@@ -21,7 +21,7 @@ const NavigationDrawer = () => {
...
@@ -21,7 +21,7 @@ const NavigationDrawer = () => {
};
};
return
(
return
(
<
div
className=
"sm:hidden"
>
<>
<
IconButton
onClick=
{
toggleDrawer
(
true
)
}
>
<
IconButton
onClick=
{
toggleDrawer
(
true
)
}
>
<
Icon
.
Menu
className=
"w-5 h-auto dark:text-gray-200"
/>
<
Icon
.
Menu
className=
"w-5 h-auto dark:text-gray-200"
/>
</
IconButton
>
</
IconButton
>
...
@@ -30,7 +30,7 @@ const NavigationDrawer = () => {
...
@@ -30,7 +30,7 @@ const NavigationDrawer = () => {
<
Navigation
/>
<
Navigation
/>
</
div
>
</
div
>
</
Drawer
>
</
Drawer
>
</
div
>
</>
);
);
};
};
...
...
web/src/hooks/useResponsiveWidth.ts
0 → 100644
View file @
0ea06452
import
useWindowSize
from
"react-use/lib/useWindowSize"
;
enum
TailwindResponsiveWidth
{
sm
=
640
,
md
=
768
,
lg
=
1024
,
}
const
useResponsiveWidth
=
()
=>
{
const
{
width
}
=
useWindowSize
();
return
{
sm
:
width
>=
TailwindResponsiveWidth
.
sm
,
md
:
width
>=
TailwindResponsiveWidth
.
md
,
lg
:
width
>=
TailwindResponsiveWidth
.
lg
,
};
};
export
default
useResponsiveWidth
;
web/src/pages/Home.tsx
View file @
0ea06452
...
@@ -3,20 +3,22 @@ import HomeSidebarDrawer from "@/components/HomeSidebarDrawer";
...
@@ -3,20 +3,22 @@ import HomeSidebarDrawer from "@/components/HomeSidebarDrawer";
import
MemoEditor
from
"@/components/MemoEditor"
;
import
MemoEditor
from
"@/components/MemoEditor"
;
import
MemoList
from
"@/components/MemoList"
;
import
MemoList
from
"@/components/MemoList"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
useResponsiveWidth
from
"@/hooks/useResponsiveWidth"
;
const
Home
=
()
=>
{
const
Home
=
()
=>
{
const
{
md
}
=
useResponsiveWidth
();
return
(
return
(
<
div
className=
"w-full flex flex-row justify-start items-start"
>
<
div
className=
"w-full flex flex-row justify-start items-start"
>
<
div
className=
"w-full px-4 md:max-w-[calc(100%-14rem)] sm:px-2 sm:pt-4"
>
<
div
className=
"w-full px-4 md:max-w-[calc(100%-14rem)] sm:px-2 sm:pt-4"
>
<
MobileHeader
>
<
MobileHeader
>
{
!
md
&&
<
HomeSidebarDrawer
/>
}
</
MobileHeader
>
<
HomeSidebarDrawer
/>
</
MobileHeader
>
<
MemoEditor
className=
"mb-2"
cacheKey=
"home-memo-editor"
/>
<
MemoEditor
className=
"mb-2"
cacheKey=
"home-memo-editor"
/>
<
MemoList
/>
<
MemoList
/>
</
div
>
</
div
>
<
div
className=
"hidden md:block sticky top-0 left-0 w-56"
>
{
md
&&
(
<
HomeSidebar
/>
<
div
className=
"hidden md:block sticky top-0 left-0 w-56"
>
</
div
>
<
HomeSidebar
/>
</
div
>
)
}
</
div
>
</
div
>
);
);
};
};
...
...
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