Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/rotten-schools-whisper.md

This file was deleted.

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: 1 addition & 30 deletions 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, Button} from '..'
import {BaseStyles, ThemeProvider, IconButton} from '..'
import Box from '../Box'
import Tooltip from './Tooltip'
import {SearchIcon} from '@primer/octicons-react'
Expand All @@ -24,35 +24,6 @@ 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: 56 additions & 1 deletion packages/react/src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ 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 @@ -49,21 +62,23 @@ 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: 0s;
animation-delay: 0.4s;
}
}

&.tooltipped-no-delay:hover,
&.tooltipped-no-delay:active,
&.tooltipped-no-delay:focus,
&.tooltipped-no-delay:focus-within {
&::before,
&::after {
animation-delay: 0s;
}
Expand All @@ -87,6 +102,14 @@ 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 @@ -110,6 +133,14 @@ 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 @@ -138,6 +169,14 @@ 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 @@ -148,6 +187,14 @@ 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 @@ -177,11 +224,19 @@ 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