Skip to content
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
7 changes: 7 additions & 0 deletions .changeset/mean-kangaroos-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@primer/react": major
"@primer/styled-react": patch
---

- remove sx, SxProp, exports
- add type ThemeColorPaths, type ThemeShadowPaths
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
"type BannerProps",
"BaseStyles",
"type BaseStylesProps",
"type BetterCssProperties",
"type BetterSystemStyleObject",
"BranchName",
"type BranchNameProps",
"Breadcrumb",
Expand Down Expand Up @@ -95,7 +93,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
"LinkButton",
"type LinkButtonProps",
"type LinkProps",
"merge",
"NavList",
"type NavListDividerProps",
"type NavListGroupHeadingProps",
Expand Down Expand Up @@ -172,8 +169,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
"type SubNavLinkProps",
"type SubNavLinksProps",
"type SubNavProps",
"sx",
"type SxProp",
"Text",
"Textarea",
"type TextareaProps",
Expand All @@ -184,9 +179,11 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
"type TextInputWithTokensProps",
"type TextProps",
"theme",
"ThemeColorPaths",
"themeGet",
"ThemeProvider",
"type ThemeProviderProps",
"ThemeShadowPaths",
"Timeline",
"type TimelineBadgeProps",
"type TimelineBodyProps",
Expand Down
5 changes: 1 addition & 4 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

export {default as theme} from './theme'
export {default as theme, type ThemeColorPaths, type ThemeShadowPaths} from './theme'
export {get as themeGet} from './constants'
export {default as BaseStyles} from './BaseStyles'
export type {BaseStylesProps} from './BaseStyles'
Expand Down Expand Up @@ -225,8 +225,5 @@ export type {
ChildrenPropTypes as PageHeaderChildrenPropTypes,
} from './PageHeader'

export {default as sx, merge} from './sx'
export type {BetterCssProperties, BetterSystemStyleObject, SxProp} from './sx'

export {SkeletonBox} from './Skeleton'
export type {SkeletonBoxProps} from './Skeleton'
3 changes: 0 additions & 3 deletions packages/react/src/sx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {SystemCssProperties, SystemStyleObject} from '@styled-system/css'
import css from '@styled-system/css'
import type {ThemeColorPaths, ThemeShadowPaths} from './theme'
import type {ColorProps, BorderColorProps, ShadowProps} from 'styled-system'
import merge from 'deepmerge'

export type BetterCssProperties = {
[K in keyof SystemCssProperties]: K extends keyof ColorProps
Expand Down Expand Up @@ -37,5 +36,3 @@ export interface SxProp {
const sx = (props: SxProp) => css(props.sx)

export default sx

export {merge}
4 changes: 2 additions & 2 deletions packages/styled-react/src/components/ActionMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ActionMenu as PrimerActionMenu, type SxProp, type SlotMarker} from '@primer/react'
import {sx} from '../sx'
import {ActionMenu as PrimerActionMenu, type SlotMarker} from '@primer/react'
import {sx, type SxProp} from '../sx'
import styled from 'styled-components'
import type {ComponentProps} from 'react'

Expand Down
3 changes: 1 addition & 2 deletions packages/styled-react/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Button as PrimerButton, type ButtonProps as PrimerButtonProps, type SlotMarker} from '@primer/react'
import type {SxProp, CSSCustomProperties} from '../sx'
import type {BetterSystemStyleObject} from '../styled-props'
import type {SxProp, CSSCustomProperties, BetterSystemStyleObject} from '../sx'
import {forwardRef} from 'react'
import type {ForwardRefComponent} from '../polymorphic'
import styled from 'styled-components'
Expand Down
8 changes: 2 additions & 6 deletions packages/styled-react/src/components/CircleBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
CircleBadge as PrimerCircleBadge,
type CircleBadgeProps as PrimerCircleBadgeProps,
sx,
type SxProp,
} from '@primer/react'
import {CircleBadge as PrimerCircleBadge, type CircleBadgeProps as PrimerCircleBadgeProps} from '@primer/react'
import styled from 'styled-components'
import {type ForwardRefComponent} from '../polymorphic'
import sx, {type SxProp} from '../sx'
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import should use named import for consistency. Change import sx, {type SxProp} to import {sx, type SxProp} to match the pattern used in other component files.

Suggested change
import sx, {type SxProp} from '../sx'
import {sx, type SxProp} from '../sx'

Copilot uses AI. Check for mistakes.

type CircleBadgeProps<As extends React.ElementType> = PrimerCircleBadgeProps<As> & SxProp

Expand Down
8 changes: 2 additions & 6 deletions packages/styled-react/src/components/FormControl.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
FormControl as PrimerFormControl,
type FormControlProps as PrimerFormControlProps,
type SxProp,
} from '@primer/react'
import {FormControl as PrimerFormControl, type FormControlProps as PrimerFormControlProps} from '@primer/react'
import {type PropsWithChildren} from 'react'
import styled from 'styled-components'
import {sx} from '../sx'
import {sx, type SxProp} from '../sx'

