Skip to content

Commit b43327b

Browse files
liuliu-devfrancineluccallastflowers
authored andcommitted
Remove support for sx from the ActionList component in @primer/react/deprecated (#6944)
Co-authored-by: Marie Lucca <[email protected]> Co-authored-by: Marie Lucca <[email protected]> Co-authored-by: llastflowers <[email protected]> Co-authored-by: Brittany L. Houtz <[email protected]>
1 parent 073d02e commit b43327b

File tree

22 files changed

+496
-356
lines changed

22 files changed

+496
-356
lines changed

.changeset/afraid-teams-throw.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@primer/react': major
3+
'@primer/styled-react': minor
4+
---
5+
6+
Remove sx from deprecated ActionList component.

packages/react/src/FilteredActionList/FilteredActionList.module.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
overflow: hidden;
55
}
66

7+
.Header {
8+
/* stylelint-disable-next-line primer/box-shadow */
9+
box-shadow: 0 1px 0 var(--borderColor-default);
10+
z-index: 1;
11+
}
12+
713
.Container {
814
display: flex;
915
height: 100%;

packages/react/src/FilteredActionList/FilteredActionList.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import {scrollIntoView, FocusKeys} from '@primer/behaviors'
33
import type {KeyboardEventHandler} from 'react'
44
import type React from 'react'
55
import {useCallback, useEffect, useRef, useState} from 'react'
6-
import styled from 'styled-components'
76
import type {TextInputProps} from '../TextInput'
87
import TextInput from '../TextInput'
9-
import {get} from '../constants'
108
import {ActionList} from '../ActionList'
119
import type {GroupedListProps, ListPropsBase, ItemInput, RenderItemFn} from './'
1210
import {useFocusZone} from '../hooks/useFocusZone'
@@ -49,11 +47,6 @@ export interface FilteredActionListProps extends Partial<Omit<GroupedListProps,
4947
onSelectAllChange?: (checked: boolean) => void
5048
}
5149

