Skip to content

Commit

Permalink
fix: alignment of tooltip to source on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
mdt2 committed May 8, 2024
1 parent 4ba7f11 commit 774d2d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
18 changes: 11 additions & 7 deletions components/tooltip/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ governing permissions and limitations under the License.
inline-size: var(--mod-tooltip-tip-square-size, var(--spectrum-tooltip-tip-square-size));

inset-block-start: 100%;
/* stylelint-disable-next-line csstools/use-logical */
/* stylelint-disable-next-line csstools/use-logical -- intentional use of non-logical property */
left: 50%;
transform: translateX(-50%);

Expand Down Expand Up @@ -392,7 +392,8 @@ governing permissions and limitations under the License.
.spectrum-Tooltip--right,
.spectrum-Tooltip--right-bottom,
.spectrum-Tooltip--right-top {
margin-inline-start: calc(var(--mod-tooltip-tip-block-size, var(--spectrum-tooltip-tip-block-size)) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)));
/* stylelint-disable-next-line csstools/use-logical -- intentional use of non-logical property */
margin-left: calc(var(--mod-tooltip-tip-block-size, var(--spectrum-tooltip-tip-block-size)) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)));

/* Tooltip animates to right ⮕ */
&.is-open {
Expand All @@ -404,7 +405,8 @@ governing permissions and limitations under the License.
.spectrum-Tooltip--left,
.spectrum-Tooltip--left-bottom,
.spectrum-Tooltip--left-top {
margin-inline-end: calc(var(--mod-tooltip-tip-block-size, var(--spectrum-tooltip-tip-block-size)) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)));
/* stylelint-disable-next-line csstools/use-logical -- intentional use of non-logical property */
margin-right: calc(var(--mod-tooltip-tip-block-size, var(--spectrum-tooltip-tip-block-size)) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)));

/* Tooltip animates to left ⬅ */
&.is-open {
Expand Down Expand Up @@ -486,7 +488,8 @@ governing permissions and limitations under the License.
.spectrum-Tooltip--bottom-right,
.spectrum-Tooltip--bottom-start,
.spectrum-Tooltip--bottom-end {
inset-inline-start: 50%;
/* stylelint-disable-next-line csstools/use-logical -- intentional use of non-logical property */
left: 50%;
transform: translate(-50%, 0);
}

Expand Down Expand Up @@ -528,7 +531,8 @@ governing permissions and limitations under the License.
.spectrum-Tooltip--start,
.spectrum-Tooltip--start-top,
.spectrum-Tooltip--start-bottom {
inset-inline-end: 100%;
/* stylelint-disable-next-line csstools/use-logical -- intentional use of non-logical property */
right: 100%;
}

/* RTL */
Expand All @@ -547,7 +551,8 @@ governing permissions and limitations under the License.
.spectrum-Tooltip--end,
.spectrum-Tooltip--end-top,
.spectrum-Tooltip--end-bottom {
inset-inline: 100% auto;
/* stylelint-disable-next-line csstools/use-logical -- intentional use of non-logical property */
left: 100%;
}

/* RTL */
Expand Down Expand Up @@ -600,7 +605,6 @@ governing permissions and limitations under the License.
}
}

/* stylelint-disable max-nesting-depth */
/* RTL */
&:dir(rtl) {
&:hover,
Expand Down
8 changes: 8 additions & 0 deletions components/tooltip/metadata/tooltip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ sections:
This component can be modified via its `--mod-*` prefixed custom properties. A list of those prefixed custom properties can be found <a class="spectrum-Link" href="https://github.com/adobe/spectrum-css/tree/main/components/tooltip/metadata/mods.md">here</a>.
- name: Migration Guide
description: |
### Version 6.1.1
This patch includes tooltip placement adjustments for RTL bugs and increased coverage with Chromatic VRTs. Some clarification on placements:
- If you use a Start or End placement, the tooltip *will* change to the other side of the source when the text direction (LTR/RTL) is changed
- If you use a Left or Right placement, the tooltip *will not* change sides when text direction is changed
As a result of the placement specifications, some placements intentionally use non-logical properties in the CSS (particularly for tooltips that show on hover).
### Tooltip now has 22 directions
- 10 of the new directions are logical and should be tested both left-to-right and right-to-left
examples:
Expand Down

0 comments on commit 774d2d0

Please sign in to comment.