Skip to content

Commit

Permalink
fix(tooltip): position fix (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
asudoh authored and alisonjoseph committed Jun 1, 2018
1 parent d855cfe commit 8d01153
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
13 changes: 4 additions & 9 deletions src/components/tooltip/_tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
display: none;
max-width: rem(240px);
background: $ui-01;
margin-top: $spacing-xs;
padding: $spacing-md;
border: 1px solid $ui-03;
border-radius: rem(4px);
Expand Down Expand Up @@ -99,13 +98,11 @@
}

&[data-floating-menu-direction='left'] {
margin-left: -$spacing-sm;

.#{$prefix}--tooltip__caret {
left: auto;
top: 44.7%;
top: 50%;
right: rem(-5px);
transform: rotate(-45deg);
transform: rotate(-45deg) translate(50%, -50%);
}
}

Expand All @@ -118,13 +115,11 @@
}

&[data-floating-menu-direction='right'] {
margin-left: $spacing-sm;

.#{$prefix}--tooltip__caret {
left: rem(-5px);
top: 44.7%;
top: 50%;
right: auto;
transform: rotate(135deg);
transform: rotate(135deg) translate(-50%, 50%);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/tooltip/tooltip.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</svg>
</div>
</div>
<div id="unique-tooltip" data-floating-menu-direction="top" class="bx--tooltip">
<div id="unique-tooltip" data-floating-menu-direction="bottom" class="bx--tooltip">
<span class="bx--tooltip__caret"></span>
<p>This is some tooltip text. This box shows the maximum amount of text that should appear inside. If more room is needed
please use a modal instead.</p>
Expand Down
7 changes: 0 additions & 7 deletions src/components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ const getMenuOffset = (menuBody, menuDirection) => {
values[arrowPositionProp] = values[arrowPositionProp] || -6; // IE, etc.
if (Object.keys(values).every(name => !isNaN(values[name]))) {
const { [arrowPositionProp]: arrowPosition, 'border-bottom-width': borderBottomWidth } = values;
if (arrowPositionProp === 'bottom') {
return {
left: 0,
top: 0,
[menuPositionAdjustmentProp]: Math.sqrt(borderBottomWidth ** 2 * 2) - arrowPosition * 4,
};
}
return {
left: 0,
top: 0,
Expand Down

0 comments on commit 8d01153

Please sign in to comment.