Skip to content

Commit 05b6af4

Browse files
committed
chore: add changeset
1 parent 42cb678 commit 05b6af4

File tree

6 files changed

+71
-23
lines changed

6 files changed

+71
-23
lines changed

.changeset/odd-spoons-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Separate BulkActions and SelectAllActions for new bulk selection experience"

polaris-react/src/components/CheckableButton/CheckableButton.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ $button-vertical-padding: calc(
7373

7474
&.CheckableButton-autoWidth {
7575
width: auto;
76+
font-size: var(--p-font-size-75);
7677

7778
@media #{$p-breakpoints-sm-up} {
7879
flex: none;

polaris-react/src/components/CheckableButton/CheckableButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface CheckableButtonProps {
2020
disabled?: boolean;
2121
onToggleAll?(): void;
2222
autoWidth?: boolean;
23+
ariaLive?: 'off' | 'assertive' | 'polite';
2324
}
2425

2526
export function CheckableButton({
@@ -32,6 +33,7 @@ export function CheckableButton({
3233
measuring,
3334
disabled,
3435
autoWidth,
36+
ariaLive,
3537
}: CheckableButtonProps) {
3638
const checkBoxRef = useRef<CheckboxHandles>(null);
3739

@@ -75,7 +77,9 @@ export function CheckableButton({
7577
ref={checkBoxRef}
7678
/>
7779
</div>
78-
<span className={styles.Label}>{label}</span>
80+
<span className={styles.Label} aria-live={ariaLive}>
81+
{label}
82+
</span>
7983
</div>
8084
);
8185
}

polaris-react/src/components/SelectAllActions/SelectAllActions.scss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '../../styles/common';
2+
13
.SelectAllActions {
24
display: flex;
35
gap: var(--p-space-025);
@@ -20,3 +22,36 @@
2022
opacity: 0;
2123
display: none;
2224
}
25+
26+
.PaginatedSelectAll {
27+
font-size: var(--p-font-size-75);
28+
font-weight: var(--p-font-weight-semibold);
29+
}
30+
31+
.AllAction {
32+
font-size: var(--p-font-size-75);
33+
font-weight: var(--p-font-weight-semibold);
34+
border: 0;
35+
background: none;
36+
padding: 0;
37+
cursor: pointer;
38+
color: var(--p-interactive);
39+
@include focus-ring;
40+
41+
&:hover,
42+
&:focus {
43+
color: var(--p-interactive-hovered);
44+
}
45+
46+
&:active {
47+
color: var(--p-interactive-pressed);
48+
}
49+
50+
&:focus {
51+
@include no-focus-ring;
52+
}
53+
54+
&:focus:not(:active) {
55+
@include focus-ring($style: 'focused');
56+
}
57+
}

polaris-react/src/components/SelectAllActions/SelectAllActions.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import {Transition} from 'react-transition-group';
33

44
import {classNames} from '../../utilities/css';
55
import type {Action} from '../../types';
6-
import {Button} from '../Button';
6+
import {UnstyledButton} from '../UnstyledButton';
77
import {CheckableButton} from '../CheckableButton';
88

99
import styles from './SelectAllActions.scss';
1010

1111
type TransitionStatus = 'entering' | 'entered' | 'exiting' | 'exited';
12+
type AriaLive = 'off' | 'assertive' | 'polite' | undefined;
1213

1314
export interface SelectAllActionsProps {
1415
/** Visually hidden text for screen readers */
@@ -43,38 +44,37 @@ export function SelectAllActions({
4344
onToggleAll,
4445
}: SelectAllActionsProps) {
4546
const paginatedSelectAllActionMarkup = paginatedSelectAllAction ? (
46-
<Button
47+
<UnstyledButton
48+
className={styles.AllAction}
4749
onClick={paginatedSelectAllAction.onAction}
4850
plain
51+
size="slim"
4952
disabled={disabled}
5053
>
5154
{paginatedSelectAllAction.content}
52-
</Button>
55+
</UnstyledButton>
5356
) : null;
5457

55-
const paginatedSelectAllTextMarkup =
56-
paginatedSelectAllText && paginatedSelectAllAction ? (
57-
<span aria-live="polite">{paginatedSelectAllText}</span>
58-
) : (
59-
paginatedSelectAllText
60-
);
58+
const hasTextAndAction = paginatedSelectAllText && paginatedSelectAllAction;
6159

62-
const paginatedSelectAllMarkup =
63-
paginatedSelectAllActionMarkup || paginatedSelectAllTextMarkup ? (
64-
<div className={styles.PaginatedSelectAll}>
65-
{paginatedSelectAllTextMarkup} {paginatedSelectAllActionMarkup}
66-
</div>
67-
) : null;
60+
const paginatedSelectAllMarkup = paginatedSelectAllActionMarkup ? (
61+
<div className={styles.PaginatedSelectAll}>
62+
{paginatedSelectAllActionMarkup}
63+
</div>
64+
) : null;
65+
66+
const ariaLive: AriaLive = hasTextAndAction ? 'polite' : undefined;
6867

6968
const checkableButtonProps = {
7069
accessibilityLabel,
71-
label,
70+
label: hasTextAndAction ? paginatedSelectAllText : label,
7271
selected,
7372
selectMode,
7473
onToggleAll,
7574
disabled,
7675
plain: !smallScreen,
7776
autoWidth: true,
77+
ariaLive,
7878
};
7979
const markup = (
8080
<Transition timeout={0} in={selectMode} key="markup">

polaris-react/src/components/SelectAllActions/tests/SelectAllActions.test.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Transition, CSSTransition} from 'react-transition-group';
33
import {mountWithApp} from 'tests/utilities';
44

55
import {CheckableButton} from '../../CheckableButton';
6-
import {Button} from '../../Button';
6+
import {UnstyledButton} from '../../UnstyledButton';
77
import {SelectAllActions} from '../SelectAllActions';
88
import styles from '../SelectAllActions.scss';
99

@@ -195,11 +195,12 @@ describe('<SelectAllActions />', () => {
195195
it('renders when provided', () => {
196196
const {paginatedSelectAllText} = selectAllActionProps;
197197
const selectAllActions = mountWithApp(
198-
<SelectAllActions {...selectAllActionProps} />,
198+
<SelectAllActions
199+
{...selectAllActionProps}
200+
paginatedSelectAllAction={{content: 'content', onAction: () => {}}}
201+
/>,
199202
);
200-
expect(
201-
selectAllActions.find('div', {className: styles.PaginatedSelectAll}),
202-
).toContainReactText(paginatedSelectAllText);
203+
expect(selectAllActions).toContainReactText(paginatedSelectAllText);
203204
});
204205

205206
it('does not render when not provided', () => {
@@ -222,7 +223,9 @@ describe('<SelectAllActions />', () => {
222223
paginatedSelectAllAction={{content: 'content', onAction: spy}}
223224
/>,
224225
);
225-
selectAllActions.find(Button, {onClick: spy})!.trigger('onClick');
226+
selectAllActions
227+
.find(UnstyledButton, {onClick: spy})!
228+
.trigger('onClick');
226229
expect(spy).toHaveBeenCalled();
227230
});
228231
});

0 commit comments

Comments
 (0)