Skip to content

Commit 278b7e5

Browse files
committed
refactor: .href -> .path
update: JSdocs
1 parent e9eb120 commit 278b7e5

File tree

11 files changed

+47128
-10255
lines changed

11 files changed

+47128
-10255
lines changed

package-lock.json

Lines changed: 36569 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AppAlert/AppAlert.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import clsx from 'clsx';
22
import { Theme, makeStyles } from '@material-ui/core/styles';
33
import MuiAlert, { AlertProps as MuiAlertProps } from '@material-ui/lab/Alert';
44

5+
/**
6+
* Note: You can change these const to control default appearance of the AppAlert component
7+
*/
58
const APP_ALERT_SEVERITY = 'info'; // 'error' | 'info'| 'success' | 'warning'
69
const APP_ALERT_VARIANT = 'standard'; // 'filled' | 'outlined' | 'standard'
10+
const APP_ALERT_ELEVATION = 5;
711

812
const useStyles = makeStyles((theme: Theme) => ({
913
root: {
@@ -18,14 +22,15 @@ const useStyles = makeStyles((theme: Theme) => ({
1822
const AppAlert: React.FC<MuiAlertProps> = ({
1923
severity = APP_ALERT_SEVERITY,
2024
variant = APP_ALERT_VARIANT,
25+
elevation = APP_ALERT_ELEVATION,
2126
className,
2227
onClose,
2328
...restOfProps
2429
}) => {
2530
const classes = useStyles();
2631
const classRoot = clsx(classes.root, className);
2732

28-
return <MuiAlert className={classRoot} severity={severity} variant={variant} onClose={onClose} {...restOfProps} />;
33+
return <MuiAlert className={classRoot} severity={severity} variant={variant} elevation={elevation} onClose={onClose} {...restOfProps} />;
2934
};
3035

3136
export default AppAlert;

src/components/AppButton/AppButton.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function testButtonColor(colorName: string, expectedClassName = colorName, ignor
1818

1919
let button = await span.closest('button'); // parent <button> element
2020
expect(button).toBeDefined();
21+
// console.log('button.className:', button?.className)
2122
if (!ignoreClassName) {
2223
expect(button?.className?.includes(`makeStyles-${expectedClassName}`)).toBeTruthy(); // There is "makeStyles-[expectedClassName]-xxx" class
2324
}

src/components/AppButton/AppButton.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import Box from '@material-ui/core/Box';
44
import Button, { ButtonProps } from '@material-ui/core/Button';
55
import { buttonStylesByNames, ColorName } from '../../utils/style';
66

7+
/**
8+
* Note: You can change these const to control default appearance of the AppButton component
9+
*/
710
const APP_BUTTON_VARIANT = 'contained'; // | 'text' | 'outlined'
11+
const APP_BUTTON_MARGIN = 1;
812

913
const useStyles = makeStyles((theme: Theme) => ({
1014
box: {
@@ -31,24 +35,24 @@ interface Props extends Omit<ButtonProps, 'color'> {
3135
}
3236

3337
/**
34-
* Application styled Material UI Button
38+
* Application styled Material UI Button with Box around to specify margins using props
3539
* @class AppButton
3640
* @param {string} [color] - name of color from Material UI palette 'primary', 'secondary', 'warning', and so on
3741
* @param {string} [children] - content to render, overrides .label and .text
3842
* @param {string} [label] - text to render, alternate to .text
3943
* @param {string} [text] - text to render, alternate to .label
4044
*/
4145
const AppButton: React.FC<Props> = ({
42-
className,
4346
children,
47+
className,
4448
color = 'default',
4549
label,
46-
text,
4750
m = 0,
48-
mt = 1,
49-
mb = 1,
50-
ml = 1,
51-
mr = 1,
51+
mt = APP_BUTTON_MARGIN,
52+
mb = APP_BUTTON_MARGIN,
53+
ml = APP_BUTTON_MARGIN,
54+
mr = APP_BUTTON_MARGIN,
55+
text,
5256
underline = 'none',
5357
...restOfProps
5458
}) => {

src/components/SideBar/SideBarNavigation.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ const useStyles = makeStyles((theme: Theme) => ({
3535
}));
3636

3737
/**
38-
* Renders list of Navigation Items for SideBar
39-
* @param {array} props.links - list of objects to render as navigation links
38+
* Renders list of Navigation Items inside SideBar
39+
* @param {string} [prop.className] - optional className for styling
40+
* @param {array} props.items - list of objects to render as navigation links
4041
* @param {boolean} [props.showIcons] - icons in links are visible when true
4142
* @param {func} [props.afterLinkClink] - optional callback called when some link was clicked
4243
*/
@@ -59,11 +60,11 @@ const SideBarNavigation: React.FC<Props> = ({
5960
<nav>
6061
<List className={classRoot} {...restOfProps}>
6162
{items.map((link) => (
62-
<ListItem key={`${link.title}-${link.href}`} className={classes.item} disableGutters>
63+
<ListItem key={`${link.title}-${link.path}`} className={classes.item} disableGutters>
6364
<Button
6465
className={classes.button}
6566
component={SideBarLink}
66-
to={link.href as string}
67+
to={link.path as string}
6768
onClick={afterLinkClick}
6869
>
6970
<div className={classes.iconOrMargin}>{showIcons && link.icon ? <AppIcon icon={link.icon} /> : null}</div>

src/components/TopBar/TopBar.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import clsx from 'clsx';
2-
import { Theme, makeStyles } from '@material-ui/core/styles';
3-
import AppBar from '@material-ui/core/AppBar';
4-
import Toolbar from '@material-ui/core/Toolbar';
5-
import Typography from '@material-ui/core/Typography';
2+
import { makeStyles, Theme, AppBar, Toolbar, Typography } from '@material-ui/core';
63
import AppIconButton from '../AppIconButton';
74

85
const useStyles = makeStyles((theme: Theme) => ({

src/components/UserInfo/UserInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface UserInfoProps {
3636
const UserInfo = ({ className, showAvatar = false, user, ...restOfProps }: UserInfoProps) => {
3737
const classes = useStyles();
3838

39-
const fullName = [user?.first_name || '', user?.last_name || ''].join(' ').trim();
39+
const fullName = user?.name || [user?.nameFirst || '', user?.nameLast || ''].join(' ').trim();
4040
const srcAvatar = user?.avatar ? user?.avatar : undefined;
4141
const userPhoneOrEmail = user?.phone || (user?.email as string);
4242

src/routes/Layout/PrivateLayout.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,30 @@ function updateDocumentTitle(title = '') {
5555
const SIDE_BAR_PRIVATE_ITEMS: Array<LinkToPage> = [
5656
{
5757
title: 'Home',
58-
href: '/',
58+
path: '/',
5959
icon: 'home',
6060
},
6161
{
6262
title: 'Profile',
63-
href: '/user',
63+
path: '/user',
6464
icon: 'account',
6565
},
6666
{
6767
title: 'About',
68-
href: '/about',
68+
path: '/about',
6969
icon: 'info',
7070
},
7171
{
7272
title: 'Dev Tools',
73-
href: '/dev',
73+
path: '/dev',
7474
icon: 'settings',
7575
},
7676
];
7777

7878
/**
7979
* Renders "Private Layout" composition
8080
*/
81-
const Layout: React.FC = ({ children }) => {
81+
const PrivateLayout: React.FC = ({ children }) => {
8282
const [state] = useAppStore();
8383
const [openSideBar, setOpenSideBar] = useState(false);
8484
const theme = useTheme();
@@ -131,4 +131,4 @@ const Layout: React.FC = ({ children }) => {
131131
);
132132
};
133133

134-
export default Layout;
134+
export default PrivateLayout;

src/routes/Layout/PublicLayout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ const useStyles = makeStyles((theme: Theme) => ({
4242
const SIDE_BAR_PUBLIC_ITEMS: Array<LinkToPage> = [
4343
{
4444
title: 'Log In',
45-
href: '/auth/login',
45+
path: '/auth/login',
4646
icon: 'login',
4747
},
4848
{
4949
title: 'Sign Up',
50-
href: '/auth/signup',
50+
path: '/auth/signup',
5151
icon: 'signup',
5252
},
5353
{
5454
title: 'About',
55-
href: '/about',
55+
path: '/about',
5656
icon: 'info',
5757
},
5858
];

src/utils/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export type ObjectPropByName = Record<string, any>;
66
*/
77
export declare interface LinkToPage {
88
title?: string;
9-
href?: string;
9+
path?: string;
1010
icon?: string;
1111
}

0 commit comments

Comments
 (0)