Skip to content

Commit

Permalink
Merge pull request #5 from ViktorSvertoka/Dima-DiaryPage1
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka authored Sep 15, 2023
2 parents 8762095 + f82bbd3 commit b6e057b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/components/Diary/DaySwitch/DaySwitch.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import { useState } from 'react';
import {
Wrap,
Expand All @@ -9,6 +7,7 @@ import {
DayChangeIcon,
BtnNext,
} from './DaySwitch.styled';
import Icon from '../../Icon/Icon';

const DaySwitch = () => {
const [currentDate, setCurrentDate] = useState(new Date());
Expand Down Expand Up @@ -36,11 +35,11 @@ const DaySwitch = () => {
<Wrap>
<DateLabel>{formattedDate}</DateLabel>
<CalenderIcon />
<BtnPrev onClick={switchToPreviousDay}>
<DayChangeIcon />
<BtnPrev onClick={switchToPreviousDay} className="button">
<Icon symbolId="icon-arrow-left" width="16" height="16" />
</BtnPrev>
<BtnNext onClick={switchToNextDay}>
<DayChangeIcon />
<BtnNext onClick={switchToNextDay} className="button">
<Icon symbolId="icon-arrow-right" width="16" height="16" />
</BtnNext>
</Wrap>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/Diary/DaySwitch/DaySwitch.styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ const BtnPrev = styled.button`
width: 16px;
height: 16px;
flex-shrink: 0;
cursor: pointer;
margin: 0;
padding: 0;
background-color: transparent;
color: white;
`;

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

const DayChangeIcon = styled.svg``;
Expand Down
18 changes: 18 additions & 0 deletions src/components/Icon/Icon.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import PropTypes from 'prop-types';
const spritePath = '/src/images/sprite.svg';

const Icon = ({ symbolId, width, height }) => {
return (
<svg className="icon" width={width} height={height}>
<use xlinkHref={`${spritePath}#${symbolId}`} />
</svg>
);
};

Icon.propTypes = {
symbolId: PropTypes.string.isRequired,
width: PropTypes.string.isRequired,
height: PropTypes.string.isRequired,
};

export default Icon;
2 changes: 1 addition & 1 deletion src/images/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b6e057b

Please sign in to comment.