mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-25 02:30:20 +02:00
Refactoring: Spinner button component
This commit is contained in:
parent
e1cbc4a782
commit
bf4e7143f2
@ -1,58 +0,0 @@
|
||||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import Icon from 'Components/Icon';
|
||||
import { icons } from 'Helpers/Props';
|
||||
import Button from './Button';
|
||||
import styles from './SpinnerButton.css';
|
||||
|
||||
function SpinnerButton(props) {
|
||||
const {
|
||||
className,
|
||||
isSpinning,
|
||||
isDisabled,
|
||||
spinnerIcon,
|
||||
children,
|
||||
...otherProps
|
||||
} = props;
|
||||
|
||||
return (
|
||||
<Button
|
||||
className={classNames(
|
||||
className,
|
||||
styles.button,
|
||||
isSpinning && styles.isSpinning
|
||||
)}
|
||||
isDisabled={isDisabled || isSpinning}
|
||||
{...otherProps}
|
||||
>
|
||||
<span className={styles.spinnerContainer}>
|
||||
<Icon
|
||||
className={styles.spinner}
|
||||
name={spinnerIcon}
|
||||
isSpinning={true}
|
||||
/>
|
||||
</span>
|
||||
|
||||
<span className={styles.label}>
|
||||
{children}
|
||||
</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
SpinnerButton.propTypes = {
|
||||
...Button.Props,
|
||||
className: PropTypes.string.isRequired,
|
||||
isSpinning: PropTypes.bool.isRequired,
|
||||
isDisabled: PropTypes.bool,
|
||||
spinnerIcon: PropTypes.object.isRequired,
|
||||
children: PropTypes.node
|
||||
};
|
||||
|
||||
SpinnerButton.defaultProps = {
|
||||
className: styles.button,
|
||||
spinnerIcon: icons.SPINNER
|
||||
};
|
||||
|
||||
export default SpinnerButton;
|
40
frontend/src/Components/Link/SpinnerButton.tsx
Normal file
40
frontend/src/Components/Link/SpinnerButton.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
import { FontAwesomeIconProps } from '@fortawesome/react-fontawesome';
|
||||
import classNames from 'classnames';
|
||||
import React from 'react';
|
||||
import Icon from 'Components/Icon';
|
||||
import { icons } from 'Helpers/Props';
|
||||
import Button, { ButtonProps } from './Button';
|
||||
import styles from './SpinnerButton.css';
|
||||
|
||||
export interface SpinnerButtonProps extends ButtonProps {
|
||||
isSpinning: boolean;
|
||||
isDisabled?: boolean;
|
||||
spinnerIcon?: FontAwesomeIconProps['icon'];
|
||||
}
|
||||
|
||||
export default function SpinnerButton({
|
||||
className = styles.button,
|
||||
isSpinning,
|
||||
isDisabled,
|
||||
spinnerIcon = icons.SPINNER,
|
||||
children,
|
||||
...otherProps
|
||||
}: SpinnerButtonProps) {
|
||||
return (
|
||||
<Button
|
||||
className={classNames(
|
||||
className,
|
||||
styles.button,
|
||||
isSpinning && styles.isSpinning
|
||||
)}
|
||||
isDisabled={isDisabled || isSpinning}
|
||||
{...otherProps}
|
||||
>
|
||||
<span className={styles.spinnerContainer}>
|
||||
<Icon className={styles.spinner} name={spinnerIcon} isSpinning={true} />
|
||||
</span>
|
||||
|
||||
<span className={styles.label}>{children}</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user