Skip to content

Commit 48706b9

Browse files
refactor(Icon): migrate to ts
1 parent 83e0594 commit 48706b9

File tree

26 files changed

+65
-59
lines changed

26 files changed

+65
-59
lines changed

src/components/BasicNodeViewer/BasicNodeViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import cn from 'bem-cn-lite';
22

33
import EntityStatus from '../EntityStatus/EntityStatus';
44
import {Tags} from '../Tags';
5-
import Icon from '../Icon/Icon';
5+
import {Icon} from '../Icon';
66

77
import './BasicNodeViewer.scss';
88

src/components/ClusterInfo/ClusterInfo.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import {formatStorageValues} from '../../utils';
2424
//@ts-ignore
2525
import {TxAllocator} from '../../utils/constants';
2626
import {AutoFetcher} from '../../utils/autofetcher';
27-
//@ts-ignore
28-
import Icon from '../Icon/Icon';
27+
import {Icon} from '../Icon';
2928
import {setHeader} from '../../store/reducers/header';
3029
import routes, {CLUSTER_PAGES, createHref} from '../../routes';
3130

src/components/CopyToClipboard/CopyToClipboard.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Button, CopyToClipboard as CopyToClipboardUiKit} from '@gravity-ui/uikit';
22
import createToast from '../../utils/createToast';
3-
//@ts-ignore
4-
import Icon from '../Icon/Icon';
3+
import {Icon} from '../Icon';
54

65
interface CopyToClipboardProps {
76
text: string;

src/components/CriticalActionDialog/CriticalActionDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {useState} from 'react';
22
import PropTypes from 'prop-types';
33
import cn from 'bem-cn-lite';
44
import {Dialog} from '@gravity-ui/uikit';
5-
import Icon from '../Icon/Icon';
5+
import {Icon} from '../Icon';
66

77
import './CriticalActionDialog.scss';
88

src/components/EmptyState/EmptyState.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {ReactNode} from 'react';
22
import cn from 'bem-cn-lite';
33

4-
import Icon from '../Icon/Icon';
4+
import {Icon} from '../Icon';
55

66
import './EmptyState.scss';
77

src/components/EnableFullscreenButton/EnableFullscreenButton.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Button} from '@gravity-ui/uikit';
22
import {useDispatch} from 'react-redux';
33
import {enableFullscreen} from '../../store/reducers/fullscreen';
4-
import Icon from '../Icon/Icon';
4+
import {Icon} from '../Icon';
55

66
interface EnableFullscreenButtonProps {
77
disabled?: boolean;
@@ -13,7 +13,12 @@ function EnableFullscreenButton({disabled}: EnableFullscreenButtonProps) {
1313
dispatch(enableFullscreen());
1414
};
1515
return (
16-
<Button onClick={onEnableFullscreen} view="flat-secondary" disabled={disabled} title='Fullscreen'>
16+
<Button
17+
onClick={onEnableFullscreen}
18+
view="flat-secondary"
19+
disabled={disabled}
20+
title="Fullscreen"
21+
>
1722
<Icon name="enableFullscreen" viewBox={'0 0 16 16'} height={16} width={16} />
1823
</Button>
1924
);

src/components/Fullscreen/Fullscreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import cn from 'bem-cn-lite';
66

77
import {useDispatch} from 'react-redux';
88
import {disableFullscreen} from '../../store/reducers/fullscreen';
9-
import Icon from '../Icon/Icon';
9+
import {Icon} from '../Icon';
1010

1111
import './Fullscreen.scss';
1212

src/components/Icon/Icon.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/components/Icon/Icon.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {Icon as UiKitIcon} from '@gravity-ui/uikit';
2+
3+
interface IconProps {
4+
name: string;
5+
height?: number | string;
6+
width?: number | string;
7+
viewBox?: string;
8+
className?: string;
9+
onClick?: (event: React.MouseEvent<SVGElement, MouseEvent>) => void;
10+
}
11+
12+
export const Icon = ({
13+
name,
14+
height = 16,
15+
width = 16,
16+
viewBox = '0 0 16 16',
17+
className,
18+
onClick,
19+
}: IconProps) => {
20+
return (
21+
<UiKitIcon
22+
// @ts-expect-error
23+
// Both url and id strings are required in this uikit component.
24+
// However, if no url provided, component uses id, which is what we need.
25+
// If it is fixed in uikit it could be safely removed
26+
data={{id: `icon.${name}`, viewBox}}
27+
height={height}
28+
width={width}
29+
className={className}
30+
onClick={onClick}
31+
/>
32+
);
33+
};

src/components/Icon/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Icon';

0 commit comments

Comments
 (0)