Skip to content

Commit 2056cdb

Browse files
mrcthmslaurkim
authored andcommitted
[BulkActions] Improve visibility of the BulkActions bar (Shopify#7851)
### WHY are these changes introduced? Some feedback we got from SLT around the new Bulk Actions bar UX is that, whilst a nice update, it can sometimes be hard to detect that the bulk actions bar has appeared. This PR addresses that by tweaking some of the settings for the sticky Bulk Actions bar. ### WHAT is this pull request doing? This PR updates the bulk actions to use a "dark UI" pattern, similar to the ContextualSaveBar and Toast components currently in Polaris. The placement of the bar has been updated to be a little higher on the screen, up from 16px from the bottom, to 48px from the bottom. We have also combined the `--p-shadow-deep` and `--p-shadow-popover` shadow tokens to increase the visual lift the component has from the rest of the index UI. https://user-images.githubusercontent.com/2562596/206267671-6782a7bc-f9c6-47ff-8a04-da374fcdf499.mov ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide Co-authored-by: Lo Kim <lo.kim@shopify.com>
1 parent 761a2c8 commit 2056cdb

File tree

14 files changed

+59
-38
lines changed

14 files changed

+59
-38
lines changed

.changeset/purple-hairs-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Updated shadow and placement of the BulkActions bar for greater visibility

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ $bulk-actions-button-stacking-order: (
66
);
77

88
.Group {
9+
/* stylelint-disable -- polaris: Used to apply dark theme to action buttons */
10+
--p-surface: var(--p-surface-dark);
11+
--p-text: var(--p-text-on-dark);
12+
--p-icon: var(--p-text-on-dark);
13+
--p-action-secondary-hovered: var(--p-action-secondary-hovered-dark);
14+
--p-action-secondary-pressed: var(--p-action-secondary-pressed-dark);
15+
/* stylelint-enable */
916
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
1017
@include text-style-input;
1118
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
@@ -18,7 +25,7 @@ $bulk-actions-button-stacking-order: (
1825
width: 100%;
1926
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
2027
justify-content: center;
21-
transition: var(--p-duration-250) var(--p-ease-in);
28+
transition: var(--p-duration-100) var(--p-ease);
2229
transition-property: transform, opacity;
2330
transform: translateY(120px);
2431
padding: 0 var(--p-space-4);
@@ -65,7 +72,7 @@ $bulk-actions-button-stacking-order: (
6572
padding: var(--p-space-4);
6673
background: var(--p-surface);
6774
border-radius: var(--p-border-radius-2);
68-
box-shadow: var(--p-shadow-popover);
75+
box-shadow: var(--p-shadow-deep), var(--p-shadow-popover);
6976
max-width: 100%;
7077

7178
.Group-measuring & {
@@ -78,6 +85,11 @@ $bulk-actions-button-stacking-order: (
7885

7986
.BulkActionButton {
8087
white-space: nowrap;
88+
89+
button {
90+
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
91+
display: flex;
92+
}
8193
}
8294

8395
.disabled {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
} from '../../types';
1414
import {ActionList} from '../ActionList';
1515
import {Popover} from '../Popover';
16-
import {ButtonGroup} from '../ButtonGroup';
16+
import {Inline} from '../Inline';
1717
// eslint-disable-next-line import/no-deprecated
1818
import {EventListener} from '../EventListener';
1919

@@ -299,10 +299,10 @@ class BulkActionsInner extends PureComponent<CombinedProps, State> {
299299

300300
const groupContent =
301301
promotedActionsMarkup || actionsPopover ? (
302-
<ButtonGroup>
302+
<Inline gap="3">
303303
{promotedActionsMarkup}
304304
{actionsPopover}
305-
</ButtonGroup>
305+
</Inline>
306306
) : null;
307307

308308
if (!groupContent) {
@@ -311,7 +311,7 @@ class BulkActionsInner extends PureComponent<CombinedProps, State> {
311311

312312
const group = (
313313
<Transition
314-
timeout={250}
314+
timeout={100}
315315
in={selectMode}
316316
key="group"
317317
nodeRef={this.groupNode}

polaris-react/src/components/BulkActions/components/BulkActionButton/BulkActionButton.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React, {useRef} from 'react';
2+
import {HorizontalDotsMinor} from '@shopify/polaris-icons';
23

34
import type {DisableableAction} from '../../../../types';
45
import {Button} from '../../../Button';
6+
import {Icon} from '../../../Icon';
57
import {Indicator} from '../../../Indicator';
68
import {useComponentDidMount} from '../../../../utilities/use-component-did-mount';
79
import styles from '../../BulkActions.scss';
@@ -37,12 +39,17 @@ export function BulkActionButton({
3739
<Button
3840
external={external}
3941
url={url}
40-
aria-label={accessibilityLabel}
42+
aria-label={disclosure ? content : accessibilityLabel}
4143
onClick={onAction}
4244
disabled={disabled}
43-
disclosure={disclosure}
45+
size="slim"
46+
icon={
47+
disclosure ? (
48+
<Icon source={HorizontalDotsMinor} color="base" />
49+
) : undefined
50+
}
4451
>
45-
{content}
52+
{disclosure ? undefined : content}
4653
</Button>
4754
{indicator && <Indicator />}
4855
</div>

polaris-react/src/components/BulkActions/hooks/tests/use-is-bulk-actions-sticky.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('useIsBulkActionsSticky', () => {
6262
it('returns the offset correctly when select mode is true', () => {
6363
const component = mountWithApp(<Component selectMode />);
6464
const result = component.findAll('span')[0]?.text();
65-
expect(result).toBe('300');
65+
expect(result).toBe('308');
6666
});
6767

6868
it('returns the width value correctly', () => {

polaris-react/src/components/BulkActions/hooks/use-is-bulk-actions-sticky.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {debounce} from '../../../utilities/debounce';
44

55
const DEBOUNCE_PERIOD = 250;
66

7-
const PADDING_IN_SELECT_MODE = 100;
7+
const PADDING_IN_SELECT_MODE = 92;
88

99
export function useIsBulkActionsSticky(selectMode: boolean) {
1010
const hasIOSupport =
@@ -24,8 +24,8 @@ export function useIsBulkActionsSticky(selectMode: boolean) {
2424

2525
const options = {
2626
root: null,
27-
rootMargin: '0px',
28-
threshold: 1,
27+
rootMargin: '-12px',
28+
threshold: 0,
2929
};
3030
const observerRef = useRef<IntersectionObserver | null>(
3131
hasIOSupport ? new IntersectionObserver(handleIntersect, options) : null,

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -307,21 +307,4 @@ describe('<BulkActions />', () => {
307307
});
308308
});
309309
});
310-
311-
describe('buttongroup', () => {
312-
// Since we need to break our component model and reach into ButtonGroup to access the CheckableButton
313-
// and ensure only the first element flex grows, we add this test to ensure the mark-up does not change
314-
it('has the mark-up structure to target the CheckableButton', () => {
315-
const bulkActions = mountWithApp(
316-
<BulkActions {...bulkActionProps} selectMode />,
317-
);
318-
319-
const checkableButton = bulkActions!
320-
.find('div', {
321-
className: 'ButtonGroupWrapper',
322-
})!
323-
.domNode!.querySelector('div > div.Item:first-child');
324-
expect(checkableButton).not.toBeNull();
325-
});
326-
});
327310
});

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@
429429
padding-right: var(--p-space-3);
430430
}
431431

432+
&.sizeSlim {
433+
padding-left: var(--p-space-1);
434+
padding-right: var(--p-space-1);
435+
}
436+
432437
.Icon:first-child {
433438
margin-left: 0;
434439
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
border-radius: inherit;
1616
}
1717

18-
.IndexTableWithBulkActions {
18+
.IndexTableWrapper {
19+
border-radius: inherit;
20+
}
21+
22+
.IndexTableWrapperWithBulkActions {
1923
// stylelint-disable-next-line -- Polaris component custom properties
20-
--pc-index-table-bulk-actions-offset: 100px;
24+
--pc-index-table-bulk-actions-offset: 92px;
2125
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
2226
padding-bottom: var(--pc-index-table-bulk-actions-offset);
27+
border-radius: 0;
2328
}
2429

2530
.LoadingContainer-enter {
@@ -592,7 +597,7 @@ $loading-panel-height: 53px;
592597
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
593598
top: auto;
594599
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
595-
bottom: var(--p-space-4);
600+
bottom: calc(var(--p-space-10) - var(--p-space-1));
596601
}
597602

598603
.SelectAllActionsWrapper {

polaris-react/src/components/IndexTable/IndexTable.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@ export function WithBulkActionsAndSelectionAcrossPages() {
645645
);
646646

647647
return (
648-
<div style={{padding: 'var(--p-space-4)'}}>
648+
<div
649+
style={{padding: 'var(--p-space-4) var(--p-space-4) var(--p-space-10)'}}
650+
>
649651
<Card>
650652
<IndexTable
651653
resourceName={resourceName}

0 commit comments

Comments
 (0)