Skip to content

Commit

Permalink
Tooltip v1: Remove the caret from the tooltip to make it consistent w…
Browse files Browse the repository at this point in the history
…ith the new tooltip, css and rails - Do not merge (#4156)

* Tooltip v1: Remove the caret

* update the border radius

* snaps

* test(vrt): update snapshots

* do not delay the animation

* fix up conflict issue snapshot

* Update .changeset/rotten-schools-whisper.md

---------

Co-authored-by: langermank <langermank@users.noreply.github.com>
  • Loading branch information
broccolinisoup and langermank authored Mar 4, 2024
1 parent 32b0cf7 commit 9bd3a0c
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 191 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-schools-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Tooltip v1: Remove the caret from the tooltip to make it consistent with the new tooltip design
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.
31 changes: 30 additions & 1 deletion packages/react/src/Tooltip/Tooltip.features.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import type {Meta} from '@storybook/react'
import {BaseStyles, ThemeProvider, IconButton} from '..'
import {BaseStyles, ThemeProvider, IconButton, Button} from '..'
import Box from '../Box'
import Tooltip from './Tooltip'
import {SearchIcon} from '@primer/octicons-react'
Expand All @@ -24,6 +24,35 @@ export default {
],
} as Meta

export const AllDirections = () => (
<Box sx={{padding: 5, display: 'flex', gap: '8px'}}>
<Tooltip direction="n" aria-label="Supplementary text">
<Button>North</Button>
</Tooltip>
<Tooltip direction="s" aria-label="Supplementary text">
<Button>South</Button>
</Tooltip>
<Tooltip direction="e" aria-label="Supplementary text">
<Button>East</Button>
</Tooltip>
<Tooltip direction="w" aria-label="Supplementary text">
<Button>West</Button>
</Tooltip>
<Tooltip direction="ne" aria-label="Supplementary text">
<Button>North East</Button>
</Tooltip>
<Tooltip direction="nw" aria-label="Supplementary text">
<Button>North West</Button>
</Tooltip>
<Tooltip direction="se" aria-label="Supplementary text">
<Button>Southeast</Button>
</Tooltip>
<Tooltip direction="sw" aria-label="Supplementary text">
<Button>Southwest</Button>
</Tooltip>
</Box>
)

export const IconButtonTooltip = () => (
<Box sx={{p: 5}}>
<Tooltip aria-label="Search">
Expand Down
57 changes: 1 addition & 56 deletions packages/react/src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ const TooltipBase = styled.span<SxProp>`
position: relative;
display: inline-block;
&::before {
position: absolute;
z-index: 1000001;
display: none;
width: 0px;
height: 0px;
color: ${get('colors.neutral.emphasisPlus')};
pointer-events: none;
content: '';
border: 6px solid transparent;
opacity: 0;
}
&::after {
position: absolute;
z-index: 1000000;
Expand Down Expand Up @@ -62,23 +49,21 @@ const TooltipBase = styled.span<SxProp>`
&:active,
&:focus,
&:focus-within {
&::before,
&::after {
display: inline-block;
text-decoration: none;
animation-name: tooltip-appear;
animation-duration: 0.1s;
animation-fill-mode: forwards;
animation-timing-function: ease-in;
animation-delay: 0.4s;
animation-delay: 0s;
}
}
&.tooltipped-no-delay:hover,
&.tooltipped-no-delay:active,
&.tooltipped-no-delay:focus,
&.tooltipped-no-delay:focus-within {
&::before,
&::after {
animation-delay: 0s;
}
Expand All @@ -102,14 +87,6 @@ const TooltipBase = styled.span<SxProp>`
right: 50%;
margin-top: 6px;
}
&::before {
top: auto;
right: 50%;
bottom: -7px;
margin-right: -6px;
border-bottom-color: ${get('colors.neutral.emphasisPlus')};
}
}
&.tooltipped-se {
Expand All @@ -133,14 +110,6 @@ const TooltipBase = styled.span<SxProp>`
bottom: 100%;
margin-bottom: 6px;
}
&::before {
top: -7px;
right: 50%;
bottom: auto;
margin-right: -6px;
border-top-color: ${get('colors.neutral.emphasisPlus')};
}
}
&.tooltipped-ne {
Expand Down Expand Up @@ -169,14 +138,6 @@ const TooltipBase = styled.span<SxProp>`
margin-right: 6px;
transform: translateY(50%);
}
&::before {
top: 50%;
bottom: 50%;
left: -7px;
margin-top: -6px;
border-left-color: ${get('colors.neutral.emphasisPlus')};
}
}
// tooltipped to the right
Expand All @@ -187,14 +148,6 @@ const TooltipBase = styled.span<SxProp>`
margin-left: 6px;
transform: translateY(50%);
}
&::before {
top: 50%;
right: -7px;
bottom: 50%;
margin-top: -6px;
border-right-color: ${get('colors.neutral.emphasisPlus')};
}
}
&.tooltipped-multiline {
Expand Down Expand Up @@ -224,19 +177,11 @@ const TooltipBase = styled.span<SxProp>`
margin-right: 0;
}
&.tooltipped-align-right-2::before {
right: 15px;
}
&.tooltipped-align-left-2::after {
left: 0;
margin-left: 0;
}
&.tooltipped-align-left-2::before {
left: 10px;
}
${sx};
`

Expand Down
Loading

0 comments on commit 9bd3a0c

Please sign in to comment.