-
Notifications
You must be signed in to change notification settings - Fork 26
/
stamp.js
80 lines (75 loc) 路 1.79 KB
/
stamp.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
import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/core';
import { customProperties as vars } from '@commercetools-uikit/design-system';
import InsetSquish from '@commercetools-uikit/spacings-inset-squish';
export const availableTones = [
'critical',
'warning',
'positive',
'information',
'primary',
'secondary',
];
const getToneStyles = props => {
switch (props.tone) {
case 'critical': {
return css`
background-color: ${vars.colorError95};
border: 1px solid ${vars.colorError};
`;
}
case 'warning': {
return css`
background-color: ${vars.colorWarning95};
border: 1px solid ${vars.colorWarning};
`;
}
case 'positive': {
return css`
background-color: ${vars.colorPrimary85};
border: 1px solid ${vars.colorPrimary40};
`;
}
case 'information': {
return css`
background-color: ${vars.colorInfo95};
border: 1px solid ${vars.colorInfo};
`;
}
case 'primary': {
return css`
background-color: ${vars.colorPrimary95};
border: 1px solid ${vars.colorPrimary25};
`;
}
case 'secondary': {
return css`
background-color: ${vars.colorNeutral90};
border: 1px solid ${vars.colorNeutral60};
`;
}
default:
return css``;
}
};
const Label = props => (
<div
css={[
css`
color: ${vars.colorSolid};
font-size: ${vars.fontSizeDefault};
border-radius: 2px;
`,
getToneStyles(props),
]}
>
<InsetSquish scale="s">{props.children}</InsetSquish>
</div>
);
Label.displayName = 'Label';
Label.propTypes = {
tone: PropTypes.oneOf(availableTones).isRequired,
children: PropTypes.node.isRequired,
};
export default Label;