Skip to content

Commit

Permalink
Pagehead no longer accepts styled system props (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfuchs committed Nov 22, 2021
1 parent 79ca808 commit 23f6a3a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-socks-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/components': major
---

Pagehead 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.
17 changes: 4 additions & 13 deletions docs/content/Pagehead.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,9 @@ Give a page a clear, separated title and optional top nav by using Pagehead.
<Pagehead>Pagehead</Pagehead>
```

## System props

<Note variant="warning">

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

</Note>

Pagehead 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 |
| :--- | :----- | :-----: | :---------------------------------- |
| as | String | `div` | Sets the HTML tag for the component |
| Name | Type | Default | Description |
| :--- | :---------------- | :-----: | :----------------------------------- |
| as | String | `div` | Sets the HTML tag for the component |
| sx | SystemStyleObject | {} | Style to be applied to the component |
5 changes: 2 additions & 3 deletions src/Pagehead.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
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 Pagehead = styled.div<SystemCommonProps & SxProp>`
const Pagehead = styled.div<SxProp>`
position: relative;
padding-top: ${get('space.4')};
padding-bottom: ${get('space.4')};
margin-bottom: ${get('space.4')};
border-bottom: 1px solid ${get('colors.border.default')};
${COMMON};
${sx};
`

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

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

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

0 comments on commit 23f6a3a

Please sign in to comment.