Skip to content

Commit 074b954

Browse files
committed
feat: add fadeInDown animation
1 parent b17051d commit 074b954

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

.storybook/animate.stories.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ const {linkTo} = require('@storybook/addon-links');
55
const {create} = require('../index');
66
const {addon: addonRule} = require('../addon/rule');
77
const {addon: addonKeyframes} = require('../addon/keyframes');
8-
const {addon: addonFadeIn} = require('../addon/animate/fadeIn');
8+
9+
const animations = [
10+
'fadeIn',
11+
'fadeInDown',
12+
];
913

1014
const nano = create();
1115
addonRule(nano);
1216
addonKeyframes(nano);
13-
addonFadeIn(nano);
1417
const {rule} = nano;
1518

1619
var className = rule({
@@ -19,7 +22,11 @@ var className = rule({
1922
background: 'red',
2023
});
2124

22-
storiesOf('Addons/Animate', module)
23-
.add('fadeIn', () =>
24-
h('div', {className: 'fadeIn' + className}, 'Hello world')
25-
)
25+
let stories = storiesOf('Addons/Animate', module);
26+
27+
animations.forEach(name => {
28+
stories = stories.add(name, () => {
29+
require('../addon/animate/' + name).addon(nano);
30+
return h('div', {className: name + className});
31+
});
32+
});

addon/animate/fadeInDown.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
exports.addon = function (renderer) {
4+
if (process.env.NODE_ENV !== 'production') {
5+
require('../__dev__/warnOnMissingDependencies')('animate', renderer, ['keyframes']);
6+
}
7+
8+
renderer.put('', {
9+
'@keyframes fadeInDown': {
10+
from: {
11+
opacity: 0,
12+
transform: 'translate3d(0, -10%, 0)'
13+
},
14+
15+
to: {
16+
opacity: 1,
17+
transform: 'translate3d(0, 0, 0)',
18+
}
19+
},
20+
21+
'.fadeInDown': {
22+
animation: 'fadeInDown .3s',
23+
}
24+
});
25+
};

0 commit comments

Comments
 (0)