1
1
import React from "react" ;
2
2
import styled , { css } from "styled-components" ;
3
- import { borderBox , small as smallStyle } from "../../styles/common-style" ;
3
+ import {
4
+ borderBox ,
5
+ fadeIn ,
6
+ small as smallStyle ,
7
+ } from "../../styles/common-style" ;
4
8
5
9
export interface TooltipBaseProps {
6
10
place ?: "left" | "right" | "top" | "bottom" ;
@@ -9,6 +13,82 @@ export interface TooltipBaseProps {
9
13
10
14
const StyledText = styled . small `` ;
11
15
16
+ const Tip = styled . div < TooltipBaseProps > `
17
+ content: "";
18
+ position: absolute;
19
+ border-width: 8px;
20
+ border-style: solid;
21
+
22
+ ::after {
23
+ content: "";
24
+ position: absolute;
25
+ border-style: solid;
26
+ border-width: 7px;
27
+ }
28
+
29
+ ${ ( { place, theme } ) => css `
30
+ ${ place === "top" &&
31
+ css `
32
+ top: 100%;
33
+ left: 50%;
34
+ transform: translateX(-50%);
35
+ border-color: ${ theme . klerosUIComponentsStroke } transparent transparent
36
+ transparent;
37
+
38
+ ::after {
39
+ left: -7px;
40
+ top: -8.5px;
41
+ border-color: ${ theme . klerosUIComponentsLightBlue } transparent
42
+ transparent transparent;
43
+ }
44
+ ` }
45
+ ${ place === "right" &&
46
+ css `
47
+ top: 50%;
48
+ right: 100%;
49
+ transform: translateY(-50%);
50
+ border-color: transparent ${ theme . klerosUIComponentsStroke } transparent
51
+ transparent;
52
+
53
+ ::after {
54
+ left: -5.5px;
55
+ top: -7px;
56
+ border-color: transparent ${ theme . klerosUIComponentsLightBlue }
57
+ transparent transparent;
58
+ }
59
+ ` }
60
+ ${ place === "bottom" &&
61
+ css `
62
+ left: 50%;
63
+ bottom: 100%;
64
+ transform: translateX(-50%);
65
+ border-color: transparent transparent ${ theme . klerosUIComponentsStroke }
66
+ transparent;
67
+
68
+ ::after {
69
+ left: -7px;
70
+ top: -5.5px;
71
+ border-color: transparent transparent
72
+ ${ theme . klerosUIComponentsLightBlue } transparent;
73
+ }
74
+ ` }
75
+ ${ place === "left" &&
76
+ css `
77
+ top: 50%;
78
+ left: 100%;
79
+ transform: translateY(-50%);
80
+ border-color: transparent transparent transparent
81
+ ${ theme . klerosUIComponentsStroke } ;
82
+ ::after {
83
+ left: -8.5px;
84
+ top: -7px;
85
+ border-color: transparent transparent transparent
86
+ ${ theme . klerosUIComponentsLightBlue } ;
87
+ }
88
+ ` }
89
+ ` }
90
+ ` ;
91
+
12
92
const StyledTooltip = styled . span < TooltipBaseProps > `
13
93
${ borderBox }
14
94
${ ( { place, theme, small } ) => css `
@@ -17,8 +97,9 @@ const StyledTooltip = styled.span<TooltipBaseProps>`
17
97
z-index: 1;
18
98
width: max-content;
19
99
max-width: 240px;
20
- background: ${ theme . klerosUIComponentsPrimaryBlue } ;
21
- border-radius: 3px;
100
+ background: ${ theme . klerosUIComponentsLightBlue } ;
101
+ border: 1px solid ${ theme . klerosUIComponentsStroke } ;
102
+ border-radius: 7px;
22
103
padding: 13px 16px;
23
104
display: flex;
24
105
justify-content: center;
@@ -28,67 +109,32 @@ const StyledTooltip = styled.span<TooltipBaseProps>`
28
109
${ smallStyle }
29
110
font-weight: 100;
30
111
text-align: ${ small ? "center" : "left" } ;
31
- color: ${ theme . klerosUIComponentsWhiteBackground } ;
32
- }
33
-
34
- ::after {
35
- content: "";
36
- position: absolute;
37
- border-width: 8px;
38
- border-style: solid;
112
+ color: ${ theme . klerosUIComponentsPrimaryText } ;
39
113
}
40
114
41
115
${ place === "top" &&
42
116
css `
43
117
bottom: calc(100% + 16px);
44
118
left: 50%;
45
119
transform: translateX(-50%);
46
- ::after {
47
- top: 100%;
48
- left: 50%;
49
- transform: translateX(-50%);
50
- border-color: ${ theme . klerosUIComponentsPrimaryBlue } transparent
51
- transparent transparent;
52
- }
53
120
` }
54
121
${ place === "right" &&
55
122
css `
56
123
top: 50%;
57
124
left: calc(100% + 16px);
58
125
transform: translateY(-50%);
59
- ::after {
60
- top: 50%;
61
- right: 100%;
62
- transform: translateY(-50%);
63
- border-color: transparent ${ theme . klerosUIComponentsPrimaryBlue }
64
- transparent transparent;
65
- }
66
126
` }
67
127
${ place === "bottom" &&
68
128
css `
69
129
top: calc(100% + 16px);
70
130
left: 50%;
71
131
transform: translateX(-50%);
72
- ::after {
73
- left: 50%;
74
- bottom: 100%;
75
- transform: translateX(-50%);
76
- border-color: transparent transparent
77
- ${ theme . klerosUIComponentsPrimaryBlue } transparent;
78
- }
79
132
` }
80
133
${ place === "left" &&
81
134
css `
82
135
top: 50%;
83
136
right: calc(100% + 16px);
84
137
transform: translateY(-50%);
85
- ::after {
86
- top: 50%;
87
- left: 100%;
88
- transform: translateY(-50%);
89
- border-color: transparent transparent transparent
90
- ${ theme . klerosUIComponentsPrimaryBlue } ;
91
- }
92
138
` }
93
139
` }
94
140
` ;
@@ -99,6 +145,7 @@ const Wrapper = styled.div`
99
145
100
146
&:hover ${ StyledTooltip } {
101
147
visibility: visible;
148
+ animation: ${ fadeIn } 200ms ease-in;
102
149
}
103
150
` ;
104
151
@@ -116,8 +163,9 @@ const Tooltip: React.FC<TooltipProps> = ({
116
163
} ) => (
117
164
< Wrapper { ...props } >
118
165
{ children }
119
- < StyledTooltip { ...{ small, place } } >
120
- < StyledText > { text } </ StyledText >
166
+ < StyledTooltip { ...{ small, place } } className = "tooltip-container" >
167
+ < Tip { ...{ place } } />
168
+ < StyledText className = "tooltip-text" > { text } </ StyledText >
121
169
</ StyledTooltip >
122
170
</ Wrapper >
123
171
) ;
0 commit comments