diff --git a/.changeset/hip-balloons-wash.md b/.changeset/hip-balloons-wash.md new file mode 100644 index 00000000000..3a85c12fd76 --- /dev/null +++ b/.changeset/hip-balloons-wash.md @@ -0,0 +1,5 @@ +--- +"@primer/react": major +--- + +Remove sx prop from LabelGroup diff --git a/packages/react/src/LabelGroup/LabelGroup.module.css b/packages/react/src/LabelGroup/LabelGroup.module.css new file mode 100644 index 00000000000..c623694e4cf --- /dev/null +++ b/packages/react/src/LabelGroup/LabelGroup.module.css @@ -0,0 +1,7 @@ +.OverlayToggle_LabelWrapper { + gap: var(--base-size-4) !important; +} + +.OverlayToggle_CloseButtonWrapper { + min-inline-size: unset !important; +} diff --git a/packages/react/src/LabelGroup/LabelGroup.tsx b/packages/react/src/LabelGroup/LabelGroup.tsx index 5aaf6f8edd8..80193753f59 100644 --- a/packages/react/src/LabelGroup/LabelGroup.tsx +++ b/packages/react/src/LabelGroup/LabelGroup.tsx @@ -5,11 +5,10 @@ import {getFocusableChild} from '@primer/behaviors/utils' import {get} from '../constants' import VisuallyHidden from '../_VisuallyHidden' import {AnchoredOverlay} from '../AnchoredOverlay' -import Box from '../Box' import {Button, IconButton} from '../Button' import {useTheme} from '../ThemeProvider' -import type {SxProp} from '../sx' -import sx from '../sx' +import {Stack, StackItem} from '../Stack/Stack' +import classes from './LabelGroup.module.css' export type LabelGroupProps = { /** Customize the element type of the rendered container */ @@ -18,12 +17,12 @@ export type LabelGroupProps = { overflowStyle?: 'inline' | 'overlay' /** How many tokens to show. `'auto'` truncates the tokens to fit in the parent container. Passing a number will truncate after that number tokens. If this is undefined, tokens will never be truncated. */ visibleChildCount?: 'auto' | number -} & SxProp +} -const StyledLabelGroupContainer = styled.div` +const StyledLabelGroupContainer = styled.div` display: flex; flex-wrap: nowrap; - gap: ${get('space.1')}; + gap: var(--base-size-4); line-height: 1; max-width: 100%; overflow: hidden; @@ -38,8 +37,6 @@ const StyledLabelGroupContainer = styled.div` margin-block-end: 0; list-style-type: none; } - - ${sx}; ` const ItemWrapper = styled.div` @@ -136,18 +133,22 @@ const OverlayToggle: React.FC< )} focusZoneSettings={{disabled: true}} > - - - {children} - - - + + + + {children} + + + + + + ) : null @@ -156,7 +157,6 @@ const LabelGroup: React.FC> = ({ children, visibleChildCount, overflowStyle = 'overlay', - sx: sxProp, as = 'ul', }) => { const containerRef = React.useRef(null) @@ -336,7 +336,6 @@ const LabelGroup: React.FC> = ({ ref={containerRef} data-overflow={overflowStyle === 'inline' && isOverflowShown ? 'inline' : undefined} data-list={isList || undefined} - sx={sxProp} as={as} > {React.Children.map(children, (child, index) => ( @@ -378,7 +377,7 @@ const LabelGroup: React.FC> = ({ ) : ( - + {isList ? React.Children.map(children, (child, index) => { return
  • {child}
  • diff --git a/packages/react/src/__tests__/LabelGroup.test.tsx b/packages/react/src/__tests__/LabelGroup.test.tsx index 77a89f65581..d0b972abc16 100644 --- a/packages/react/src/__tests__/LabelGroup.test.tsx +++ b/packages/react/src/__tests__/LabelGroup.test.tsx @@ -29,7 +29,7 @@ describe('LabelGroup', () => { thresholds: [], })) as jest.Mock - behavesAsComponent({Component: LabelGroup, options: {skipAs: true}}) + behavesAsComponent({Component: LabelGroup, options: {skipAs: true, skipSx: true}}) checkExports('LabelGroup', { default: LabelGroup, diff --git a/packages/react/src/sx.ts b/packages/react/src/sx.ts index 5b9a20fc011..d66c30672df 100644 --- a/packages/react/src/sx.ts +++ b/packages/react/src/sx.ts @@ -29,6 +29,11 @@ export interface SxProp { sx?: BetterSystemStyleObject } +export interface DeprecatedSxProp { + /** @deprecated Update `sx` using CSS modules or style. */ + sx?: BetterSystemStyleObject +} + const sx = (props: SxProp) => css(props.sx) export default sx