Skip to content

Commit 304a243

Browse files
committed
refactor: FC -> FunctionComponent
1 parent 4f4b168 commit 304a243

File tree

13 files changed

+93
-63
lines changed

13 files changed

+93
-63
lines changed

src/components/AppAlert/AppAlert.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FunctionComponent } from 'react';
12
import clsx from 'clsx';
23
import { Theme } from '@mui/material/styles';
34
import makeStyles from '@mui/styles/makeStyles';
@@ -20,7 +21,7 @@ const useStyles = makeStyles((theme: Theme) => ({
2021
/**
2122
* Application styled Alert component
2223
*/
23-
const AppAlert: React.FC<MuiAlertProps> = ({
24+
const AppAlert: FunctionComponent<MuiAlertProps> = ({
2425
severity = APP_ALERT_SEVERITY,
2526
variant = APP_ALERT_VARIANT,
2627
elevation = APP_ALERT_ELEVATION,

src/components/AppButton/AppButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FunctionComponent } from 'react';
12
import clsx from 'clsx';
23
import { Theme } from '@mui/material/styles';
34
import makeStyles from '@mui/styles/makeStyles';
@@ -43,7 +44,7 @@ interface Props extends Omit<ButtonProps, 'color'> {
4344
* @param {string} [label] - text to render, alternate to .text
4445
* @param {string} [text] - text to render, alternate to .label
4546
*/
46-
const AppButton: React.FC<Props> = ({
47+
const AppButton: FunctionComponent<Props> = ({
4748
children,
4849
className,
4950
color = 'default',

src/components/AppForm/AppForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactNode, FormHTMLAttributes } from 'react';
1+
import { ReactNode, FormHTMLAttributes, FunctionComponent } from 'react';
22
import { Box, Grid } from '@mui/material';
33
import { Theme } from '@mui/material/styles';
44
import makeStyles from '@mui/styles/makeStyles';
@@ -17,7 +17,7 @@ interface Props extends FormHTMLAttributes<HTMLFormElement> {
1717
/**
1818
* Application styled Form container
1919
*/
20-
const AppForm: React.FC<Props> = ({ children, ...resOfProps }) => {
20+
const AppForm: FunctionComponent<Props> = ({ children, ...resOfProps }) => {
2121
const classes = useStyles();
2222
return (
2323
<form {...resOfProps}>

src/components/AppIcon/AppIcon.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FunctionComponent } from 'react';
12
import { SvgIcon } from '@mui/material';
23
// SVG assets
34
import { ReactComponent as LogoIcon } from './logo.svg';
@@ -53,16 +54,17 @@ const ICONS: Record<string, React.ComponentType> = {
5354
notifications: NotificationsIcon,
5455
};
5556

57+
interface Props {
58+
name?: string; // Icon's name
59+
icon?: string; // Icon's name alternate prop
60+
}
61+
5662
/**
5763
* Renders SVG icon by given Icon name
5864
* @param {string} [props.name] - name of the Icon to render
5965
* @param {string} [props.icon] - name of the Icon to render
6066
*/
61-
interface Props {
62-
name?: string; // Icon's name
63-
icon?: string; // Icon's name alternate prop
64-
}
65-
const AppIcon: React.FC<Props> = ({ name, icon, ...restOfProps }) => {
67+
const AppIcon: FunctionComponent<Props> = ({ name, icon, ...restOfProps }) => {
6668
const iconName = (name || icon || 'default').trim().toLowerCase();
6769
const ComponentToRender = ICONS[iconName] || DefaultIcon;
6870
return <ComponentToRender {...restOfProps} />;

src/components/AppIconButton/AppIconButton.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FunctionComponent } from 'react';
12
import clsx from 'clsx';
23
import { Theme } from '@mui/material/styles';
34
import makeStyles from '@mui/styles/makeStyles';
@@ -19,10 +20,6 @@ function getValidMuiColor(color: string | undefined): PropTypes.Color | undefine
1920
}
2021
}
2122

22-
/**
23-
* Renders Material UI IconButton with SVG icon by given Name
24-
* @param {string} [props.icon] - name of Icon to render inside the IconButton
25-
*/
2623
interface Props extends Omit<IconButtonProps, 'color'> {
2724
color?: ColorName | 'inherit';
2825
icon?: string;
@@ -31,7 +28,20 @@ interface Props extends Omit<IconButtonProps, 'color'> {
3128
to?: string; // Link prop
3229
href?: string; // Link prop
3330
}
34-
const AppIconButton: React.FC<Props> = ({ color, className, children, disabled, icon, title, ...restOfProps }) => {
31+
32+
/**
33+
* Renders Material UI IconButton with SVG icon by given Name
34+
* @param {string} [props.icon] - name of Icon to render inside the IconButton
35+
*/
36+
const AppIconButton: FunctionComponent<Props> = ({
37+
color,
38+
className,
39+
children,
40+
disabled,
41+
icon,
42+
title,
43+
...restOfProps
44+
}) => {
3545
const classes = useStyles();
3646
const classButton = clsx(classes[color as ColorName], className);
3747
const colorButton = getValidMuiColor(color);

src/components/SideBar/SideBar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback } from 'react';
1+
import { FunctionComponent, useCallback } from 'react';
22
import clsx from 'clsx';
33
import Divider from '@mui/material/Divider';
44
import Drawer, { DrawerProps } from '@mui/material/Drawer';
@@ -42,19 +42,19 @@ const useStyles = makeStyles((theme: Theme) => ({
4242
},
4343
}));
4444

45+
interface Props extends Pick<DrawerProps, 'anchor' | 'className' | 'open' | 'variant' | 'onClose'> {
46+
items: Array<LinkToPage>;
47+
}
4548
/**
4649
* Renders SideBar with Menu and User details
4750
* Actually for Authenticated users only, rendered in "Private Layout"
4851
* @param {string} [prop.anchor] - 'left' or 'right'
4952
* @param {string} [prop.className] - optional className for <div> tag
5053
* @param {boolean} props.open - the Drawer is visible when true
5154
* @param {string} props.variant - variant of the Drawer, one of 'permanent', 'persistent', 'temporary'
52-
* @param {func} [props.onClose] - called when the Drawer is closing
55+
* @param {function} [props.onClose] - called when the Drawer is closing
5356
*/
54-
interface Props extends Pick<DrawerProps, 'anchor' | 'className' | 'open' | 'variant' | 'onClose'> {
55-
items: Array<LinkToPage>;
56-
}
57-
const SideBar: React.FC<Props> = ({ anchor, className, open, variant, items, onClose, ...restOfProps }) => {
57+
const SideBar: FunctionComponent<Props> = ({ anchor, className, open, variant, items, onClose, ...restOfProps }) => {
5858
const [state, dispatch] = useAppStore();
5959
const classes = useStyles();
6060

src/components/SideBar/SideBarNavigation.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import makeStyles from '@mui/styles/makeStyles';
77
import AppIcon from '../AppIcon';
88
import SideBarLink from './SideBarLink';
99
import { LinkToPage } from '../../utils/type';
10+
import { FunctionComponent } from 'react';
1011

1112
const useStyles = makeStyles((theme: Theme) => ({
1213
root: {},
@@ -35,20 +36,21 @@ const useStyles = makeStyles((theme: Theme) => ({
3536
},
3637
}));
3738

38-
/**
39-
* Renders list of Navigation Items inside SideBar
40-
* @param {string} [prop.className] - optional className for styling
41-
* @param {array} props.items - list of objects to render as navigation links
42-
* @param {boolean} [props.showIcons] - icons in links are visible when true
43-
* @param {func} [props.afterLinkClink] - optional callback called when some link was clicked
44-
*/
4539
interface Props {
4640
className?: string;
4741
items: Array<LinkToPage>;
4842
showIcons?: boolean;
4943
afterLinkClick?: React.MouseEventHandler;
5044
}
51-
const SideBarNavigation: React.FC<Props> = ({
45+
46+
/**
47+
* Renders list of Navigation Items inside SideBar
48+
* @param {string} [prop.className] - optional className for styling
49+
* @param {array} props.items - list of objects to render as navigation links
50+
* @param {boolean} [props.showIcons] - icons in links are visible when true
51+
* @param {function} [props.afterLinkClink] - optional callback called when some link was clicked
52+
*/
53+
const SideBarNavigation: FunctionComponent<Props> = ({
5254
className,
5355
items,
5456
showIcons = false,

src/components/TopBar/TopBar.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FunctionComponent } from 'react';
12
import clsx from 'clsx';
23
import { Theme, AppBar, Toolbar, Typography } from '@mui/material';
34
import makeStyles from '@mui/styles/makeStyles';
@@ -26,17 +27,18 @@ const useStyles = makeStyles((theme: Theme) => ({
2627
buttons: {},
2728
}));
2829

29-
/**
30-
* Renders TopBar composition
31-
*/
3230
interface Props {
3331
className?: string;
3432
title?: string;
3533
isAuthenticated?: boolean;
3634
onMenu?: () => void;
3735
onNotifications?: () => void;
3836
}
39-
const TopBar: React.FC<Props> = ({
37+
38+
/**
39+
* Renders TopBar composition
40+
*/
41+
const TopBar: FunctionComponent<Props> = ({
4042
className,
4143
title = '',
4244
isAuthenticated,

src/components/dialogs/CommonDialog.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactNode, useCallback } from 'react';
1+
import { FunctionComponent, ReactNode, useCallback } from 'react';
22
import { Dialog, DialogActions, DialogContent, DialogProps } from '@mui/material';
33
import makeStyles from '@mui/styles/makeStyles';
44
import createStyles from '@mui/styles/createStyles';
@@ -13,11 +13,6 @@ const useStyles = makeStyles((theme) =>
1313
})
1414
);
1515

16-
/**
17-
* Shows generic "Common" dialog
18-
* @param {function} props.onConfirm - event for Confirm button, called as onConfirm(data)
19-
* @param {function} props.onClose - event for Close and Cancel buttons and the backdrop
20-
*/
2116
interface Props extends DialogProps {
2217
data?: unknown;
2318
title?: string;
@@ -29,7 +24,13 @@ interface Props extends DialogProps {
2924
onConfirm?: (data: unknown) => void;
3025
onClose?: (event: {}) => void;
3126
}
32-
const CommonDialog: React.FC<Props> = ({
27+
28+
/**
29+
* Shows generic "Common" dialog
30+
* @param {function} props.onConfirm - event for Confirm button, called as onConfirm(data)
31+
* @param {function} props.onClose - event for Close and Cancel buttons and the backdrop
32+
*/
33+
const CommonDialog: FunctionComponent<Props> = ({
3334
open = false, // Don't show dialog by default
3435
data, // optional data passed to onConfirm callback
3536
title = 'Missing title...',

src/components/dialogs/CompositionDialog.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactNode } from 'react';
1+
import { FunctionComponent, ReactNode } from 'react';
22
import { Box, Dialog, DialogActions, DialogContent, DialogProps } from '@mui/material';
33
import makeStyles from '@mui/styles/makeStyles';
44
import createStyles from '@mui/styles/createStyles';
@@ -11,16 +11,17 @@ const useStyles = makeStyles((theme) =>
1111
})
1212
);
1313

14-
/**
15-
* Makes composition of Content and Actions inside the Dialog.
16-
*/
1714
interface Props extends DialogProps {
1815
title?: string;
1916
content?: ReactNode;
2017
actions?: ReactNode;
2118
onClose?: (event: {}) => void;
2219
}
23-
const CompositionDialog: React.FC<Props> = ({
20+
21+
/**
22+
* Makes composition of Content and Actions inside the Dialog.
23+
*/
24+
const CompositionDialog: FunctionComponent<Props> = ({
2425
actions,
2526
open = false, // Don't show dialog by default
2627
children = null,

0 commit comments

Comments
 (0)