2018-08-24 07:57:23 +00:00
|
|
|
import React from 'react';
|
2018-08-25 16:56:24 +00:00
|
|
|
import styled, { css } from 'styled-components';
|
2018-08-24 07:57:23 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-08-25 12:34:04 +00:00
|
|
|
import Paragraph from 'components/Paragraph';
|
2018-08-31 20:35:21 +00:00
|
|
|
import { FONT_SIZE } from 'config/variables';
|
2018-08-25 16:49:21 +00:00
|
|
|
import { DASH, GREEN_COLOR } from 'config/animations';
|
2018-08-24 07:57:23 +00:00
|
|
|
import colors from 'config/colors';
|
|
|
|
|
|
|
|
const Wrapper = styled.div`
|
|
|
|
position: relative;
|
|
|
|
width: ${props => `${props.size}px`};
|
|
|
|
height: ${props => `${props.size}px`};
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const SvgWrapper = styled.svg`
|
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
animation: rotate 2s linear infinite;
|
|
|
|
transform-origin: center center;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const CircleWrapper = styled.circle`
|
2019-03-04 12:33:02 +00:00
|
|
|
${props =>
|
|
|
|
props.isRoute &&
|
|
|
|
css`
|
|
|
|
stroke: ${props.transparentRoute ? 'transparent' : colors.GRAY_LIGHT};
|
|
|
|
`}
|
2018-08-24 07:57:23 +00:00
|
|
|
|
2019-03-04 12:33:02 +00:00
|
|
|
${props =>
|
|
|
|
props.isPath &&
|
|
|
|
css`
|
|
|
|
stroke-width: ${props.transparentRoute ? '2px' : '1px'};
|
|
|
|
stroke-dasharray: 1, 200;
|
|
|
|
stroke-dashoffset: 0;
|
|
|
|
animation: ${DASH} 1.5s ease-in-out infinite,
|
|
|
|
${props.animationColor || GREEN_COLOR} 6s ease-in-out infinite;
|
|
|
|
stroke-linecap: round;
|
|
|
|
`};
|
2018-08-24 07:57:23 +00:00
|
|
|
`;
|
|
|
|
|
2018-08-30 12:16:43 +00:00
|
|
|
const StyledParagraph = styled(Paragraph)`
|
2018-12-13 12:42:52 +00:00
|
|
|
font-size: ${props => (props.isSmallText ? FONT_SIZE.SMALL : FONT_SIZE.BIG)};
|
2018-08-30 12:16:43 +00:00
|
|
|
color: ${props => (props.isWhiteText ? colors.WHITE : colors.TEXT_PRIMARY)};
|
|
|
|
`;
|
|
|
|
|
2018-08-24 07:57:23 +00:00
|
|
|
const Loader = ({
|
2019-03-04 12:33:02 +00:00
|
|
|
className,
|
|
|
|
text,
|
|
|
|
isWhiteText = false,
|
|
|
|
isSmallText,
|
|
|
|
size = 100,
|
|
|
|
animationColor,
|
|
|
|
transparentRoute,
|
2018-08-24 07:57:23 +00:00
|
|
|
}) => (
|
2018-08-25 16:56:24 +00:00
|
|
|
<Wrapper className={className} size={size}>
|
2019-03-04 12:33:02 +00:00
|
|
|
<StyledParagraph isSmallText={isSmallText} isWhiteText={isWhiteText}>
|
|
|
|
{text}
|
|
|
|
</StyledParagraph>
|
2018-08-24 07:57:23 +00:00
|
|
|
<SvgWrapper viewBox="25 25 50 50">
|
|
|
|
<CircleWrapper
|
2019-01-09 14:02:38 +00:00
|
|
|
animationColor={animationColor}
|
2018-08-24 07:57:23 +00:00
|
|
|
cx="50"
|
|
|
|
cy="50"
|
|
|
|
r="20"
|
|
|
|
fill="none"
|
|
|
|
stroke=""
|
|
|
|
strokeMiterlimit="10"
|
|
|
|
isRoute
|
2019-01-09 14:57:59 +00:00
|
|
|
transparentRoute={transparentRoute}
|
2018-08-24 07:57:23 +00:00
|
|
|
/>
|
|
|
|
<CircleWrapper
|
2019-01-09 14:57:59 +00:00
|
|
|
animationColor={animationColor}
|
2018-08-24 07:57:23 +00:00
|
|
|
cx="50"
|
|
|
|
cy="50"
|
|
|
|
r="20"
|
|
|
|
fill="none"
|
|
|
|
strokeMiterlimit="10"
|
|
|
|
isPath
|
2019-01-09 14:57:59 +00:00
|
|
|
transparentRoute={transparentRoute}
|
2018-08-24 07:57:23 +00:00
|
|
|
/>
|
|
|
|
</SvgWrapper>
|
|
|
|
</Wrapper>
|
|
|
|
);
|
|
|
|
|
|
|
|
Loader.propTypes = {
|
2018-08-30 12:16:43 +00:00
|
|
|
isWhiteText: PropTypes.bool,
|
2018-08-31 20:35:21 +00:00
|
|
|
isSmallText: PropTypes.bool,
|
2018-08-24 07:57:23 +00:00
|
|
|
className: PropTypes.string,
|
|
|
|
text: PropTypes.string,
|
2019-01-10 10:32:40 +00:00
|
|
|
animationColor: PropTypes.object,
|
2019-01-09 14:57:59 +00:00
|
|
|
transparentRoute: PropTypes.bool,
|
2018-08-24 07:57:23 +00:00
|
|
|
size: PropTypes.number,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Loader;
|