2019-09-10 11:28:56 +00:00
|
|
|
import React from "react";
|
|
|
|
import styled from "styled-components";
|
|
|
|
import Weekday from "./weekday";
|
2019-12-04 09:36:13 +00:00
|
|
|
import Text from "../../text";
|
2019-09-10 11:28:56 +00:00
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import { isArrayEqual } from "../../../utils/array";
|
|
|
|
|
|
|
|
const StyledWeekdays = styled.div`
|
2020-10-16 13:16:01 +00:00
|
|
|
width: ${(props) => (props.size === "base" ? "272px" : "295px")};
|
2019-09-10 11:28:56 +00:00
|
|
|
display: flex;
|
|
|
|
margin-bottom: -5px;
|
|
|
|
|
|
|
|
.dayText {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
class Weekdays extends React.Component {
|
|
|
|
shouldComponentUpdate(nextProps) {
|
|
|
|
const { optionsWeekdays, size } = this.props;
|
|
|
|
if (
|
|
|
|
isArrayEqual(optionsWeekdays, nextProps.optionsWeekdays) &&
|
|
|
|
size === nextProps.size
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
//console.log("Weekdays render");
|
|
|
|
const { optionsWeekdays, size } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<StyledWeekdays size={size}>
|
|
|
|
{optionsWeekdays.map((weekday, index) => {
|
|
|
|
return (
|
|
|
|
<Weekday key={index}>
|
2020-10-16 13:16:01 +00:00
|
|
|
<Text color={weekday.color} isBold={true} className={"dayText"}>
|
2019-09-10 11:28:56 +00:00
|
|
|
{" "}
|
|
|
|
{weekday.value}{" "}
|
2019-12-04 09:36:13 +00:00
|
|
|
</Text>
|
2019-09-10 11:28:56 +00:00
|
|
|
</Weekday>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</StyledWeekdays>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Weekdays.propTypes = {
|
|
|
|
optionsWeekdays: PropTypes.array,
|
2020-10-16 13:16:01 +00:00
|
|
|
size: PropTypes.string,
|
2019-09-10 11:28:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Weekdays;
|