Skip to content

Commit

Permalink
Add a new entry point as next and update draft Tooltip to export it…
Browse files Browse the repository at this point in the history
… from next (#4250)

* Add a new entry point as  and update draft Tooltip to export it from next

* fix linting n add changeset

* move the src code out of drafts and update docs

* fix folder path and storyname

* test(vrt): update snapshots

* update tooltip's position to be absolute

* Update docs/content/TooltipV2.mdx

---------

Co-authored-by: broccolinisoup <broccolinisoup@users.noreply.github.com>
  • Loading branch information
2 people authored and lukasoppermann committed Apr 16, 2024
1 parent fe6412f commit 65aae45
Show file tree
Hide file tree
Showing 68 changed files with 107 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-badgers-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Add a new entry point 'next' and export the Tooltip v2 from it with an updated documentation
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/content/Tooltip.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ import DeprecationBanner from '../components/DeprecationBanner'

<DeprecationBanner replacementUrl={'/components/tooltip/react/latest'} />

## Deprecation

Use [the next version of Tooltip](/TooltipV2) for accessibility improvements.

The Tooltip component adds a tooltip to add context to interactive elements on the page.

## Usage

**_⚠️ 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.
Expand Down
20 changes: 14 additions & 6 deletions docs/content/drafts/Tooltip.mdx → docs/content/TooltipV2.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
---
componentId: tooltip_v2
title: Tooltip v2
status: Draft
source: https://github.com/primer/react/tree/main/packages/react/src/drafts/Tooltip.tsx
status: Beta
a11yReviewed: true
source: https://github.com/primer/react/tree/main/packages/react/src/TooltipV2/Tooltip.tsx
---

import data from '../../../packages/react/src/drafts/Tooltip/Tooltip.docs.json'
import data from '../../packages/react/src/TooltipV2/Tooltip.docs.json'

```js
//👇 Notice the new bundle, `next`👇
import {Tooltip} from '@primer/react/next'
```

## Usage

The Tooltip component is used to add context to interactive elements on the page.

Expand All @@ -23,7 +31,7 @@ Tooltip should only be used on an element that is interactive such as a button o

Default tooltip is suitable for interactive controls that require additional context.

```jsx live
```jsx live next
<Tooltip text="This change cannot be undone.">
<Button>Delete</Button>
</Tooltip>
Expand All @@ -33,7 +41,7 @@ Default tooltip is suitable for interactive controls that require additional con

Tooltip can be used to label interactive controls that has no visible text label such as interactive icon links.

```jsx live
```jsx live next
<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'}}>
<Octicon icon={BookIcon} sx={{color: 'fg.muted'}} />
Expand All @@ -43,7 +51,7 @@ Tooltip can be used to label interactive controls that has no visible text label

### With direction

```jsx live
```jsx live next
<Box sx={{padding: 5, display: 'flex', gap: '8px'}}>
<Tooltip direction="n" text="Supplementary text">
<Button>North</Button>
Expand Down
4 changes: 4 additions & 0 deletions docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as octicons from '@primer/octicons-react'
import * as primerComponents from '@primer/react'
import * as drafts from '@primer/react/drafts'
import * as deprecated from '@primer/react/deprecated'
import * as experimental from '@primer/react/experimental'
import * as next from '@primer/react/next'
import {Placeholder} from '@primer/react/Placeholder'
import React from 'react'
import State from '../../../components/State'
Expand All @@ -24,7 +26,9 @@ export default function resolveScope(metastring) {
...primerComponents,
...octiconComponents,
...(metastring.includes('drafts') ? drafts : {}),
...(metastring.includes('experimental') ? experimental : {}),
...(metastring.includes('deprecated') ? deprecated : {}),
...(metastring.includes('next') ? next : {}),
ReactRouterLink,
State,
Placeholder,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
url: /Token
- title: Tooltip
url: /Tooltip
- title: Tooltip v2
url: /TooltipV2
- title: TreeView
url: /TreeView
- title: Truncate
Expand All @@ -170,8 +172,6 @@
url: /drafts/PageHeader
- title: SelectPanel v2
url: /drafts/SelectPanel
- title: Tooltip v2
url: /drafts/Tooltip
- title: Deprecated
children:
- title: ActionList (legacy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@ import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'

test.describe('Tooltip--experimental', () => {
test.describe('TooltipV2', () => {
test.describe('Default', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip--default',
id: 'components-tooltipv2--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,
},
)
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`TooltipV2.Default.${theme}.png`, {
threshold: 0.1,
})
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip--default',
id: 'components-tooltipv2--default',
globals: {
colorScheme: theme,
},
Expand All @@ -42,7 +39,7 @@ test.describe('Tooltip--experimental', () => {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--anchor-has-margin',
id: 'components-tooltipv2-features--anchor-has-margin',
globals: {
colorScheme: theme,
},
Expand All @@ -51,7 +48,7 @@ test.describe('Tooltip--experimental', () => {
// Default state
await page.keyboard.press('Tab')
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
`Tooltip--experimental.Anchor Has Margin.${theme}.png`,
`TooltipV2.Anchor Has Margin.${theme}.png`,
{
threshold: 0.1,
},
Expand All @@ -60,7 +57,7 @@ test.describe('Tooltip--experimental', () => {

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--anchor-has-margin',
id: 'components-tooltipv2-features--anchor-has-margin',
globals: {
colorScheme: theme,
},
Expand All @@ -76,7 +73,7 @@ test.describe('Tooltip--experimental', () => {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--calculated-direction',
id: 'components-tooltipv2-features--calculated-direction',
globals: {
colorScheme: theme,
},
Expand All @@ -85,7 +82,7 @@ test.describe('Tooltip--experimental', () => {
// Default state
await page.keyboard.press('Tab')
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
`Tooltip--experimental.Calculated Direction.${theme}.png`,
`TooltipV2.Calculated Direction.${theme}.png`,
{
threshold: 0.1,
},
Expand All @@ -94,7 +91,7 @@ test.describe('Tooltip--experimental', () => {

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--calculated-direction',
id: 'components-tooltipv2-features--calculated-direction',
globals: {
colorScheme: theme,
},
Expand All @@ -110,7 +107,7 @@ test.describe('Tooltip--experimental', () => {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--icon-button-with-description',
id: 'components-tooltipv2-features--icon-button-with-description',
globals: {
colorScheme: theme,
},
Expand All @@ -119,7 +116,7 @@ test.describe('Tooltip--experimental', () => {
// Default state
await page.keyboard.press('Tab')
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
`Tooltip--experimental.Icon Button With Description.${theme}.png`,
`TooltipV2.Icon Button With Description.${theme}.png`,
{
threshold: 0.1,
},
Expand All @@ -128,7 +125,7 @@ test.describe('Tooltip--experimental', () => {

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--icon-button-with-description',
id: 'components-tooltipv2-features--icon-button-with-description',
globals: {
colorScheme: theme,
},
Expand All @@ -144,25 +141,22 @@ test.describe('Tooltip--experimental', () => {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--label-type',
id: 'components-tooltipv2-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,
},
)
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`TooltipV2.Label Type.${theme}.png`, {
threshold: 0.1,
})
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-tooltip-features--label-type',
id: 'components-tooltipv2-features--label-type',
globals: {
colorScheme: theme,
},
Expand Down
8 changes: 8 additions & 0 deletions packages/react/next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"_comment1": "this is required only for typescript. once this is fixed https://github.com/microsoft/TypeScript/issues/33079 we can remove this hack",
"name": "@primer/react/next",
"types": "../lib-esm/next/index.d.ts",
"main": "../lib-esm/next/index.js",
"type": "module",
"sideEffects": false
}
4 changes: 4 additions & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"import": "./lib-esm/deprecated/index.js",
"require": "./lib/deprecated/index.js"
},
"./next": {
"import": "./lib-esm/next/index.js",
"require": "./lib/next/index.js"
},
"./lib-esm/*": {
"import": [
"./lib-esm/*.js",
Expand Down
3 changes: 3 additions & 0 deletions packages/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const input = new Set([
// "./deprecated"
'src/deprecated/index.ts',

// "./next"
'src/next/index.ts',

// Make sure all members are exported
'src/constants.ts',

Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/ActionList/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import styled from 'styled-components'
import {AlertIcon} from '@primer/octicons-react'
import type {BoxProps} from '../Box'
import Box from '../Box'
import type {TooltipProps} from '../drafts/Tooltip/Tooltip'
import {Tooltip} from '../drafts/Tooltip/Tooltip'
import type {TooltipProps} from '../TooltipV2/Tooltip'
import {Tooltip} from '../TooltipV2/Tooltip'
import {useId} from '../hooks/useId'
import {useSlots} from '../hooks/useSlots'
import type {BetterSystemStyleObject, SxProp} from '../sx'
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ActionMenu/ActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Button} from '../Button'
import {useId} from '../hooks/useId'
import type {MandateProps} from '../utils/types'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import {Tooltip} from '../drafts/Tooltip/Tooltip'
import {Tooltip} from '../TooltipV2/Tooltip'

export type MenuContextProps = Pick<
AnchoredOverlayProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "tooltip_v2",
"name": "Tooltip",
"status": "draft",
"status": "beta",
"a11yReviewed": true,
"stories": [],
"props": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {Button, IconButton, Breadcrumbs, ActionMenu, ActionList, NavList} from '../..'
import {PageHeader} from '../../PageHeader'
import {Button, IconButton, Breadcrumbs, ActionMenu, ActionList, NavList} from '..'
import {PageHeader} from '../PageHeader'
import {Tooltip} from './Tooltip'
import {
GitBranchIcon,
Expand All @@ -13,10 +13,10 @@ import {
CommentIcon,
XIcon,
} from '@primer/octicons-react'
import {default as VisuallyHidden} from '../../_VisuallyHidden'
import {default as VisuallyHidden} from '../_VisuallyHidden'

export default {
title: 'Drafts/Components/Tooltip/Examples',
title: 'Components/TooltipV2/Examples',
component: Tooltip,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import {IconButton, Button, Box, Link, Octicon, ActionMenu, ActionList} from '../..'
import {IconButton, Button, Box, Link, Octicon, ActionMenu, ActionList} from '..'
import {Tooltip} from './Tooltip'
import {SearchIcon, BookIcon, CheckIcon, TriangleDownIcon, GitBranchIcon} from '@primer/octicons-react'

export default {
title: 'Drafts/Components/Tooltip/Features',
title: 'Components/TooltipV2/Features',
component: Tooltip,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import {Button, Box} from '../..'
import {Button, Box} from '..'
import {Tooltip} from './Tooltip'
import type {Meta, StoryFn} from '@storybook/react'

export default {
title: 'Drafts/Components/Tooltip/Playground',
title: 'Components/TooltipV2/Playground',
component: Tooltip,

args: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import {Button, Box} from '../..'
import {Button, Box} from '..'
import {Tooltip} from './Tooltip'

export default {
title: 'Drafts/Components/Tooltip',
title: 'Components/TooltipV2',
component: Tooltip,
}

Expand Down
Loading

0 comments on commit 65aae45

Please sign in to comment.