Skip to content

Commit 00261c9

Browse files
authored
remove sx from RadioGroup and Truncate (#6685)
1 parent 961c1c4 commit 00261c9

File tree

11 files changed

+80
-26
lines changed

11 files changed

+80
-26
lines changed

.changeset/rude-cycles-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': major
3+
---
4+
5+
Remove the sx prop from RadioGroup and Truncate.

packages/react/src/ActionList/Description.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export const Description: React.FC<React.PropsWithChildren<ActionListDescription
6161
ref={containerRef}
6262
id={inlineDescriptionId}
6363
className={clsx(className, classes.Description)}
64-
sx={sx}
6564
title={effectiveTitle}
6665
inline={true}
6766
maxWidth="100%"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.RadioGroupWithTopMargin {
2+
margin-top: var(--base-size-24);
3+
}

packages/react/src/Banner/Banner.examples.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {Button} from '../Button'
1010
import React from 'react'
1111
import {useFocus} from '../internal/hooks/useFocus'
1212
import {PageLayout} from '../PageLayout'
13+
import classes from './Banner.examples.stories.module.css'
1314

1415
const meta = {
1516
title: 'Components/Banner/Examples',
@@ -65,11 +66,11 @@ export const WithAnnouncement = () => {
6566
secondaryAction={<Banner.SecondaryAction>Button</Banner.SecondaryAction>}
6667
/>
6768
<RadioGroup
68-
sx={{marginTop: 4}}
6969
name="options"
7070
onChange={selected => {
7171
setSelected(selected as Choice)
7272
}}
73+
className={classes.RadioGroupWithTopMargin}
7374
>
7475
<RadioGroup.Label>Choices</RadioGroup.Label>
7576
<FormControl>

packages/react/src/RadioGroup/RadioGroup.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import CheckboxOrRadioGroupCaption from '../internal/components/CheckboxOrRadioG
77
import CheckboxOrRadioGroupLabel from '../internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel'
88
import CheckboxOrRadioGroupValidation from '../internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupValidation'
99
import {useRenderForcingRef} from '../hooks'
10-
import type {SxProp} from '../sx'
1110

12-
type RadioGroupProps = {
11+
export type RadioGroupProps = {
1312
/**
1413
* An onChange handler that gets called when the selection changes
1514
*/
@@ -18,8 +17,7 @@ type RadioGroupProps = {
1817
* The name used to identify this group of radios
1918
*/
2019
name: string
21-
} & CheckboxOrRadioGroupProps &
22-
SxProp
20+
} & CheckboxOrRadioGroupProps
2321

2422
export const RadioGroupContext = createContext<{
2523
disabled?: boolean
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export {default, RadioGroupContext} from './RadioGroup'
2+
3+
export type {RadioGroupProps} from './RadioGroup'

packages/react/src/Truncate/Truncate.stories.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ Playground.argTypes = {
4141
disable: true,
4242
},
4343
},
44-
sx: {
45-
controls: false,
46-
table: {
47-
disable: true,
48-
},
49-
},
5044
theme: {
5145
controls: false,
5246
table: {

packages/react/src/Truncate/Truncate.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
import React from 'react'
22
import {clsx} from 'clsx'
33
import type {MaxWidthProps} from 'styled-system'
4-
import type {SxProp} from '../sx'
54
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
6-
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
75
import classes from './Truncate.module.css'
86

97
type TruncateProps = React.HTMLAttributes<HTMLElement> & {
108
title: string
119
inline?: boolean
1210
expandable?: boolean
13-
} & MaxWidthProps &
14-
SxProp
11+
} & MaxWidthProps
1512

1613
const Truncate = React.forwardRef(function Truncate(
17-
{as, children, className, title, inline, expandable, maxWidth = 125, style, sx, ...rest},
14+
{as: Component = 'div', children, className, title, inline, expandable, maxWidth = 125, style, ...rest},
1815
ref,
1916
) {
2017
return (
21-
<BoxWithFallback
18+
<Component
2219
{...rest}
2320
ref={ref}
24-
as={as}
2521
className={clsx(className, classes.Truncate)}
2622
data-expandable={expandable}
2723
data-inline={inline}
@@ -33,10 +29,9 @@ const Truncate = React.forwardRef(function Truncate(
3329
typeof maxWidth === 'number' ? `${maxWidth}px` : typeof maxWidth === 'string' ? maxWidth : undefined,
3430
} as React.CSSProperties
3531
}
36-
sx={sx}
3732
>
3833
{children}
39-
</BoxWithFallback>
34+
</Component>
4035
)
4136
}) as PolymorphicForwardRefComponent<'div', TruncateProps>
4237

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
124124
"type ProgressBarProps",
125125
"Radio",
126126
"RadioGroup",
127+
"type RadioGroupProps",
127128
"type RadioProps",
128129
"registerPortalRoot",
129130
"RelativeTime",

packages/react/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export type {PortalProps} from './Portal'
129129
export {ProgressBar} from './ProgressBar'
130130
export type {ProgressBarProps, ProgressBarItemProps} from './ProgressBar'
131131
export {default as RadioGroup} from './RadioGroup'
132+
export type {RadioGroupProps} from './RadioGroup'
132133
export type {RelativeTimeProps} from './RelativeTime'
133134
export {default as RelativeTime} from './RelativeTime'
134135
export {SegmentedControl} from './SegmentedControl'

0 commit comments

Comments
 (0)