Skip to content

Commit

Permalink
Revert Tooltip caret removal (#2324)
Browse files Browse the repository at this point in the history
Co-authored-by: langermank <langermank@users.noreply.github.com>
  • Loading branch information
langermank and langermank authored Oct 23, 2023
1 parent 8270c06 commit cc44952
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/red-moles-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@primer/view-components": patch
---

Revert Tooltip caret removal

<!-- Changed components: Tooltip -->

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 76 additions & 3 deletions app/components/primer/alpha/tool_tip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const isPopoverOpen = (() => {
return (el: Element) => (selector ? el.matches(selector) : setSelector(el))
})()

const TOOLTIP_ARROW_EDGE_OFFSET = 6
const TOOLTIP_SR_ONLY_CLASS = 'sr-only'
const TOOLTIP_OFFSET = 4
const TOOLTIP_OFFSET = 10

type Direction = 'n' | 's' | 'e' | 'w' | 'ne' | 'se' | 'nw' | 'sw'

Expand Down Expand Up @@ -91,15 +92,33 @@ class ToolTipElement extends HTMLElement {
text-wrap: balance;
}
:host:before{
position: absolute;
z-index: 1000001;
color: var(--bgColor-emphasis, var(--color-neutral-emphasis-plus));
content: "";
border: 6px solid transparent;
opacity: 0;
}
@keyframes tooltip-appear {
from {
opacity: 0;
}
to {
opacity: 1
opacity: 1;
}
}
:host:after{
position: absolute;
display: block;
right: 0;
left: 0;
height: 12px;
content: "";
}
:host(:popover-open),
:host(:popover-open):before {
animation-name: tooltip-appear;
Expand All @@ -108,11 +127,65 @@ class ToolTipElement extends HTMLElement {
animation-timing-function: ease-in;
}
:host(.\\:popover-open) {
:host(.\\:popover-open),
:host(.\\:popover-open):before {
animation-name: tooltip-appear;
animation-duration: .1s;
animation-fill-mode: forwards;
animation-timing-function: ease-in;
animation-delay: .4s;
}
:host(.tooltip-s):before,
:host(.tooltip-n):before {
right: 50%;
margin-right: -${TOOLTIP_ARROW_EDGE_OFFSET}px;
}
:host(.tooltip-s):before,
:host(.tooltip-se):before,
:host(.tooltip-sw):before {
bottom: 100%;
border-bottom-color: var(--bgColor-emphasis, var(--color-neutral-emphasis-plus));
}
:host(.tooltip-s):after,
:host(.tooltip-se):after,
:host(.tooltip-sw):after {
bottom: 100%
}
:host(.tooltip-n):before,
:host(.tooltip-ne):before,
:host(.tooltip-nw):before {
top: 100%;
border-top-color: var(--bgColor-emphasis, var(--color-neutral-emphasis-plus));
}
:host(.tooltip-n):after,
:host(.tooltip-ne):after,
:host(.tooltip-nw):after {
top: 100%;
}
:host(.tooltip-se):before,
:host(.tooltip-ne):before {
left: 0;
margin-left: ${TOOLTIP_ARROW_EDGE_OFFSET}px;
}
:host(.tooltip-sw):before,
:host(.tooltip-nw):before {
right: 0;
margin-right: ${TOOLTIP_ARROW_EDGE_OFFSET}px;
}
:host(.tooltip-w):before {
top: 50%;
bottom: 50%;
left: 100%;
margin-top: -6px;
border-left-color: var(--bgColor-emphasis, var(--color-neutral-emphasis-plus));
}
:host(.tooltip-e):before {
top: 50%;
right: 100%;
bottom: 50%;
margin-top: -6px;
border-right-color: var(--bgColor-emphasis, var(--color-neutral-emphasis-plus));
}
`
}
Expand Down

0 comments on commit cc44952

Please sign in to comment.