Skip to content

Commit d926726

Browse files
committed
🅾️ Added JSON data files, and rearranging some components
Signed-off-by: Srikant Sahoo <[email protected]>
1 parent 68e23fd commit d926726

36 files changed

+567
-132
lines changed

package-lock.json

+104-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/atomic/avatar.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from "react";
2+
import { makeStyles } from "@material-ui/core/styles";
3+
import Button from "@material-ui/core/Button";
4+
import { ICONS } from "../../utils/constants";
5+
import IconButton from "@material-ui/core/IconButton";
6+
import PositionedPopper from "./popper";
7+
import KeyShortcuts from "./keyShortcuts";
8+
import KEY_SHORTCUTS from "../../utils/keyShortcuts";
9+
import Theme from "../../utils/theme";
10+
import { ICONS_SVG } from "../../utils/theme";
11+
import IconWrapper from "./iconWrapper";
12+
import Avatar from "@material-ui/core/Avatar";
13+
14+
const useStyles = makeStyles((theme) => ({
15+
small: {
16+
width: theme.spacing(3),
17+
height: theme.spacing(3),
18+
},
19+
large: {
20+
width: theme.spacing(7),
21+
height: theme.spacing(7),
22+
},
23+
}));
24+
25+
// TODO: Add badges and avatars.js(which will contain a list of MetabAvatar)
26+
// and <AvatarGroup />(Material UI component)
27+
// Documentation: https://material-ui.com/components/avatars/
28+
29+
const MetabAvatar = (props) => {
30+
const classes = useStyles();
31+
const [anchorEl, setAnchorEl] = React.useState(null);
32+
33+
return (
34+
<>
35+
{props.type === "letter" ? (
36+
<Avatar className={classes.small} variant="square">
37+
H
38+
</Avatar> // classname - small | large, variant - square | rounded
39+
) : (
40+
<Avatar alt="Cindy Baker" src="/static/images/avatar/3.jpg" />
41+
)}
42+
</>
43+
);
44+
};
45+
46+
export default MetabAvatar;

src/components/atomic/avatars.js

Whitespace-only changes.

