diff --git a/src/LoadingIndicator/LoadingIndicator.spec.js b/src/LoadingIndicator/LoadingIndicator.spec.tsx similarity index 89% rename from src/LoadingIndicator/LoadingIndicator.spec.js rename to src/LoadingIndicator/LoadingIndicator.spec.tsx index 058fa3d9..b3a9c1f1 100644 --- a/src/LoadingIndicator/LoadingIndicator.spec.js +++ b/src/LoadingIndicator/LoadingIndicator.spec.tsx @@ -1,7 +1,5 @@ -import React from 'react'; - import { renderWithTheme } from '../../test/utils'; -import LoadingIndicator from './LoadingIndicator'; +import { LoadingIndicator } from './LoadingIndicator'; describe('', () => { it('renders LoadingIndicator', () => { diff --git a/src/LoadingIndicator/LoadingIndicator.stories.js b/src/LoadingIndicator/LoadingIndicator.stories.tsx similarity index 77% rename from src/LoadingIndicator/LoadingIndicator.stories.js rename to src/LoadingIndicator/LoadingIndicator.stories.tsx index 68521696..c3f9e186 100644 --- a/src/LoadingIndicator/LoadingIndicator.stories.js +++ b/src/LoadingIndicator/LoadingIndicator.stories.tsx @@ -1,8 +1,7 @@ -import React from 'react'; - +import { ComponentMeta } from '@storybook/react'; import styled from 'styled-components'; -import { LoadingIndicator } from '..'; +import { LoadingIndicator } from 'react95'; const Wrapper = styled.div` background: ${({ theme }) => theme.material}; @@ -13,7 +12,7 @@ export default { title: 'LoadingIndicator', component: LoadingIndicator, decorators: [story => {story()}] -}; +} as ComponentMeta; export function Default() { return ( diff --git a/src/LoadingIndicator/LoadingIndicator.js b/src/LoadingIndicator/LoadingIndicator.tsx similarity index 75% rename from src/LoadingIndicator/LoadingIndicator.js rename to src/LoadingIndicator/LoadingIndicator.tsx index 47a55a4d..78457d71 100644 --- a/src/LoadingIndicator/LoadingIndicator.js +++ b/src/LoadingIndicator/LoadingIndicator.tsx @@ -1,9 +1,13 @@ import React, { forwardRef } from 'react'; -import propTypes from 'prop-types'; - -import styled, { keyframes, css } from 'styled-components'; - +import styled, { css, keyframes } from 'styled-components'; import { StyledCutout } from '../Cutout/Cutout'; +import { CommonStyledProps } from '../types'; + +type LoadingIndicatorProps = { + isLoading?: boolean; + shadow?: boolean; +} & React.HTMLAttributes & + CommonStyledProps; const Wrapper = styled.div` display: inline-block; @@ -127,35 +131,28 @@ const IndeterminateSecondaryInner = styled.span` animation: ${secondaryScale} 2s infinite linear; `; -const LoadingIndicator = forwardRef(function LoadingIndicator(props, ref) { - const { isLoading, shadow, ...otherProps } = props; - - return ( - - - {isLoading && ( - - - - - - - - - )} - - - ); -}); - -LoadingIndicator.defaultProps = { - shadow: false, - isLoading: true -}; - -LoadingIndicator.propTypes = { - shadow: propTypes.bool, - isLoading: propTypes.bool -}; +const LoadingIndicator = forwardRef( + function LoadingIndicator( + { isLoading = true, shadow = false, ...otherProps }, + ref + ) { + return ( + + + {isLoading && ( + + + + + + + + + )} + + + ); + } +); -export default LoadingIndicator; +export { LoadingIndicator, LoadingIndicatorProps }; diff --git a/src/index.ts b/src/index.ts index 46f83018..be46c73d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ export { default as Fieldset } from './Fieldset/Fieldset'; export * from './Hourglass/Hourglass'; export { default as List } from './List/List'; export { default as ListItem } from './ListItem/ListItem'; -export { default as LoadingIndicator } from './LoadingIndicator/LoadingIndicator'; +export * from './LoadingIndicator/LoadingIndicator'; export { default as NumberField } from './NumberField/NumberField'; export * from './Panel/Panel'; export * from './Progress/Progress';