feat(ott-250): added preloader (#149)
* feat(ott-250): added preloader * fix(ott-250): deleted white space * fix(ott-250): not finshied yet * fix(ott-250): added useRequest hooks * fix(ott-250): minor bug Co-authored-by: Armen <armen9339@gmail.com>keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
parent
194d09e009
commit
df16579eb1
@ -0,0 +1,16 @@ |
||||
import React from 'react' |
||||
|
||||
import { LoaderProps } from './types' |
||||
import { Wrapper, Circles } from './styled' |
||||
|
||||
export const Loader = ({ color, diameter }: LoaderProps) => ( |
||||
<Wrapper color={color} diameter={diameter}> |
||||
<Circles color={color} /> |
||||
</Wrapper> |
||||
) |
||||
|
||||
export const LoaderUI = { |
||||
Circles, |
||||
Loader, |
||||
Wrapper, |
||||
} |
||||
@ -0,0 +1,57 @@ |
||||
import styled, { css, keyframes } from 'styled-components' |
||||
|
||||
import { LoaderProps } from './types' |
||||
|
||||
const animation = keyframes` |
||||
0%, |
||||
100% { |
||||
transform: scale(0); |
||||
} |
||||
50% { |
||||
transform: scale(1.0); |
||||
} |
||||
` |
||||
|
||||
export const Wrapper = styled.div<LoaderProps>` |
||||
position: relative; |
||||
margin: 0 auto; |
||||
|
||||
${({ diameter = 25 }) => ( |
||||
diameter |
||||
? css` |
||||
width: ${diameter}px; |
||||
height: ${diameter}px; |
||||
` |
||||
: '' |
||||
)} |
||||
|
||||
:before, |
||||
:after { |
||||
content: ''; |
||||
position: absolute; |
||||
top: 0; |
||||
background-color: ${({ color }) => color}; |
||||
width: 100%; |
||||
height: 100%; |
||||
border-radius: 50%; |
||||
animation: ${animation} 1s infinite ease-in-out; |
||||
} |
||||
|
||||
:before { |
||||
left: -130%; |
||||
animation-delay: 0.2s; |
||||
} |
||||
|
||||
:after { |
||||
left: 130%; |
||||
animation-delay: -0.2s; |
||||
} |
||||
` |
||||
|
||||
export const Circles = styled.div<LoaderProps>` |
||||
background-color: ${({ color }) => color}; |
||||
width: 100%; |
||||
height: 100%; |
||||
border-radius: 50%; |
||||
animation: ${animation} 1s infinite ease-in-out; |
||||
` |
||||
@ -0,0 +1,6 @@ |
||||
export type LoaderProps = { |
||||
/** цвет кружков прелоадера */ |
||||
color?: string, |
||||
/** диаметр кружков прелоадера */ |
||||
diameter?: number, |
||||
} |
||||
Loading…
Reference in new issue