-
Notifications
You must be signed in to change notification settings - Fork 26
/
calendar-day.js
115 lines (107 loc) 路 2.35 KB
/
calendar-day.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/core';
import { customProperties as vars } from '@commercetools-uikit/design-system';
const getStyles = props => {
const styles = [];
if (!['heading', 'spacing'].includes(props.type)) {
styles.push(css`
text-align: center;
padding: ${vars.spacingS} 0;
cursor: default;
border-radius: ${vars.borderRadius4};
`);
}
if (['heading', 'spacing'].includes(props.type)) {
styles.push(css`
text-align: center;
padding: ${vars.spacingS} 0;
cursor: default;
color: ${vars.colorNeutral60};
`);
}
if (props.isHighlighted) {
styles.push(
css`
background-color: ${vars.colorNeutral90};
`
);
}
if (props.isSelected) {
styles.push(
css`
background-color: ${vars.colorPrimary};
color: ${vars.colorSurface};
`
);
}
if (props.isRangeStart || props.isRangeEnd) {
styles.push(
css`
background-color: ${vars.colorPrimary40};
color: ${vars.colorSurface};
`
);
}
if (props.isRangeBetween) {
styles.push(
css`
background-color: ${vars.colorNeutral90};
color: ${vars.fontColorForInput};
`
);
}
if (
!props.isSelected &&
!props.isRangeStart &&
!props.isRangeEnd &&
props.isToday
) {
styles.push(css`
color: ${vars.colorInfo};
font-weight: bold;
`);
}
if (props.disabled) {
styles.push(css`
color: ${vars.fontColorForInputWhenDisabled};
cursor: not-allowed;
`);
}
return styles;
};
const CalendarDay = props => {
const {
isHighlighted,
isSelected,
isRangeStart,
isRangeBetween,
isRangeEnd,
isToday,
...rest
} = props;
return (
<li
css={css`
list-style-type: none;
display: inline-block;
margin: 2px 1%;
width: 12%;
`}
>
<div css={getStyles(props)} {...rest} />
</li>
);
};
CalendarDay.displayName = 'CalendarDay';
CalendarDay.propTypes = {
children: PropTypes.node,
type: PropTypes.oneOf(['heading', 'spacing', 'day']),
isHighlighted: PropTypes.bool,
isSelected: PropTypes.bool,
isRangeStart: PropTypes.bool,
isRangeBetween: PropTypes.bool,
isRangeEnd: PropTypes.bool,
isToday: PropTypes.bool,
};
export default CalendarDay;