Skip to content

Commit 9fce541

Browse files
chore: cleanup sx prop (#7032)
1 parent 9bad0bb commit 9fce541

File tree

15 files changed

+64
-49
lines changed

15 files changed

+64
-49
lines changed

.changeset/mean-kangaroos-count.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@primer/react": major
3+
"@primer/styled-react": patch
4+
---
5+
6+
- remove sx, SxProp, exports
7+
- add type ThemeColorPaths, type ThemeShadowPaths

packages/react/src/__tests__/__snapshots__/exports.test.ts.snap

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
3131
"type BannerProps",
3232
"BaseStyles",
3333
"type BaseStylesProps",
34-
"type BetterCssProperties",
35-
"type BetterSystemStyleObject",
3634
"BranchName",
3735
"type BranchNameProps",
3836
"Breadcrumb",
@@ -95,7 +93,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
9593
"LinkButton",
9694
"type LinkButtonProps",
9795
"type LinkProps",
98-
"merge",
9996
"NavList",
10097
"type NavListDividerProps",
10198
"type NavListGroupHeadingProps",
@@ -172,8 +169,6 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
172169
"type SubNavLinkProps",
173170
"type SubNavLinksProps",
174171
"type SubNavProps",
175-
"sx",
176-
"type SxProp",
177172
"Text",
178173
"Textarea",
179174
"type TextareaProps",
@@ -184,9 +179,11 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
184179
"type TextInputWithTokensProps",
185180
"type TextProps",
186181
"theme",
182+
"ThemeColorPaths",
187183
"themeGet",
188184
"ThemeProvider",
189185
"type ThemeProviderProps",
186+
"ThemeShadowPaths",
190187
"Timeline",
191188
"type TimelineBadgeProps",
192189
"type TimelineBodyProps",

packages/react/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
export {default as theme} from './theme'
3+
export {default as theme, type ThemeColorPaths, type ThemeShadowPaths} from './theme'
44
export {get as themeGet} from './constants'
55
export {default as BaseStyles} from './BaseStyles'
66
export type {BaseStylesProps} from './BaseStyles'
@@ -225,8 +225,5 @@ export type {
225225
ChildrenPropTypes as PageHeaderChildrenPropTypes,
226226
} from './PageHeader'
227227

228-
export {default as sx, merge} from './sx'
229-
export type {BetterCssProperties, BetterSystemStyleObject, SxProp} from './sx'
230-
231228
export {SkeletonBox} from './Skeleton'
232229
export type {SkeletonBoxProps} from './Skeleton'

packages/react/src/sx.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type {SystemCssProperties, SystemStyleObject} from '@styled-system/css'
22
import css from '@styled-system/css'
33
import type {ThemeColorPaths, ThemeShadowPaths} from './theme'
44
import type {ColorProps, BorderColorProps, ShadowProps} from 'styled-system'
5-
import merge from 'deepmerge'
65

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

3938
export default sx
40-
41-
export {merge}

packages/styled-react/src/components/ActionMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {ActionMenu as PrimerActionMenu, type SxProp, type SlotMarker} from '@primer/react'
2-
import {sx} from '../sx'
1+
import {ActionMenu as PrimerActionMenu, type SlotMarker} from '@primer/react'
2+
import {sx, type SxProp} from '../sx'
33
import styled from 'styled-components'
44
import type {ComponentProps} from 'react'
55

packages/styled-react/src/components/Button.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Button as PrimerButton, type ButtonProps as PrimerButtonProps, type SlotMarker} from '@primer/react'
2-
import type {SxProp, CSSCustomProperties} from '../sx'
3-
import type {BetterSystemStyleObject} from '../styled-props'
2+
import type {SxProp, CSSCustomProperties, BetterSystemStyleObject} from '../sx'
43
import {forwardRef} from 'react'
54
import type {ForwardRefComponent} from '../polymorphic'
65
import styled from 'styled-components'

packages/styled-react/src/components/CircleBadge.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import {
2-
CircleBadge as PrimerCircleBadge,
3-
type CircleBadgeProps as PrimerCircleBadgeProps,
4-
sx,
5-
type SxProp,
6-
} from '@primer/react'
1+
import {CircleBadge as PrimerCircleBadge, type CircleBadgeProps as PrimerCircleBadgeProps} from '@primer/react'
72
import styled from 'styled-components'
83
import {type ForwardRefComponent} from '../polymorphic'
4+
import sx, {type SxProp} from '../sx'
95

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

packages/styled-react/src/components/FormControl.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import {
2-
FormControl as PrimerFormControl,
3-
type FormControlProps as PrimerFormControlProps,
4-
type SxProp,
5-
} from '@primer/react'
1+
import {FormControl as PrimerFormControl, type FormControlProps as PrimerFormControlProps} from '@primer/react'
62
import {type PropsWithChildren} from 'react'
73
import styled from 'styled-components'
8-
import {sx} from '../sx'
4+
import {sx, type SxProp} from '../sx'
95

106
type FormControlProps = PropsWithChildren<PrimerFormControlProps> & SxProp
117

packages/styled-react/src/components/IconButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import {
22
IconButton as PrimerIconButton,
33
type IconButtonProps as PrimerIconButtonProps,
44
type SlotMarker,
5-
type SxProp,
65
} from '@primer/react'
76
import {type ForwardRefComponent} from '../polymorphic'
87
import {generateCustomSxProp} from './Button'
98
import {forwardRef} from 'react'
109
import styled from 'styled-components'
11-
import {sx} from '../sx'
10+
import {sx, type SxProp} from '../sx'
1211

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

packages/styled-react/src/components/LinkButton.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import {
2-
LinkButton as PrimerLinkButton,
3-
type LinkButtonProps as PrimerLinkButtonProps,
4-
sx,
5-
type SxProp,
6-
} from '@primer/react'
1+
import {LinkButton as PrimerLinkButton, type LinkButtonProps as PrimerLinkButtonProps} from '@primer/react'
72
import styled from 'styled-components'
83
import {type ForwardRefComponent} from '../polymorphic'
4+
import {sx, type SxProp} from '../sx'
95

106
type LinkButtonProps = PrimerLinkButtonProps & SxProp
117

0 commit comments

Comments
 (0)