Skip to content

Commit e27c3c8

Browse files
authored
Added Tooltip stories (#3881)
* added existing tooltip story to storybook * checkpoint * refactored Tooltip files and labelled v1 * fix exports test * cleanup old snapshot * Updated documentation
1 parent 4ea8bcf commit e27c3c8

File tree

12 files changed

+56
-21
lines changed

12 files changed

+56
-21
lines changed

docs/content/Tooltip.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
componentId: tooltip
33
title: Tooltip
44
status: Alpha
5-
source: https://github.com/primer/react/blob/main/src/Tooltip.tsx
5+
source: https://github.com/primer/react/blob/main/src/Tooltip/Tooltip.tsx
66
---
77

8-
import data from '../../src/Tooltip.docs.json'
8+
import data from '../../src/Tooltip/Tooltip.docs.json'
99
import DeprecationBanner from '../components/DeprecationBanner'
1010

1111
<DeprecationBanner replacementUrl={'/design/components/tooltip/react'} />
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import React from 'react'
22
import {Meta} from '@storybook/react'
3-
import {BaseStyles, ThemeProvider, IconButton, Button} from '..'
3+
import {BaseStyles, ThemeProvider, IconButton} from '..'
44
import Box from '../Box'
5-
import Tooltip from '../Tooltip'
5+
import Tooltip from './Tooltip'
66
import {SearchIcon} from '@primer/octicons-react'
77

8+
/* Tooltip v1 */
9+
810
export default {
9-
title: 'Components/Tooltip',
11+
title: 'Components/Tooltip/Features',
1012
component: Tooltip,
1113

1214
decorators: [
@@ -22,14 +24,6 @@ export default {
2224
],
2325
} as Meta
2426

25-
export const Default = () => (
26-
<Box sx={{p: 5}}>
27-
<Tooltip aria-label="Hello, Tooltip!">
28-
<Button>Hover me</Button>
29-
</Tooltip>
30-
</Box>
31-
)
32-
3327
export const IconButtonTooltip = () => (
3428
<Box sx={{p: 5}}>
3529
<Tooltip aria-label="Search">

src/Tooltip/Tooltip.stories.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react'
2+
import {Meta} from '@storybook/react'
3+
import {BaseStyles, ThemeProvider, Button} from '..'
4+
import Box from '../Box'
5+
import Tooltip from './Tooltip'
6+
7+
/* Tooltip v1 */
8+
9+
export default {
10+
title: 'Components/Tooltip',
11+
component: Tooltip,
12+
13+
decorators: [
14+
Story => {
15+
return (
16+
<ThemeProvider>
17+
<BaseStyles>
18+
<Story />
19+
</BaseStyles>
20+
</ThemeProvider>
21+
)
22+
},
23+
],
24+
} as Meta
25+
26+
export const Default = () => (
27+
<Box sx={{p: 5}}>
28+
<Tooltip aria-label="Hello, Tooltip!">
29+
<Button>Hover me</Button>
30+
</Tooltip>
31+
</Box>
32+
)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React from 'react'
2-
import Tooltip, {TooltipProps} from '../Tooltip'
2+
import Tooltip, {TooltipProps} from './Tooltip'
33
import {render, renderClasses, rendersClass, behavesAsComponent, checkExports} from '../utils/testing'
44
import {render as HTMLRender} from '@testing-library/react'
55
import {axe, toHaveNoViolations} from 'jest-axe'
66

7+
/* Tooltip v1 */
8+
79
expect.extend(toHaveNoViolations)
810

911
describe('Tooltip', () => {

src/Tooltip.tsx renamed to src/Tooltip/Tooltip.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import clsx from 'clsx'
22
import React from 'react'
33
import styled from 'styled-components'
4-
import {get} from './constants'
5-
import sx, {SxProp} from './sx'
6-
import {ComponentProps} from './utils/types'
4+
import {get} from '../constants'
5+
import sx, {SxProp} from '../sx'
6+
import {ComponentProps} from '../utils/types'
7+
8+
/* Tooltip v1 */
79

810
const TooltipBase = styled.span<SxProp>`
911
position: relative;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react'
2-
import Tooltip from '../Tooltip'
2+
import Tooltip from '../Tooltip/Tooltip'
3+
4+
/* Tooltip v1 */
35

46
export function shouldAcceptCallWithNoProps() {
57
return <Tooltip />
File renamed without changes.

src/Tooltip/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {default} from './Tooltip'
2+
export type {TooltipProps} from './Tooltip'

src/__tests__/storybook.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const allowlist = [
5151
'Textarea',
5252
'TextInput',
5353
'TextInputWithTokens',
54+
'Tooltip',
5455
'TreeView',
5556
'Timeline',
5657
'ToggleSwitch',

0 commit comments

Comments
 (0)