Skip to content

Commit 50cbda3

Browse files
committed
add entrance animations
1 parent cd90148 commit 50cbda3

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

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

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,35 @@ $bulk-actions-button-stacking-order: (
77

88
.Group {
99
@include text-style-input;
10-
display: none;
10+
display: flex;
1111
align-items: center;
1212
flex-wrap: wrap;
1313
opacity: 0;
1414
width: 90vw;
1515
justify-content: center;
16+
transition: var(--p-duration-250) var(--p-ease-in);
17+
transform: translateY(120px);
1618

17-
@media #{$p-breakpoints-sm-up} {
19+
&.Group-not-sticky {
20+
transform: none;
21+
opacity: 1;
22+
}
23+
24+
&.Group-entering,
25+
&.Group-exiting {
26+
opacity: 0;
1827
display: flex;
28+
}
1929

20-
&.Group-exiting {
21-
transition: none;
22-
}
30+
&.Group-entered {
31+
opacity: 1;
32+
display: flex;
33+
transform: translateY(0);
34+
}
2335

24-
&.Group-exited {
25-
opacity: 0;
26-
display: none;
27-
}
36+
&.Group-exited {
37+
opacity: 0;
38+
display: none;
2839
}
2940

3041
&.Group-measuring {
@@ -34,22 +45,6 @@ $bulk-actions-button-stacking-order: (
3445
}
3546
}
3647

37-
.Group-entering,
38-
.Group-exiting {
39-
opacity: 0;
40-
display: flex;
41-
}
42-
43-
.Group-entered {
44-
opacity: 1;
45-
display: flex;
46-
}
47-
48-
.Group-exited {
49-
opacity: 0;
50-
display: none;
51-
}
52-
5348
.ButtonGroupWrapper {
5449
width: 100%;
5550
max-width: 100%;

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

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {PureComponent, createRef} from 'react';
2-
import {Transition} from 'react-transition-group';
2+
import {TransitionGroup, CSSTransition} from 'react-transition-group';
33

44
import {debounce} from '../../utilities/debounce';
55
import {classNames} from '../../utilities/css';
@@ -41,6 +41,8 @@ export interface BulkActionsProps {
4141
onSelectModeToggle?(selectMode: boolean): void;
4242
/** Callback when more actions button is toggled */
4343
onMoreActionPopoverToggle?(isOpen: boolean): void;
44+
/** If the BulkActions is currently sticky in view */
45+
isSticky?: boolean;
4446
}
4547

4648
type CombinedProps = BulkActionsProps & {
@@ -188,7 +190,7 @@ class BulkActionsInner extends PureComponent<CombinedProps, State> {
188190

189191
// eslint-disable-next-line @typescript-eslint/member-ordering
190192
render() {
191-
const {selectMode, disabled, promotedActions, i18n} = this.props;
193+
const {selectMode, disabled, promotedActions, i18n, isSticky} = this.props;
192194

193195
const actionSections = this.actionSections();
194196

@@ -294,31 +296,34 @@ class BulkActionsInner extends PureComponent<CombinedProps, State> {
294296
}
295297

296298
const group = (
297-
<Transition
298-
timeout={0}
299-
in={selectMode}
300-
key="group"
301-
nodeRef={this.groupNode}
302-
>
303-
{(status: TransitionStatus) => {
304-
const groupClassName = classNames(
305-
styles.Group,
306-
!measuring && styles[`Group-${status}`],
307-
measuring && styles['Group-measuring'],
308-
);
309-
return (
310-
<div className={groupClassName} ref={this.groupNode}>
311-
<EventListener event="resize" handler={this.handleResize} />
312-
<div
313-
className={styles.ButtonGroupWrapper}
314-
ref={this.setButtonsNode}
315-
>
316-
{groupContent}
299+
<TransitionGroup>
300+
<CSSTransition
301+
timeout={250}
302+
in={selectMode}
303+
key="group"
304+
nodeRef={this.groupNode}
305+
>
306+
{(status: TransitionStatus) => {
307+
const groupClassName = classNames(
308+
styles.Group,
309+
!isSticky && styles['Group-not-sticky'],
310+
!measuring && isSticky && styles[`Group-${status}`],
311+
measuring && styles['Group-measuring'],
312+
);
313+
return (
314+
<div className={groupClassName} ref={this.groupNode}>
315+
<EventListener event="resize" handler={this.handleResize} />
316+
<div
317+
className={styles.ButtonGroupWrapper}
318+
ref={this.setButtonsNode}
319+
>
320+
{groupContent}
321+
</div>
317322
</div>
318-
</div>
319-
);
320-
}}
321-
</Transition>
323+
);
324+
}}
325+
</CSSTransition>
326+
</TransitionGroup>
322327
);
323328

324329
return <div ref={this.setContainerNode}>{group}</div>;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ function IndexTableBase({
562562
promotedActions={promotedActions}
563563
actions={actions}
564564
onSelectModeToggle={condensed ? handleSelectModeToggle : undefined}
565+
isSticky={isBulkActionsSticky}
565566
/>
566567
</div>
567568
) : null;

0 commit comments

Comments
 (0)