make the DL spinner a styled component
							parent
							
								
									4b39b46b6a
								
							
						
					
					
						commit
						e97ac5d7c7
					
				@ -1,41 +1,87 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import classNames from 'classnames';
 | 
			
		||||
import styled from 'styled-components';
 | 
			
		||||
 | 
			
		||||
interface Props {
 | 
			
		||||
  size: 'small' | 'mini' | 'normal';
 | 
			
		||||
type Props = {
 | 
			
		||||
  size: 'small' | 'normal';
 | 
			
		||||
  direction?: string;
 | 
			
		||||
}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export class Spinner extends React.Component<Props> {
 | 
			
		||||
  public render() {
 | 
			
		||||
    const { size, direction } = this.props;
 | 
			
		||||
// Module: Spinner
 | 
			
		||||
 | 
			
		||||
const spinner56Path =
 | 
			
		||||
  'M52.3599009,14.184516 C54.6768062,18.2609741 56,22.9759628 56,28 C56,43.463973 43.463973,56 28,56 L28,54 C42.3594035,54 54,42.3594035 54,28 C54,23.3403176 52.7742128,18.9669331 50.6275064,15.1847144 L52.3599009,14.184516 Z';
 | 
			
		||||
 | 
			
		||||
const spinner24Path =
 | 
			
		||||
  'M22.5600116,6.29547931 C23.4784938,7.99216184 24,9.93517878 24,12 C24,18.627417 18.627417,24 12,24 L12,22 C17.5228475,22 22,17.5228475 22,12 C22,10.2995217 21.5755584,8.6981771 20.8268371,7.29612807 L22.5600116,6.29547931 Z';
 | 
			
		||||
 | 
			
		||||
const SpinnerArc = styled.svg`
 | 
			
		||||
  position: absolute;
 | 
			
		||||
  top: 0;
 | 
			
		||||
  left: 0;
 | 
			
		||||
  background: none;
 | 
			
		||||
  z-index: 3;
 | 
			
		||||
  height: 56px;
 | 
			
		||||
  width: 56px;
 | 
			
		||||
 | 
			
		||||
  animation: spinner-arc-animation 3000ms linear infinite;
 | 
			
		||||
  animation-play-state: inherit;
 | 
			
		||||
 | 
			
		||||
  @keyframes spinner-arc-animation {
 | 
			
		||||
    0% {
 | 
			
		||||
      transform: rotate(0deg);
 | 
			
		||||
    }
 | 
			
		||||
    50% {
 | 
			
		||||
      transform: rotate(180deg);
 | 
			
		||||
    }
 | 
			
		||||
    100% {
 | 
			
		||||
      transform: rotate(360deg);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
const SpinnerContainer = styled.div`
 | 
			
		||||
  margin-inline-start: auto;
 | 
			
		||||
  margin-inline-end: auto;
 | 
			
		||||
  position: relative;
 | 
			
		||||
  height: 56px;
 | 
			
		||||
  width: 56px;
 | 
			
		||||
 | 
			
		||||
  /* :hover {
 | 
			
		||||
    animation-play-state: running;
 | 
			
		||||
  }
 | 
			
		||||
  animation-play-state: paused;
 | 
			
		||||
  */
 | 
			
		||||
  animation-play-state: running;
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
const SpinnerContainerSmall = styled(SpinnerContainer)`
 | 
			
		||||
  height: 24px;
 | 
			
		||||
  width: 24px;
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
const SpinnerArcSmall = styled(SpinnerArc)`
 | 
			
		||||
  height: 24px;
 | 
			
		||||
  width: 24px;
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
export const Spinner = (props: Props) => {
 | 
			
		||||
  const { size } = props;
 | 
			
		||||
 | 
			
		||||
  if (size === 'small') {
 | 
			
		||||
    return (
 | 
			
		||||
      <div
 | 
			
		||||
        className={classNames(
 | 
			
		||||
          'module-spinner__container',
 | 
			
		||||
          `module-spinner__container--${size}`,
 | 
			
		||||
          direction ? `module-spinner__container--${direction}` : null,
 | 
			
		||||
          direction ? `module-spinner__container--${size}-${direction}` : null
 | 
			
		||||
        )}
 | 
			
		||||
      >
 | 
			
		||||
        <div
 | 
			
		||||
          className={classNames(
 | 
			
		||||
            'module-spinner__circle',
 | 
			
		||||
            `module-spinner__circle--${size}`,
 | 
			
		||||
            direction ? `module-spinner__circle--${direction}` : null,
 | 
			
		||||
            direction ? `module-spinner__circle--${size}-${direction}` : null
 | 
			
		||||
          )}
 | 
			
		||||
        />
 | 
			
		||||
        <div
 | 
			
		||||
          className={classNames(
 | 
			
		||||
            'module-spinner__arc',
 | 
			
		||||
            `module-spinner__arc--${size}`,
 | 
			
		||||
            direction ? `module-spinner__arc--${direction}` : null,
 | 
			
		||||
            direction ? `module-spinner__arc--${size}-${direction}` : null
 | 
			
		||||
          )}
 | 
			
		||||
        />
 | 
			
		||||
      </div>
 | 
			
		||||
      <SpinnerContainerSmall>
 | 
			
		||||
        <SpinnerArcSmall>
 | 
			
		||||
          <path d={spinner24Path} />
 | 
			
		||||
        </SpinnerArcSmall>
 | 
			
		||||
      </SpinnerContainerSmall>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <SpinnerContainer>
 | 
			
		||||
      <SpinnerArc>
 | 
			
		||||
        <path d={spinner56Path} />
 | 
			
		||||
      </SpinnerArc>
 | 
			
		||||
    </SpinnerContainer>
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue