Skip to content

Commit 23a2ff9

Browse files
jonrohanpksjce
authored andcommitted
refactor(Stack): Remove sx prop support from the Stack component (#6610)
1 parent 9bb5ed7 commit 23a2ff9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.changeset/young-dots-heal.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 sx prop support from the Stack component

packages/react/src/Stack/Stack.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {getResponsiveAttributes} from '../internal/utils/getResponsiveAttributes
55
import classes from './Stack.module.css'
66
import {clsx} from 'clsx'
77
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
8-
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
98

109
type GapScale = 'none' | 'condensed' | 'normal' | 'spacious'
1110
type Gap = GapScale | ResponsiveValue<GapScale>
@@ -71,7 +70,7 @@ type StackProps<As> = React.PropsWithChildren<{
7170
const Stack = forwardRef(
7271
(
7372
{
74-
as,
73+
as: Component = 'div',
7574
children,
7675
align = 'stretch',
7776
direction = 'vertical',
@@ -85,8 +84,7 @@ const Stack = forwardRef(
8584
forwardedRef,
8685
) => {
8786
return (
88-
<BoxWithFallback
89-
as={as}
87+
<Component
9088
ref={forwardedRef}
9189
{...rest}
9290
className={clsx(className, classes.Stack)}
@@ -98,7 +96,7 @@ const Stack = forwardRef(
9896
{...getResponsiveAttributes('padding', padding)}
9997
>
10098
{children}
101-
</BoxWithFallback>
99+
</Component>
102100
)
103101
},
104102
) as PolymorphicForwardRefComponent<ElementType, StackProps<ElementType>>
@@ -124,18 +122,17 @@ type StackItemProps<As> = React.PropsWithChildren<{
124122
className?: string
125123
}>
126124

127-
const StackItem = forwardRef(({as, children, grow, shrink, className, ...rest}, forwardedRef) => {
125+
const StackItem = forwardRef(({as: Component = 'div', children, grow, shrink, className, ...rest}, forwardedRef) => {
128126
return (
129-
<BoxWithFallback
130-
as={as}
127+
<Component
131128
ref={forwardedRef}
132129
{...rest}
133130
className={clsx(className, classes.StackItem)}
134131
{...getResponsiveAttributes('grow', grow)}
135132
{...getResponsiveAttributes('shrink', shrink)}
136133
>
137134
{children}
138-
</BoxWithFallback>
135+
</Component>
139136
)
140137
}) as PolymorphicForwardRefComponent<ElementType, StackProps<ElementType>>
141138

0 commit comments

Comments
 (0)