11import React from "react" ;
22import 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" ;
48
59export interface TooltipBaseProps {
610 place ?: "left" | "right" | "top" | "bottom" ;
@@ -9,6 +13,82 @@ export interface TooltipBaseProps {
913
1014const StyledText = styled . small `` ;
1115
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+
1292const StyledTooltip = styled . span < TooltipBaseProps > `
1393 ${ borderBox }
1494 ${ ( { place, theme, small } ) => css `
@@ -17,8 +97,9 @@ const StyledTooltip = styled.span<TooltipBaseProps>`
1797 z-index: 1;
1898 width: max-content;
1999 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;
22103 padding: 13px 16px;
23104 display: flex;
24105 justify-content: center;
@@ -28,67 +109,32 @@ const StyledTooltip = styled.span<TooltipBaseProps>`
28109 ${ smallStyle }
29110 font-weight: 100;
30111 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 } ;
39113 }
40114
41115 ${ place === "top" &&
42116 css `
43117 bottom: calc(100% + 16px);
44118 left: 50%;
45119 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- }
53120 ` }
54121 ${ place === "right" &&
55122 css `
56123 top: 50%;
57124 left: calc(100% + 16px);
58125 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- }
66126 ` }
67127 ${ place === "bottom" &&
68128 css `
69129 top: calc(100% + 16px);
70130 left: 50%;
71131 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- }
79132 ` }
80133 ${ place === "left" &&
81134 css `
82135 top: 50%;
83136 right: calc(100% + 16px);
84137 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- }
92138 ` }
93139 ` }
94140` ;
@@ -99,6 +145,7 @@ const Wrapper = styled.div`
99145
100146 &:hover ${ StyledTooltip } {
101147 visibility: visible;
148+ animation: ${ fadeIn } 200ms ease-in;
102149 }
103150` ;
104151
@@ -116,8 +163,9 @@ const Tooltip: React.FC<TooltipProps> = ({
116163} ) => (
117164 < Wrapper { ...props } >
118165 { 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 >
121169 </ StyledTooltip >
122170 </ Wrapper >
123171) ;
0 commit comments