Skip to content

Commit 4bb2bb9

Browse files
authored
Truncate no longer accepts styled system props (#1578)
1 parent 32ed3b3 commit 4bb2bb9

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

.changeset/beige-dots-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/components': major
3+
---
4+
5+
Truncate 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.

docs/content/Truncate.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,12 @@ You can use the `expandable` boolean prop to display the truncated text on hover
4444
</Truncate>
4545
```
4646

47-
## System props
48-
49-
<Note variant="warning">
50-
51-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
52-
53-
</Note>
54-
55-
Truncate components get `TYPOGRAPHY` and `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
56-
5747
## Component props
5848

59-
| Name | Type | Default | Description |
60-
| :--------- | :------ | :-----: | :----------------------------------------------------------- |
61-
| as | String | `div` | Sets the HTML tag for the component |
62-
| maxWidth | Number | 125 | Sets the max-width of the text |
63-
| inline | Boolean | false | displays text as inline block and vertical aligns to the top |
64-
| expandable | Boolean | false | allows the truncated text to be displayed on hover |
49+
| Name | Type | Default | Description |
50+
| :--------- | :---------------- | :-----: | :----------------------------------------------------------- |
51+
| as | String | `div` | Sets the HTML tag for the component |
52+
| maxWidth | Number | 125 | Sets the max-width of the text |
53+
| inline | Boolean | false | displays text as inline block and vertical aligns to the top |
54+
| expandable | Boolean | false | allows the truncated text to be displayed on hover |
55+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/Truncate.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import styled from 'styled-components'
22
import {maxWidth, MaxWidthProps} from 'styled-system'
3-
import {COMMON, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './constants'
43
import sx, {SxProp} from './sx'
54
import {ComponentProps} from './utils/types'
65

@@ -9,13 +8,9 @@ type StyledTruncateProps = {
98
inline?: boolean
109
expandable?: boolean
1110
} & MaxWidthProps &
12-
SystemTypographyProps &
13-
SystemCommonProps &
1411
SxProp
1512

1613
const Truncate = styled.div<StyledTruncateProps>`
17-
${TYPOGRAPHY}
18-
${COMMON}
1914
display: ${props => (props.inline ? 'inline-block' : 'inherit')};
2015
overflow: hidden;
2116
text-overflow: ellipsis;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import Truncate from '../Truncate'
3+
4+
export function shouldAcceptCallWithNoProps() {
5+
return <Truncate title="Hello" />
6+
}
7+
8+
export function shouldNotAcceptSystemProps() {
9+
// @ts-expect-error system props should not be accepted
10+
return <Truncate title="Hello" backgroundColor="indigo" />
11+
}

0 commit comments

Comments
 (0)