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
0c52f1ee
Commit
0c52f1ee
authored
Jan 12, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak home style
parent
1994c20c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
21 deletions
+37
-21
HomeSidebar.tsx
web/src/components/HomeSidebar.tsx
+12
-2
HomeSidebarDrawer.tsx
web/src/components/HomeSidebarDrawer.tsx
+1
-1
TaskList.tsx
web/src/components/MemoContent/TaskList.tsx
+4
-0
index.tsx
web/src/components/MemoContent/index.tsx
+4
-4
context.ts
web/src/components/MemoContent/types/context.ts
+1
-3
NavigationDrawer.tsx
web/src/components/NavigationDrawer.tsx
+1
-1
Home.tsx
web/src/pages/Home.tsx
+14
-10
No files found.
web/src/components/HomeSidebar.tsx
View file @
0c52f1ee
import
classNames
from
"classnames"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
PersonalStatistics
from
"./PersonalStatistics"
;
import
PersonalStatistics
from
"./PersonalStatistics"
;
import
SearchBar
from
"./SearchBar"
;
import
SearchBar
from
"./SearchBar"
;
import
TagList
from
"./TagList"
;
import
TagList
from
"./TagList"
;
const
HomeSidebar
=
()
=>
{
interface
Props
{
className
?:
string
;
}
const
HomeSidebar
=
(
props
:
Props
)
=>
{
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
return
(
return
(
<
aside
className=
"relative w-full h-full max-h-screen overflow-auto hide-scrollbar flex flex-col justify-start items-start py-4 sm:pt-6"
>
<
aside
className=
{
classNames
(
"relative w-full h-auto max-h-screen overflow-auto hide-scrollbar flex flex-col justify-start items-start"
,
props
.
className
)
}
>
<
SearchBar
/>
<
SearchBar
/>
<
PersonalStatistics
user=
{
currentUser
}
/>
<
PersonalStatistics
user=
{
currentUser
}
/>
<
TagList
/>
<
TagList
/>
...
...
web/src/components/HomeSidebarDrawer.tsx
View file @
0c52f1ee
...
@@ -27,7 +27,7 @@ const HomeSidebarDrawer = () => {
...
@@ -27,7 +27,7 @@ const HomeSidebarDrawer = () => {
</
IconButton
>
</
IconButton
>
<
Drawer
anchor=
"right"
size=
"sm"
open=
{
open
}
onClose=
{
toggleDrawer
(
false
)
}
>
<
Drawer
anchor=
"right"
size=
"sm"
open=
{
open
}
onClose=
{
toggleDrawer
(
false
)
}
>
<
div
className=
"w-full h-full px-5 bg-zinc-100 dark:bg-zinc-900"
>
<
div
className=
"w-full h-full px-5 bg-zinc-100 dark:bg-zinc-900"
>
<
HomeSidebar
/>
<
HomeSidebar
className=
"py-4"
/>
</
div
>
</
div
>
</
Drawer
>
</
Drawer
>
</>
</>
...
...
web/src/components/MemoContent/TaskList.tsx
View file @
0c52f1ee
...
@@ -17,6 +17,10 @@ const TaskList: React.FC<Props> = ({ index, complete, children }: Props) => {
...
@@ -17,6 +17,10 @@ const TaskList: React.FC<Props> = ({ index, complete, children }: Props) => {
const
memoStore
=
useMemoStore
();
const
memoStore
=
useMemoStore
();
const
handleCheckboxChange
=
async
(
on
:
boolean
)
=>
{
const
handleCheckboxChange
=
async
(
on
:
boolean
)
=>
{
if
(
context
.
readonly
||
!
context
.
memoId
)
{
return
;
}
const
nodeIndex
=
Number
(
index
);
const
nodeIndex
=
Number
(
index
);
if
(
isNaN
(
nodeIndex
))
{
if
(
isNaN
(
nodeIndex
))
{
return
;
return
;
...
...
web/src/components/MemoContent/index.tsx
View file @
0c52f1ee
...
@@ -6,8 +6,8 @@ import Renderer from "./Renderer";
...
@@ -6,8 +6,8 @@ import Renderer from "./Renderer";
import
{
RendererContext
}
from
"./types"
;
import
{
RendererContext
}
from
"./types"
;
interface
Props
{
interface
Props
{
memoId
:
number
;
nodes
:
Node
[];
nodes
:
Node
[];
memoId
?:
number
;
readonly
?:
boolean
;
readonly
?:
boolean
;
className
?:
string
;
className
?:
string
;
onMemoContentClick
?:
(
e
:
React
.
MouseEvent
)
=>
void
;
onMemoContentClick
?:
(
e
:
React
.
MouseEvent
)
=>
void
;
...
@@ -18,7 +18,7 @@ const MemoContent: React.FC<Props> = (props: Props) => {
...
@@ -18,7 +18,7 @@ const MemoContent: React.FC<Props> = (props: Props) => {
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
memoStore
=
useMemoStore
();
const
memoStore
=
useMemoStore
();
const
memoContentContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
memoContentContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
allowEdit
=
currentUser
?.
id
===
memoStore
.
getMemoById
(
memoId
)?.
creatorId
&&
!
props
.
readonly
;
const
allowEdit
=
!
props
.
readonly
&&
memoId
&&
currentUser
?.
id
===
memoStore
.
getMemoById
(
memoId
)?.
creatorId
;
const
handleMemoContentClick
=
async
(
e
:
React
.
MouseEvent
)
=>
{
const
handleMemoContentClick
=
async
(
e
:
React
.
MouseEvent
)
=>
{
if
(
onMemoContentClick
)
{
if
(
onMemoContentClick
)
{
...
@@ -32,15 +32,15 @@ const MemoContent: React.FC<Props> = (props: Props) => {
...
@@ -32,15 +32,15 @@ const MemoContent: React.FC<Props> = (props: Props) => {
return
(
return
(
<
RendererContext
.
Provider
<
RendererContext
.
Provider
value=
{
{
value=
{
{
memoId
,
nodes
,
nodes
,
memoId
,
readonly
:
!
allowEdit
,
readonly
:
!
allowEdit
,
}
}
}
}
>
>
<
div
className=
{
`w-full flex flex-col justify-start items-start text-gray-800 dark:text-gray-300 ${className || ""}`
}
>
<
div
className=
{
`w-full flex flex-col justify-start items-start text-gray-800 dark:text-gray-300 ${className || ""}`
}
>
<
div
<
div
ref=
{
memoContentContainerRef
}
ref=
{
memoContentContainerRef
}
className=
"w-full max-w-full word-break text-base leading-6 space-y-1"
className=
"w-full max-w-full word-break text-base leading-6 space-y-1
whitespace-pre-wrap
"
onClick=
{
handleMemoContentClick
}
onClick=
{
handleMemoContentClick
}
>
>
{
nodes
.
map
((
node
,
index
)
=>
{
{
nodes
.
map
((
node
,
index
)
=>
{
...
...
web/src/components/MemoContent/types/context.ts
View file @
0c52f1ee
import
{
createContext
}
from
"react"
;
import
{
createContext
}
from
"react"
;
import
{
UNKNOWN_ID
}
from
"@/helpers/consts"
;
import
{
Node
}
from
"@/types/proto/api/v2/markdown_service"
;
import
{
Node
}
from
"@/types/proto/api/v2/markdown_service"
;
interface
Context
{
interface
Context
{
memoId
:
number
;
nodes
:
Node
[];
nodes
:
Node
[];
memoId
?:
number
;
readonly
?:
boolean
;
readonly
?:
boolean
;
}
}
export
const
RendererContext
=
createContext
<
Context
>
({
export
const
RendererContext
=
createContext
<
Context
>
({
memoId
:
UNKNOWN_ID
,
nodes
:
[],
nodes
:
[],
});
});
web/src/components/NavigationDrawer.tsx
View file @
0c52f1ee
...
@@ -26,7 +26,7 @@ const NavigationDrawer = () => {
...
@@ -26,7 +26,7 @@ const NavigationDrawer = () => {
<
Icon
.
Menu
className=
"w-5 h-auto dark:text-gray-400"
/>
<
Icon
.
Menu
className=
"w-5 h-auto dark:text-gray-400"
/>
</
IconButton
>
</
IconButton
>
<
Drawer
anchor=
"left"
size=
"sm"
open=
{
open
}
onClose=
{
toggleDrawer
(
false
)
}
>
<
Drawer
anchor=
"left"
size=
"sm"
open=
{
open
}
onClose=
{
toggleDrawer
(
false
)
}
>
<
div
className=
"w-full h-full px-4 bg-zinc-100 dark:bg-zinc-900"
>
<
div
className=
"w-full h-full
overflow-auto
px-4 bg-zinc-100 dark:bg-zinc-900"
>
<
Navigation
/>
<
Navigation
/>
</
div
>
</
div
>
</
Drawer
>
</
Drawer
>
...
...
web/src/pages/Home.tsx
View file @
0c52f1ee
...
@@ -61,10 +61,14 @@ const Home = () => {
...
@@ -61,10 +61,14 @@ const Home = () => {
};
};
return
(
return
(
<
div
className=
"w-full max-w-5xl sm:px-6 flex flex-row justify-center items-start sm:gap-6"
>
<
section
className=
"@container w-full max-w-5xl min-h-full flex flex-col justify-start items-center sm:pt-3 md:pt-6 pb-8"
>
<
div
className=
{
classNames
(
"w-full sm:pt-3 md:pt-6"
,
md
&&
"max-w-[calc(100%-14rem)]"
)
}
>
{
!
md
&&
(
<
MobileHeader
className=
"sm:px-0"
>
{
!
md
&&
<
HomeSidebarDrawer
/>
}
</
MobileHeader
>
<
MobileHeader
>
<
div
className=
"w-full px-4 sm:px-0"
>
<
HomeSidebarDrawer
/>
</
MobileHeader
>
)
}
<
div
className=
{
classNames
(
"w-full flex flex-row justify-start items-start px-4 sm:px-6 gap-6"
)
}
>
<
div
className=
"w-full"
>
<
MemoEditor
className=
"mb-2"
cacheKey=
"home-memo-editor"
/>
<
MemoEditor
className=
"mb-2"
cacheKey=
"home-memo-editor"
/>
<
div
className=
"flex flex-col justify-start items-start w-full max-w-full pb-28"
>
<
div
className=
"flex flex-col justify-start items-start w-full max-w-full pb-28"
>
<
MemoFilter
/>
<
MemoFilter
/>
...
@@ -91,13 +95,13 @@ const Home = () => {
...
@@ -91,13 +95,13 @@ const Home = () => {
)
}
)
}
</
div
>
</
div
>
</
div
>
</
div
>
{
md
&&
(
<
div
className=
"sticky top-0 left-0 shrink-0 -mt-6 w-56 h-full"
>
<
HomeSidebar
className=
"py-6"
/>
</
div
>
)
}
</
div
>
</
div
>
{
md
&&
(
</
section
>
<
div
className=
"sticky top-0 left-0 shrink-0 w-56 h-full"
>
<
HomeSidebar
/>
</
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