Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
butter-studio
Commits
618943bf
Commit
618943bf
authored
Aug 07, 2021
by
Kim, Subin
Browse files
Calender 컴포넌트 생성 및 내용 수정 중
parent
96ec1478
Changes
2
Hide whitespace changes
Inline
Side-by-side
client/src/components/Calender/Calender.js
0 → 100644
View file @
618943bf
import
{
useState
,
useEffect
}
from
"
react
"
;
import
moment
from
"
moment
"
;
import
styles
from
"
./calender.module.scss
"
;
const
Calender
=
({
selectDate
,
setSelectDate
})
=>
{
const
[
dateList
,
setDateList
]
=
useState
([])
const
[
week
,
setWeek
]
=
useState
([
"
일
"
,
"
월
"
,
"
화
"
,
"
수
"
,
"
목
"
,
"
금
"
,
"
토
"
])
useEffect
(()
=>
{
getDate
(
selectDate
)
},
[])
function
getDate
(
oneDay
)
{
let
dateArr
=
[]
let
lastWeek
=
moment
(
oneDay
).
subtract
(
7
,
'
days
'
)
const
nextWeek
=
moment
(
oneDay
).
add
(
7
,
'
days
'
)
while
(
lastWeek
.
isBefore
(
nextWeek
))
{
dateArr
.
push
({
date
:
lastWeek
.
format
(
'
YYYY-MM-DD
'
),
day
:
lastWeek
.
format
(
'
d
'
)
})
lastWeek
.
add
(
1
,
'
days
'
)
}
console
.
log
(
"
arr=
"
,
dateArr
)
console
.
log
(
"
same==
"
,
moment
(
oneDay
).
isSame
(
'
2021-08-07
'
))
const
resultArr
=
dateArr
.
map
(
el
=>
<
div
onClick
=
{()
=>
setSelectDate
(
el
.
date
)}
>
{
moment
(
el
.
date
).
isSame
(
oneDay
)
||
el
.
date
.
split
(
'
-
'
)[
2
]
===
"
01
"
?
<
strong
>
{
moment
(
el
.
date
).
format
(
'
YYYY.MM
'
)}
<
/strong> : ""
}
<
div
>
<
strong
>
{
moment
(
el
.
date
).
format
(
'
DD
'
)}
<
/strong
>
<
em
>
{
moment
(
el
.
date
).
isSame
(
oneDay
)
?
"
오늘
"
:
week
[
el
.
day
]}
<
/em
>
<
/div
>
<
/div>
)
setDateList
(
resultArr
)
}
return
(
<>
{
console
.
log
(
"
date==
"
,
selectDate
)}
<
div
>
<
i
className
=
"
bi bi-chevron-left
"
><
/i
>
{
dateList
.
map
(
el
=>
el
)}
<
i
className
=
"
bi bi-chevron-right
"
><
/i
>
<
/div
>
<
/
>
)
}
export
default
Calender
\ No newline at end of file
client/src/components/Calender/calender.module.scss
0 → 100644
View file @
618943bf
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