Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
송용우
2020-08-25 21:56:40 +0900
1
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0a64d87ac33df5b79ec5ab2e97cf9d3d318c608b
0a64d87a
1 parent
837e049a
Update Heatmap calendar
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
6 deletions
jaksimsamil-page/src/components/home/HeatMap.js
jaksimsamil-page/src/components/home/HomeForm.js
jaksimsamil-page/src/containers/home/HomeContainer.js
jaksimsamil-page/src/components/home/HeatMap.js
0 → 100644
View file @
0a64d87
import
React
,
{
use
}
from
'react'
;
import
CalendarHeatmap
from
'react-calendar-heatmap'
;
import
'react-calendar-heatmap/dist/styles.css'
;
/*
TODO: 날짜 범위 지정, 날짜별 검색 추가
*/
/*
solvedBJbyDATE:
solvedBJbyDATE:{
20190304 : [Object]
...
}
*/
const
HeatMap
=
(
HMArr
)
=>
{
return
(
<
div
>
<
CalendarHeatmap
onClick
=
{()
=>
{
console
.
log
(
HMArr
);
}}
startDate
=
{
new
Date
(
'2020-01-01'
)}
endDate
=
{
new
Date
(
'2020-12-01'
)}
values
=
{
HMArr
.
HMArr
}
classForValue
=
{(
value
)
=>
{
if
(
!
value
)
{
return
'color-empty'
;
}
return
`color-github-
${
value
.
count
}
`
;
}}
tooltipDataAttrs
=
{(
value
)
=>
{
return
{
'data-tooltip'
:
`
${
value
.
date
}
has count:
${
value
.
count
}
`
,
};
}}
showWeekdayLabels
=
{
true
}
/
>
<
/div
>
);
};
export
default
HeatMap
;
jaksimsamil-page/src/components/home/HomeForm.js
View file @
0a64d87
...
...
@@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles';
import
Paper
from
'@material-ui/core/Paper'
;
import
Grid
from
'@material-ui/core/Grid'
;
import
palette
from
'../../lib/styles/palette'
;
import
AuthForm
from
'../auth/AuthForm
'
;
import
HeatMap
from
'./HeatMap
'
;
const
useStyles
=
makeStyles
((
theme
)
=>
({
root
:
{
flexGrow
:
1
,
...
...
@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
color
:
theme
.
palette
.
text
.
secondary
,
},
}));
const
HomeForm
=
({
PSdata
,
goalNum
})
=>
{
const
HomeForm
=
({
PSdata
,
HMArr
,
goalNum
})
=>
{
const
classes
=
useStyles
();
return
PSdata
?
(
<
div
className
=
{
classes
.
root
}
>
...
...
@@ -48,7 +48,11 @@ const HomeForm = ({ PSdata, goalNum }) => {
<
h3
>
마지막으로
푼
문제
<
/h3
>
<
/Paper
>
<
/Grid
>
<
Grid
item
xs
=
{
12
}
>
<
Paper
className
=
{
classes
.
paper
}
>
<
HeatMap
HMArr
=
{
HMArr
}
/
>
<
/Paper
>
<
/Grid
>
<
Grid
item
xs
=
{
4
}
>
<
Paper
className
=
{
classes
.
paper
}
>
<
h1
>
{
PSdata
.
weekNum
}
<
/h1
>
...
...
jaksimsamil-page/src/containers/home/HomeContainer.js
View file @
0a64d87
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
withRouter
}
from
'react-router-dom'
;
import
HomeForm
from
'../../components/home/HomeForm'
;
import
{
getPROFILE
,
initializeProfile
}
from
'../../modules/profile'
;
const
HomeContainer
=
({
history
})
=>
{
const
dispatch
=
useDispatch
();
const
[
HMArr
,
setHMArr
]
=
useState
([]);
const
{
user
,
profile
}
=
useSelector
(({
user
,
profile
})
=>
({
user
:
user
.
user
,
profile
:
profile
,
}));
const
makeHeatmapValues
=
(
PSdata
)
=>
{
let
obj_keys
=
Object
.
keys
(
PSdata
);
let
result
=
[];
for
(
let
i
=
0
;
i
<
obj_keys
.
length
;
i
++
)
{
result
.
push
({
date
:
//2019-10-15
obj_keys
[
i
].
slice
(
0
,
4
)
+
'-'
+
obj_keys
[
i
].
slice
(
4
,
6
)
+
'-'
+
obj_keys
[
i
].
slice
(
6
,
8
),
count
:
PSdata
[
obj_keys
[
i
]].
length
,
});
}
return
result
;
};
useEffect
(()
=>
{
if
(
!
user
)
{
alert
(
'로그인이 필요합니다 '
);
...
...
@@ -23,7 +42,9 @@ const HomeContainer = ({ history }) => {
}
},
[
dispatch
,
user
,
history
]);
useEffect
(()
=>
{
console
.
log
(
profile
);
if
(
profile
.
solvedBJ_date
)
{
setHMArr
(
makeHeatmapValues
(
profile
.
solvedBJ_date
.
solvedBJbyDATE
));
}
},
[
profile
]);
useEffect
(()
=>
{
if
(
user
)
{
...
...
@@ -31,6 +52,12 @@ const HomeContainer = ({ history }) => {
dispatch
(
getPROFILE
({
username
}));
}
},
[
dispatch
,
user
]);
return
<
HomeForm
PSdata
=
{
profile
.
solvedBJ_date
}
goalNum
=
{
profile
.
goalNum
}
/>
;
return
(
<
HomeForm
PSdata
=
{
profile
.
solvedBJ_date
}
HMArr
=
{
HMArr
}
goalNum
=
{
profile
.
goalNum
}
/
>
);
};
export
default
withRouter
(
HomeContainer
);
...
...
송용우
@2019102188
2020-09-26 12:41:26 UTC
Mentioned in commit
112fc5b5
Please
register
or
login
to post a comment