Skip to content

Commit

Permalink
Upgrade components to better structure
Browse files Browse the repository at this point in the history
  • Loading branch information
drublic committed Nov 22, 2020
1 parent de84694 commit 8adeeab
Show file tree
Hide file tree
Showing 28 changed files with 97 additions and 122 deletions.
30 changes: 0 additions & 30 deletions src/AddButton/AddButton.tsx

This file was deleted.

File renamed without changes.
31 changes: 30 additions & 1 deletion src/AddButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
import AddButton from "./AddButton";
import React, { FunctionComponent } from "react";
import { Fab, Theme, makeStyles } from "@material-ui/core";
import AddIcon from "@material-ui/icons/Add";

const useStyles = makeStyles((theme: Theme) => ({
button: {
position: "fixed",
right: theme.spacing(3),
bottom: theme.spacing(3),
},
}));

type AddButtonProps = {
onClick: (...args: any[]) => any;
};

const AddButton: FunctionComponent<AddButtonProps> = ({ onClick }) => {
const classes = useStyles();

return (
<Fab
color="secondary"
aria-label="add"
className={classes.button}
onClick={onClick}
>
<AddIcon />
</Fab>
);
};

export default AddButton;
File renamed without changes.
3 changes: 0 additions & 3 deletions src/AppContainer/index.ts

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion src/Base/index.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeStyles, Theme } from "@material-ui/core";
import { DRAWER_WIDTH } from "../Drawer/Drawer";
import { DRAWER_WIDTH } from "../Drawer";

const useStyles = makeStyles((theme: Theme) => ({
"@global html": {
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions src/Base/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/Base/Base.tsx → src/Base/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FunctionComponent, useState } from "react";
import * as H from "history";
import classNames from "classnames";
import { MenuDataItem } from "../Menu/Menu";
import { MenuDataItem } from "../Menu";
import Drawer from "../Drawer";
import Header from "../Header";
import useStyles from "./index.styles";
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions src/Confirm/index.ts

This file was deleted.

File renamed without changes.
3 changes: 0 additions & 3 deletions src/Dashboard/index.ts

This file was deleted.

File renamed without changes.
65 changes: 0 additions & 65 deletions src/Drawer/Drawer.tsx

This file was deleted.

File renamed without changes.
64 changes: 63 additions & 1 deletion src/Drawer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
import Drawer from "./Drawer";
import React from "react";
import {
Drawer as MaterialDrawer,
Divider,
IconButton,
Theme,
} from "@material-ui/core";
import ChevronLeftIcon from "@material-ui/icons/ChevronLeft";
import Menu from "../Menu";
import { MenuDataItem } from "../Menu";
import { makeStyles } from "@material-ui/styles";

export const DRAWER_WIDTH = 240;
const useStyles = makeStyles((theme: Theme) => ({
drawerPaper: {
width: DRAWER_WIDTH,
},

drawerHeader: {
display: "flex",
alignItems: "center",
justifyContent: "flex-end",
padding: "0 8px",
height: theme.spacing(8),
},
}));

type DrawerProps = {
data: MenuDataItem[];
isOpen?: boolean;
onClose: (...args: any[]) => any;
redirectTo: (...args: any[]) => any;
};

const Drawer: React.SFC<DrawerProps> = ({
data,
isOpen = false,
onClose,
redirectTo,
}) => {
const classes = useStyles();

return (
<MaterialDrawer
variant="persistent"
classes={{
paper: classes.drawerPaper,
}}
anchor="left"
open={isOpen}
>
<div className={classes.drawerHeader}>
<IconButton onClick={onClose}>
<ChevronLeftIcon />
</IconButton>
</div>

<Divider />

<Menu data={data} redirectTo={redirectTo} />
</MaterialDrawer>
);
};

export default Drawer;
File renamed without changes.
3 changes: 0 additions & 3 deletions src/Header/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/Header/Header.tsx → src/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Typography,
} from "@material-ui/core";
import MenuIcon from "@material-ui/icons/Menu";
import { DRAWER_WIDTH } from "../Drawer/Drawer";
import { DRAWER_WIDTH } from "../Drawer";

const useStyles = makeStyles((theme: Theme) => ({
appBar: {
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions src/Menu/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions src/Tabs/index.ts

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion src/tests/data/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import BugIcon from "@material-ui/icons/BugReport";
import { MenuDataItem } from "../../Menu/Menu";
import { MenuDataItem } from "../../Menu";

const menu: MenuDataItem[] = [
{
Expand Down

0 comments on commit 8adeeab

Please sign in to comment.