Skip to content

Commit

Permalink
Added Tooltip stories (#3881)
Browse files Browse the repository at this point in the history
* added existing tooltip story to storybook

* checkpoint

* refactored Tooltip files and labelled v1

* fix exports test

* cleanup old snapshot

* Updated documentation
  • Loading branch information
agreenberry authored Oct 31, 2023
1 parent 4ea8bcf commit e27c3c8
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/content/Tooltip.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
componentId: tooltip
title: Tooltip
status: Alpha
source: https://github.com/primer/react/blob/main/src/Tooltip.tsx
source: https://github.com/primer/react/blob/main/src/Tooltip/Tooltip.tsx
---

import data from '../../src/Tooltip.docs.json'
import data from '../../src/Tooltip/Tooltip.docs.json'
import DeprecationBanner from '../components/DeprecationBanner'

<DeprecationBanner replacementUrl={'/design/components/tooltip/react'} />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react'
import {Meta} from '@storybook/react'
import {BaseStyles, ThemeProvider, IconButton, Button} from '..'
import {BaseStyles, ThemeProvider, IconButton} from '..'
import Box from '../Box'
import Tooltip from '../Tooltip'
import Tooltip from './Tooltip'
import {SearchIcon} from '@primer/octicons-react'

/* Tooltip v1 */

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

decorators: [
Expand All @@ -22,14 +24,6 @@ export default {
],
} as Meta

export const Default = () => (
<Box sx={{p: 5}}>
<Tooltip aria-label="Hello, Tooltip!">
<Button>Hover me</Button>
</Tooltip>
</Box>
)

export const IconButtonTooltip = () => (
<Box sx={{p: 5}}>
<Tooltip aria-label="Search">
Expand Down
32 changes: 32 additions & 0 deletions src/Tooltip/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react'
import {Meta} from '@storybook/react'
import {BaseStyles, ThemeProvider, Button} from '..'
import Box from '../Box'
import Tooltip from './Tooltip'

/* Tooltip v1 */

export default {
title: 'Components/Tooltip',
component: Tooltip,

decorators: [
Story => {
return (
<ThemeProvider>
<BaseStyles>
<Story />
</BaseStyles>
</ThemeProvider>
)
},
],
} as Meta

export const Default = () => (
<Box sx={{p: 5}}>
<Tooltip aria-label="Hello, Tooltip!">
<Button>Hover me</Button>
</Tooltip>
</Box>
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react'
import Tooltip, {TooltipProps} from '../Tooltip'
import Tooltip, {TooltipProps} from './Tooltip'
import {render, renderClasses, rendersClass, behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'

/* Tooltip v1 */

expect.extend(toHaveNoViolations)

describe('Tooltip', () => {
Expand Down
8 changes: 5 additions & 3 deletions src/Tooltip.tsx → src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import clsx from 'clsx'
import React from 'react'
import styled from 'styled-components'
import {get} from './constants'
import sx, {SxProp} from './sx'
import {ComponentProps} from './utils/types'
import {get} from '../constants'
import sx, {SxProp} from '../sx'
import {ComponentProps} from '../utils/types'

/* Tooltip v1 */

const TooltipBase = styled.span<SxProp>`
position: relative;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react'
import Tooltip from '../Tooltip'
import Tooltip from '../Tooltip/Tooltip'

/* Tooltip v1 */

export function shouldAcceptCallWithNoProps() {
return <Tooltip />
Expand Down
2 changes: 2 additions & 0 deletions src/Tooltip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {default} from './Tooltip'
export type {TooltipProps} from './Tooltip'
1 change: 1 addition & 0 deletions src/__tests__/storybook.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const allowlist = [
'Textarea',
'TextInput',
'TextInputWithTokens',
'Tooltip',
'TreeView',
'Timeline',
'ToggleSwitch',
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export type {
} from './Timeline'
export {default as Token, IssueLabelToken, AvatarToken} from './Token'
export type {TokenProps} from './Token'
export {default as Tooltip} from './Tooltip'
export type {TooltipProps} from './Tooltip'
export {default as Tooltip} from './Tooltip/Tooltip'
export type {TooltipProps} from './Tooltip/Tooltip'
export {default as Truncate} from './Truncate'
export type {TruncateProps} from './Truncate'

Expand Down
2 changes: 1 addition & 1 deletion src/internal/components/TextInputInnerAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {forwardRef} from 'react'
import {IconProps} from '@primer/octicons-react'
import Box from '../../Box'
import {Button, IconButton, ButtonProps} from '../../Button'
import Tooltip from '../../Tooltip'
import Tooltip from '../../Tooltip/Tooltip'
import {BetterSystemStyleObject, merge, SxProp} from '../../sx'

type TextInputActionProps = Omit<
Expand Down

0 comments on commit e27c3c8

Please sign in to comment.