-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tooltip: Tooltip V2 as an experimental/draft with the new popover API (…
…#3394) * Tooltip remediations as an experimental * Update generated/components.json * fix export path * popover with keith and top layer height experiment to accomodate ::before * get rid of caret, align styling and update the API * fix after stuff * add a calculated direction to properly position ::after relatively to tooltip * clean up * add a story for a dotcom usage * re organise stories and remove caret styles for now * ewmove unused Box * css polyfill issues are resolved - huge thanks to Keith * update tests to reflect default direction s * ActionMenu.Anchor tooltip - not the cleanest code * ActionMenu.Anchor and ActionMenu.Button with tooltip * only type the child * fix type * use React.forwardRef and clean up impl for action menu anchor buttons * move tooltip from experimental to drafts * export tooltip in draft * SSR friendly polyfill * Resolve oddbird-polyfil module resolution issue - huge thanks to Josh * add e2e stories, clean up * test(vrt): update snapshots * add changeset * test(vrt): update snapshots * update docs * to revert later - just adding a test story to sgare * delete snapshots to regenerate them * test(vrt): update snapshots * Remove animations delays and noDelay prop * reorganise vrt * test(vrt): update snapshots * add threshold to snapshots * delete failed snapshots * delete failed snapshots * ActionMenu.Button children undefined at dotcom * 🔥 snapshots * reorganise if logic in actionmenu * test(vrt): update snapshots * remove always failing or flaky snapshot tests * reorganise action menu again * add popover polyfill to the esm only modules in rollup * add test cases for tooltip on action menu both for v1 and v2 * clean up * Update docs/gatsby-config.js --------- Co-authored-by: broccolinisoup <broccolinisoup@users.noreply.github.com>
- Loading branch information
1 parent
f080f72
commit 9cd50f7
Showing
66 changed files
with
1,328 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@primer/react': minor | ||
--- | ||
|
||
Tooltip: Release Tooltip v2 as a draft/experimental | ||
|
||
<!-- Changed components: _none_ --> |
Binary file added
BIN
+10.7 KB
....ts-snapshots/Tooltip--experimental-Anchor-Has-Margin-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
...test.ts-snapshots/Tooltip--experimental-Anchor-Has-Margin-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
...-snapshots/Tooltip--experimental-Anchor-Has-Margin-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
...mental.test.ts-snapshots/Tooltip--experimental-Anchor-Has-Margin-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.7 KB
....ts-snapshots/Tooltip--experimental-Anchor-Has-Margin-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
...ts-snapshots/Tooltip--experimental-Anchor-Has-Margin-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
...snapshots/Tooltip--experimental-Anchor-Has-Margin-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
...ental.test.ts-snapshots/Tooltip--experimental-Anchor-Has-Margin-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
...ts-snapshots/Tooltip--experimental-Anchor-Has-Margin-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.9 KB
...-snapshots/Tooltip--experimental-Calculated-Direction-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.8 KB
...t.ts-snapshots/Tooltip--experimental-Calculated-Direction-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...apshots/Tooltip--experimental-Calculated-Direction-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.9 KB
...tal.test.ts-snapshots/Tooltip--experimental-Calculated-Direction-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.9 KB
...-snapshots/Tooltip--experimental-Calculated-Direction-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...snapshots/Tooltip--experimental-Calculated-Direction-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...pshots/Tooltip--experimental-Calculated-Direction-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...al.test.ts-snapshots/Tooltip--experimental-Calculated-Direction-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...snapshots/Tooltip--experimental-Calculated-Direction-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.63 KB
...ental.test.ts-snapshots/Tooltip--experimental-Default-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.57 KB
...erimental.test.ts-snapshots/Tooltip--experimental-Default-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.69 KB
...al.test.ts-snapshots/Tooltip--experimental-Default-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.62 KB
...ip--experimental.test.ts-snapshots/Tooltip--experimental-Default-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.63 KB
...ental.test.ts-snapshots/Tooltip--experimental-Default-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.66 KB
...ntal.test.ts-snapshots/Tooltip--experimental-Default-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.63 KB
...l.test.ts-snapshots/Tooltip--experimental-Default-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.66 KB
...p--experimental.test.ts-snapshots/Tooltip--experimental-Default-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.66 KB
...ntal.test.ts-snapshots/Tooltip--experimental-Default-light-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.81 KB
...ts/Tooltip--experimental-Icon-Button-With-Description-dark-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.67 KB
...pshots/Tooltip--experimental-Icon-Button-With-Description-dark-dimmed-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.84 KB
...Tooltip--experimental-Icon-Button-With-Description-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.71 KB
....ts-snapshots/Tooltip--experimental-Icon-Button-With-Description-dark-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.81 KB
...ts/Tooltip--experimental-Icon-Button-With-Description-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.8 KB
...s/Tooltip--experimental-Icon-Button-With-Description-light-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.84 KB
...ooltip--experimental-Icon-Button-With-Description-light-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.8 KB
...ts-snapshots/Tooltip--experimental-Icon-Button-With-Description-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.8 KB
...s/Tooltip--experimental-Icon-Button-With-Description-light-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.02 KB
...al.test.ts-snapshots/Tooltip--experimental-Label-Type-dark-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.92 KB
...mental.test.ts-snapshots/Tooltip--experimental-Label-Type-dark-dimmed-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.1 KB
...test.ts-snapshots/Tooltip--experimental-Label-Type-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.02 KB
...-experimental.test.ts-snapshots/Tooltip--experimental-Label-Type-dark-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.02 KB
...al.test.ts-snapshots/Tooltip--experimental-Label-Type-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.92 KB
...l.test.ts-snapshots/Tooltip--experimental-Label-Type-light-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.94 KB
...est.ts-snapshots/Tooltip--experimental-Label-Type-light-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.92 KB
...experimental.test.ts-snapshots/Tooltip--experimental-Label-Type-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.92 KB
...l.test.ts-snapshots/Tooltip--experimental-Label-Type-light-tritanopia-linux.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
componentId: tooltip | ||
title: Tooltip | ||
status: Alpha | ||
--- | ||
|
||
import data from '../../../src/drafts/Tooltip/Tooltip.docs.json' | ||
|
||
The Tooltip component is used to add context to interactive elements on the page. | ||
|
||
**_⚠️ Usage warning! ⚠️_** | ||
|
||
Tooltips as a UI pattern should be our last resort for conveying information because it is hidden by default and often with zero or little visual indicator of its existence. | ||
|
||
Before adding a tooltip, please consider: Is this information essential and necessary? Can the UI be made clearer? Can the information be shown on the page by default? See [Tooltip alternatives](https://primer.style/design/accessibility/tooltip-alternatives) for more accessible alternatives. | ||
|
||
Tooltip should only be used on an element that is interactive such as a button or a link. | ||
|
||
## Examples | ||
|
||
### Default (For additional context) | ||
|
||
Default tooltip is suitable for interactive controls that require additional context. | ||
|
||
```jsx live | ||
<Tooltip text="This change cannot be undone."> | ||
<Button>Delete</Button> | ||
</Tooltip> | ||
``` | ||
|
||
### As a label | ||
|
||
Tooltip can be used to label interactive controls that has no visible text label such as interactive icon links. | ||
|
||
```jsx live | ||
<Tooltip text="Contribution Documentation for 'Primer React'" type="label"> | ||
<Link href="https://github.com/primer/react/contributor-docs/CONTRIBUTING.md" sx={{ml: 1, color: 'fg.muted'}}> | ||
<StyledOcticon icon={BookIcon} sx={{color: 'fg.muted'}} /> | ||
</Link> | ||
</Tooltip> | ||
``` | ||
|
||
### With direction | ||
|
||
```jsx live | ||
<Box sx={{padding: 5, display: 'flex', gap: '8px'}}> | ||
<Tooltip direction="n" text="Supplementary text"> | ||
<Button>North</Button> | ||
</Tooltip> | ||
<Tooltip direction="s" text="Supplementary text"> | ||
<Button>South</Button> | ||
</Tooltip> | ||
<Tooltip direction="e" text="Supplementary text"> | ||
<Button>East</Button> | ||
</Tooltip> | ||
<Tooltip direction="w" text="Supplementary text"> | ||
<Button>West</Button> | ||
</Tooltip> | ||
<Tooltip direction="ne" text="Supplementary text"> | ||
<Button>North East</Button> | ||
</Tooltip> | ||
<Tooltip direction="nw" text="Supplementary text"> | ||
<Button>North West</Button> | ||
</Tooltip> | ||
<Tooltip direction="se" text="Supplementary text"> | ||
<Button>Southeast</Button> | ||
</Tooltip> | ||
<Tooltip direction="sw" text="Supplementary text"> | ||
<Button>Southwest</Button> | ||
</Tooltip> | ||
</Box> | ||
``` | ||
|
||
## Props | ||
|
||
<ComponentProps data={data} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
import {test, expect} from '@playwright/test' | ||
import {visit} from '../test-helpers/storybook' | ||
import {themes} from '../test-helpers/themes' | ||
|
||
test.describe('Tooltip--experimental', () => { | ||
test.describe('Default', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip--default', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
await page.keyboard.press('Tab') | ||
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot( | ||
`Tooltip--experimental.Default.${theme}.png`, | ||
{ | ||
threshold: 0.1, | ||
}, | ||
) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip--default', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
} | ||
}) | ||
|
||
test.describe('Anchor Has Margin', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--anchor-has-margin', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
await page.keyboard.press('Tab') | ||
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot( | ||
`Tooltip--experimental.Anchor Has Margin.${theme}.png`, | ||
{ | ||
threshold: 0.1, | ||
}, | ||
) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--anchor-has-margin', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
} | ||
}) | ||
|
||
test.describe('Calculated Direction', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--calculated-direction', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
await page.keyboard.press('Tab') | ||
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot( | ||
`Tooltip--experimental.Calculated Direction.${theme}.png`, | ||
{ | ||
threshold: 0.1, | ||
}, | ||
) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--calculated-direction', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
} | ||
}) | ||
|
||
test.describe('Icon Button With Description', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--icon-button-with-description', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
await page.keyboard.press('Tab') | ||
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot( | ||
`Tooltip--experimental.Icon Button With Description.${theme}.png`, | ||
{ | ||
threshold: 0.1, | ||
}, | ||
) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--icon-button-with-description', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
} | ||
}) | ||
|
||
test.describe('Label Type', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--label-type', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
await page.keyboard.press('Tab') | ||
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot( | ||
`Tooltip--experimental.Label Type.${theme}.png`, | ||
{ | ||
threshold: 0.1, | ||
}, | ||
) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'drafts-components-tooltip-features--label-type', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.