Skip to content
Draft
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/shy-bees-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": major
---

Update PointerBox component to no longer support sx
5 changes: 0 additions & 5 deletions packages/react/src/Pagination/Pagination.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@
"type": "function",
"defaultValue": "(props: PageProps) => ReactNode",
"description": "Provide a custom component or render prop to render each page link within the component."
},
{
"name": "sx",
"type": "SystemStyleObject",
"deprecated": true
}
],
"subcomponents": []
Expand Down
49 changes: 19 additions & 30 deletions packages/react/src/PointerBox/PointerBox.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,53 @@
import React from 'react'
import {ThemeContext} from 'styled-components'
import type {BoxProps} from '../Box'
import Box from '../Box'
import type {CaretProps} from '../internal/components/Caret'
import Caret from '../internal/components/Caret'
import {get} from '../constants'
import type {SxProp} from '../sx'

// FIXME: Make this work with BetterStyledSystem types
type MutatedSxProps = {
sx?: {
bg?: string
backgroundColor?: string
borderColor?: string
}
} & SxProp

export type PointerBoxProps = {
caret?: CaretProps['location']
bg?: CaretProps['bg']
borderColor?: CaretProps['borderColor']
border?: CaretProps['borderWidth']
} & BoxProps &
MutatedSxProps
} & BoxProps

function PointerBox(props: PointerBoxProps) {
// don't destructure these, just grab them
const themeContext = React.useContext(ThemeContext)
const {bg, border, borderColor, theme: themeProp, sx} = props
const {caret, children, ...boxProps} = props
const {bg: sxBg, backgroundColor, ...sxRest} = sx || {}
const {bg, border, borderColor, theme: themeProp, caret, children, ...boxProps} = props
const theme = themeProp || themeContext
const customBackground = bg || sxBg || backgroundColor

const customBackground = bg ?? 'var(--bgColor-default)'
const customBorderColor = borderColor ?? 'var(--borderColor-default)'
const customBorderWidth = border ?? 'var(--borderWidth-default)'

const caretProps = {
bg: bg || sx?.bg || sx?.backgroundColor,
borderColor: borderColor || sx?.borderColor,
bg,
borderColor,
borderWidth: border,
location: caret,
theme,
}

const defaultBoxProps = {borderWidth: '1px', borderStyle: 'solid', borderColor: 'border.default', borderRadius: 2}

return (
<Box
{...defaultBoxProps}
{...boxProps}
sx={{
...sxRest,
'--custom-bg': get(`colors.${customBackground}`)({theme}),
<div
style={{
borderWidth: customBorderWidth,
borderStyle: 'solid',
borderColor: customBorderColor,
borderRadius: 'var(--borderRadius-medium)',
position: 'relative',
background: customBackground,
...(boxProps.style ?? {}),
backgroundImage: customBackground
? `linear-gradient(var(--custom-bg), var(--custom-bg)), linear-gradient(${theme.colors.canvas.default}, ${theme.colors.canvas.default})`
: undefined,
position: 'relative',
}}
{...boxProps}
>
{children}
<Caret {...caretProps} />
</Box>
</div>
)
}

Expand Down
Loading