src/components/atomic/buttons.js renamed to src/components/atomic/button.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const useStyles = makeStyles((theme) => ({
3232
// -title,
3333
// extra sizes of icon
3434

35+
// TODO: This is ICON BUTTON but also create a normal button and its variants
3536
const MetabIconButton = (props) => {
3637
const classes = useStyles();
3738
const [anchorEl, setAnchorEl] = React.useState(null);
@@ -58,15 +59,13 @@ const MetabIconButton = (props) => {
5859
: handleMouseEnter("bottom")
5960
}
6061
onMouseLeave={handleMouseLeave()}
61-
title={props.title ? props.title : ""}
62-
>
62+
title={props.title ? props.title : ""}>
6363
{props?.showPopOver && props?.popOverContent ? (
6464
<PositionedPopper
6565
open={open}
6666
anchorEl={anchorEl}
6767
placement={placement}
68-
paperCSS={props?.paperCSS}
69-
>
68+
paperCSS={props?.paperCSS}>
7069
{props?.popOverContent ? (
7170
<>
7271
{props?.children?.name ? (
@@ -90,8 +89,7 @@ const MetabIconButton = (props) => {
9089
<img
9190
src={props.iconURL ? props.iconURL : ICONS[0]}
9291
alt={props.iconAltText ? props.iconAltText : "icon"}
93-
style={{ width: "15px", height: "15px" }}
94-
></img>
92+
style={{ width: "15px", height: "15px" }}></img>
9593
) : (
9694
<IconWrapper css={props.children?.css}>
9795
{props.children?.svg}

src/components/atomic/chip.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React from "react";
2+
import { makeStyles } from "@material-ui/core/styles";
3+
import Button from "@material-ui/core/Button";
4+
import { ICONS } from "../../utils/constants";
5+
import IconButton from "@material-ui/core/IconButton";
6+
import PositionedPopper from "./popper";
7+
import KeyShortcuts from "./keyShortcuts";
8+
import KEY_SHORTCUTS from "../../utils/keyShortcuts";
9+
import Theme from "../../utils/theme";
10+
import { ICONS_SVG } from "../../utils/theme";
11+
import IconWrapper from "./iconWrapper";
12+
import { Chip } from "@material-ui/core";
13+
import DoneIcon from "@material-ui/icons/Done";
14+
15+
const useStyles = makeStyles((theme) => ({
16+
button: {
17+
width: "fit-content",
18+
height: "fit-content",
19+
},
20+
}));
21+
22+
// MetabChip contains logic for one chip
23+
// TODO: Remove excessive import statements
24+
25+
const MetabChip = (props) => {
26+
const classes = useStyles();
27+
const [anchorEl, setAnchorEl] = React.useState(null);
28+
29+
const handleDelete = () => {
30+
console.info("You clicked the delete icon.");
31+
};
32+
33+
const handleClick = () => {
34+
console.info("You clicked the Chip.");
35+
};
36+
37+
// TODO: onclick, clickable property, onDelete, Avatar(with img & letter)
38+
// Documentation: https://material-ui.com/components/chips/#chip
39+
40+
return (
41+
<Chip
42+
size={props?.size ? props.size : "small"} // small or medium
43+
variant={props?.variant ? props.variant : "default"} // default or outlined
44+
label={props?.label ? props.label : "chip"}
45+
avatar={"wda"} // TODO: CustomAvatar <Avatar alt="Natacha" src="/static/images/avatar/1.jpg" />
46+
onClick={handleClick}
47+
onDelete={handleDelete}
48+
deleteIcon={<DoneIcon />}
49+
icon={<DoneIcon />}
50+
href={props?.href ? props.href : "#chip"}
51+
/>
52+
);
53+
};
54+
55+
export default MetabChip;

src/components/atomic/chips.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from "react";
2+
import { makeStyles } from "@material-ui/core/styles";
3+
import Chip from "@material-ui/core/Chip";
4+
import Paper from "@material-ui/core/Paper";
5+
import TagFacesIcon from "@material-ui/icons/TagFaces";
6+
7+
const useStyles = makeStyles((theme) => ({
8+
root: {
9+
display: "flex",
10+
justifyContent: "center",
11+
flexWrap: "wrap",
12+
listStyle: "none",
13+
padding: theme.spacing(0.5),
14+
margin: 0,
15+
},
16+
chip: {
17+
margin: theme.spacing(0.5),
18+
},
19+
}));
20+
21+
// Documentation: https://material-ui.com/components/chips/#chip
22+
// TODO: Customize chips array to your needs, pass on chip array
23+
24+
export default function MetabChips() {
25+
const classes = useStyles();
26+
const [chipData, setChipData] = React.useState([
27+
{ key: 0, label: "Angular" },
28+
{ key: 1, label: "jQuery" },
29+
{ key: 2, label: "Polymer" },
30+
{ key: 3, label: "React" },
31+
{ key: 4, label: "Vue.js" },
32+
]);
33+
34+
const handleDelete = (chipToDelete) => () => {
35+
setChipData((chips) =>
36+
chips.filter((chip) => chip.key !== chipToDelete.key)
37+
);
38+
};
39+
40+
return (
41+
<Paper component="ul" className={classes.root}>
42+
{chipData.map((data) => {
43+
let icon;
44+
45+
if (data.label === "React") {
46+
icon = <TagFacesIcon />;
47+
}
48+
49+
return (
50+
<li key={data.key}>
51+
<Chip
52+
icon={icon}
53+
label={data.label}
54+
onDelete={data.label === "React" ? undefined : handleDelete(data)}
55+
className={classes.chip}
56+
/>
57+
</li>
58+
);
59+
})}
60+
</Paper>
61+
);
62+
}

src/components/atomic/iconWrapper.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const useStyles = (props) =>
66
svg: { ...props.css },
77
});
88

9+
// TODO: IconWrapper - write proper comments don't know what it is doing but
10+
// it is used inside buttons.js MetabIconButton Component
11+
912
const IconWrapper = (props) => {
1013
const { svg } = useStyles(props)();
1114

src/components/atomic/keyShortcuts.js

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const useStyles = makeStyles((theme) => ({
1414
},
1515
}));
1616

17+
// KeyShortcuts has the logic to display Key shortcuts with proper
18+
// TODO: OS key layouts
19+
1720
const KeyShortcuts = (props) => {
1821
const classes = useStyles();
1922
let keys = props.children.split("|");

0 commit comments

Comments
 (0)