|
| 1 | +import styled, { keyframes } from 'styled-components'; |
| 2 | +import { LoaderProps } from './types'; |
| 3 | +import { Box } from '../Box'; |
| 4 | + |
| 5 | +const wave = keyframes` |
| 6 | + 0%, 60%, 100% { |
| 7 | + transform: initial; |
| 8 | + } |
| 9 | +
|
| 10 | + 30% { |
| 11 | + transform: translateY(-15px); |
| 12 | + } |
| 13 | +`; |
| 14 | + |
| 15 | +export const LoadingDots = styled.div<LoaderProps>` |
| 16 | + position: relative; |
| 17 | + text-align: center; |
| 18 | + width: 48px; |
| 19 | + height: 48px; |
| 20 | + margin-left: auto; |
| 21 | + margin-right: auto; |
| 22 | + background: ${({ theme }) => theme.COLOR.brandLightest}; |
| 23 | + border-radius: 50%; |
| 24 | + span { |
| 25 | + display: inline-block; |
| 26 | + width: 7px; |
| 27 | + height: 7px; |
| 28 | + border-radius: 50%; |
| 29 | + margin-right: 2px; |
| 30 | + margin-top: 21px; |
| 31 | + background-color: ${({ theme }) => theme.COLOR.brandMain}; |
| 32 | + animation: ${wave} 1.3s linear infinite; |
| 33 | + } |
| 34 | + span:nth-child(2) { |
| 35 | + animation-delay: -1.1s; |
| 36 | + } |
| 37 | + span:nth-child(3) { |
| 38 | + animation-delay: -0.9s; |
| 39 | + } |
| 40 | +`; |
| 41 | + |
| 42 | +export const LoadingDotsOutlined = styled.div<LoaderProps>` |
| 43 | + position: relative; |
| 44 | + text-align: center; |
| 45 | + width: 48px; |
| 46 | + height: 48px; |
| 47 | + margin-left: auto; |
| 48 | + margin-right: auto; |
| 49 | + border-radius: 50%; |
| 50 | + span { |
| 51 | + display: inline-block; |
| 52 | + width: 7px; |
| 53 | + height: 7px; |
| 54 | + border-radius: 50%; |
| 55 | + margin-right: 2px; |
| 56 | + margin-top: 21px; |
| 57 | + animation: ${wave} 1.3s linear infinite; |
| 58 | + border: 2px solid ${({ theme }) => theme.COLOR.brandMain}; |
| 59 | + } |
| 60 | + span:nth-child(2) { |
| 61 | + animation-delay: -1.1s; |
| 62 | + } |
| 63 | + span:nth-child(3) { |
| 64 | + animation-delay: -0.9s; |
| 65 | + } |
| 66 | +`; |
| 67 | + |
| 68 | +const spin = keyframes` |
| 69 | + 0% { |
| 70 | + transform: rotate(0deg); |
| 71 | + } |
| 72 | + 100% { |
| 73 | + transform: rotate(359deg); |
| 74 | + } |
| 75 | +`; |
| 76 | + |
| 77 | +const mask = keyframes` |
| 78 | + 0% { |
| 79 | + transform: rotate(0deg); |
| 80 | + } |
| 81 | + 25% { |
| 82 | + transform: rotate(180deg); |
| 83 | + } |
| 84 | + 50% { |
| 85 | + transform: rotate(180deg); |
| 86 | + } |
| 87 | + 75% { |
| 88 | + transform: rotate(360deg); |
| 89 | + } |
| 90 | + 100% { |
| 91 | + transform: rotate(360deg); |
| 92 | + } |
| 93 | +`; |
| 94 | + |
| 95 | +export const Backdrop = styled.div` |
| 96 | + position: fixed; |
| 97 | + top: 0; |
| 98 | + left: 0; |
| 99 | + width: 100vw; |
| 100 | + height: 100vh; |
| 101 | + background-color: rgba(21, 41, 53, 0.3); |
| 102 | + z-index: 999; |
| 103 | +`; |
| 104 | + |
| 105 | +export const Wrapper = styled(Box)` |
| 106 | + position: fixed; |
| 107 | + top: 50%; |
| 108 | + left: 50%; |
| 109 | + transform: translate(-50%, -50%); |
| 110 | + text-align: center; |
| 111 | + z-index: 9999; |
| 112 | + background-color: ${({ theme }) => theme.COLOR.light}; |
| 113 | + border-radius: ${({ theme }) => theme.RADIUS.m}; |
| 114 | + box-shadow: ${({ theme }) => theme.SHADOW.s}; |
| 115 | + padding: 40px 40px; |
| 116 | +`; |
| 117 | + |
| 118 | +export const Loader = styled.div<LoaderProps>` |
| 119 | + margin: 0 auto; |
| 120 | + width: ${(props: any) => (props.small ? '32px' : '64px')}; |
| 121 | + height: ${(props: any) => (props.small ? '32px' : '64px')}; |
| 122 | + animation: 1s ${spin} infinite cubic-bezier(0.255, 0.2, 0.315, 0.455); |
| 123 | + span, |
| 124 | + span:before { |
| 125 | + position: absolute; |
| 126 | + top: 0; |
| 127 | + left: 0; |
| 128 | + width: ${(props: any) => (props.small ? '16px' : '32px')}; |
| 129 | + height: ${(props: any) => (props.small ? '32px' : '64px')}; |
| 130 | + overflow: hidden; |
| 131 | + box-sizing: border-box; |
| 132 | + transform-origin: 100% 50%; |
| 133 | + border-top-left-radius: 32px; |
| 134 | + border-bottom-left-radius: 32px; |
| 135 | + } |
| 136 | + span:before { |
| 137 | + content: ''; |
| 138 | + border-width: ${(props: any) => (props.small ? '4px' : '5px')}; |
| 139 | + border-color: ${({ theme }) => theme.COLOR.brandMain}; |
| 140 | + border-style: solid; |
| 141 | + border-right-color: transparent; |
| 142 | + animation: 4s ${mask} infinite linear; |
| 143 | + } |
| 144 | + span:nth-child(1) { |
| 145 | + transform: rotate(180deg); |
| 146 | + } |
| 147 | + span:nth-child(2) { |
| 148 | + transform: rotate(360deg); |
| 149 | + &:before { |
| 150 | + animation-delay: 1s; |
| 151 | + } |
| 152 | + } |
| 153 | +`; |
0 commit comments