Skip to content

Commit

Permalink
Merge pull request #3 from ViktorSvertoka/Dima-DiaryPage
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka authored Sep 15, 2023
2 parents b3b26b6 + 7e02056 commit 640be39
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 1 deletion.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions src/components/Diary/DayDashboard/DayDashboard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const DayDashboard = () => {};

export default DayDashboard;
Empty file.
3 changes: 3 additions & 0 deletions src/components/Diary/DayExercises/DayExercises.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const DayExercises = () => {};

export default DayExercises;
Empty file.
3 changes: 3 additions & 0 deletions src/components/Diary/DayProducts/DayProducts.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const DayProducts = () => {};

export default DayProducts;
Empty file.
49 changes: 49 additions & 0 deletions src/components/Diary/DaySwitch/DaySwitch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';

import { useState } from 'react';
import {
Wrap,
DateLabel,
CalenderIcon,
BtnPrev,
DayChangeIcon,
BtnNext,
} from './DaySwitch.styled';

const DaySwitch = () => {
const [currentDate, setCurrentDate] = useState(new Date());

const switchToPreviousDay = () => {
const previousDay = new Date(currentDate);
previousDay.setDate(previousDay.getDate() - 1);
setCurrentDate(previousDay);
};

const switchToNextDay = () => {
const nextDay = new Date(currentDate);
nextDay.setDate(nextDay.getDate() + 1);
setCurrentDate(nextDay);
};

const formattedDate = `${currentDate
.getDate()
.toString()
.padStart(2, '0')}/${(currentDate.getMonth() + 1)
.toString()
.padStart(2, '0')}/${currentDate.getFullYear()}`;

return (
<Wrap>
<DateLabel>{formattedDate}</DateLabel>
<CalenderIcon />
<BtnPrev onClick={switchToPreviousDay}>
<DayChangeIcon />
</BtnPrev>
<BtnNext onClick={switchToNextDay}>
<DayChangeIcon />
</BtnNext>
</Wrap>
);
};

export default DaySwitch;
39 changes: 39 additions & 0 deletions src/components/Diary/DaySwitch/DaySwitch.styled.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import styled from 'styled-components';

const Wrap = styled.div`
display: flex;
align-items: center;
margin-left: auto;
`;

const DateLabel = styled.p`
color: #efede8;
font-family: Roboto;
font-size: 24px;
font-style: normal;
font-weight: 700;
line-height: 32px;
`;

const CalenderIcon = styled.svg`
width: 24px;
height: 24px;
`;

const BtnPrev = styled.button`
width: 16px;
height: 16px;
flex-shrink: 0;
cursor: pointer;
`;

const BtnNext = styled.button`
width: 16px;
height: 16px;
flex-shrink: 0;
cursor: pointer;
`;

const DayChangeIcon = styled.svg``;

export { Wrap, DateLabel, CalenderIcon, BtnPrev, BtnNext, DayChangeIcon };
16 changes: 15 additions & 1 deletion src/pages/DiaryPage/DiaryPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import DaySwitch from '../../components/Diary/DaySwitch/DaySwitch';
import DayProducts from '../../components/Diary/DayProducts/DayProducts';
import DayExercises from '../../components/Diary/DayExercises/DayExercises';
import DayDashboard from '../../components/Diary/DayDashboard/DayDashboard';
import { DiaryTitle, Wrapper } from './DiaryPage.styled';

const DiaryPage = () => {
return <div>Diary page</div>;
return (
<Wrapper>
<DiaryTitle>Diary</DiaryTitle>
<DaySwitch></DaySwitch>
<DayProducts></DayProducts>
<DayExercises></DayExercises>
<DayDashboard></DayDashboard>
</Wrapper>
);
};

export default DiaryPage;
13 changes: 13 additions & 0 deletions src/pages/DiaryPage/DiaryPage.styled.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from 'styled-components';

const Wrapper = styled.div`
display: flex;
padding: 52px 96px 68px;
background: #040404;
`;

const DiaryTitle = styled.h2`
padding-top: 20px;
`;

export { Wrapper, DiaryTitle };

0 comments on commit 640be39

Please sign in to comment.