Skip to content

Commit a68aad9

Browse files
llastflowersfrancineluccaliuliu-dev
authored andcommitted
Remove support for sx from ActionList component and sub-components (#6921)
Co-authored-by: Marie Lucca <[email protected]> Co-authored-by: Liu Liu <[email protected]>
1 parent eb6b302 commit a68aad9

23 files changed

+324
-233
lines changed
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+
Update ActionList component and related components to no longer support sx/styled-components

packages/react/src/ActionList/ActionList.docs.json

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
"type": "AriaRole",
3737
"defaultValue": "",
3838
"description": "ARIA role describing the function of the list. `listbox` and `menu` are a common values."
39-
},
40-
{
41-
"name": "sx",
42-
"type": "SystemStyleObject",
43-
"deprecated": true
4439
}
4540
],
4641
"subcomponents": [
@@ -113,11 +108,6 @@
113108
"required": false,
114109
"description": "id to attach to the root element of the Item",
115110
"defaultValue": ""
116-
},
117-
{
118-
"name": "sx",
119-
"type": "SystemStyleObject",
120-
"deprecated": true
121111
}
122112
]
123113
},
@@ -144,11 +134,6 @@
144134
"required": false,
145135
"description": "",
146136
"defaultValue": ""
147-
},
148-
{
149-
"name": "sx",
150-
"type": "SystemStyleObject",
151-
"deprecated": true
152137
}
153138
]
154139
},
@@ -183,11 +168,6 @@
183168
"required": false,
184169
"description": "Text describing why the item is inactive. This may be used when an item's usual functionality\nis unavailable due to a system error such as a database outage.",
185170
"defaultValue": ""
186-
},
187-
{
188-
"name": "sx",
189-
"type": "SystemStyleObject",
190-
"deprecated": true
191171
}
192172
],
193173
"passthrough": {
@@ -204,11 +184,6 @@
204184
"defaultValue": "",
205185
"required": true,
206186
"description": "Icon (or similar) positioned before item text."
207-
},
208-
{
209-
"name": "sx",
210-
"type": "SystemStyleObject",
211-
"deprecated": true
212187
}
213188
]
214189
},
@@ -221,11 +196,6 @@
221196
"defaultValue": "",
222197
"required": true,
223198
"description": "Visual positioned after item text."
224-
},
225-
{
226-
"name": "sx",
227-
"type": "SystemStyleObject",
228-
"deprecated": true
229199
}
230200
]
231201
},
@@ -282,11 +252,6 @@
282252
"defaultValue": "'inline'",
283253
"description": "`inline` descriptions are positioned beside primary text. `block` descriptions are positioned below primary text."
284254
},
285-
{
286-
"name": "sx",
287-
"type": "SystemStyleObject",
288-
"deprecated": true
289-
},
290255
{
291256
"name": "className",
292257
"type": "string | undefined",
@@ -337,11 +302,6 @@
337302
"defaultValue": "h3",
338303
"required": false,
339304
"description": "The level of the heading and it is only required (enforce by runtime warning) for lists. (i.e. not required for ActionMenu or listbox roles)"
340-
},
341-
{
342-
"name": "sx",
343-
"type": "SystemStyleObject",
344-
"deprecated": true
345305
}
346306
]
347307
},
@@ -385,22 +345,6 @@
385345
"type": "AriaRole",
386346
"defaultValue": "",
387347
"description": "ARIA role describing the function of the list inside the group. `listbox` and `menu` are a common values."
388-
},
389-
{
390-
"name": "sx",
391-
"type": "SystemStyleObject",
392-
"deprecated": true
393-
}
394-
]
395-
},
396-
{
397-
"filePath": "/Users/mperrotti/work-dir/react/packages/react/src/ActionList/Divider.tsx",
398-
"name": "ActionList.Divider",
399-
"props": [
400-
{
401-
"name": "sx",
402-
"type": "SystemStyleObject",
403-
"deprecated": true
404348
}
405349
]
406350
}

packages/react/src/ActionList/Description.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import React from 'react'
22
import Truncate from '../Truncate'
3-
import type {SxProp} from '../sx'
43
import {ItemContext} from './shared'
54
import classes from './ActionList.module.css'
6-
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
75
import {clsx} from 'clsx'
86

97
export type ActionListDescriptionProps = {
@@ -16,17 +14,18 @@ export type ActionListDescriptionProps = {
1614
variant?: 'inline' | 'block'
1715

1816
className?: string
17+
style?: React.CSSProperties
1918
/**
2019
* Whether the inline description should truncate the text on overflow.
2120
*/
2221
truncate?: boolean
23-
} & SxProp
22+
}
2423

