-
Notifications
You must be signed in to change notification settings - Fork 589
/
Tag.js
71 lines (62 loc) · 1.57 KB
/
Tag.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
import { upperCase, upperFirst } from 'lodash';
import PropTypes from 'prop-types';
import React from 'react';
import { compose, onlyUpdateForKeys, withProps } from 'recompact';
import styled from 'styled-components/primitives';
import { Centered, Column } from './layout';
import { Text as TextElement } from './text';
import { colors, padding } from '../styles';
const TagBorderRadius = 7;
const Container = styled(Column)`
${padding(7, 10)};
background-color: ${colors.white};
border-radius: ${TagBorderRadius};
text-align: left;
z-index: 1;
`;
const OuterBorder = styled(Centered)`
border-color: ${colors.alpha(colors.black, 0.06)};
border-radius: ${TagBorderRadius};
border-width: 1;
flex: none;
overflow: hidden;
z-index: 2;
`;
const Text = styled(TextElement).attrs({
color: colors.blueGreyLightest,
size: 'medium',
weight: 'medium',
})`
letter-spacing: -0.18px;
line-height: 18;
`;
const Title = styled(TextElement).attrs({
color: colors.blueGreyLightest,
size: 'tiny',
weight: 'medium',
})`
letter-spacing: 0.3px;
line-height: 13;
margin-bottom: 1;
opacity: 0.7;
`;
const enhance = compose(
withProps(({ text, title }) => ({
text: upperFirst(text),
title: upperCase(title),
})),
onlyUpdateForKeys(['text', 'title']),
);
const Tag = enhance(({ text, title, ...props }) => (
<OuterBorder {...props}>
<Container>
<Title>{title}</Title>
<Text>{text}</Text>
</Container>
</OuterBorder>
));
Tag.propTypes = {
text: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
};
export default Tag;