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
6d7186fc
Commit
6d7186fc
authored
Jan 17, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: rebuild timeline page
parent
e4488da9
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
199 additions
and
119 deletions
+199
-119
ActivityCalendar.tsx
web/src/components/ActivityCalendar.tsx
+66
-0
MemoView.tsx
web/src/components/MemoView.tsx
+4
-3
TimelineMemo.tsx
web/src/components/TimelineMemo.tsx
+0
-28
Explore.tsx
web/src/pages/Explore.tsx
+1
-1
Home.tsx
web/src/pages/Home.tsx
+1
-1
Inboxes.tsx
web/src/pages/Inboxes.tsx
+3
-2
Resources.tsx
web/src/pages/Resources.tsx
+3
-2
Timeline.tsx
web/src/pages/Timeline.tsx
+120
-81
UserProfile.tsx
web/src/pages/UserProfile.tsx
+1
-1
No files found.
web/src/components/ActivityCalendar.tsx
0 → 100644
View file @
6d7186fc
import
{
Tooltip
}
from
"@mui/joy"
;
import
classNames
from
"classnames"
;
interface
Props
{
// Format: 2021-1
month
:
string
;
data
:
Record
<
string
,
number
>
;
}
const
getBgColor
=
(
count
:
number
,
maxCount
:
number
)
=>
{
if
(
count
===
0
)
{
return
"bg-gray-100 dark:bg-gray-700"
;
}
const
ratio
=
count
/
maxCount
;
if
(
ratio
>
0.7
)
{
return
"bg-blue-600"
;
}
else
if
(
ratio
>
0.5
)
{
return
"bg-blue-400"
;
}
else
if
(
ratio
>
0.3
)
{
return
"bg-blue-300"
;
}
else
{
return
"bg-blue-200"
;
}
};
const
ActivityCalendar
=
(
props
:
Props
)
=>
{
const
{
month
:
monthStr
,
data
}
=
props
;
const
[
year
,
month
]
=
monthStr
.
split
(
"-"
);
const
dayInMonth
=
new
Date
(
Number
(
year
),
Number
(
month
),
0
).
getDate
();
const
firstDay
=
new
Date
(
Number
(
year
),
Number
(
month
)
-
1
,
1
).
getDay
();
const
lastDay
=
new
Date
(
Number
(
year
),
Number
(
month
)
-
1
,
dayInMonth
).
getDay
();
const
maxCount
=
Math
.
max
(...
Object
.
values
(
data
));
const
days
=
[];
for
(
let
i
=
0
;
i
<
firstDay
;
i
++
)
{
days
.
push
(
0
);
}
for
(
let
i
=
1
;
i
<=
dayInMonth
;
i
++
)
{
days
.
push
(
i
);
}
for
(
let
i
=
0
;
i
<
6
-
lastDay
;
i
++
)
{
days
.
push
(
0
);
}
return
(
<
div
className=
"w-28 h-20 p-0.5 shrink-0 grid grid-cols-7 grid-flow-row gap-1"
>
{
days
.
map
((
day
,
index
)
=>
{
const
date
=
`${year}-${month}-${day}`
;
const
count
=
data
[
date
]
||
0
;
return
day
?
(
<
Tooltip
className=
"shrink-0"
key=
{
`${date}-${index}`
}
title=
{
`${count} memos in ${date}`
}
placement=
"top"
>
<
div
className=
{
classNames
(
"w-3 h-3 rounded flex justify-center items-center"
,
getBgColor
(
count
,
maxCount
))
}
></
div
>
</
Tooltip
>
)
:
(
<
div
key=
{
`${date}-${index}`
}
className=
{
classNames
(
"shrink-0 opacity-30 w-3 h-3 rounded flex justify-center items-center"
,
getBgColor
(
count
,
maxCount
))
}
></
div
>
);
})
}
</
div
>
);
};
export
default
ActivityCalendar
;
web/src/components/MemoView.tsx
View file @
6d7186fc
import
{
Divider
,
Tooltip
}
from
"@mui/joy"
;
import
{
Divider
,
Tooltip
}
from
"@mui/joy"
;
import
classNames
from
"classnames"
;
import
copy
from
"copy-to-clipboard"
;
import
copy
from
"copy-to-clipboard"
;
import
{
memo
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
memo
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
toast
}
from
"react-hot-toast"
;
...
@@ -30,13 +31,13 @@ import "@/less/memo.less";
...
@@ -30,13 +31,13 @@ import "@/less/memo.less";
interface
Props
{
interface
Props
{
memo
:
Memo
;
memo
:
Memo
;
showCreator
?:
boolean
;
showCreator
?:
boolean
;
showParent
?:
boolean
;
showVisibility
?:
boolean
;
showVisibility
?:
boolean
;
showPinnedStyle
?:
boolean
;
showPinnedStyle
?:
boolean
;
className
?:
string
;
}
}
const
MemoView
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
MemoView
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
memo
}
=
props
;
const
{
memo
,
className
}
=
props
;
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
navigateTo
=
useNavigateTo
();
const
navigateTo
=
useNavigateTo
();
const
{
i18n
}
=
useTranslation
();
const
{
i18n
}
=
useTranslation
();
...
@@ -165,7 +166,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -165,7 +166,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
return
(
return
(
<
div
<
div
className=
{
`group memo-wrapper ${"memos-" + memo.id} ${memo.pinned && props.showPinnedStyle ? "pinned" : ""}`
}
className=
{
classNames
(
"group memo-wrapper"
,
"memos-"
+
memo
.
id
,
memo
.
pinned
&&
props
.
showPinnedStyle
?
"pinned"
:
""
,
className
)
}
ref=
{
memoContainerRef
}
ref=
{
memoContainerRef
}
>
>
<
div
className=
"memo-top-wrapper mb-1"
>
<
div
className=
"memo-top-wrapper mb-1"
>
...
...
web/src/components/TimelineMemo.tsx
deleted
100644 → 0
View file @
e4488da9
import
MemoContent
from
"@/components/MemoContent"
;
import
MemoResourceListView
from
"@/components/MemoResourceListView"
;
import
{
getTimeString
}
from
"@/helpers/datetime"
;
import
{
MemoRelation_Type
}
from
"@/types/proto/api/v2/memo_relation_service"
;
import
{
Memo
}
from
"@/types/proto/api/v2/memo_service"
;
import
MemoRelationListView
from
"./MemoRelationListView"
;
interface
Props
{
memo
:
Memo
;
}
const
TimelineMemo
=
(
props
:
Props
)
=>
{
const
{
memo
}
=
props
;
const
relations
=
memo
.
relations
.
filter
((
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
REFERENCE
);
return
(
<
div
className=
"relative w-full flex flex-col justify-start items-start"
>
<
div
className=
"w-full flex flex-row justify-start items-center mt-0.5 mb-1 text-sm font-mono text-gray-500 dark:text-gray-400"
>
<
span
className=
"opacity-80"
>
{
getTimeString
(
memo
.
displayTime
)
}
</
span
>
</
div
>
<
MemoContent
memoId=
{
memo
.
id
}
nodes=
{
memo
.
nodes
}
/>
<
MemoResourceListView
resourceList=
{
memo
.
resources
}
/>
<
MemoRelationListView
memo=
{
memo
}
relationList=
{
relations
}
/>
</
div
>
);
};
export
default
TimelineMemo
;
web/src/pages/Explore.tsx
View file @
6d7186fc
...
@@ -56,7 +56,7 @@ const Explore = () => {
...
@@ -56,7 +56,7 @@ const Explore = () => {
<
div
className=
"relative w-full h-auto flex flex-col justify-start items-start px-4 sm:px-6"
>
<
div
className=
"relative w-full h-auto flex flex-col justify-start items-start px-4 sm:px-6"
>
<
MemoFilter
/>
<
MemoFilter
/>
{
sortedMemos
.
map
((
memo
)
=>
(
{
sortedMemos
.
map
((
memo
)
=>
(
<
MemoView
key=
{
memo
.
id
}
memo=
{
memo
}
showCreator
showParent
/>
<
MemoView
key=
{
memo
.
id
}
memo=
{
memo
}
showCreator
/>
))
}
))
}
{
isRequesting
?
(
{
isRequesting
?
(
...
...
web/src/pages/Home.tsx
View file @
6d7186fc
...
@@ -73,7 +73,7 @@ const Home = () => {
...
@@ -73,7 +73,7 @@ const Home = () => {
<
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
/>
{
sortedMemos
.
map
((
memo
)
=>
(
{
sortedMemos
.
map
((
memo
)
=>
(
<
MemoView
key=
{
`${memo.id}-${memo.updateTime}`
}
memo=
{
memo
}
showVisibility
showPinnedStyle
showParent
/>
<
MemoView
key=
{
`${memo.id}-${memo.updateTime}`
}
memo=
{
memo
}
showVisibility
showPinnedStyle
/>
))
}
))
}
{
isRequesting
?
(
{
isRequesting
?
(
<
div
className=
"flex flex-col justify-start items-center w-full my-4"
>
<
div
className=
"flex flex-col justify-start items-center w-full my-4"
>
...
...
web/src/pages/Inboxes.tsx
View file @
6d7186fc
...
@@ -25,8 +25,9 @@ const Inboxes = () => {
...
@@ -25,8 +25,9 @@ const Inboxes = () => {
<
div
className=
"w-full px-4 sm:px-6"
>
<
div
className=
"w-full px-4 sm:px-6"
>
<
div
className=
"w-full shadow flex flex-col justify-start items-start px-4 py-3 rounded-xl bg-white dark:bg-zinc-800 text-black dark:text-gray-300"
>
<
div
className=
"w-full shadow flex flex-col justify-start items-start px-4 py-3 rounded-xl bg-white dark:bg-zinc-800 text-black dark:text-gray-300"
>
<
div
className=
"relative w-full flex flex-row justify-between items-center"
>
<
div
className=
"relative w-full flex flex-row justify-between items-center"
>
<
p
className=
"px-2 py-1 flex flex-row justify-start items-center select-none opacity-80"
>
<
p
className=
"py-1 flex flex-row justify-start items-center select-none opacity-80"
>
<
Icon
.
Bell
className=
"w-5 h-auto mr-1"
/>
{
t
(
"common.inbox"
)
}
<
Icon
.
Bell
className=
"w-6 h-auto mr-1 opacity-80"
/>
<
span
className=
"text-lg"
>
{
t
(
"common.inbox"
)
}
</
span
>
</
p
>
</
p
>
</
div
>
</
div
>
<
div
className=
"w-full h-auto flex flex-col justify-start items-start px-2 pb-4"
>
<
div
className=
"w-full h-auto flex flex-col justify-start items-start px-2 pb-4"
>
...
...
web/src/pages/Resources.tsx
View file @
6d7186fc
...
@@ -71,8 +71,9 @@ const Resources = () => {
...
@@ -71,8 +71,9 @@ const Resources = () => {
<
div
className=
"w-full px-4 sm:px-6"
>
<
div
className=
"w-full px-4 sm:px-6"
>
<
div
className=
"w-full shadow flex flex-col justify-start items-start px-4 py-3 rounded-xl bg-white dark:bg-zinc-800 text-black dark:text-gray-300"
>
<
div
className=
"w-full shadow flex flex-col justify-start items-start px-4 py-3 rounded-xl bg-white dark:bg-zinc-800 text-black dark:text-gray-300"
>
<
div
className=
"relative w-full flex flex-row justify-between items-center"
>
<
div
className=
"relative w-full flex flex-row justify-between items-center"
>
<
p
className=
"px-2 py-1 flex flex-row justify-start items-center select-none opacity-80"
>
<
p
className=
"py-1 flex flex-row justify-start items-center select-none opacity-80"
>
<
Icon
.
Paperclip
className=
"w-5 h-auto mr-1"
/>
{
t
(
"common.resources"
)
}
<
Icon
.
Paperclip
className=
"w-6 h-auto mr-1 opacity-80"
/>
<
span
className=
"text-lg"
>
{
t
(
"common.resources"
)
}
</
span
>
</
p
>
</
p
>
<
div
>
<
div
>
<
Input
<
Input
...
...
web/src/pages/Timeline.tsx
View file @
6d7186fc
This diff is collapsed.
Click to expand it.
web/src/pages/UserProfile.tsx
View file @
6d7186fc
...
@@ -92,7 +92,7 @@ const UserProfile = () => {
...
@@ -92,7 +92,7 @@ const UserProfile = () => {
</
div
>
</
div
>
</
div
>
</
div
>
{
sortedMemos
.
map
((
memo
)
=>
(
{
sortedMemos
.
map
((
memo
)
=>
(
<
MemoView
key=
{
memo
.
id
}
memo=
{
memo
}
showVisibility
showPinnedStyle
showParent
/>
<
MemoView
key=
{
memo
.
id
}
memo=
{
memo
}
showVisibility
showPinnedStyle
/>
))
}
))
}
{
isRequesting
?
(
{
isRequesting
?
(
<
div
className=
"flex flex-col justify-start items-center w-full my-4"
>
<
div
className=
"flex flex-col justify-start items-center w-full my-4"
>
...
...
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