Skip to content

Commit 055db07

Browse files
authored
adds LoadingOverlay to the DS (#421)
1 parent 82cc67a commit 055db07

File tree

7 files changed

+131
-0
lines changed

7 files changed

+131
-0
lines changed

spec/__snapshots__/Storyshots.test.js.snap

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,6 +3424,39 @@ exports[`Storyshots Design System/Form Elements/RadioButtonGroup Description Row
34243424
</div>
34253425
`;
34263426

3427+
exports[`Storyshots Design System/LoadingOverlay Default 1`] = `
3428+
<div
3429+
style={
3430+
Object {
3431+
"padding": "1rem",
3432+
}
3433+
}
3434+
>
3435+
<div
3436+
className="overlay"
3437+
style={Object {}}
3438+
>
3439+
<svg
3440+
aria-hidden="true"
3441+
className="svg-inline--fa fa-spinner-third fa-w-16 fa-spinner"
3442+
data-icon="spinner-third"
3443+
data-prefix="fas"
3444+
focusable="false"
3445+
role="img"
3446+
style={Object {}}
3447+
viewBox="0 0 512 512"
3448+
xmlns="http://www.w3.org/2000/svg"
3449+
>
3450+
<path
3451+
d="M456.433 371.72l-27.79-16.045c-7.192-4.152-10.052-13.136-6.487-20.636 25.82-54.328 23.566-118.602-6.768-171.03-30.265-52.529-84.802-86.621-144.76-91.424C262.35 71.922 256 64.953 256 56.649V24.56c0-9.31 7.916-16.609 17.204-15.96 81.795 5.717 156.412 51.902 197.611 123.408 41.301 71.385 43.99 159.096 8.042 232.792-4.082 8.369-14.361 11.575-22.424 6.92z"
3452+
fill="currentColor"
3453+
style={Object {}}
3454+
/>
3455+
</svg>
3456+
</div>
3457+
</div>
3458+
`;
3459+
34273460
exports[`Storyshots Design System/Modal Danger Modal 1`] = `
34283461
<div
34293462
style={
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from 'react';
2+
import classNames from 'classnames';
3+
import PropTypes from 'prop-types';
4+
5+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6+
import { faSpinnerThird } from '@fortawesome/pro-solid-svg-icons';
7+
8+
import './LoadingOverlay.scss';
9+
10+
const LoadingOverlay = (props) => {
11+
// Only set style if this is not visible to let CSS handle how to display this
12+
const classes = classNames(
13+
'overlay',
14+
{
15+
'overlay--text': !!props.text,
16+
'overlay--content-top': props.contentTop,
17+
},
18+
);
19+
20+
return (
21+
<div
22+
className={classes}
23+
style={props.visible ? {} : { display: 'none' }}
24+
>
25+
{ props.header && (
26+
<p className="overlay__header">
27+
{props.header}
28+
</p>
29+
)}
30+
{ props.text && <p className={props.textClassName}>{props.text}</p> }
31+
32+
<FontAwesomeIcon className="fa-spinner" icon={faSpinnerThird} />
33+
</div>
34+
);
35+
};
36+
37+
LoadingOverlay.propTypes = {
38+
contentTop: PropTypes.bool,
39+
header: PropTypes.string,
40+
text: PropTypes.string,
41+
textClassName: PropTypes.string,
42+
visible: PropTypes.bool,
43+
};
44+
45+
LoadingOverlay.defaultProps = {
46+
contentTop: false,
47+
header: undefined,
48+
text: undefined,
49+
textClassName: undefined,
50+
visible: true,
51+
};
52+
53+
export default LoadingOverlay;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ArgsTable, Story, Preview } from '@storybook/addon-docs/blocks';
2+
import LoadingOverlay from './LoadingOverlay';
3+
4+
# LoadingOverlay
5+
A visual indicator for a loading state.
6+
7+
<Preview>
8+
<Story id="design-system-loadingoverlay--default" />
9+
</Preview>
10+
11+
<ArgsTable of={LoadingOverlay} />
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.fa-spinner {
2+
animation: spin infinite 0.6s linear;
3+
}
4+
5+
@keyframes spin {
6+
from {
7+
transform: rotate(0deg);
8+
}
9+
to {
10+
transform: rotate(360deg);
11+
}
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
3+
import LoadingOverlay from 'src/LoadingOverlay';
4+
5+
import mdx from './LoadingOverlay.mdx';
6+
7+
export default {
8+
title: 'Design System/LoadingOverlay',
9+
component: LoadingOverlay,
10+
parameters: {
11+
docs: {
12+
page: mdx,
13+
},
14+
},
15+
};
16+
17+
export const Default = () => (
18+
<LoadingOverlay visible />
19+
);

src/LoadingOverlay/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './LoadingOverlay';

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import FormControlLabel from 'src/FormControlLabel';
1212
import FormGroup from 'src/FormGroup';
1313
import Input from 'src/Input';
1414
import InputLabel from 'src/InputLabel';
15+
import LoadingOverlay from 'src/LoadingOverlay';
1516
import {
1617
Modal,
1718
MODAL_SIZES,
@@ -68,6 +69,7 @@ export {
6869
FormGroup,
6970
Input,
7071
InputLabel,
72+
LoadingOverlay,
7173
MessageTypes,
7274
Modal,
7375
MODAL_SIZES,

0 commit comments

Comments
 (0)