type FormControlProps = PropsWithChildren<PrimerFormControlProps> & SxProp

Expand Down
3 changes: 1 addition & 2 deletions packages/styled-react/src/components/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import {
IconButton as PrimerIconButton,
type IconButtonProps as PrimerIconButtonProps,
type SlotMarker,
type SxProp,
} from '@primer/react'
import {type ForwardRefComponent} from '../polymorphic'
import {generateCustomSxProp} from './Button'
import {forwardRef} from 'react'
import styled from 'styled-components'
import {sx} from '../sx'
import {sx, type SxProp} from '../sx'

type IconButtonProps = PrimerIconButtonProps & SxProp & {as?: React.ElementType}

Expand Down
8 changes: 2 additions & 6 deletions packages/styled-react/src/components/LinkButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
LinkButton as PrimerLinkButton,
type LinkButtonProps as PrimerLinkButtonProps,
sx,
type SxProp,
} from '@primer/react'
import {LinkButton as PrimerLinkButton, type LinkButtonProps as PrimerLinkButtonProps} from '@primer/react'
import styled from 'styled-components'
import {type ForwardRefComponent} from '../polymorphic'
import {sx, type SxProp} from '../sx'

type LinkButtonProps = PrimerLinkButtonProps & SxProp

Expand Down
3 changes: 2 additions & 1 deletion packages/styled-react/src/components/Overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Overlay as PrimerOverlay, type OverlayProps as PrimerOverlayProps, sx, type SxProp} from '@primer/react'
import {Overlay as PrimerOverlay, type OverlayProps as PrimerOverlayProps} from '@primer/react'
import styled from 'styled-components'
import {type ForwardRefComponent} from '../polymorphic'
import {sx, type SxProp} from '../sx'

type OverlayProps = PrimerOverlayProps & SxProp

Expand Down
8 changes: 2 additions & 6 deletions packages/styled-react/src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
Tooltip as PrimerTooltip,
type TooltipProps as PrimerTooltipProps,
type SxProp,
type SlotMarker,
} from '@primer/react'
import {Tooltip as PrimerTooltip, type TooltipProps as PrimerTooltipProps, type SlotMarker} from '@primer/react'
import {Box} from './Box'
import {forwardRef, type ForwardRefExoticComponent, type RefAttributes} from 'react'
import type {SxProp} from '../sx'

type TooltipProps = PrimerTooltipProps & SxProp

Expand Down
5 changes: 2 additions & 3 deletions packages/styled-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export {
type ThemeProviderProps,
type BaseStylesProps,
} from './components/FeatureFlaggedTheming'
export {merge} from '@primer/react'
export {theme} from '@primer/react'
export {themeGet} from '@primer/react'

Expand Down Expand Up @@ -84,6 +83,6 @@ export {Token, type TokenProps} from './components/Token'
export {Truncate, type TruncateProps} from './components/Truncate'
export {UnderlineNav, type UnderlineNavProps, type UnderlineNavItemProps} from './components/UnderlineNav'

export {sx, type SxProp} from './sx'
export {merge, sx, type SxProp} from './sx'

export type {BetterSystemStyleObject} from './styled-props'
export {type BetterSystemStyleObject} from './sx'
2 changes: 0 additions & 2 deletions packages/styled-react/src/styled-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ export type StyledProps = SxProp &
BorderProps &
PositionProps &
ShadowProps

export type {BetterSystemStyleObject} from '@primer/react'
39 changes: 38 additions & 1 deletion packages/styled-react/src/sx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
export {sx, type SxProp} from '@primer/react'
import type {SystemCssProperties, SystemStyleObject} from '@styled-system/css'
import css from '@styled-system/css'
import type {ThemeColorPaths, ThemeShadowPaths} from '@primer/react'
import type {ColorProps, BorderColorProps, ShadowProps} from 'styled-system'
import merge from 'deepmerge'

export type BetterCssProperties = {
[K in keyof SystemCssProperties]: K extends keyof ColorProps
? ThemeColorPaths | SystemCssProperties[K]
: K extends keyof BorderColorProps
? ThemeColorPaths | SystemCssProperties[K]
: K extends keyof ShadowProps
? ThemeShadowPaths | SystemCssProperties[K]
: SystemCssProperties[K]
}

// Support CSS custom properties in the `sx` prop
export type CSSCustomProperties = {
[key: `--${string}`]: string | number
}

type CSSSelectorObject = {
[cssSelector: string]: SystemStyleObject | CSSCustomProperties
}

export type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject | CSSCustomProperties | CSSSelectorObject

export interface SxProp {
/**
* @deprecated The `sx` prop is deprecated. Replace with a `div` or
* appropriate HTML element instead, with a CSS class for styling.
* @see https://github.com/primer/react/blob/main/contributor-docs/migration-from-box.md
* */
sx?: BetterSystemStyleObject
}

const sx = (props: SxProp) => css(props.sx)

export default sx

export {merge, sx}
Loading