Skip to content

Commit

Permalink
♿ [open-formulieren/open-forms#4717] Added text alternative to loader
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Oct 2, 2024
1 parent df913a7 commit 8443340
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/components/Loader.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import PropTypes from 'prop-types';
import React from 'react';
import {FormattedMessage} from 'react-intl';

import {getBEMClassName} from 'utils';

export const MODIFIERS = ['centered', 'only-child', 'small', 'gray'];

const Loader = ({modifiers = []}) => {
const Loader = ({modifiers = [], withoutTranslation}) => {
const className = getBEMClassName('loading', modifiers);
return (
<div className={className} role="status">
<span className={getBEMClassName('loading__spinner')} />
<span className="sr-only">
{withoutTranslation ? (
'Loading...'
) : (
<FormattedMessage description="Loading content text" defaultMessage="Loading..." />
)}
</span>
</div>
);
};

Loader.propTypes = {
withoutTranslation: PropTypes.bool,
modifiers: PropTypes.arrayOf(PropTypes.oneOf(MODIFIERS)),
};

Expand Down
1 change: 1 addition & 0 deletions src/components/Loader.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default {
component: _Loader,
args: {
modifiers: [],
withoutTranslation: true
},
argTypes: {
modifiers: {
Expand Down
2 changes: 1 addition & 1 deletion src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const I18NManager = ({languageSelectorTarget, onLanguageChangeDone, children}) =
};
}, [baseUrl, languageCode]);

if (loading) return <Loader modifiers={['centered']} />;
if (loading) return <Loader modifiers={['centered']} withoutTranslation />;

if (error) {
throw error;
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,11 @@
"description": "return to form start link after 403",
"originalDefault": "Back to form start"
},
"eAmrdi": {
"defaultMessage": "Loading...",
"description": "Loading content text",
"originalDefault": "Loading..."
},
"eO6Ysb": {
"defaultMessage": "Your payment is currently processing.",
"description": "payment processing status",
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,11 @@
"description": "return to form start link after 403",
"originalDefault": "Back to form start"
},
"eAmrdi": {
"defaultMessage": "Loading...",
"description": "Loading content text",
"originalDefault": "Loading..."
},
"eO6Ysb": {
"defaultMessage": "De betaling wordt momenteel verwerkt.",
"description": "payment processing status",
Expand Down

0 comments on commit 8443340

Please sign in to comment.