Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Lottie Animation #143

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/react-lottie": "^1.2.5",
"bn.js": "^4.12.0",
"i18next": "^20.1.0",
"i18next-http-backend": "^1.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.8.12",
"react-lottie": "^1.2.3",
"react-redux": "^7.2.3",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/loading.json

Large diffs are not rendered by default.

39 changes: 22 additions & 17 deletions src/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import React from "react";
import styled, { keyframes } from "styled-components";
import loading from "../assets/loading-icon.png";
import Lottie from "react-lottie";
import loadingData from "../assets/loading.json";

const StyledLoading = styled.div`
position: absolute;
Expand All @@ -14,28 +15,32 @@ const StyledLoading = styled.div`
align-items: center;
`;

const rotate = keyframes`
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
const Circle = styled.div`
width: 200px;
height: 200px;
border-radius: 50%;
overflow: hidden;

div {
transform: scale(1.3) translateY(20px);
}
`;

const Animation = styled.img`
border-radius: 50%;
width: 100px;
height: 100px;
filter: contrast(1.02);
user-select: none;
animation: ${rotate} 2s linear 0s infinite;
`;
const defaultOptions = {
loop: true,
autoplay: true,
animationData: loadingData,
rendererSettings: {
preserveAspectRatio: "xMidYMid slice",
},
};

const Loading: React.FC = () => {
return (
<StyledLoading>
<Animation src={loading} />
<Circle>
<Lottie options={defaultOptions} height={200} width={200} />
</Circle>
</StyledLoading>
);
};
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,13 @@
dependencies:
react-i18next "*"

"@types/react-lottie@^1.2.5":
version "1.2.5"
resolved "https://registry.yarnpkg.com/@types/react-lottie/-/react-lottie-1.2.5.tgz#659322961de534227ba354109342cad967d98841"
integrity sha512-g5c7r0VN8g0hLsFEtR71ZFDWDp6niY4D/7llcAcLjV3LpaoyANmaQ9jispskWpkAUP+NYQcFllMtoGIWUM6VRw==
dependencies:
"@types/react" "*"

"@types/react-redux@^7.1.16":
version "7.1.16"
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.16.tgz#0fbd04c2500c12105494c83d4a3e45c084e3cb21"
Expand Down Expand Up @@ -7920,6 +7927,11 @@ loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4
dependencies:
js-tokens "^3.0.0 || ^4.0.0"

lottie-web@^5.1.3:
version "5.7.8"
resolved "https://registry.yarnpkg.com/lottie-web/-/lottie-web-5.7.8.tgz#c7a2e42983bcb42093590a03ccdde8741d3f960e"
integrity sha512-VxKCZk33GwZac6mVHvT3grUFR/zrMsW85M7vxQPrgpJOP2IhcnjMbuD0h7muBkXgw84K9KmGulmcyzvhpzSMAg==

lower-case@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28"
Expand Down Expand Up @@ -10181,6 +10193,14 @@ react-is@^17.0.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

react-lottie@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/react-lottie/-/react-lottie-1.2.3.tgz#8544b96939e088658072eea5e12d912cdaa3acc1"
integrity sha512-qLCERxUr8M+4mm1LU0Ruxw5Y5Fn/OmYkGfnA+JDM/dZb3oKwVAJCjwnjkj9TMHtzR2U6sMEUD3ZZ1RaHagM7kA==
dependencies:
babel-runtime "^6.26.0"
lottie-web "^5.1.3"

react-redux@^7.2.3:
version "7.2.3"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.2.3.tgz#4c084618600bb199012687da9e42123cca3f0be9"
Expand Down