Skip to content

Commit 5aee32e

Browse files
committed
sidebar calender
1 parent 0e00797 commit 5aee32e

File tree

5 files changed

+228
-5
lines changed

5 files changed

+228
-5
lines changed
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React, { useState, useEffect } from 'react'
2+
import moment from 'moment'
3+
import buildCalender from '../../Screens/Calender/build'
4+
import Header from '../Sidebar/SideCalenderHeader'
5+
import dayStyles from '../../Screens/Calender/calender-day'
6+
import './side-calender.css'
7+
8+
const SideCalendar = () => {
9+
const [calender, setCalender] = useState([])
10+
const [value, setValue] = useState(moment())
11+
const [eventtrue, setEventTrue] = useState(false)
12+
13+
useEffect(() => {
14+
setCalender(buildCalender(value))
15+
}, [value])
16+
17+
const handleEventChange = () => {
18+
setEventTrue(true)
19+
}
20+
21+
return (
22+
<>
23+
<div className='calendar-side'>
24+
<Header value={value} setValue={setValue} />
25+
26+
<div className='body-side'>
27+
<div className='day-names-side'>
28+
{['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map((d) => (
29+
<div className='week-side'>{d}</div>
30+
))}
31+
</div>
32+
{calender.map((week) => (
33+
<div>
34+
{week.map((day) => (
35+
<div
36+
className='day-side'
37+
onClick={() => setValue(day)}
38+
>
39+
<div className={dayStyles(day, value) + '-side'} onClick={() => handleEventChange()}>
40+
{day.format('D').toString()}
41+
</div>
42+
</div>
43+
))}
44+
</div>
45+
))}
46+
</div>
47+
<button className='button-sidebar'>View Calender</button>
48+
</div>
49+
50+
</>
51+
)
52+
}
53+
54+
export default SideCalendar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react'
2+
3+
export default function CalendarHeader ({ value, setValue }) {
4+
function currMonthName () {
5+
return value.format('MMMM')
6+
}
7+
8+
function currYear () {
9+
return value.format('YYYY')
10+
}
11+
12+
function prevMonth () {
13+
return value.clone().subtract(1, 'month')
14+
}
15+
16+
function nextMonth () {
17+
return value.clone().add(1, 'month')
18+
}
19+
20+
function thisMonth () {
21+
return value.isSame(new Date(), 'month')
22+
}
23+
24+
return (
25+
<div className='header-side'>
26+
<div className='calender-header-container-side'>
27+
<div className='calender-month-wrapper-side'>
28+
29+
<div
30+
className='previous-side'
31+
onClick={() => setValue(prevMonth())}
32+
>
33+
{String.fromCharCode(171)}
34+
</div>
35+
<div className='current-side'>
36+
{currMonthName()} {currYear()}
37+
</div>
38+
39+
<div className='next-side' onClick={() => setValue(nextMonth())}>
40+
{String.fromCharCode(187)}
41+
</div>
42+
</div>
43+
44+
</div>
45+
</div>
46+
)
47+
}

src/Components/Sidebar/Sidebar.jsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState } from 'react'
22
import { useHistory, useLocation } from 'react-router-dom'
33
import './sidebar.css'
4+
import SideCalendar from './SideCalender'
45

56
const mainnav = [
67
{
@@ -80,8 +81,9 @@ function MainNav ({ dropdownActive, setDropdownActive }) {
8081
}
8182

8283
return (
83-
<ul className='list-container'>
84-
{
84+
<>
85+
<ul className='list-container'>
86+
{
8587
mainnav.map(navitem => {
8688
return (
8789
<li className={navitem.dropdown.length > 0 ? 'list-items' : 'list-items-menu'} key={navitem.name}>
@@ -121,6 +123,9 @@ function MainNav ({ dropdownActive, setDropdownActive }) {
121123
)
122124
})
123125
}
124-
</ul>
126+
</ul>
127+
{/* <Calender /> */}
128+
<SideCalendar />
129+
</>
125130
)
126131
}
+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
.calendar-side {
2+
box-sizing: border-box;
3+
font-size: 1rem;
4+
max-width: 400px;
5+
position: fixed;
6+
left: 0;
7+
bottom: 0;
8+
}
9+
10+
.header-side {
11+
background-color: #2b2b2c;
12+
text-align: center;
13+
line-height: 29px;
14+
color: white;
15+
font-weight: 300;
16+
height: 30px;
17+
font-size: 17px;
18+
}
19+
20+
.day-names-side {
21+
display: flex;
22+
flex-wrap: wrap;
23+
width: 195px;
24+
margin: 0 auto;
25+
align-items: center;
26+
color: white;
27+
}
28+
29+
.week-side {
30+
background-color: #141414;
31+
width: calc(100% / 7);
32+
height: 44px;
33+
line-height: 44px;
34+
text-align: center;
35+
color: rgb((172), 167, 167);
36+
font-weight: 300;
37+
}
38+
39+
.week-side div {
40+
width: 100%;
41+
}
42+
43+
.day-side {
44+
position: relative;
45+
width: calc(100% / 7);
46+
height: 44px;
47+
display: inline-block;
48+
background-color: black;
49+
padding: 0;
50+
margin: 0;
51+
box-sizing: border-box;
52+
z-index: 1;
53+
text-align: center;
54+
color: white;
55+
border: 1px solid rgb(22, 21, 21);
56+
line-height: 2;
57+
font-size: 14px;
58+
}
59+
60+
.calender-month-wrapper-side {
61+
display: flex;
62+
}
63+
64+
.calender-header-container-side {
65+
display: flex;
66+
align-items: center;
67+
justify-content: space-between;
68+
}
69+
70+
.today-side {
71+
background-color: rgb(64, 95, 80);
72+
height: 27px;
73+
width: 27px;
74+
border-radius: 5px;
75+
margin-top: 5px;
76+
}
77+
78+
.before-side {
79+
color: white;
80+
background-color: rgb(12, 11, 11);
81+
height: 27px;
82+
width: 27px;
83+
border-radius: 5px;
84+
margin-top: 5px;
85+
}
86+
87+
.previous-side {
88+
text-align: left;
89+
margin-left: 1rem;
90+
margin-right: 25px;
91+
color: rgba(0, 198, 136, 1);
92+
cursor: pointer;
93+
}
94+
95+
.next-side {
96+
margin-left: 36px;
97+
color: rgba(0, 198, 136, 1);
98+
cursor: pointer;
99+
}
100+
101+
.button-sidebar {
102+
background-color: #00c688;
103+
border: none;
104+
color: white;
105+
padding: 15px 32px;
106+
text-align: center;
107+
text-decoration: none;
108+
display: inline-block;
109+
font-size: 16px;
110+
width: 100%;
111+
}
112+
113+
.selected-side {
114+
background-color: rgba(0, 198, 136, 1);
115+
color: white;
116+
font-weight: bold;
117+
height: 27px;
118+
width: 30px;
119+
}

src/Screens/Calender/Calender.jsx

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ const Calender = () => {
2424
dispatch(listCalenderEvents())
2525
}, [dispatch])
2626

27-
console.log('evet', eventtrue)
28-
2927
const handleEventChange = () => {
3028
setEventTrue(true)
3129
}

0 commit comments

Comments
 (0)