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
32123e0c
Unverified
Commit
32123e0c
authored
Oct 02, 2024
by
Xavier Hocquet
Committed by
GitHub
Oct 02, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add month toggle on hover (#3972)
* Add month toggle on hover * Lint
parent
4c0c7431
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
UserStatisticsView.tsx
web/src/components/UserStatisticsView.tsx
+29
-6
No files found.
web/src/components/UserStatisticsView.tsx
View file @
32123e0c
...
@@ -2,7 +2,17 @@ import { Divider, Tooltip } from "@mui/joy";
...
@@ -2,7 +2,17 @@ import { Divider, Tooltip } from "@mui/joy";
import
clsx
from
"clsx"
;
import
clsx
from
"clsx"
;
import
dayjs
from
"dayjs"
;
import
dayjs
from
"dayjs"
;
import
{
countBy
}
from
"lodash-es"
;
import
{
countBy
}
from
"lodash-es"
;
import
{
CalendarDaysIcon
,
CheckCircleIcon
,
Code2Icon
,
LinkIcon
,
ListTodoIcon
,
MoreVerticalIcon
,
RefreshCcwIcon
}
from
"lucide-react"
;
import
{
CalendarDaysIcon
,
CheckCircleIcon
,
ChevronLeftIcon
,
ChevronRightIcon
,
Code2Icon
,
LinkIcon
,
ListTodoIcon
,
MoreVerticalIcon
,
RefreshCcwIcon
,
}
from
"lucide-react"
;
import
{
useState
}
from
"react"
;
import
{
useState
}
from
"react"
;
import
toast
from
"react-hot-toast"
;
import
toast
from
"react-hot-toast"
;
import
{
memoServiceClient
}
from
"@/grpcweb"
;
import
{
memoServiceClient
}
from
"@/grpcweb"
;
...
@@ -31,7 +41,7 @@ const UserStatisticsView = () => {
...
@@ -31,7 +41,7 @@ const UserStatisticsView = () => {
const
[
memoStats
,
setMemoStats
]
=
useState
<
UserMemoStats
>
({
link
:
0
,
taskList
:
0
,
code
:
0
,
incompleteTasks
:
0
});
const
[
memoStats
,
setMemoStats
]
=
useState
<
UserMemoStats
>
({
link
:
0
,
taskList
:
0
,
code
:
0
,
incompleteTasks
:
0
});
const
[
activityStats
,
setActivityStats
]
=
useState
<
Record
<
string
,
number
>>
({});
const
[
activityStats
,
setActivityStats
]
=
useState
<
Record
<
string
,
number
>>
({});
const
[
selectedDate
]
=
useState
(
new
Date
());
const
[
selectedDate
]
=
useState
(
new
Date
());
const
[
monthString
,
set
MonthString
]
=
useState
(
dayjs
(
selectedDate
.
toDateString
()).
format
(
"YYYY-MM"
));
const
[
visibleMonthString
,
setVisible
MonthString
]
=
useState
(
dayjs
(
selectedDate
.
toDateString
()).
format
(
"YYYY-MM"
));
const
days
=
Math
.
ceil
((
Date
.
now
()
-
currentUser
.
createTime
!
.
getTime
())
/
86400000
);
const
days
=
Math
.
ceil
((
Date
.
now
()
-
currentUser
.
createTime
!
.
getTime
())
/
86400000
);
useAsyncEffect
(
async
()
=>
{
useAsyncEffect
(
async
()
=>
{
...
@@ -79,16 +89,24 @@ const UserStatisticsView = () => {
...
@@ -79,16 +89,24 @@ const UserStatisticsView = () => {
<
div
className=
"w-full mb-1 flex flex-row justify-between items-center"
>
<
div
className=
"w-full mb-1 flex flex-row justify-between items-center"
>
<
div
className=
"relative text-base font-medium leading-6 flex flex-row items-center dark:text-gray-400"
>
<
div
className=
"relative text-base font-medium leading-6 flex flex-row items-center dark:text-gray-400"
>
<
CalendarDaysIcon
className=
"w-5 h-auto mr-1 opacity-60"
strokeWidth=
{
1.5
}
/>
<
CalendarDaysIcon
className=
"w-5 h-auto mr-1 opacity-60"
strokeWidth=
{
1.5
}
/>
<
span
>
{
dayjs
(
m
onthString
).
toDate
().
toLocaleString
(
i18n
.
language
,
{
year
:
"numeric"
,
month
:
"long"
})
}
</
span
>
<
span
>
{
dayjs
(
visibleM
onthString
).
toDate
().
toLocaleString
(
i18n
.
language
,
{
year
:
"numeric"
,
month
:
"long"
})
}
</
span
>
<
input
<
input
className=
"inset-0 absolute z-1 opacity-0"
className=
"inset-0 absolute z-1 opacity-0"
type=
"month"
type=
"month"
value=
{
m
onthString
}
value=
{
visibleM
onthString
}
onFocus=
{
(
e
:
any
)
=>
e
.
target
.
showPicker
()
}
onFocus=
{
(
e
:
any
)
=>
e
.
target
.
showPicker
()
}
onChange=
{
(
e
)
=>
setMonthString
(
e
.
target
.
value
||
dayjs
().
format
(
"YYYY-MM"
))
}
onChange=
{
(
e
)
=>
set
Visible
MonthString
(
e
.
target
.
value
||
dayjs
().
format
(
"YYYY-MM"
))
}
/>
/>
</
div
>
</
div
>
<
div
className=
"invisible group-hover:visible flex justify-end items-center"
>
<
div
className=
"invisible group-hover:visible flex justify-end items-center"
>
<
ChevronLeftIcon
className=
"w-4 h-auto shrink-0 opacity-60"
onClick=
{
()
=>
setVisibleMonthString
(
dayjs
(
visibleMonthString
).
subtract
(
1
,
"month"
).
format
(
"YYYY-MM"
))
}
/>
<
ChevronRightIcon
className=
"w-4 h-auto shrink-0 opacity-60"
onClick=
{
()
=>
setVisibleMonthString
(
dayjs
(
visibleMonthString
).
add
(
1
,
"month"
).
format
(
"YYYY-MM"
))
}
/>
<
Popover
>
<
Popover
>
<
PopoverTrigger
>
<
PopoverTrigger
>
<
MoreVerticalIcon
className=
"w-4 h-auto shrink-0 opacity-60"
/>
<
MoreVerticalIcon
className=
"w-4 h-auto shrink-0 opacity-60"
/>
...
@@ -103,7 +121,12 @@ const UserStatisticsView = () => {
...
@@ -103,7 +121,12 @@ const UserStatisticsView = () => {
</
div
>
</
div
>
</
div
>
</
div
>
<
div
className=
"w-full"
>
<
div
className=
"w-full"
>
<
ActivityCalendar
month=
{
monthString
}
selectedDate=
{
selectedDate
.
toDateString
()
}
data=
{
activityStats
}
onClick=
{
onCalendarClick
}
/>
<
ActivityCalendar
month=
{
visibleMonthString
}
selectedDate=
{
selectedDate
.
toDateString
()
}
data=
{
activityStats
}
onClick=
{
onCalendarClick
}
/>
{
memoAmount
>
0
&&
(
{
memoAmount
>
0
&&
(
<
p
className=
"mt-1 w-full text-xs italic opacity-80"
>
<
p
className=
"mt-1 w-full text-xs italic opacity-80"
>
<
span
>
{
memoAmount
}
</
span
>
memos in
<
span
>
{
days
}
</
span
>
{
days
>
1
?
"days"
:
"day"
}
<
span
>
{
memoAmount
}
</
span
>
memos in
<
span
>
{
days
}
</
span
>
{
days
>
1
?
"days"
:
"day"
}
...
...
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