Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["react-app"]
"presets": ["@babel/preset-react", "@babel/preset-env"]
}
15 changes: 13 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"extends": [
"airbnb",
"prettier/react",
"plugin:react/recommended",
"plugin:prettier/recommended"
],
"env": {
Expand All @@ -12,5 +12,16 @@
"node": true,
"browser": true,
"jest": true
},
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"**/setupTests.js" // jest setup
],
"optionalDependencies": false
}
]
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
*.log
.idea
dist

*storybook.log
2 changes: 1 addition & 1 deletion .scripts/prepublish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
echo "=> Transpiling 'src' into ES5 ..."
echo ""
rm -rf ./dist
NODE_ENV=production ./node_modules/.bin/babel --ignore tests,stories --plugins "transform-runtime" ./src --out-dir ./dist
NODE_ENV=production ./node_modules/.bin/babel --ignore tests,stories --plugins "@babel/transform-runtime" ./src --out-dir ./dist
echo ""
echo "=> Transpiling completed."

Expand Down
47 changes: 0 additions & 47 deletions .scripts/publish_storybook.sh

This file was deleted.

12 changes: 0 additions & 12 deletions .storybook/config.js

This file was deleted.

15 changes: 15 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
const config = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-webpack5-compiler-swc",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-webpack5",
options: {},
},
};
export default config;
13 changes: 13 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type { import('@storybook/react').Preview } */
const preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,44 @@ npm install --save react-lottie-wrapper
```

## Usage
A react functional component example (React 16.8.0+).

Import pinjump.json.json as animation data
```jsx
import { useState } from "react";
import { Lottie } from "react-lottie-wrapper";
import * as animationData from "./pinjump.json";

const LottieControl = () => {
const [isStopped, setIsStopped] = useState(false);
const [isPaused, setIsPaused] = useState(false);

const defaultOptions = {
loop: true,
autoplay: true,
animationData: animationData.default,
rendererSettings: {
preserveAspectRatio: "xMidYMid slice"
}
};

return (
<Lottie
options={defaultOptions}
height={400}
width={400}
isStopped={isStopped}
isPaused={isPaused}
/>
)
}
```
A class based example of implementation. Import pinjump.json.json as animation data.

NOTE: We will be deprecating this in future versions. It is advised that you use the functional version provided. You can see an example of the implementation above.

```jsx
import React, { Component } from "react"
import Lottie from "react-lottie-wrapper";
import { ReactLottie } from "react-lottie-wrapper";
import * as animationData from "./pinjump.json"

export default class LottieControl extends Component {
Expand Down Expand Up @@ -105,13 +137,10 @@ export default class LottieControl extends Component {
)
}
}

```

### props
The `<Lottie />` Component supports the following properties:


The `<Lottie /> and <ReactLottie />` Components supports the following properties:

**options** *required*

Expand Down
Loading