diff --git a/frontend/src/Activity/Queue/QueueStatus.tsx b/frontend/src/Activity/Queue/QueueStatus.tsx index 64d802df8..2bd7f6d79 100644 --- a/frontend/src/Activity/Queue/QueueStatus.tsx +++ b/frontend/src/Activity/Queue/QueueStatus.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import Icon from 'Components/Icon'; +import Icon, { IconProps } from 'Components/Icon'; import Popover from 'Components/Tooltip/Popover'; import { icons, kinds } from 'Helpers/Props'; import TooltipPosition from 'Helpers/Props/TooltipPosition'; @@ -61,7 +61,7 @@ function QueueStatus(props: QueueStatusProps) { // status === 'downloading' let iconName = icons.DOWNLOADING; - let iconKind = kinds.DEFAULT; + let iconKind: IconProps['kind'] = kinds.DEFAULT; let title = translate('Downloading'); if (status === 'paused') { diff --git a/frontend/src/Components/Icon.js b/frontend/src/Components/Icon.js deleted file mode 100644 index d200b8c08..000000000 --- a/frontend/src/Components/Icon.js +++ /dev/null @@ -1,73 +0,0 @@ -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import React, { PureComponent } from 'react'; -import { kinds } from 'Helpers/Props'; -import styles from './Icon.css'; - -class Icon extends PureComponent { - - // - // Render - - render() { - const { - containerClassName, - className, - name, - kind, - size, - title, - isSpinning, - ...otherProps - } = this.props; - - const icon = ( - - ); - - if (title) { - return ( - - {icon} - - ); - } - - return icon; - } -} - -Icon.propTypes = { - containerClassName: PropTypes.string, - className: PropTypes.string, - name: PropTypes.object.isRequired, - kind: PropTypes.string.isRequired, - size: PropTypes.number.isRequired, - title: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), - isSpinning: PropTypes.bool.isRequired, - fixedWidth: PropTypes.bool.isRequired -}; - -Icon.defaultProps = { - kind: kinds.DEFAULT, - size: 14, - isSpinning: false, - fixedWidth: false -}; - -export default Icon; diff --git a/frontend/src/Components/Icon.tsx b/frontend/src/Components/Icon.tsx new file mode 100644 index 000000000..86ff57a30 --- /dev/null +++ b/frontend/src/Components/Icon.tsx @@ -0,0 +1,59 @@ +import { + FontAwesomeIcon, + FontAwesomeIconProps, +} from '@fortawesome/react-fontawesome'; +import classNames from 'classnames'; +import React, { ComponentProps } from 'react'; +import { kinds } from 'Helpers/Props'; +import styles from './Icon.css'; + +export interface IconProps + extends Omit< + FontAwesomeIconProps, + 'icon' | 'spin' | 'name' | 'title' | 'size' + > { + containerClassName?: ComponentProps<'span'>['className']; + name: FontAwesomeIconProps['icon']; + kind?: Extract<(typeof kinds.all)[number], keyof typeof styles>; + size?: number; + isSpinning?: FontAwesomeIconProps['spin']; + title?: string | (() => string); +} + +export default function Icon({ + containerClassName, + className, + name, + kind = kinds.DEFAULT, + size = 14, + title, + isSpinning = false, + fixedWidth = false, + ...otherProps +}: IconProps) { + const icon = ( + + ); + + if (title) { + return ( + + {icon} + + ); + } + + return icon; +} diff --git a/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx b/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx index 402be769a..d4f234fa3 100644 --- a/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx +++ b/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx @@ -525,7 +525,7 @@ function InteractiveImportRow(props: InteractiveImportRowProps) { <> {indexerFlags ? ( } + anchor={} title={translate('IndexerFlags')} body={} position={tooltipPositions.LEFT} diff --git a/frontend/src/InteractiveSearch/InteractiveSearchRow.tsx b/frontend/src/InteractiveSearch/InteractiveSearchRow.tsx index 49b8d7823..d860b7fb9 100644 --- a/frontend/src/InteractiveSearch/InteractiveSearchRow.tsx +++ b/frontend/src/InteractiveSearch/InteractiveSearchRow.tsx @@ -264,7 +264,7 @@ function InteractiveSearchRow(props: InteractiveSearchRowProps) { {indexerFlags ? ( } + anchor={} title={translate('IndexerFlags')} body={} position={tooltipPositions.LEFT} diff --git a/frontend/src/Series/Index/Overview/SeriesIndexOverviewInfoRow.tsx b/frontend/src/Series/Index/Overview/SeriesIndexOverviewInfoRow.tsx index 11ab1b7f7..b23b915c8 100644 --- a/frontend/src/Series/Index/Overview/SeriesIndexOverviewInfoRow.tsx +++ b/frontend/src/Series/Index/Overview/SeriesIndexOverviewInfoRow.tsx @@ -1,11 +1,10 @@ -import { IconDefinition } from '@fortawesome/free-regular-svg-icons'; import React from 'react'; -import Icon from 'Components/Icon'; +import Icon, { IconProps } from 'Components/Icon'; import styles from './SeriesIndexOverviewInfoRow.css'; interface SeriesIndexOverviewInfoRowProps { title?: string; - iconName?: IconDefinition; + iconName: IconProps['name']; label: string | null; } diff --git a/frontend/src/System/Status/Health/Health.tsx b/frontend/src/System/Status/Health/Health.tsx index 281d95ac6..087146740 100644 --- a/frontend/src/System/Status/Health/Health.tsx +++ b/frontend/src/System/Status/Health/Health.tsx @@ -3,7 +3,7 @@ import { useDispatch, useSelector } from 'react-redux'; import AppState from 'App/State/AppState'; import Alert from 'Components/Alert'; import FieldSet from 'Components/FieldSet'; -import Icon from 'Components/Icon'; +import Icon, { IconProps } from 'Components/Icon'; import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; @@ -97,7 +97,7 @@ function Health() { {items.map((item) => { const source = item.source; - let kind = kinds.WARNING; + let kind: IconProps['kind'] = kinds.WARNING; switch (item.type.toLowerCase()) { case 'error': kind = kinds.DANGER; diff --git a/frontend/src/System/Tasks/Queued/QueuedTaskRow.tsx b/frontend/src/System/Tasks/Queued/QueuedTaskRow.tsx index 4511bcbf4..66d762039 100644 --- a/frontend/src/System/Tasks/Queued/QueuedTaskRow.tsx +++ b/frontend/src/System/Tasks/Queued/QueuedTaskRow.tsx @@ -2,7 +2,7 @@ import moment from 'moment'; import React, { useCallback, useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { CommandBody } from 'Commands/Command'; -import Icon from 'Components/Icon'; +import Icon, { IconProps } from 'Components/Icon'; import IconButton from 'Components/Link/IconButton'; import ConfirmModal from 'Components/Modal/ConfirmModal'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; @@ -19,7 +19,10 @@ import translate from 'Utilities/String/translate'; import QueuedTaskRowNameCell from './QueuedTaskRowNameCell'; import styles from './QueuedTaskRow.css'; -function getStatusIconProps(status: string, message: string | undefined) { +function getStatusIconProps( + status: string, + message: string | undefined +): IconProps { const title = titleCase(status); switch (status) {