generated from hatchways/express-starter
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from hatchways/FE-Forum-Page-Create-Post-dialo…
…g-#54 Fe forum page create post dialog #54
- Loading branch information
Showing
5 changed files
with
247 additions
and
7 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
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,159 @@ | ||
import React, { useState, useMemo } from 'react'; | ||
import { | ||
Grid, | ||
Button, | ||
InputLabel, | ||
TextField, | ||
Divider, | ||
Typography, | ||
Box, | ||
Tooltip, | ||
FormHelperText, | ||
} from '@material-ui/core'; | ||
import { useDropzone } from 'react-dropzone'; | ||
import { baseStyle, activeStyle, acceptStyle, rejectStyle } from './ForumModalStyles'; | ||
import { makeStyles } from '@material-ui/styles'; | ||
import CloseIcon from '@material-ui/icons/Close'; | ||
import AddIcon from '@material-ui/icons/Add'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
divider: { | ||
margin: theme.spacing(2, 0), | ||
}, | ||
input: { | ||
width: '100%', | ||
paddingBottom: theme.spacing(2), | ||
}, | ||
label: { | ||
paddingBottom: theme.spacing(1), | ||
}, | ||
title: { | ||
marginBottom: theme.spacing(1), | ||
}, | ||
imageContainer: { | ||
flex: 1, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
padding: theme.spacing(1, 0), | ||
}, | ||
|
||
button: { | ||
width: '100%', | ||
}, | ||
close: { | ||
height: 2.5, | ||
}, | ||
})); | ||
|
||
const ForumModal = ({ handleClose }) => { | ||
const classes = useStyles(); | ||
|
||
const [title, setTitle] = useState(); | ||
const [description, setDescription] = useState(); | ||
|
||
const onDrop = () => { | ||
console.log('Dropped'); | ||
}; | ||
|
||
const createPost = () => {}; | ||
|
||
const { getRootProps, isDragActive, isDragAccept, isDragReject } = useDropzone({ | ||
onDrop, | ||
maxFiles: 1, | ||
accept: 'image/*', | ||
}); | ||
const style = useMemo( | ||
() => ({ | ||
...baseStyle, | ||
...(isDragActive ? activeStyle : {}), | ||
...(isDragAccept ? acceptStyle : {}), | ||
...(isDragReject ? rejectStyle : {}), | ||
}), | ||
[isDragActive, isDragReject, isDragAccept] | ||
); | ||
|
||
return ( | ||
<div> | ||
<Grid item> | ||
<Button onClick={handleClose} color="primary" className={classes.close}> | ||
<CloseIcon /> | ||
</Button> | ||
<Typography | ||
variant="h2" | ||
id="modal-title" | ||
align="center" | ||
className={classes.title} | ||
> | ||
Add Forum Post | ||
</Typography> | ||
<Typography variant="h4" id="modal-description" align="center"> | ||
Create a post for students in your course! | ||
</Typography> | ||
<Divider className={classes.divider} /> | ||
</Grid> | ||
|
||
<Grid item container justify="center"> | ||
<form> | ||
<Grid item> | ||
<InputLabel className={classes.label}>Post Title</InputLabel> | ||
<TextField | ||
variant="outlined" | ||
defaultValue={title} | ||
onChange={e => setTitle(e.target.value)} | ||
className={classes.input} | ||
placeholder="Add a title.." | ||
/> | ||
</Grid> | ||
|
||
<Grid item> | ||
<InputLabel className={classes.label}> | ||
Post Description | ||
</InputLabel> | ||
<TextField | ||
variant="outlined" | ||
id="outlined-multiline-static" | ||
multiline | ||
rows={4} | ||
defaultValue={description} | ||
onChange={e => setDescription(e.target.value)} | ||
className={classes.input} | ||
placeholder="Add a description.." | ||
/> | ||
</Grid> | ||
<Grid item> | ||
<Box className={classes.imageContainer}> | ||
<FormHelperText className={classes.label}> | ||
Drag and drop post picture{' '} | ||
</FormHelperText> | ||
<Tooltip | ||
title="Drag and drop post picture" | ||
arrow | ||
placement="right" | ||
> | ||
<Box {...getRootProps({ style })}> | ||
<img | ||
src="https://www.rcdrilling.com/wp-content/uploads/2013/12/default_image_01-1024x1024-570x321.png" | ||
className={classes.large} | ||
alt="Post" | ||
/> | ||
</Box> | ||
</Tooltip> | ||
</Box> | ||
</Grid> | ||
<Grid item> | ||
<Button | ||
color="primary" | ||
startIcon={<AddIcon />} | ||
onSubmit={createPost} | ||
className={classes.button} | ||
> | ||
Create Post | ||
</Button> | ||
</Grid> | ||
</form> | ||
</Grid> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ForumModal; |
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,21 @@ | ||
export const baseStyle = { | ||
borderWidth: 3, | ||
borderRadius: 5, | ||
borderColor: '#eeeeee', | ||
borderStyle: 'solid', | ||
backgroundColor: '#d8d8d8', | ||
outline: 'none', | ||
transition: 'border .24s ease-in-out', | ||
}; | ||
|
||
export const activeStyle = { | ||
borderColor: '#2196f3', | ||
}; | ||
|
||
export const acceptStyle = { | ||
borderColor: '#00e676', | ||
}; | ||
|
||
export const rejectStyle = { | ||
borderColor: '#ff1744', | ||
}; |
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