import React, { memo } from 'react'; import Icon from './Icon'; import { I18n } from '../locale'; const LoaderRing = ({ radius, stroke, percent }) => { const normalizedRadius = radius - stroke * 2; const circumference = normalizedRadius * 2 * Math.PI; const strokeDashoffset = circumference - percent * circumference; return ( {percent === null ? ( ) : ( )} ); }; export default memo((props) => { const { body, loading, finished, mini, lazy, white, className = '', progress: { total, remaining, percent, } = {}, } = props; if (!loading && !finished) { return null; } let classNameString = 'loader'; if (className) { classNameString += ` ${className}`; } if (mini) { classNameString += ' loader--mini'; } if (body) { classNameString += ' loader--body'; } if (lazy) { classNameString += ' loader--lazy'; } if (white) { classNameString += ' loader--white'; } if (!navigator.onLine) { return (

); } if (finished) { classNameString += ' loader--finished'; return (
); } classNameString += ' loader--progress'; return (
{total > 0 && remaining >= 0 && (
{`${total - remaining} / ${total}`}
)}
); });