diff --git a/.changeset/rotten-schools-whisper.md b/.changeset/rotten-schools-whisper.md deleted file mode 100644 index c64ad0276a9..00000000000 --- a/.changeset/rotten-schools-whisper.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/react': minor ---- - -Tooltip v1: Remove the caret from the tooltip to make it consistent with the new tooltip design diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-colorblind-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-colorblind-open-linux.png index 2dd86a8cd1e..13c0f1fd200 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-colorblind-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-colorblind-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-dimmed-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-dimmed-open-linux.png index 1351e2d7526..4cfb242f690 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-dimmed-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-dimmed-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-high-contrast-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-high-contrast-open-linux.png index ed268e6cf27..7b297cb3103 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-high-contrast-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-high-contrast-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-open-linux.png index 916bab6c482..e254be8ae47 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-tritanopia-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-tritanopia-open-linux.png index 2dd86a8cd1e..13c0f1fd200 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-tritanopia-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-dark-tritanopia-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-colorblind-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-colorblind-open-linux.png index 7d47f2f9443..72572185338 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-colorblind-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-colorblind-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-high-contrast-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-high-contrast-open-linux.png index f4a46433262..d520cb1eaf4 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-high-contrast-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-high-contrast-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-open-linux.png index ed38c83b1fb..ab1d7dd970e 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-open-linux.png differ diff --git a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-tritanopia-open-linux.png b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-tritanopia-open-linux.png index 7d47f2f9443..72572185338 100644 Binary files a/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-tritanopia-open-linux.png and b/.playwright/snapshots/components/Tooltip.test.ts-snapshots/Tooltip-Default-light-tritanopia-open-linux.png differ diff --git a/packages/react/src/Tooltip/Tooltip.features.stories.tsx b/packages/react/src/Tooltip/Tooltip.features.stories.tsx index a977be340db..2d66a68c3f3 100644 --- a/packages/react/src/Tooltip/Tooltip.features.stories.tsx +++ b/packages/react/src/Tooltip/Tooltip.features.stories.tsx @@ -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' @@ -24,35 +24,6 @@ export default { ], } as Meta -export const AllDirections = () => ( - - - - - - - - - - - - - - - - - - - - - - - - - - -) - export const IconButtonTooltip = () => ( diff --git a/packages/react/src/Tooltip/Tooltip.tsx b/packages/react/src/Tooltip/Tooltip.tsx index c499c77d72b..a98700cd6bd 100644 --- a/packages/react/src/Tooltip/Tooltip.tsx +++ b/packages/react/src/Tooltip/Tooltip.tsx @@ -12,6 +12,19 @@ const TooltipBase = styled.span` 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; @@ -49,6 +62,7 @@ const TooltipBase = styled.span` &:active, &:focus, &:focus-within { + &::before, &::after { display: inline-block; text-decoration: none; @@ -56,7 +70,7 @@ const TooltipBase = styled.span` animation-duration: 0.1s; animation-fill-mode: forwards; animation-timing-function: ease-in; - animation-delay: 0s; + animation-delay: 0.4s; } } @@ -64,6 +78,7 @@ const TooltipBase = styled.span` &.tooltipped-no-delay:active, &.tooltipped-no-delay:focus, &.tooltipped-no-delay:focus-within { + &::before, &::after { animation-delay: 0s; } @@ -87,6 +102,14 @@ const TooltipBase = styled.span` right: 50%; margin-top: 6px; } + + &::before { + top: auto; + right: 50%; + bottom: -7px; + margin-right: -6px; + border-bottom-color: ${get('colors.neutral.emphasisPlus')}; + } } &.tooltipped-se { @@ -110,6 +133,14 @@ const TooltipBase = styled.span` bottom: 100%; margin-bottom: 6px; } + + &::before { + top: -7px; + right: 50%; + bottom: auto; + margin-right: -6px; + border-top-color: ${get('colors.neutral.emphasisPlus')}; + } } &.tooltipped-ne { @@ -138,6 +169,14 @@ const TooltipBase = styled.span` 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 @@ -148,6 +187,14 @@ const TooltipBase = styled.span` 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 { @@ -177,11 +224,19 @@ const TooltipBase = styled.span` 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}; `