Skip to content

Commit

Permalink
Brush layout of calendar and datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
SamIvan-ark committed Feb 26, 2024
1 parent 7183ac1 commit 768949c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/components/Calendar/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Calendar = ({
};
return (
<div className="calendar-wrapper">
<hr className="calendar-divider" />
<p className="calendar-header">Календарь</p>
<div className="calendar-control">
<button
Expand Down
2 changes: 0 additions & 2 deletions src/components/Calendar/DayUnit/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
color: #363a47;
border: 1px solid transparent;
transition: border 500ms;
-webkit-user-select: none;
user-select: none;
width: 50px;
height: 33px;
}
Expand Down
16 changes: 15 additions & 1 deletion src/components/Calendar/style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.calendar-wrapper {
position: absolute;
width: 100%;
padding: 20px 15px 0;
padding: 10px 15px 0;
bottom: 0;
left: 0;
right: 0;
Expand All @@ -27,6 +27,19 @@
font-size: 1.4em;
}

.calendar-divider {
width: 15%;
margin-left: auto;
margin-right: auto;
border-radius: 2px;
height: 5px;
margin-block-start: 0;
margin-block-end: 0;
background-color: #d7d7df;
border: none;
margin-bottom: 15px;
}

.calendar-control {
position: relative;
display: flex;
Expand Down Expand Up @@ -88,4 +101,5 @@ li {
width: 100%;
border-radius: 12px;
font-weight: bold;
margin-bottom: 15px;
}
54 changes: 28 additions & 26 deletions src/components/DatePicker/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,38 @@ const DatePicker = ({ date, updateDate, setIsCalendarOpen }) => {

return (
<div className="datepicker-wrapper">
<button
aria-label="Предыдущий день"
className="date-control"
onClick={() => updateDate(minusDay(date))}
type="button"
>
<ArrowLeft className="arrow-icon" />
</button>
<div className="date-container">
<CalendarIcon />
<nav className="datepicker">
<button
className="date-picker"
onClick={() => setIsCalendarOpen(true)}
aria-label="Предыдущий день"
className="date-control"
onClick={() => updateDate(minusDay(date))}
type="button"
>
{dateFormatter.format(date)}
<ArrowLeft className="arrow-icon" />
</button>
</div>
<button
aria-label="Следующий день"
className={cn(
'date-control',
{ 'button-disabled': pickedCurrentDay },
)}
disabled={pickedCurrentDay}
onClick={() => updateDate(plusDay(date))}
type="button"
>
<ArrowRight className="arrow-icon" />
</button>
<div className="date-container">
<CalendarIcon />
<button
className="date-picker"
onClick={() => setIsCalendarOpen(true)}
type="button"
>
{dateFormatter.format(date)}
</button>
</div>
<button
aria-label="Следующий день"
className={cn(
'date-control',
{ 'button-disabled': pickedCurrentDay },
)}
disabled={pickedCurrentDay}
onClick={() => updateDate(plusDay(date))}
type="button"
>
<ArrowRight className="arrow-icon" />
</button>
</nav>
</div>
);
};
Expand Down
15 changes: 8 additions & 7 deletions src/components/DatePicker/style.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
.datepicker-wrapper {
background-color: #eff3f6;
}

.datepicker {
display: flex;
justify-content: space-between;
background-color: #eff3f6;
padding: 12px;
box-sizing: border-box;
max-width: 650px;
margin: 0 auto;
}

.date-control {
Expand All @@ -13,12 +18,6 @@
padding: 0;
width: 34px;
height: 34px;
cursor: pointer;
}

.button-disabled {
background-color: transparent;
cursor: not-allowed;
}

.arrow-icon {
Expand All @@ -42,6 +41,8 @@
font-weight: 600;
font-size: 14px;
display: inline-block;
width: 100%;
height: 100%;
}

.calendar-icon {
Expand Down
11 changes: 11 additions & 0 deletions src/styles/App.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
body {
font-family: Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif
}

button {
user-select: none;
-webkit-user-select: none;
cursor: pointer;
}

.button-disabled {
background-color: transparent;
cursor: not-allowed;
}

0 comments on commit 768949c

Please sign in to comment.