2524
export const Description: React.FC<React.PropsWithChildren<ActionListDescriptionProps>> = ({
2625
variant = 'inline',
27-
sx,
2826
className,
2927
truncate,
28+
style,
3029
...props
3130
}) => {
3231
const {blockDescriptionId, inlineDescriptionId} = React.useContext(ItemContext)
@@ -45,22 +44,22 @@ export const Description: React.FC<React.PropsWithChildren<ActionListDescription
4544

4645
if (variant === 'block' || !truncate) {
4746
return (
48-
<BoxWithFallback
49-
as="span"
50-
sx={sx}
47+
<span
5148
id={variant === 'block' ? blockDescriptionId : inlineDescriptionId}
5249
className={clsx(className, classes.Description)}
50+
style={style}
5351
data-component="ActionList.Description"
5452
>
5553
{props.children}
56-
</BoxWithFallback>
54+
</span>
5755
)
5856
} else {
5957
return (
6058
<Truncate
6159
ref={containerRef}
6260
id={inlineDescriptionId}
6361
className={clsx(className, classes.Description)}
62+
style={style}
6463
title={effectiveTitle}
6564
inline={true}
6665
maxWidth="100%"

packages/react/src/ActionList/Divider.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import type React from 'react'
2-
import type {SxProp} from '../sx'
32
import {clsx} from 'clsx'
43
import classes from './ActionList.module.css'
5-
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
64

7-
export type ActionListDividerProps = SxProp & {
5+
export type ActionListDividerProps = {
86
className?: string
7+
style?: React.CSSProperties
98
}
109

1110
/**
12-
* Visually separates `Item`s or `Group`s in an `ActionList`.
11+
* Visually separates `Items` or `Groups` in an `ActionList`.
1312
*/
14-
export const Divider: React.FC<React.PropsWithChildren<ActionListDividerProps>> = ({sx, className}) => {
13+
export const Divider: React.FC<React.PropsWithChildren<ActionListDividerProps>> = ({className, style}) => {
1514
return (
16-
<BoxWithFallback
15+
<li
1716
className={clsx(className, classes.Divider)}
18-
as="li"
17+
style={style}
1918
aria-hidden="true"
20-
sx={sx}
2119
data-component="ActionList.Divider"
2220
/>
2321
)

packages/react/src/ActionList/Group.tsx

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import React from 'react'
22
import {useId} from '../hooks/useId'
3-
import type {SxProp} from '../sx'
43
import {ListContext, type ActionListProps} from './shared'
54
import type {ActionListHeadingProps} from './Heading'
65
import {useSlots} from '../hooks/useSlots'
76
import {invariant} from '../utils/invariant'
87
import {clsx} from 'clsx'
98
import classes from './ActionList.module.css'
109
import groupClasses from './Group.module.css'
11-
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
1210

1311
type HeadingProps = {
1412
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
1513
className?: string
1614
children: React.ReactNode
1715
id?: string
18-
} & SxProp
16+
}
1917

2018
const Heading: React.FC<HeadingProps & React.HTMLAttributes<HTMLHeadingElement>> = ({
2119
as: Component = 'h3',
@@ -25,10 +23,9 @@ const Heading: React.FC<HeadingProps & React.HTMLAttributes<HTMLHeadingElement>>
2523
...rest
2624
}) => {
2725
return (
28-
// Box is temporary to support lingering sx usage
29-
<BoxWithFallback as={Component} className={className} id={id} {...rest}>
26+
<Component className={className} id={id} {...rest}>
3027
{children}
31-
</BoxWithFallback>
28+
</Component>
3229
)
3330
}
3431

@@ -58,12 +55,11 @@ export type ActionListGroupProps = React.HTMLAttributes<HTMLLIElement> & {
5855
* Secondary text which provides additional information about a `Group`.
5956
*/
6057
auxiliaryText?: string
61-
} & SxProp & {
62-
/**
63-
* Whether multiple Items or a single Item can be selected in the Group. Overrides value on ActionList root.
64-
*/
65-
selectionVariant?: ActionListProps['selectionVariant'] | false
66-
}
58+
/**
59+
* Whether multiple Items or a single Item can be selected in the Group. Overrides value on ActionList root.
60+
*/
61+
selectionVariant?: ActionListProps['selectionVariant'] | false
62+
}
6763

6864
type ContextProps = Pick<ActionListGroupProps, 'selectionVariant'> & {groupHeadingId: string | undefined}
6965
export const GroupContext = React.createContext<ContextProps>({
@@ -101,12 +97,7 @@ export const Group: React.FC<React.PropsWithChildren<ActionListGroupProps>> = ({
10197
}
10298

10399
return (
104-
<BoxWithFallback
105-
as="li"
106-
className={clsx(className, groupClasses.Group)}
107-
role={listRole ? 'none' : undefined}
108-
{...props}
109-
>
100+
<li className={clsx(className, groupClasses.Group)} role={listRole ? 'none' : undefined} {...props}>
110101
<GroupContext.Provider value={{selectionVariant, groupHeadingId}}>
111102
{title && !slots.groupHeading ? (
112103
// Escape hatch: supports old API <ActionList.Group title="group title"> in a non breaking way
@@ -126,13 +117,12 @@ export const Group: React.FC<React.PropsWithChildren<ActionListGroupProps>> = ({
126117
{slots.groupHeading ? childrenWithoutSlots : props.children}
127118
</ul>
128119
</GroupContext.Provider>
129-
</BoxWithFallback>
120+
</li>
130121
)
131122
}
132123

133124
export type ActionListGroupHeadingProps = Pick<ActionListGroupProps, 'variant' | 'auxiliaryText'> &
134125
Omit<ActionListHeadingProps, 'as'> &
135-
SxProp &
136126
React.HTMLAttributes<HTMLElement> & {
137127
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
138128
headingWrapElement?: 'div' | 'li'
@@ -156,7 +146,6 @@ export const GroupHeading: React.FC<React.PropsWithChildren<ActionListGroupHeadi
156146
auxiliaryText,
157147
children,
158148
className,
159-
sx,
160149
headingWrapElement = 'div',
161150
...props
162151
}) => {
@@ -208,7 +197,6 @@ export const GroupHeading: React.FC<React.PropsWithChildren<ActionListGroupHeadi
208197
className={clsx(className, groupClasses.GroupHeading)}
209198
as={as || 'h3'}
210199
id={groupHeadingId}
211-
sx={sx}
212200
{...props}
213201
>
214202
{_internalBackwardCompatibleTitle ?? children}

packages/react/src/ActionList/Heading.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, {forwardRef} from 'react'
2-
import type {SxProp} from '../sx'
32
import {useRefObjectAsForwardedRef} from '../hooks'
43
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
54
import {default as HeadingComponent} from '../Heading'
@@ -17,7 +16,8 @@ export type ActionListHeadingProps = {
1716
size?: HeadingVariants
1817
visuallyHidden?: boolean
1918
className?: string
20-
} & SxProp
19+
style?: React.CSSProperties
20+
}
2121

2222
export const Heading = forwardRef(({as, size, children, visuallyHidden = false, className, ...props}, forwardedRef) => {
2323
const innerRef = React.useRef<HTMLHeadingElement>(null)

packages/react/src/ActionList/Item.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {invariant} from '../utils/invariant'
1515
import VisuallyHidden from '../_VisuallyHidden'
1616
import classes from './ActionList.module.css'
1717
import {clsx} from 'clsx'
18-
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
1918
import {fixedForwardRef} from '../utils/modern-polymorphic'
2019

2120
type ActionListSubItemProps = {
@@ -57,7 +56,6 @@ const UnwrappedItem = <As extends React.ElementType = 'li'>(
5756
selected = undefined,
5857
active = false,
5958
onSelect: onSelectUser,
60-
sx: sxProp,
6159
id,
6260
role,
6361
loading,
@@ -246,10 +244,8 @@ const UnwrappedItem = <As extends React.ElementType = 'li'>(
246244
trailingVisualId,
247245
}}
248246
>
249-
<BoxWithFallback
247+
<li
250248
{...containerProps}
251-
as="li"
252-
sx={sxProp}
253249
ref={listSemantics ? forwardedRef : null}
254250
data-variant={variant === 'danger' ? variant : undefined}
255251
data-active={active ? true : undefined}
@@ -313,7 +309,7 @@ const UnwrappedItem = <As extends React.ElementType = 'li'>(
313309
</ItemWrapper>
314310
{!inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction}
315311
{slots.subItem}
316-
</BoxWithFallback>
312+
</li>
317313
</ItemContext.Provider>
318314
)
319315
}

packages/react/src/ActionList/LinkItem.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ type LinkProps = {
2121
// LinkItem does not support selected, loading, variants, etc.
2222
export type ActionListLinkItemProps = Pick<
2323
ActionListItemProps,
24-
'active' | 'children' | 'sx' | 'inactiveText' | 'variant' | 'size'
24+
'active' | 'children' | 'inactiveText' | 'variant' | 'size'
2525
> &
2626
LinkProps
2727

2828
export const LinkItem = React.forwardRef(
29-
({sx, active, inactiveText, variant, size, as: Component, className, ...props}, forwardedRef) => {
29+
({active, inactiveText, variant, size, as: Component, className, ...props}, forwardedRef) => {
3030
return (
3131
<Item
3232
className={className}
@@ -35,7 +35,6 @@ export const LinkItem = React.forwardRef(
3535
data-inactive={inactiveText ? true : undefined}
3636
variant={variant}
3737
size={size}
38-
sx={sx}
3938
_PrivateItemWrapper={({children, onClick, ...rest}) => {
4039
const clickHandler = (event: React.MouseEvent<HTMLElement>) => {
4140
onClick && onClick(event)

0 commit comments

Comments
 (0)