/* Copyright (C) 2018 Cloudbase Solutions SRL This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ // @flow import React from 'react' import { observer } from 'mobx-react' import styled, { css } from 'styled-components' import StyleProps from '../../styleUtils/StyleProps' import Palette from '../../styleUtils/Palette' const Wrapper = styled.div` position: relative; ${StyleProps.exactSize('28px')} background-repeat: no-repeat; background-position: center; ` const ProgressSvgWrapper = styled.svg` ${StyleProps.exactSize('100%')} transform: rotate(-90deg); ${props => props.spinning ? css`animation: rotate 1s linear infinite;` : ''} @keyframes rotate { 0% {transform: rotate(0deg);} 100% {transform: rotate(360deg);} } ` const ProgressText = styled.div` color: ${Palette.primary}; font-size: 9px; font-weight: ${StyleProps.fontWeights.medium}; top: 9px; position: absolute; width: 100%; text-align: center; ` const CircleProgressBar = styled.circle`` export const TEST_ID = 'smallLoading' export type Props = { loadingProgress: number, } @observer class SmallLoading extends React.Component { renderProgressImage() { let progress = this.props.loadingProgress > -1 ? this.props.loadingProgress : 25 return ( ) } renderProgressText() { if (this.props.loadingProgress === -1) { return null } return ( {this.props.loadingProgress ? this.props.loadingProgress.toFixed(0) : 0}% ) } render() { return ( {this.renderProgressImage()} {this.renderProgressText()} ) } } export default SmallLoading