Skip to content

Commit 9c6580f

Browse files
committed
Update ManageButton transition
1 parent 3ec61ff commit 9c6580f

6 files changed

Lines changed: 54 additions & 35 deletions

File tree

src/components/karaoke/player/ManageButton.jsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import classNames from 'classnames'
22
import PropTypes from 'prop-types'
33
import { Component } from 'react'
44

5+
import Swipe from 'components/transitions/Swipe'
56
import {
67
alterationResponsePropType,
78
Status,
89
} from 'reducers/alterationsResponse'
9-
import { CSSTransitionLazy } from 'thirdpartyExtensions/ReactTransitionGroup'
1010

1111
/**
1212
* ManageButton class for a button connected to a player manage command
@@ -121,8 +121,7 @@ export default class ManageButton extends Component {
121121
}
122122

123123
render() {
124-
const { onClick, disabled, className, timeout, iconDisabled, error } =
125-
this.props
124+
const { onClick, disabled, className, iconDisabled, error } = this.props
126125

127126
const onClickControlled = (e) => {
128127
// do not manage any other click during the transition
@@ -150,15 +149,11 @@ export default class ManageButton extends Component {
150149
onClick={onClickControlled}
151150
disabled={disabled}
152151
>
153-
<CSSTransitionLazy
154-
in={this.state.display}
155-
classNames="managed"
156-
timeout={timeout}
157-
>
158-
<div className="managed icon">
152+
<Swipe in={this.state.display}>
153+
<div className="managed icon transition">
159154
<i className={`las la-${icon}`}></i>
160155
</div>
161-
</CSSTransitionLazy>
156+
</Swipe>
162157
</button>
163158
)
164159
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import PropTypes from 'prop-types'
2+
import { CSSTransition } from 'react-transitioning'
3+
4+
export default function Swipe({
5+
in: inProp,
6+
duration = 300,
7+
children,
8+
...rest
9+
}) {
10+
return (
11+
<CSSTransition in={inProp} classNames="swipe" duration={duration} {...rest}>
12+
{children}
13+
</CSSTransition>
14+
)
15+
}
16+
17+
Swipe.propTypes = {
18+
in: PropTypes.bool,
19+
duration: PropTypes.number,
20+
children: PropTypes.node,
21+
}

src/style/abstracts/_transitions.scss

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
// helper for creating transition styles
88
// @param $name name of the transitiion
99
// @param $property property to transition
10-
// @param $from value of the property before entered and after exiting
10+
// @param $from value of the property before entered, and after exiting if $away is not set
1111
// @param $to value of the property after entered and before exiting
12+
// @param $away value of the property after exiting
1213
// @param $duration-enter timing of the entering step
1314
// @param $duration-exit timing of the exiting step
1415
// @param $enter enable enter step
@@ -23,6 +24,7 @@
2324
$property,
2425
$from,
2526
$to,
27+
$away: false,
2628
$duration-enter: 300ms,
2729
$duration-exit: 150ms,
2830
$enter: true,
@@ -61,7 +63,11 @@
6163

6264
@if ($exit-active) {
6365
&.#{$name}-exit-active {
64-
#{$property}: $from;
66+
@if ($away) {
67+
#{$property}: $away;
68+
} @else {
69+
#{$property}: $from;
70+
}
6571
transition: $property $duration-exit ease-in;
6672
}
6773
}
@@ -70,7 +76,11 @@
7076

7177
@if ($exit-done) {
7278
&.#{$name}-exit-done {
73-
#{$property}: $from;
79+
@if ($away) {
80+
#{$property}: $away;
81+
} @else {
82+
#{$property}: $from;
83+
}
7484
}
7585
}
7686
}

src/style/components/karaoke/player/_manage_button.scss

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
overflow: hidden;
33
position: relative;
44

5-
&.managed-error .managed.managed-enter {
6-
left: -100%;
5+
// transition for error
6+
&.managed-error .managed.swipe-enter {
7+
left: 100%;
78
}
89

910
.managed {
@@ -15,25 +16,5 @@
1516
position: absolute;
1617
top: 0;
1718
width: 100%;
18-
19-
// appearance transition
20-
&.managed-enter {
21-
left: 100%;
22-
23-
&.managed-enter-active {
24-
left: 0;
25-
transition: left 150ms ease-out;
26-
}
27-
}
28-
29-
// disappearance transition
30-
&.managed-exit {
31-
left: 0;
32-
33-
&.managed-exit-active {
34-
left: -100%;
35-
transition: left 150ms ease-out;
36-
}
37-
}
3819
}
3920
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
@use 'collapse';
22
@use 'slide';
3+
@use 'swipe';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@use '~/abstracts/transitions';
2+
3+
@include transitions.make-transition(
4+
'swipe',
5+
left,
6+
$from: -100%,
7+
$to: 0,
8+
$away: 100%,
9+
$duration-enter: 150ms,
10+
$duration-exit: 150ms
11+
);

0 commit comments

Comments
 (0)