Skip to content

Commit ae38e00

Browse files
committed
Improve tooltip styling
1 parent 39e3803 commit ae38e00

File tree

2 files changed

+87
-22
lines changed

2 files changed

+87
-22
lines changed

app/renderer/components/Tooltip.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,22 @@ class Tooltip extends React.PureComponent {
4040
{state => (
4141
<div
4242
ref={ref}
43-
className={classNames('Tooltip', `Tooltip--${state}`)}
43+
className={classNames(
44+
'Tooltip',
45+
`Tooltip--${state}`,
46+
`Tooltip--${placement}`
47+
)}
4448
style={{
4549
...style,
4650
transitionDuration: `${animationDuration}ms`,
4751
}}
4852
>
49-
{content}
53+
<div className="Tooltip__content">
54+
{content}
55+
</div>
5056
<div
5157
ref={arrowProps.ref}
52-
className={classNames('Tooltip__arrow', `Tooltip__arrow--${placement}`)}
58+
className="Tooltip__arrow"
5359
style={arrowProps.style}
5460
/>
5561
</div>
@@ -63,7 +69,12 @@ class Tooltip extends React.PureComponent {
6369
<Manager>
6470
<Reference>
6571
{({ref}) => (
66-
<div ref={ref} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
72+
<div
73+
ref={ref}
74+
style={{display: 'inlineBlock'}}
75+
onMouseEnter={this.handleMouseEnter}
76+
onMouseLeave={this.handleMouseLeave}
77+
>
6778
{children}
6879
</div>
6980
)}

app/renderer/components/Tooltip.scss

+72-18
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,93 @@
11
.Tooltip {
2-
background-color: var(--border-color);
3-
border-radius: 4px;
4-
font-size: 13px;
2+
--color: var(--border-color);
3+
--arrow-height: 8px;
4+
--arrow-width: 12px;
5+
56
opacity: 0;
6-
padding: 8px 10px;
77
transition: opacity ease-in-out;
88

9-
&--entered {
10-
opacity: 1;
9+
&__content {
10+
background-color: var(--color);
11+
border-radius: 4px;
12+
font-size: 13px;
13+
padding: 8px 10px;
14+
text-align: center;
1115
}
1216

1317
&__arrow {
18+
display: block;
19+
height: var(--arrow-height);
1420
position: absolute;
15-
width: 16px;
16-
height: 24px;
21+
width: var(--arrow-width);
1722

1823
&:before {
24+
border-color: transparent;
1925
border-style: solid;
2026
content: '';
21-
display: block;
22-
height: 0;
23-
margin: auto;
24-
width: 0;
27+
position: absolute;
2528
}
29+
}
30+
31+
&--entered {
32+
opacity: 1;
33+
}
2634

27-
&--top {
35+
&--top {
36+
padding: var(--arrow-height) 0;
37+
38+
.Tooltip__arrow {
2839
bottom: 0;
29-
height: calc(24px / 3);
40+
41+
&:before {
42+
border-top-color: var(--color);
43+
border-width: var(--arrow-height) calc(var(--arrow-width) / 2) 0;
44+
top: 0;
45+
}
46+
}
47+
}
48+
49+
&--right {
50+
padding: 0 var(--arrow-height);
51+
52+
.Tooltip__arrow {
53+
height: var(--arrow-width);
3054
left: 0;
31-
margin-bottom: calc(-24px / 3);
32-
width: 16px;
55+
width: var(--arrow-height);
56+
57+
&:before {
58+
border-right-color: var(--color);
59+
border-width: calc(var(--arrow-width) / 2) var(--arrow-height) calc(var(--arrow-width) / 2) 0;
60+
right: 0;
61+
}
62+
}
63+
}
64+
65+
&--bottom {
66+
padding: var(--arrow-height) 0;
67+
68+
.Tooltip__arrow {
69+
top: 0;
70+
71+
&:before {
72+
border-bottom-color: var(--color);
73+
border-width: 0 calc(var(--arrow-width) / 2) var(--arrow-height);
74+
bottom: 0;
75+
}
76+
}
77+
}
78+
79+
&--left {
80+
padding: 0 var(--arrow-height);
81+
82+
.Tooltip__arrow {
83+
height: var(--arrow-width);
84+
right: 0;
85+
width: var(--arrow-height);
3386

3487
&:before {
35-
border-color: var(--border-color) transparent transparent transparent;
36-
border-width: calc(24px / 3) 8px 0 8px;
88+
border-left-color: var(--color);
89+
border-width: calc(var(--arrow-width) / 2) 0 calc(var(--arrow-width) / 2) var(--arrow-height);
90+
left: 0;
3791
}
3892
}
3993
}

0 commit comments

Comments
 (0)