1 | import * as React from 'react';
|
2 | import styled from 'styled-components';
|
3 |
|
4 | import { Colors, Sizes, TextHelper, Icons } from '../index';
|
5 | import { styledByMediaQuery } from '../utils/styles';
|
6 |
|
7 | const Box = styled.div`
|
8 | position: relative;
|
9 | margin-left: ${Sizes.s4}px;
|
10 | `;
|
11 |
|
12 | const Info = styled.div`
|
13 | cursor: pointer;
|
14 | &:hover + .tooltip {
|
15 | opacity: 1;
|
16 | z-index: 1
|
17 | }
|
18 | `;
|
19 |
|
20 | const Tooltip = styled.div.attrs({
|
21 | className: 'tooltip',
|
22 | })`
|
23 | opacity: 0;
|
24 | background-color: ${ Colors.regalBlue};
|
25 | color: ${ Colors.white };
|
26 | border-radius: 4px;
|
27 | position: absolute;
|
28 | z-index: 1;
|
29 | left: 18px;
|
30 | bottom: -13px;
|
31 | transition: all 0.3s ease-in;
|
32 | filter: drop-shadow(0 2px 2px rgb(146, 146, 146));
|
33 | padding: 16px;
|
34 | max-width: 266px;
|
35 | width: 266px;
|
36 | z-index: -1;
|
37 | line-height: 24px;
|
38 | font-family: ${TextHelper.fontVariant('regular')};
|
39 | display: none;
|
40 |
|
41 | ${styledByMediaQuery(`display: block;`)}
|
42 |
|
43 | &:before {
|
44 | content: '';
|
45 | position: inherit;
|
46 | left: -13px;
|
47 | bottom: 15px;
|
48 | border-top: 5px solid transparent;
|
49 | border-right: 13px solid ${ Colors.regalBlue};
|
50 | border-bottom: 9px solid transparent;
|
51 | }
|
52 | `;
|
53 |
|
54 | export default ({ children }: { children: React.ReactNode|React.ReactChild|string }) => (
|
55 | <Box>
|
56 | <Info><Icons.Info /></Info>
|
57 | <Tooltip>{children}</Tooltip>
|
58 | </Box>
|
59 | );
|