84 |
85 |
86 |
95 |
96 |
97 |
98 | )
99 | }
100 |
101 | export default LiquidLoader;
--------------------------------------------------------------------------------
/src/movingSquare/MovingSquareLoader.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import styled from '@emotion/styled';
4 | import { keyframes } from '@emotion/core';
5 |
6 | import { Colors, pauseAnim, loaderDuration } from '../utilities/utilities';
7 | import LoaderBox from '../wrapper/wrapper';
8 |
9 |
10 |
11 | export interface MovingSquareProps {
12 | loading: boolean;
13 | size?: number;
14 | pause?: boolean;
15 | duration?: number;
16 | colors?: string[];
17 | }
18 |
19 | const dProps = {
20 | loading: true,
21 | size: 60,
22 | duration: 1,
23 | colors: [Colors.Purple, Colors.Purple]
24 | }
25 |
26 |
27 | const MovingSquareLoader = (props: MovingSquareProps) => {
28 |
29 | const {
30 | loading,
31 | size,
32 | pause,
33 | duration,
34 | colors,
35 | } = props;
36 |
37 | const SquareMove = keyframes`
38 | 0%, 100%{
39 | transform: translate(0,0) rotate(0);
40 | }
41 |
42 | 25%{
43 | transform: translate(30px,30px) rotate(45deg);
44 | }
45 |
46 | 50%{
47 | transform: translate(0px,60px) rotate(0deg);
48 | }
49 |
50 | 75%{
51 | transform: translate(-30px,30px) rotate(45deg);
52 | }
53 | `;
54 |
55 | const Loader = styled('div')`
56 | transform: ${size ? `scale(${size/100})` : `scale(${dProps.size/100})`};
57 | transform-origin: center;
58 | position: relative;
59 | width: inherit;
60 | height: inherit;
61 |
62 |
63 | &:before, &:after {
64 | content: "";
65 | width: 20px;
66 | height: 20px;
67 | position: absolute;
68 | top: 0;
69 | left: 0;
70 | animation: ${SquareMove} ${loaderDuration(duration, dProps.duration)} ease-in-out infinite;
71 | animation-play-state: ${pauseAnim(pause)};
72 | }
73 |
74 | &:before {
75 | background-color: ${colors ? `${colors[0]}` : `${dProps.colors[0]}`};
76 | }
77 |
78 | &:after {
79 | background-color: ${colors ? `${colors[1]}` : `${dProps.colors[1]}`};
80 | animation-delay: ${duration ? `${duration/2}s` : `${dProps.duration/2}s`};
81 | }
82 | `;
83 |
84 | return (
85 |