Skip to content

Commit d122122

Browse files
authored
DO NOT MERGE:Remove sx props and BoxWithFallback from TooltipV2 and Tooltip (#6667)
1 parent 2eeff36 commit d122122

File tree

9 files changed

+48
-33
lines changed

9 files changed

+48
-33
lines changed

.changeset/pink-rockets-win.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': major
3+
---
4+
5+
Update Tooltip component to no longer support sx.

packages/react/src/Tooltip/Tooltip.docs.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@
3131
"name": "wrap",
3232
"type": "boolean",
3333
"description": "Use `true` to allow text within tooltip to wrap."
34-
},
35-
{
36-
"name": "sx",
37-
"type": "SystemStyleObject",
38-
"deprecated": true
3934
}
4035
],
4136
"subcomponents": []
42-
}
37+
}

packages/react/src/Tooltip/Tooltip.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import {clsx} from 'clsx'
22
import React, {useMemo} from 'react'
33
import styled from 'styled-components'
44
import {get} from '../constants'
5-
import type {SxProp} from '../sx'
6-
import sx from '../sx'
75
import type {ComponentProps} from '../utils/types'
86
import {useId} from '../hooks'
97

108
/* Tooltip v1 */
119

12-
const TooltipBase = styled.span<SxProp>`
10+
const TooltipBase = styled.span`
1311
position: relative;
1412
display: inline-block;
1513
@@ -182,8 +180,6 @@ const TooltipBase = styled.span<SxProp>`
182180
left: 0;
183181
margin-left: 0;
184182
}
185-
186-
${sx};
187183
`
188184

189185
/**

packages/react/src/TooltipV2/Tooltip.docs.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@
5757
"name": "keybindingHint",
5858
"type": "string",
5959
"description": "Optional keybinding hint to indicate the availability of a keyboard shortcut. Supported syntax is described in the docs for the `KeybindingHint` component."
60-
},
61-
{
62-
"name": "sx",
63-
"type": "SystemStyleObject",
64-
"deprecated": true
6560
}
6661
],
6762
"subcomponents": []
68-
}
63+
}

packages/react/src/TooltipV2/Tooltip.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, {Children, useEffect, useRef, useState, useMemo} from 'react'
2-
import type {SxProp} from '../sx'
32
import {useId, useProvidedRefOrCreate, useOnEscapePress, useIsMacOS} from '../hooks'
43
import {invariant} from '../utils/invariant'
54
import {warning} from '../utils/warning'
@@ -11,17 +10,14 @@ import classes from './Tooltip.module.css'
1110
import {getAccessibleKeybindingHintString, KeybindingHint, type KeybindingHintProps} from '../KeybindingHint'
1211
import VisuallyHidden from '../_VisuallyHidden'
1312
import useSafeTimeout from '../hooks/useSafeTimeout'
14-
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
1513

1614
export type TooltipDirection = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
17-
export type TooltipProps = React.PropsWithChildren<
18-
{
19-
direction?: TooltipDirection
20-
text: string
21-
type?: 'label' | 'description'
22-
keybindingHint?: KeybindingHintProps['keys']
23-
} & SxProp
24-
> &
15+
export type TooltipProps = React.PropsWithChildren<{
16+
direction?: TooltipDirection
17+
text: string
18+
type?: 'label' | 'description'
19+
keybindingHint?: KeybindingHintProps['keys']
20+
}> &
2521
React.HTMLAttributes<HTMLElement>
2622

2723
type TriggerPropsType = Pick<
@@ -298,8 +294,7 @@ export const Tooltip = React.forwardRef(
298294
child.props.onMouseLeave?.(event)
299295
},
300296
})}
301-
<BoxWithFallback
302-
as="span"
297+
<span
303298
className={clsx(className, classes.Tooltip)}
304299
ref={tooltipElRef}
305300
data-direction={calculatedDirection}
@@ -332,7 +327,7 @@ export const Tooltip = React.forwardRef(
332327
) : (
333328
text
334329
)}
335-
</BoxWithFallback>
330+
</span>
336331
</>
337332
</TooltipContext.Provider>
338333
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {Tooltip as PrimerTooltip, type TooltipProps as PrimerTooltipProps, type SxProp} from '@primer/react'
2+
import {
3+
Tooltip as PrimerDeprecatedTooltip,
4+
type TooltipProps as PrimerDeprecatedTooltipProps,
5+
} from '@primer/react/deprecated'
6+
import {Box} from './Box'
7+
import {forwardRef, type ForwardRefExoticComponent, type RefAttributes} from 'react'
8+
9+
type TooltipProps = PrimerTooltipProps & SxProp
10+
11+
const Tooltip: ForwardRefExoticComponent<TooltipProps & RefAttributes<HTMLDivElement>> = forwardRef<
12+
HTMLDivElement,
13+
TooltipProps
14+
>(function Tooltip(props, ref) {
15+
return <Box as={PrimerTooltip} ref={ref} {...props} />
16+
})
17+
18+
export {Tooltip, type TooltipProps}
19+
20+
type DeprecatedTooltipProps = PrimerDeprecatedTooltipProps & SxProp
21+
22+
function DeprecatedTooltip(props: DeprecatedTooltipProps) {
23+
return <Box as={PrimerDeprecatedTooltip} {...props} />
24+
}
25+
export {DeprecatedTooltip, type DeprecatedTooltipProps}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export {TabNav, type TabNavProps, type TabNavLinkProps} from './components/TabNav'
22
export {Dialog, type DialogProps, type DialogHeaderProps} from './components/DialogV1'
3-
export {Octicon, Tooltip, type TooltipProps} from '@primer/react/deprecated'
3+
export {Octicon} from '@primer/react/deprecated'
4+
export {DeprecatedTooltip as Tooltip, type DeprecatedTooltipProps as TooltipProps} from './components/Tooltip'

packages/styled-react/src/experimental.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ export {
1313
type UnderlinePanelsTabProps,
1414
type UnderlinePanelsPanelProps,
1515
} from './components/UnderlinePanels'
16-
export {Table, Tooltip} from '@primer/react/experimental'
16+
17+
export {Tooltip, type TooltipProps} from './components/Tooltip'
18+
19+
export {Table} from '@primer/react/experimental'

packages/styled-react/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export {Select} from '@primer/react'
99
export {Text} from '@primer/react'
1010
export {Textarea} from '@primer/react'
1111
export {TextInput} from '@primer/react'
12-
export {Tooltip} from '@primer/react'
1312
export {type TextInputProps} from '@primer/react'
1413

1514
// theming depends on styled-components
@@ -64,6 +63,7 @@ export {
6463
type TimelineBreakProps,
6564
} from './components/Timeline'
6665
export {ToggleSwitch, type ToggleSwitchProps} from './components/ToggleSwitch'
66+
export {Tooltip, type TooltipProps} from './components/Tooltip'
6767
export {Token, type TokenProps} from './components/Token'
6868
export {Truncate, type TruncateProps} from './components/Truncate'
6969
export {UnderlineNav, type UnderlineNavProps, type UnderlineNavItemProps} from './components/UnderlineNav'

0 commit comments

Comments
 (0)