Skip to content

Commit 97808dd

Browse files
authored
Add Prettier and Travis (#31)
* Add Prettier and Travis * Ignore dist
1 parent 22a3817 commit 97808dd

File tree

11 files changed

+55
-31
lines changed

11 files changed

+55
-31
lines changed

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
package.json
3+
gift.json
4+
dist

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
node_js:
3+
- '12'
4+
install:
5+
- yarn --frozen-lockfile
6+
script: yarn test
7+
cache:
8+
directories:
9+
- node_modules
10+
env:
11+
matrix:
12+
- CI=true TZ=Europe/Paris
13+
notifications:
14+
email: false

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# react-native-web-lottie
2+
23
> React Native for Web implementation of Lottie
34
45
## Getting started
6+
57
`$ npm install react-native-web-lottie --save`
68

79
Alias the package in your webpack config:
@@ -17,14 +19,18 @@ resolve: {
1719
```
1820

1921
## Usage
22+
2023
See [Lottie's docs](https://airbnb.io/lottie/#/react-native).
2124

2225
## Examples
26+
2327
See the [storybook](https://react-native-web-community.github.io/react-native-web-lottie/storybook).
2428

2529
## Contributing
30+
2631
PRs are welcome!
2732

2833
The following important features are not implemented:
34+
2935
- `progress` prop
3036
- imperative API

docs/.storybook/babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module.exports = function(api) {
1+
module.exports = function (api) {
22
api.cache(true);
33
return {
44
presets: ['module:metro-react-native-babel-preset'],
5-
plugins: ['react-native-web']
5+
plugins: ['react-native-web'],
66
};
77
};

docs/.storybook/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setOptions({
1010
goFullScreen: false,
1111
showLeftPanel: true,
1212
showDownPanel: false,
13-
downPanelInRight: false
13+
downPanelInRight: false,
1414
});
1515

1616
function loadStories() {

docs/.storybook/decorator-centered.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ const styles = StyleSheet.create({
1010
},
1111
});
1212

13-
export default function(renderStory) {
13+
export default function (renderStory) {
1414
return <View style={styles.root}>{renderStory()}</View>;
1515
}

docs/.storybook/webpack.config.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
const path = require('path');
22
const webpack = require('webpack');
33

4-
module.exports = ({config, mode}) => {
4+
module.exports = ({ config, mode }) => {
55
const DEV = mode === 'DEVELOPMENT';
66

77
const libDirectory = path.resolve(__dirname, '../../');
88

99
config.module.rules.push({
1010
test: /\.js$/,
11-
include: [
12-
path.resolve(libDirectory, 'src'),
13-
path.resolve(libDirectory, 'docs'),
14-
],
11+
include: [path.resolve(libDirectory, 'src'), path.resolve(libDirectory, 'docs')],
1512
use: {
1613
loader: 'babel-loader',
1714
options: {
1815
cacheDirectory: true,
1916
presets: ['module:metro-react-native-babel-preset'],
2017
plugins: ['react-native-web'],
21-
}
22-
}
18+
},
19+
},
2320
});
2421

2522
config.plugins.push(
2623
new webpack.DefinePlugin({
2724
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
28-
'process.env.__REACT_NATIVE_DEBUG_ENABLED__': DEV
25+
'process.env.__REACT_NATIVE_DEBUG_ENABLED__': DEV,
2926
})
3027
);
3128

3229
config.resolve.extensions = ['.web.js', '.js', '.json', '.web.jsx', '.jsx'];
3330

3431
config.resolve.alias = {
3532
'react-native$': 'react-native-web',
36-
'lottie-react-native': path.join(__dirname, '../../src/')
33+
'lottie-react-native': path.join(__dirname, '../../src/'),
3734
};
3835

3936
return config;

docs/stories/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ import { storiesOf } from '@storybook/react';
77
storiesOf('Lottie', module)
88
.add('basic', () => <Animation source={require('./assets/gift.json')} autoPlay />)
99
.add('loop', () => <Animation source={require('./assets/gift.json')} loop autoPlay />)
10-
.add('onAnimationFinish', () => <Animation source={require('./assets/gift.json')} autoPlay onAnimationFinish={() => alert('Finished!')}/>);
10+
.add('onAnimationFinish', () => (
11+
<Animation source={require('./assets/gift.json')} autoPlay onAnimationFinish={() => alert('Finished!')} />
12+
));

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"scripts": {
2323
"prepublish": "yarn build",
2424
"build": "mkdir -p dist && babel src --out-dir dist --copy-files",
25-
"test": "echo \"Error: no test specified\" && exit 1"
25+
"test": "prettier --check ."
2626
},
2727
"babel": {
2828
"presets": [
@@ -44,7 +44,7 @@
4444
"babel-loader": "^8.0.5",
4545
"babel-plugin-react-native-web": "^0.10.0",
4646
"metro-react-native-babel-preset": "^0.51.1",
47-
"prettier": "^1.7.3",
47+
"prettier": "^2.0.5",
4848
"react": "^16.7.0",
4949
"react-art": "^16.7.0",
5050
"react-dom": "^16.7.0",

src/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Animation extends PureComponent {
1616
}
1717
}
1818

19-
loadAnimation = props => {
19+
loadAnimation = (props) => {
2020
if (this.anim) {
2121
this.anim.destroy();
2222
}
@@ -27,37 +27,37 @@ class Animation extends PureComponent {
2727
renderer: 'svg',
2828
loop: props.loop || false,
2929
autoplay: props.autoPlay,
30-
rendererSettings: props.rendererSettings || {},
30+
rendererSettings: props.rendererSettings || {},
3131
});
3232

3333
if (props.onAnimationFinish) {
34-
this.anim.addEventListener("complete", props.onAnimationFinish);
34+
this.anim.addEventListener('complete', props.onAnimationFinish);
3535
}
3636
};
3737

38-
setAnimationDOMNode = ref => (this.animationDOMNode = ReactDOM.findDOMNode(ref));
38+
setAnimationDOMNode = (ref) => (this.animationDOMNode = ReactDOM.findDOMNode(ref));
3939

4040
play = (...frames) => {
4141
if (!this.anim) {
42-
return
42+
return;
4343
}
4444

45-
this.anim.playSegments(frames, true)
46-
}
45+
this.anim.playSegments(frames, true);
46+
};
4747

4848
reset = () => {
4949
if (!this.anim) {
50-
return
50+
return;
5151
}
5252

53-
this.anim.stop()
54-
}
55-
53+
this.anim.stop();
54+
};
55+
5656
render() {
5757
return <View style={this.props.style} ref={this.setAnimationDOMNode} />;
5858
}
5959
}
6060

6161
export default React.forwardRef((props, ref) => (
62-
<Animation {...props} ref={typeof ref == 'function' ? c => ref(c && c.anim) : ref} />
62+
<Animation {...props} ref={typeof ref == 'function' ? (c) => ref(c && c.anim) : ref} />
6363
));

0 commit comments

Comments
 (0)