-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build basic elements of the UI
closes #7
- Loading branch information
Hagop Taminian
committed
Oct 16, 2020
1 parent
15e44b6
commit d6b2ed3
Showing
13 changed files
with
629 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import Button from '@material-ui/core/Button'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import Dialog from '@material-ui/core/Dialog'; | ||
import DialogActions from '@material-ui/core/DialogActions'; | ||
import DialogContent from '@material-ui/core/DialogContent'; | ||
import DialogTitle from '@material-ui/core/DialogTitle'; | ||
import InputLabel from '@material-ui/core/InputLabel'; | ||
import MenuItem from '@material-ui/core/MenuItem'; | ||
import Select from '@material-ui/core/Select'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
dialogContent: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
}, | ||
shortInputField: { | ||
width: '50%', | ||
}, | ||
addedMargin: { | ||
marginTop: theme.spacing(2), | ||
}, | ||
})); | ||
|
||
const CreateNewItem = ({ open, handleClose }) => { | ||
const classes = useStyles(); | ||
const [itemName, setItemName] = useState(''); | ||
const [itemType, setItemType] = useState(''); | ||
const [itemDescription, setItemDescription] = useState(''); | ||
const [itemImageUrl, setItemImageUrl] = useState(''); | ||
|
||
const handleNameInput = (event) => { | ||
setItemName(event.target.value); | ||
}; | ||
|
||
const handleItemSelect = (event) => { | ||
setItemType(event.target.value); | ||
}; | ||
|
||
const handleDescriptionInput = (event) => { | ||
setItemDescription(event.target.value); | ||
}; | ||
|
||
const handleImageUrlInput = (event) => { | ||
setItemImageUrl(event.target.value); | ||
}; | ||
|
||
const submitNewItem = () => {}; | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
onClose={() => { | ||
setItemType(''); | ||
handleClose(); | ||
}} | ||
maxWidth="sm" | ||
fullWidth | ||
> | ||
<DialogTitle id="create-new-item-form">Create new item</DialogTitle> | ||
<DialogContent className={classes.dialogContent}> | ||
<TextField | ||
autoFocus | ||
margin="dense" | ||
id="name" | ||
label="Name" | ||
value={itemName} | ||
onChange={handleNameInput} | ||
className={classes.shortInputField} | ||
/> | ||
<InputLabel id="item-type" className={classes.addedMargin}> | ||
Type | ||
</InputLabel> | ||
<Select | ||
labelId="item-type-select" | ||
id="item-type-select" | ||
value={itemType} | ||
onChange={handleItemSelect} | ||
className={classes.shortInputField} | ||
> | ||
<MenuItem value="Space">Space</MenuItem> | ||
<MenuItem value="Application">Application</MenuItem> | ||
<MenuItem value="Exercise">Exercise</MenuItem> | ||
</Select> | ||
<TextField | ||
margin="dense" | ||
id="description" | ||
label="Description" | ||
value={itemDescription} | ||
onChange={handleDescriptionInput} | ||
multiline | ||
rows={4} | ||
rowsMax={4} | ||
fullWidth | ||
/> | ||
<TextField | ||
margin="dense" | ||
id="imageUrl" | ||
label="Image (URL)" | ||
value={itemImageUrl} | ||
onChange={handleImageUrlInput} | ||
fullWidth | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
onClick={() => { | ||
setItemType(''); | ||
handleClose(); | ||
}} | ||
color="primary" | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
submitNewItem(itemName, itemType, itemDescription, itemImageUrl); | ||
handleClose(); | ||
}} | ||
color="primary" | ||
> | ||
Add item | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
CreateNewItem.propTypes = { | ||
open: PropTypes.func.isRequired, | ||
handleClose: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default CreateNewItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useState } from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import AddCircleIcon from '@material-ui/icons/AddCircle'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
import CreateNewItem from './CreateNewItem'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
marginBottom: theme.spacing(2), | ||
}, | ||
createNewButton: { | ||
cursor: 'pointer', | ||
}, | ||
})); | ||
|
||
const CreateNewItemButton = () => { | ||
const [open, setOpen] = useState(false); | ||
const classes = useStyles(); | ||
|
||
const handleClickOpen = () => { | ||
setOpen(true); | ||
}; | ||
|
||
const handleClose = () => { | ||
setOpen(false); | ||
}; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Tooltip placement="left" title="Create new item" arrow> | ||
<AddCircleIcon | ||
color="primary" | ||
fontSize="large" | ||
className={classes.createNewButton} | ||
onClick={handleClickOpen} | ||
/> | ||
</Tooltip> | ||
<CreateNewItem | ||
open={open} | ||
setOpen={setOpen} | ||
handleClickOpen={handleClickOpen} | ||
handleClose={handleClose} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreateNewItemButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Link } from 'react-router-dom'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import MoreVertIcon from '@material-ui/icons/MoreVert'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
marginTop: theme.spacing(1), | ||
marginBottom: theme.spacing(1), | ||
}, | ||
header: { | ||
display: 'flex', | ||
}, | ||
avatar: { | ||
marginLeft: theme.spacing(1), | ||
marginRight: theme.spacing(1), | ||
}, | ||
title: { | ||
fontSize: '0.9rem', | ||
fontWeight: 'bold', | ||
}, | ||
link: { | ||
textDecoration: 'none', | ||
color: 'inherit', | ||
}, | ||
subtitle: { | ||
fontSize: '0.72rem', | ||
}, | ||
})); | ||
|
||
const CustomCardHeader = ({ id, creator, title, type }) => { | ||
const classes = useStyles(); | ||
return ( | ||
<div className={classes.root}> | ||
<div className={classes.header}> | ||
<Avatar src={creator.avatar} className={classes.avatar} /> | ||
<div> | ||
<Link to={`/items/${id}`} className={classes.link}> | ||
<Typography className={classes.title}>{title}</Typography> | ||
</Link> | ||
<Typography className={classes.subtitle}> | ||
{`A ${type.toLowerCase()} by ${creator.name}`} | ||
</Typography> | ||
</div> | ||
</div> | ||
<IconButton> | ||
<MoreVertIcon /> | ||
</IconButton> | ||
</div> | ||
); | ||
}; | ||
|
||
CustomCardHeader.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
creator: PropTypes.string.isRequired, | ||
title: PropTypes.string.isRequired, | ||
type: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default CustomCardHeader; |
Oops, something went wrong.