Skip to content

Commit 67e005e

Browse files
authored
Merge pull request #1 from obetomuniz/with-default-props
Use defaultProps instead of ternary statements
2 parents 5f94d03 + 902ed55 commit 67e005e

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

BaseAnimation.js

+19-8
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
1515
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
1616

1717
var BaseAnimation = _styledComponents2.default.div(_templateObject, function (props) {
18-
return props.duration ? props.duration : '1s';
18+
return props.duration;
1919
}, function (props) {
20-
return props.timingFunction ? props.timingFunction : 'ease';
20+
return props.timingFunction;
2121
}, function (props) {
22-
return props.delay ? props.delay : '0s';
22+
return props.delay;
2323
}, function (props) {
24-
return props.iterationCount ? props.iterationCount : '1';
24+
return props.iterationCount;
2525
}, function (props) {
26-
return props.direction ? props.direction : 'normal';
26+
return props.direction;
2727
}, function (props) {
28-
return props.fillMode ? props.fillMode : 'both';
28+
return props.fillMode;
2929
}, function (props) {
30-
return props.playState ? props.playState : 'running';
30+
return props.playState;
3131
}, function (props) {
32-
return props.inline ? 'inline-block' : 'initial';
32+
return props.inline;
3333
});
3434

35+
BaseAnimation.defaultProps = {
36+
duration: '1s',
37+
timingFunction: 'ease',
38+
delay: '0s',
39+
iterationCount: '1',
40+
direction: 'normal',
41+
fillMode: 'both',
42+
playState: 'running',
43+
inline: 'initial'
44+
};
45+
3546
exports.default = BaseAnimation;

src/BaseAnimation.js

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
import styled from 'styled-components';
22

33
const BaseAnimation = styled.div`
4-
animation-duration: ${props => props.duration ? props.duration : '1s'};
5-
animation-timing-function: ${props => props.timingFunction ? props.timingFunction : 'ease'};
6-
animation-delay: ${props => props.delay ? props.delay : '0s'};
7-
animation-iteration-count: ${props => props.iterationCount ? props.iterationCount : '1'};
8-
animation-direction: ${props => props.direction ? props.direction : 'normal'};
9-
animation-fill-mode: ${props => props.fillMode ? props.fillMode : 'both'};
10-
animation-play-state: ${props => props.playState ? props.playState : 'running'};
11-
display: ${props => props.inline ? 'inline-block' : 'initial'};
4+
animation-duration: ${props => props.duration};
5+
animation-timing-function: ${props => props.timingFunction};
6+
animation-delay: ${props => props.delay};
7+
animation-iteration-count: ${props => props.iterationCount};
8+
animation-direction: ${props => props.direction};
9+
animation-fill-mode: ${props => props.fillMode};
10+
animation-play-state: ${props => props.playState};
11+
display: ${props => props.inline};
1212
`;
1313

14+
BaseAnimation.defaultProps = {
15+
duration: '1s',
16+
timingFunction: 'ease',
17+
delay: '0s',
18+
iterationCount: '1',
19+
direction: 'normal',
20+
fillMode: 'both',
21+
playState: 'running',
22+
inline: 'initial'
23+
}
24+
1425
export default BaseAnimation;

0 commit comments

Comments
 (0)