|
1 | 1 | import React, { forwardRef } from 'react';
|
2 |
| -import propTypes from 'prop-types'; |
3 |
| - |
4 |
| -import styled, { keyframes, css } from 'styled-components'; |
5 |
| - |
| 2 | +import styled, { css, keyframes } from 'styled-components'; |
6 | 3 | import { StyledCutout } from '../Cutout/Cutout';
|
| 4 | +import { CommonStyledProps } from '../types'; |
| 5 | + |
| 6 | +type LoadingIndicatorProps = { |
| 7 | + isLoading?: boolean; |
| 8 | + shadow?: boolean; |
| 9 | +} & React.HTMLAttributes<HTMLDivElement> & |
| 10 | + CommonStyledProps; |
7 | 11 |
|
8 | 12 | const Wrapper = styled.div`
|
9 | 13 | display: inline-block;
|
@@ -127,35 +131,28 @@ const IndeterminateSecondaryInner = styled.span`
|
127 | 131 | animation: ${secondaryScale} 2s infinite linear;
|
128 | 132 | `;
|
129 | 133 |
|
130 |
| -const LoadingIndicator = forwardRef(function LoadingIndicator(props, ref) { |
131 |
| - const { isLoading, shadow, ...otherProps } = props; |
132 |
| - |
133 |
| - return ( |
134 |
| - <Wrapper ref={ref} role='progressbar' {...otherProps}> |
135 |
| - <ProgressCutout shadow={shadow}> |
136 |
| - {isLoading && ( |
137 |
| - <IndeterminateWrapper data-testid='loading-wrapper'> |
138 |
| - <IndeterminatePrimary> |
139 |
| - <IndeterminatePrimaryInner /> |
140 |
| - </IndeterminatePrimary> |
141 |
| - <IndeterminateSecondary> |
142 |
| - <IndeterminateSecondaryInner /> |
143 |
| - </IndeterminateSecondary> |
144 |
| - </IndeterminateWrapper> |
145 |
| - )} |
146 |
| - </ProgressCutout> |
147 |
| - </Wrapper> |
148 |
| - ); |
149 |
| -}); |
150 |
| - |
151 |
| -LoadingIndicator.defaultProps = { |
152 |
| - shadow: false, |
153 |
| - isLoading: true |
154 |
| -}; |
155 |
| - |
156 |
| -LoadingIndicator.propTypes = { |
157 |
| - shadow: propTypes.bool, |
158 |
| - isLoading: propTypes.bool |
159 |
| -}; |
| 134 | +const LoadingIndicator = forwardRef<HTMLDivElement, LoadingIndicatorProps>( |
| 135 | + function LoadingIndicator( |
| 136 | + { isLoading = true, shadow = false, ...otherProps }, |
| 137 | + ref |
| 138 | + ) { |
| 139 | + return ( |
| 140 | + <Wrapper ref={ref} role='progressbar' {...otherProps}> |
| 141 | + <ProgressCutout shadow={shadow}> |
| 142 | + {isLoading && ( |
| 143 | + <IndeterminateWrapper data-testid='loading-wrapper'> |
| 144 | + <IndeterminatePrimary> |
| 145 | + <IndeterminatePrimaryInner /> |
| 146 | + </IndeterminatePrimary> |
| 147 | + <IndeterminateSecondary> |
| 148 | + <IndeterminateSecondaryInner /> |
| 149 | + </IndeterminateSecondary> |
| 150 | + </IndeterminateWrapper> |
| 151 | + )} |
| 152 | + </ProgressCutout> |
| 153 | + </Wrapper> |
| 154 | + ); |
| 155 | + } |
| 156 | +); |
160 | 157 |
|
161 |
| -export default LoadingIndicator; |
| 158 | +export { LoadingIndicator, LoadingIndicatorProps }; |
0 commit comments