1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-15 12:59:09 +00:00
trezor-wallet/src/components/Loader/index.js

100 lines
2.7 KiB
JavaScript
Raw Normal View History

import React from 'react';
import styled, { css } from 'styled-components';
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';
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};
`}
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;
`};
`;
const StyledParagraph = styled(Paragraph)`
2018-12-13 12:42:52 +00:00
font-size: ${props => (props.isSmallText ? FONT_SIZE.SMALL : FONT_SIZE.BIG)};
color: ${props => (props.isWhiteText ? colors.WHITE : colors.TEXT_PRIMARY)};
`;
const Loader = ({
2019-03-04 12:33:02 +00:00
className,
text,
isWhiteText = false,
isSmallText,
size = 100,
animationColor,
transparentRoute,
}) => (
<Wrapper className={className} size={size}>
2019-03-04 12:33:02 +00:00
<StyledParagraph isSmallText={isSmallText} isWhiteText={isWhiteText}>
{text}
</StyledParagraph>
<SvgWrapper viewBox="25 25 50 50">
<CircleWrapper
2019-01-09 14:02:38 +00:00
animationColor={animationColor}
cx="50"
cy="50"
r="20"
fill="none"
stroke=""
strokeMiterlimit="10"
isRoute
2019-01-09 14:57:59 +00:00
transparentRoute={transparentRoute}
/>
<CircleWrapper
2019-01-09 14:57:59 +00:00
animationColor={animationColor}
cx="50"
cy="50"
r="20"
fill="none"
strokeMiterlimit="10"
isPath
2019-01-09 14:57:59 +00:00
transparentRoute={transparentRoute}
/>
</SvgWrapper>
</Wrapper>
);
Loader.propTypes = {
isWhiteText: PropTypes.bool,
2018-08-31 20:35:21 +00:00
isSmallText: PropTypes.bool,
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,
size: PropTypes.number,
};
export default Loader;