Skip to content

Commit

Permalink
feat(spinner): [EMU-6599] add spinner component
Browse files Browse the repository at this point in the history
  • Loading branch information
a-maffei committed Sep 4, 2023
1 parent b161a13 commit ad11fb1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export {
InformationBox,
Badge,
images,
Spinner,
} from './lib';

export * from './lib/components/icon';
Expand All @@ -46,6 +47,6 @@ export type {
TableHeader,
UploadedFile,
UploadStatus,
} from './lib';
} from './lib';

ReactDOM.render(<App />, document.getElementById('root'));
19 changes: 19 additions & 0 deletions src/lib/components/spinner/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Spinner, SpinnerProps } from '.';

const story = {
title: 'JSX/Spinner',
component: Spinner,
argTypes: {
size: {
control: { type: 'select' },
defaultValue: 's',
description: 'Property that allows to customize the size of the spinner.',
},
},
};

export const SpinnerStory = ({ size }: SpinnerProps) => <Spinner size={size} />;

SpinnerStory.storyName = 'Spinner';

export default story;
11 changes: 11 additions & 0 deletions src/lib/components/spinner/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { render, screen } from '../../util/testUtils';

import { Spinner } from '.';

describe('Spinner component', () => {
it('Should render spinner', async () => {
render(<Spinner></Spinner>);

expect(screen.getByTestId('ds-spinner')).toBeInTheDocument();
});
});
14 changes: 14 additions & 0 deletions src/lib/components/spinner/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import classNames from 'classnames';

export interface SpinnerProps {
size?: 's' | 'm' | 'l';
}

const Spinner = ({ size = 's' }: SpinnerProps) => (
<div
className={classNames('ds-spinner', `ds-spinner__${size}`)}
data-testid="ds-spinner"
></div>
);

export { Spinner };
8 changes: 5 additions & 3 deletions src/lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { DateSelector } from './components/dateSelector';
import { SignaturePad } from './components/signaturePad';
import { AutocompleteAddress } from './components/autocompleteAddress';
import { Input } from './components/input';
import {
import {
MultiDropzone,
FileType,
MultiDropzoneProps,
UploadedFile,
UploadStatus
UploadStatus,
} from './components/multiDropzone';
import { DownloadButton } from './components/downloadButton';
import { InformationBox } from './components/informationBox';
Expand Down Expand Up @@ -44,6 +44,7 @@ import { SegmentedControl } from './components/segmentedControl';
import { Markdown } from './components/markdown';
import { Link } from './components/link';
import { images } from './util/images';
import { Spinner } from './components/spinner';

export * from './components/icon';

Expand Down Expand Up @@ -81,14 +82,15 @@ export {
InformationBox,
Badge,
images,
Spinner,
};

export type {
FileType,
MultiDropzoneProps,
TableHeader,
UploadedFile,
UploadStatus
UploadStatus,
};

export type { DownloadStatus } from './models/download';

0 comments on commit ad11fb1

Please sign in to comment.