diff --git a/client/src/components/Forum/ForumContent.js b/client/src/components/Forum/ForumContent.js index f639f55..f7cef13 100644 --- a/client/src/components/Forum/ForumContent.js +++ b/client/src/components/Forum/ForumContent.js @@ -18,6 +18,7 @@ import DialogContent from '@material-ui/core/DialogContent'; import CloseIcon from '@material-ui/icons/Close'; import ForwardIcon from '@material-ui/icons/Forward'; import ForwardOutlinedIcon from '@material-ui/icons/ForwardOutlined'; +import ForumModal from './ForumModal'; const useStyles = makeStyles(theme => ({ headerContainer: { @@ -141,10 +142,27 @@ const ForumContent = () => { - - + + + + + diff --git a/client/src/components/Forum/ForumModal.js b/client/src/components/Forum/ForumModal.js new file mode 100644 index 0000000..87790af --- /dev/null +++ b/client/src/components/Forum/ForumModal.js @@ -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 ( +
+ + + + Add Forum Post + + + Create a post for students in your course! + + + + + +
+ + Post Title + setTitle(e.target.value)} + className={classes.input} + placeholder="Add a title.." + /> + + + + + Post Description + + setDescription(e.target.value)} + className={classes.input} + placeholder="Add a description.." + /> + + + + + Drag and drop post picture{' '} + + + + Post + + + + + + + +
+
+
+ ); +}; + +export default ForumModal; diff --git a/client/src/components/Forum/ForumModalStyles.js b/client/src/components/Forum/ForumModalStyles.js new file mode 100644 index 0000000..5902dec --- /dev/null +++ b/client/src/components/Forum/ForumModalStyles.js @@ -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', +}; diff --git a/client/src/components/Forum/PostCard.js b/client/src/components/Forum/PostCard.js index 6d0a9f8..be84cfd 100644 --- a/client/src/components/Forum/PostCard.js +++ b/client/src/components/Forum/PostCard.js @@ -12,7 +12,7 @@ const useStyles = makeStyles(theme => ({ marginTop: theme.spacing(2), backgroundColor: theme.palette.background.paper, boxShadow: theme.shadows[5], - borderRadius: 10, + borderRadius: 15, }, actionArea: { height: 120, diff --git a/client/src/themes/theme.js b/client/src/themes/theme.js index 273e7f0..94eb96c 100644 --- a/client/src/themes/theme.js +++ b/client/src/themes/theme.js @@ -68,4 +68,30 @@ export const theme = createMuiTheme({ }, }, }, + overrides: { + MuiButton: { + textPrimary: { + color: '#FFF', + background: 'linear-gradient(45deg, #2574FF, #4B00FF)', + textTransform: 'none', + fontSize: 14, + padding: 20, + height: '3rem', + }, + outlinedPrimary: { + color: '#FFF', + textTransform: 'none', + fontSize: 14, + padding: 20, + height: '3rem', + }, + outlinedSecondary: { + color: '#2968FF', + textTransform: 'none', + fontSize: 14, + padding: 20, + height: '3rem', + }, + }, + }, }); diff --git a/server/models/forum.js b/server/models/Forum.js similarity index 100% rename from server/models/forum.js rename to server/models/Forum.js diff --git a/server/models/Post.js b/server/models/Post.js new file mode 100644 index 0000000..09ef07e --- /dev/null +++ b/server/models/Post.js @@ -0,0 +1,47 @@ +const mongoose = require('mongoose'); + +const { Schema } = mongoose; + +const PostSchema = new Schema({ + // user creating this specific post + user: { + type: Schema.Types.ObjectId, + ref: 'User', + }, + name: { + type: String, + }, + postAvatar: { + type: String, + default: '', + }, + title: { + type: String, + required: true, + }, + text: { + type: String, + required: true, + }, + isDeleted: { + type: Boolean, + default: false, + }, + votes: [ + { + user: { type: Schema.Types.ObjectId }, + }, + ], + comments: [ + { + type: Schema.Types.ObjectId, + ref: 'Comment', + }, + ], + date: { + type: Date, + default: Date.now, + }, +}); + +module.exports = mongoose.model('Post', PostSchema);