Skip to content

Commit 24f5a3c

Browse files
author
Vikas Agarwal
committed
Github issue #372, [Pagination] - keep fixed pagination option displaying 5 pages.
-- Added new lighter theme for the tooltips to align with paginator tooltip designs -- Fixed pointer style for the case where tooltip is shown in the right of the target
1 parent 776a122 commit 24f5a3c

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

components/Tooltip/Tooltip.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Tooltip extends Component {
3636
ttContainer.style.padding = tooltipPadding + 'px'
3737
tooltipPointer.style.width = pointerWidth + 'px'
3838
tooltipPointer.style.height = pointerWidth + 'px'
39+
tooltipPointer.classList.remove('upward-pointer', 'downward-pointer', 'leftward-pointer')
3940
const ttBorderRadius = getComputedStyle(ttContainer).getPropertyValue('border-top-left-radius').replace(/[^-\d\.]/g, '')
4041
//if right side of tooltip will fit above/below target on screen when centered to target
4142
if (targetRectCenterX + (tooltip.clientWidth / 2) + tooltipMargin < document.body.clientWidth) {
@@ -68,16 +69,19 @@ class Tooltip extends Component {
6869
if (targetRectCenterX < (tooltip.clientWidth / 2) + tooltipMargin && window.scrollY < (targetRectCenterY - (tooltip.clientHeight / 2)) && targetRect.right + tooltip.clientWidth + tooltipMargin + (pointerWidth/2) + pointerGap < document.body.clientWidth) {
6970
tooltip.style.left = parseInt(targetRectStyle.marginLeft) + targetRect.width + pointerGap + (pointerWidth/2) + 'px'
7071
tooltip.style.top = targetRect.height / 2 - (tooltip.clientHeight/2) + 'px'
71-
tooltipPointer.style.top = pointerGap + pointerWidth /2 + 'px'
72+
tooltipPointer.style.top = tooltipRect.height/2 - (pointerWidth / Math.sqrt(2)) + 'px'
7273
tooltipPointerLeft = - (pointerWidth/2) + 'px'
74+
tooltipPointer.classList.add('leftward-pointer')
7375
} else {
7476
tooltip.style.top = targetRect.height + pointerGap + (pointerWidth/2) + 'px'
77+
tooltipPointer.classList.add('upward-pointer')
7578
tooltipPointer.style.top = - pointerGap + 'px'
7679
}
7780
} else {
7881
tooltip.style.top = - tooltip.clientHeight - pointerGap - (pointerWidth / Math.sqrt(2)) + 'px'
7982
tooltipPointer.style.bottom = - (pointerWidth/2) + 'px'
8083
tooltipPointer.style.top = 'auto'
84+
tooltipPointer.classList.add('downward-pointer')
8185
}
8286
tooltipPointer.style.left = tooltipPointerLeft
8387

components/Tooltip/Tooltip.scss

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@
2525
}
2626

2727
.tooltip-content-container {
28-
background-color: $tc-gray-80;
29-
color: #fff;
3028
width: 100%;
31-
height: 100%;
29+
overflow: hidden;
3230
padding: 15px;
3331
-webkit-border-radius: 5px;
3432
-moz-border-radius: 5px;
@@ -38,32 +36,58 @@
3836
position: absolute;
3937
height: 10px;
4038
width: 10px;
41-
background-color: $tc-gray-80;
4239
transform: rotate(45deg);
4340
bottom: -5px;
4441
left: calc(50% - 5px);
45-
z-index:-1;
4642
}
4743

4844
.tooltip-body {
49-
// position: relative;
50-
color: #fff;
5145
font-size: 14px;
5246
padding: 0;
5347
margin: 0;
54-
// z-index:2;
5548
}
5649
}
5750
}
5851
//tooltip theme styling
5952
&.default {
6053
.tooltip-content-container {
54+
background-color: $tc-gray-80;
55+
color: #fff;
6156
//additional theme styling goes here
6257
.tooltip-pointer {
63-
58+
background-color: $tc-gray-80;
6459
}
6560
.tooltip-body {
61+
color: #fff;
62+
}
63+
}
64+
}
65+
//tooltip light theme
66+
&.light {
67+
.tooltip-content-container {
68+
background-color: $tc-white;
69+
border: 1px solid $tc-gray-neutral-dark;
70+
color: $tc-gray-80;
71+
//additional theme styling goes here
72+
.tooltip-pointer {
73+
background-color: $tc-white;
74+
border-style: solid;
75+
border-color: $tc-gray-neutral-dark;
6676

77+
&.downward-pointer {
78+
border-width: 0px 1px 1px 0px;
79+
}
80+
81+
&.upward-pointer {
82+
border-width: 1px 0px 0px 1px;
83+
}
84+
85+
&.leftward-pointer {
86+
border-width: 0px 0px 1px 1px;
87+
}
88+
}
89+
.tooltip-body {
90+
color: $tc-gray-80;
6791
}
6892
}
6993
}

components/Tooltip/TooltipExamples.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require('./TooltipExamples.scss')
55

66
const TooltipExamples = () => (
77
<div className="tooltip-examples-container">
8-
<Tooltip>
8+
<Tooltip theme="light">
99
<div className="tooltip-target" id="tooltip-1">Default Mouseover Tooltip Example</div>
1010
<div className="tooltip-body">
1111
<p>This is a tooltip using the default theme.</p>

0 commit comments

Comments
 (0)