1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-29 23:12:39 +01:00

Convert IconButton to Typescript

This commit is contained in:
Treycos 2024-08-27 06:41:10 +02:00 committed by GitHub
parent cfa2f4d4c6
commit f033799d7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 59 deletions

View File

@ -1,59 +0,0 @@
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import Icon from 'Components/Icon';
import translate from 'Utilities/String/translate';
import Link from './Link';
import styles from './IconButton.css';
function IconButton(props) {
const {
className,
iconClassName,
name,
kind,
size,
isSpinning,
isDisabled,
...otherProps
} = props;
return (
<Link
className={classNames(
className,
isDisabled && styles.isDisabled
)}
aria-label={translate('TableOptionsButton')}
isDisabled={isDisabled}
{...otherProps}
>
<Icon
className={iconClassName}
name={name}
kind={kind}
size={size}
isSpinning={isSpinning}
/>
</Link>
);
}
IconButton.propTypes = {
...Link.propTypes,
className: PropTypes.string.isRequired,
iconClassName: PropTypes.string,
kind: PropTypes.string,
name: PropTypes.object.isRequired,
size: PropTypes.number,
title: PropTypes.string,
isSpinning: PropTypes.bool,
isDisabled: PropTypes.bool
};
IconButton.defaultProps = {
className: styles.button,
size: 12
};
export default IconButton;

View File

@ -0,0 +1,41 @@
import classNames from 'classnames';
import React from 'react';
import Icon, { IconProps } from 'Components/Icon';
import translate from 'Utilities/String/translate';
import Link, { LinkProps } from './Link';
import styles from './IconButton.css';
export interface IconButtonProps
extends Omit<LinkProps, 'name' | 'kind'>,
Pick<IconProps, 'name' | 'kind' | 'size' | 'isSpinning'> {
iconClassName?: IconProps['className'];
}
export default function IconButton({
className = styles.button,
iconClassName,
name,
kind,
size = 12,
isSpinning,
...otherProps
}: IconButtonProps) {
return (
<Link
className={classNames(
className,
otherProps.isDisabled && styles.isDisabled
)}
aria-label={translate('TableOptionsButton')}
{...otherProps}
>
<Icon
className={iconClassName}
name={name}
kind={kind}
size={size}
isSpinning={isSpinning}
/>
</Link>
);
}