Skip to content

Commit

Permalink
Merge pull request #1838 from SpareBank1/develop_fix-translations-spi…
Browse files Browse the repository at this point in the history
…nner

fix(ffe-spinner-react): locale for translating aria label
  • Loading branch information
pethel authored Mar 15, 2024
2 parents 8bfc6dc + 76bd776 commit 8bb8724
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/ffe-spinner-react/src/Spinner.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import React from 'react';
import { bool, string, node } from 'prop-types';
import { bool, string, node, oneOf } from 'prop-types';
import classNames from 'classnames';
import texts from './texts';

const Spinner = ({ className, immediate, large, loadingText, ...rest }) => (
const Spinner = ({
className,
immediate,
large,
loadingText,
locale,
...rest
}) => (
<div aria-live="assertive" className={className} {...rest}>
<span
className={classNames(
Expand All @@ -11,7 +19,7 @@ const Spinner = ({ className, immediate, large, loadingText, ...rest }) => (
{ 'ffe-loading-spinner--large': large },
)}
role="img"
aria-label="Vennligst vent"
aria-label={texts[locale].ariaLabel}
aria-hidden={!!loadingText}
/>
{loadingText}
Expand All @@ -23,11 +31,14 @@ Spinner.propTypes = {
immediate: bool,
large: bool,
loadingText: node,
/** 'nb', 'nn', or 'en' */
locale: oneOf(['en', 'nb', 'nn']),
};

Spinner.defaultProps = {
immediate: false,
large: false,
locale: 'nb',
};

export default Spinner;
1 change: 1 addition & 0 deletions packages/ffe-spinner-react/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface SpinnerProps extends React.ComponentProps<'span'> {
immediate?: boolean;
large?: boolean;
loadingText: React.ReactNode;
locale?: 'en' | 'nb' | 'nn';
}

declare class Spinner extends React.Component<SpinnerProps, any> {}
Expand Down
11 changes: 11 additions & 0 deletions packages/ffe-spinner-react/src/texts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const nb = {
ariaLabel: 'Vennligst vent',
};
const nn = {
ariaLabel: 'Ver vennleg og vent',
};
const en = {
ariaLabel: 'Please wait',
};

export default { nb, nn, en };

0 comments on commit 8bb8724

Please sign in to comment.