52-
const StyledHeader = styled.div`
53-
box-shadow: 0 1px 0 ${get('colors.border.default')};
54-
z-index: 1;
55-
`
56-
5750
export function FilteredActionList({
5851
loading = false,
5952
placeholderText,
@@ -346,7 +339,7 @@ export function FilteredActionList({
346339

347340
return (
348341
<div ref={inputAndListContainerRef} className={clsx(className, classes.Root)} data-testid="filtered-action-list">
349-
<StyledHeader>
342+
<div className={classes.Header}>
350343
<TextInput
351344
ref={inputRef}
352345
block
@@ -368,7 +361,7 @@ export function FilteredActionList({
368361
className={clsx(textInputClassName, {[classes.FullScreenTextInput]: fullScreenOnNarrow})}
369362
{...restTextInputProps}
370363
/>
371-
</StyledHeader>
364+
</div>
372365
<VisuallyHidden id={inputDescriptionTextId}>Items will be filtered as you type</VisuallyHidden>
373366
{onSelectAllChange !== undefined && (
374367
<div className={classes.SelectAllContainer}>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.Divider {
2+
height: var(--borderWidth-thin);
3+
/* stylelint-disable-next-line primer/colors */
4+
background: var(--borderColor-muted);
5+
/* stylelint-disable-next-line primer/spacing */
6+
margin-top: calc(var(--base-size-8) - 1px);
7+
margin-bottom: var(--base-size-8);
8+
}

packages/react/src/deprecated/ActionList/Divider.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
import styled from 'styled-components'
2-
import {get} from '../../constants'
3-
4-
export const StyledDivider = styled.div`
5-
height: 1px;
6-
background: ${get('colors.border.muted')};
7-
margin-top: calc(${get('space.2')} - 1px);
8-
margin-bottom: ${get('space.2')};
9-
`
1+
import classes from './Divider.module.css'
102

113
/**
12-
* Visually separates `Item`s or `Group`s in an `ActionList`.
4+
* Visually separates `Items or `Groups in an `ActionList`.
135
*/
146
export function Divider(): JSX.Element {
15-
return <StyledDivider />
7+
return <div data-component="ActionList.Divider" className={classes.Divider} />
168
}
179

1810
/**

packages/react/src/deprecated/ActionList/Group.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import type React from 'react'
2-
import styled from 'styled-components'
3-
import type {SxProp} from '../../sx'
4-
import sx from '../../sx'
52
import type {HeaderProps} from './Header'
63
import {Header} from './Header'
74

85
/**
96
* Contract for props passed to the `Group` component.
107
*/
11-
export interface GroupProps extends React.ComponentPropsWithoutRef<'div'>, SxProp {
8+
export interface GroupProps extends React.ComponentPropsWithoutRef<'div'> {
129
/**
1310
* Props for a `Header` to render in the `Group`.
1411
*/
@@ -30,18 +27,14 @@ export interface GroupProps extends React.ComponentPropsWithoutRef<'div'>, SxPro
3027
showItemDividers?: boolean
3128
}
3229

33-
const StyledGroup = styled.div`
34-
${sx}
35-
`
36-
3730
/**
3831
* Collects related `Items` in an `ActionList`.
3932
*/
4033
export function Group({header, items, ...props}: GroupProps): JSX.Element {
4134
return (
42-
<StyledGroup {...props}>
35+
<div {...props}>
4336
{header && <Header {...header} />}
4437
{items}
45-
</StyledGroup>
38+
</div>
4639
)
4740
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.Header {
2+
/* 6px vertical padding + 20px line height = 32px total height
3+
*
4+
* TODO: When rem-based spacing on a 4px scale lands, replace
5+
* hardcoded '6px' with 'calc((${get('space.s32')} - ${get('space.20')}) / 2)'.
6+
*/
7+
/* stylelint-disable-next-line primer/spacing */
8+
padding: 6px var(--base-size-16);
9+
font-size: var(--text-body-size-small);
10+
font-weight: var(--text-title-weight-large);
11+
color: var(--fgColor-muted);
12+
13+
&:where([data-filled]) {
14+
background: var(--bgColor-muted);
15+
margin: var(--base-size-8) 0;
16+
/* stylelint-disable-next-line primer/colors */
17+
border-top: var(--borderWidth-thin) solid var(--bgColor-neutral-muted);
18+
/* stylelint-disable-next-line primer/colors */
19+
border-bottom: var(--borderWidth-thin) solid var(--bgColor-neutral-muted);
20+
21+
&:first-child {
22+
margin-top: 0;
23+
}
24+
}
25+
}
Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import type React from 'react'
2-
import styled, {css} from 'styled-components'
3-
import {get} from '../../constants'
4-
import type {SxProp} from '../../sx'
5-
import sx from '../../sx'
2+
import {clsx} from 'clsx'
3+
import classes from './Header.module.css'
64

75
/**
86
* Contract for props passed to the `Header` component.
97
*/
10-
export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'>, SxProp {
8+
export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'> {
119
/**
1210
* Style variations. Usage is discretionary.
1311
*
@@ -27,35 +25,6 @@ export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'>, SxPr
2725
auxiliaryText?: string
2826
}
2927

30-
export const StyledHeader = styled.div<{variant: HeaderProps['variant']} & SxProp>`
31-
{
32-
/* 6px vertical padding + 20px line height = 32px total height
33-
*
34-
* TODO: When rem-based spacing on a 4px scale lands, replace
35-
* hardcoded '6px' with 'calc((${get('space.s32')} - ${get('space.20')}) / 2)'.
36-
*/
37-
}
38-
padding: 6px ${get('space.3')};
39-
font-size: ${get('fontSizes.0')};
40-
font-weight: ${get('fontWeights.bold')};
41-
color: ${get('colors.fg.muted')};
42-
43-
${({variant}) =>
44-
variant === 'filled' &&
45-
css`
46-
background: ${get('colors.canvas.subtle')};
47-
margin: ${get('space.2')} 0;
48-
border-top: 1px solid ${get('colors.neutral.muted')};
49-
border-bottom: 1px solid ${get('colors.neutral.muted')};
50-
51-
&:first-child {
52-
margin-top: 0;
53-
}
54-
`}
55-
56-
${sx}
57-
`
58-
5928
/**
6029
* Displays the name and description of a `Group`.
6130
*/
@@ -64,12 +33,19 @@ export function Header({
6433
title,
6534
auxiliaryText,
6635
children: _children,
36+
className,
6737
...props
6838
}: HeaderProps): JSX.Element {
6939
return (
70-
<StyledHeader role="heading" variant={variant} {...props}>
40+
<div
41+
role="heading"
42+
className={clsx(className, classes.Header)}
43+
data-filled={variant === 'filled' ? '' : undefined}
44+
data-component="ActionList.Header"
45+
{...props}
46+
>
7147
{title}
7248
{auxiliaryText && <span>{auxiliaryText}</span>}
73-
</StyledHeader>
49+
</div>
7450
)
7551
}

0 commit comments

Comments
 (0)