Skip to content

LabelGroup no longer accepts styled system props #1565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eleven-cycles-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/components': major
---

LabelGroup 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.
18 changes: 4 additions & 14 deletions docs/content/LabelGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,13 @@ The LabelGroup component is used to add commonly used margins and wrapping for g
```jsx live
<LabelGroup>
<Label>Default label</Label>
<Label sx={{color: "fg.onEmphasis", bg: "danger.emphasis"}}>
Label with background indicating a closed PR state
</Label>
<Label sx={{color: 'fg.onEmphasis', bg: 'danger.emphasis'}}>Label with background indicating a closed PR state</Label>
<Label outline>Default outline label</Label>
</LabelGroup>
```

## System props

<Note variant="warning">

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

</Note>

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

## Component props

LabelGroup does not get any additional props.
| Name | Type | Default | Description |
| :--- | :---------------- | :-----: | :----------------------------------- |
| sx | SystemStyleObject | {} | Style to be applied to the component |
5 changes: 2 additions & 3 deletions src/LabelGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
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 LabelGroup = styled.span<SystemCommonProps & SxProp>`
${COMMON}
const LabelGroup = styled.span<SxProp>`
& * {
margin-right: ${get('space.1')};
}
Expand Down
11 changes: 11 additions & 0 deletions src/__tests__/LabelGroup.types.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import LabelGroup from '../LabelGroup'

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

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