Skip to content

Commit

Permalink
Tooltip no longer accepts styled system props (#1577)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfuchs committed Nov 22, 2021
1 parent 84d5f3b commit 79f3133
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-worms-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/components': major
---

Tooltip no longer accepts styled-system props. Please use the `sx` prop to extend Primer component styling instead. See also https://primer.style/react/overriding-styles for information about `sx` and https://primer.style/react/system-props for context on the removal.
25 changes: 8 additions & 17 deletions docs/content/Tooltip.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@ Before adding a tooltip, please consider: Is this information essential and nece
</Box>
```

## System props

<Note variant="warning">

System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.

</Note>

Tooltip components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.

## Component props

| Name | Type | Default | Description |
| :--------- | :------ | :-----: | :------------------------------------------------------- | --------------------------------------------------------- |
| align | String | | Can be either `left` or `right`. |
| direction | String | | Can be one of `n`, `ne`, `e`, `se`, `s`, `sw`, `w`, `nw` | Sets where the tooltip renders in relation to the target. |
| noDelay | Boolean | | When set to `true`, tooltip appears without any delay |
| aria-label | String | | Text used in `aria-label` (for accessibility). |
| wrap | Boolean | | Use `true` to allow text within tooltip to wrap. |
| Name | Type | Default | Description |
| :--------- | :---------------- | :-----: | :------------------------------------------------------------------------------------------------------------------ |
| align | String | | Can be either `left` or `right`. |
| direction | String | | Can be one of `n`, `ne`, `e`, `se`, `s`, `sw`, `w`, `nw`. Sets where the tooltip renders in relation to the target. |
| noDelay | Boolean | | When set to `true`, tooltip appears without any delay |
| aria-label | String | | Text used in `aria-label` (for accessibility). |
| wrap | Boolean | | Use `true` to allow text within tooltip to wrap. |
| sx | SystemStyleObject | {} | Style to be applied to the component |
6 changes: 3 additions & 3 deletions src/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import classnames from 'classnames'
import React from 'react'
import styled from 'styled-components'
import {COMMON, get, SystemCommonProps} from './constants'
import {get} from './constants'
import sx, {SxProp} from './sx'
import {ComponentProps} from './utils/types'

const TooltipBase = styled.span<SystemCommonProps & SxProp>`
const TooltipBase = styled.span<SxProp>`
position: relative;
&::before {
Expand Down Expand Up @@ -229,7 +229,7 @@ const TooltipBase = styled.span<SystemCommonProps & SxProp>`
&.tooltipped-align-left-2::before {
left: 10px;
}
${COMMON};
${sx};
`

Expand Down
11 changes: 11 additions & 0 deletions src/__tests__/Tooltip.types.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import Tooltip from '../Tooltip'

export function shouldAcceptCallWithNoProps() {
return <Tooltip />
}

export function shouldNotAcceptSystemProps() {
// @ts-expect-error system props should not be accepted
return <Tooltip backgroundColor="thistle" />
}

0 comments on commit 79f3133

Please sign in to comment.