Skip to content

Commit 5114b03

Browse files
committed
Overlay no longer accepts styled system props
1 parent 94c6122 commit 5114b03

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

.changeset/lucky-zoos-smoke.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+
Overlay 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/Overlay.mdx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ const Demo = () => {
6565
render(<Demo />)
6666
```
6767
68-
## System props
69-
70-
<Note variant="warning">
71-
72-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
73-
74-
</Note>
75-
76-
`Overlay` gets `COMMON` system props. Read the [System Props](/system-props) doc page for a full list of available props.
77-
7868
## Component props
7969
8070
| Name | Type | Default | Description |
@@ -92,3 +82,4 @@ System props are deprecated in all components except [Box](/Box). Please use the
9282
| top | `number` | 0 | Vertical position of the overlay, relative to its closest positioned ancestor (often its `Portal`). |
9383
| left | `number` | 0 | Horizontal position of the overlay, relative to its closest positioned ancestor (often its `Portal`). |
9484
| portalContainerName | `string` | `undefined` | Optional. If defined, Overlays will be rendered in the named portal. See also `Portal`. |
85+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/Overlay.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styled from 'styled-components'
22
import React, {ReactElement, useEffect, useLayoutEffect, useRef} from 'react'
3-
import {get, COMMON, SystemPositionProps, SystemCommonProps} from './constants'
3+
import {get} from './constants'
44
import {ComponentProps} from './utils/types'
55
import {useOverlay, TouchOrMouseEvent} from './hooks'
66
import Portal from './Portal'
@@ -51,7 +51,7 @@ function getSlideAnimationStartingVector(anchorSide?: AnchorSide): {x: number; y
5151
return {x: 0, y: 0}
5252
}
5353

54-
const StyledOverlay = styled.div<StyledOverlayProps & SystemCommonProps & SxProp>`
54+
const StyledOverlay = styled.div<StyledOverlayProps & SxProp>`
5555
background-color: ${get('colors.canvas.overlay')};
5656
box-shadow: ${get('shadows.overlay.shadow')};
5757
position: absolute;
@@ -76,7 +76,6 @@ const StyledOverlay = styled.div<StyledOverlayProps & SystemCommonProps & SxProp
7676
:focus {
7777
outline: none;
7878
}
79-
${COMMON};
8079
${sx};
8180
`
8281
export type OverlayProps = {
@@ -91,7 +90,7 @@ export type OverlayProps = {
9190
left: number
9291
portalContainerName?: string
9392
preventFocusOnOpen?: boolean
94-
} & Omit<ComponentProps<typeof StyledOverlay>, 'visibility' | keyof SystemPositionProps>
93+
} & ComponentProps<typeof StyledOverlay>
9594

9695
/**
9796
* An `Overlay` is a flexible floating surface, used to display transient content such as menus,
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 Overlay from '../Overlay'
3+
4+
export function shouldAcceptCallWithNoProps() {
5+
return <Overlay />
6+
}
7+
8+
export function shouldNotAcceptSystemProps() {
9+
// @ts-expect-error system props should not be accepted
10+
return <Overlay backgroundColor="olivedrab" />
11+
}

0 commit comments

Comments
 (0)