Changing writing microblogs to Material-UI

This commit is contained in:
Clayton Wilson 2019-11-01 13:02:37 -04:00
parent ae89e3d63b
commit 3fa4cd7033
3 changed files with 173 additions and 58 deletions

View File

@ -3,6 +3,29 @@ import { BrowserRouter as Router } from "react-router-dom";
import Route from "react-router-dom/Route"; import Route from "react-router-dom/Route";
import axios from "axios"; import axios from "axios";
// Material-UI
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import withStyles from "@material-ui/styles/withStyles";
const styles = {
container: {
position: "fixed"
},
form: {
width: "300px",
height: "50px",
marginTop: "180px",
marginLeft: "50px"
},
textField: {
marginBottom: 20
}
// TextField: {
// marginBottom: "30px"
// }
}
class Writing_Microblogs extends Component { class Writing_Microblogs extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -64,65 +87,147 @@ class Writing_Microblogs extends Component {
} }
render() { render() {
const { classes } = this.props;
return ( return (
<div> // <div className={classes.container}>
<div // <div className={classes.div}>
style={{ // <form>
width: "200px", // {/* <textarea
height: "50px", // placeholder="Enter Microblog Title"
marginTop: "180px", // value={this.state.title}
marginLeft: "50px" // required
}} // onChange={this.handleChange}
> // cols={30}
<form> // rows={1}
<textarea // /> */}
placeholder="Enter Microblog Title" // <TextField
value={this.state.title} // id="title"
required // name="title"
onChange={this.handleChange} // label="Title"
cols={30} // // className={classes.textField}
rows={1} // value={this.state.title}
/> // // helperText={errors.firstName}
</form> // // error={errors.firstName ? true : false}
</div> // variant="outlined"
<div style={{ width: "200px", height: "50px", marginLeft: "50px" }}> // onChange={this.handleChange}
<form> // fullWidth
<textarea // />
placeholder="Enter topics seperated by a comma" // </form>
value={this.state.topics} // </div>
required // <div style={{ width: "200px", height: "50px", marginLeft: "50px" }}>
onChange={this.handleChangeforTopics} // <form>
cols={40} // {/* <textarea
rows={1} // placeholder="Enter topics seperated by a comma"
/> // value={this.state.topics}
</form> // required
</div> // onChange={this.handleChangeforTopics}
// cols={40}
// rows={1} */}
// <TextField
// id="topics"
// name="topics"
// label="topics"
// // className={classes.textField}
// value={this.state.topics}
// // helperText={errors.firstName}
// // error={errors.firstName ? true : false}
// variant="outlined"
// onChange={this.handleChange}
// fullWidth
// />
// </form>
// </div>
<div style={{ width: "200px", marginLeft: "50px" }}> // <div style={{ width: "200px", marginLeft: "50px" }}>
<form onSubmit={this.handleSubmit}> // <form onSubmit={this.handleSubmit}>
<textarea // {/* <textarea
value={this.state.value} // value={this.state.value}
required // required
maxLength="250" // maxLength="250"
placeholder="Write Microblog here..." // placeholder="Write Microblog here..."
onChange={e => { // onChange={e => {
this.handleChangeforPost(e); // this.handleChangeforPost(e);
this.handleChangeforCharacterCount(e); // this.handleChangeforCharacterCount(e);
}} // }}
cols={40} // cols={40}
rows={20} // rows={20}
/> // /> */}
<div style={{ fontSize: "14px", marginRight: "-100px" }}> // <TextField
<p2>Characters Left: {this.state.characterCount}</p2> // id="bio"
</div> // name="bio"
<div style={{ marginRight: "-100px" }}> // label="Bio"
<button onClick>Share Post</button> // className={classes.textField}
</div> // value={this.state.bio}
</form> // // helperText={errors.bio}
</div> // // error={errors.bio ? true : false}
// multiline
// rows="8"
// variant="outlined"
// onChange={this.handleChange}
// fullWidth
// />
// <div style={{ fontSize: "14px", marginRight: "-100px" }}>
// <p2>Characters Left: {this.state.characterCount}</p2>
// </div>
// <div style={{ marginRight: "-100px" }}>
// {/* <button onClick>Share Post</button> */}
// <Button
// onClick
// >
// Share Post
// </Button>
// </div>
// </form>
// </div>
// </div>
<div className={classes.container}>
<form className={classes.form}>
<TextField
// style={{marginBottom: 20}}
id="title"
name="title"
label="Title"
className={classes.textField}
value={this.state.title}
// helperText={errors.firstName}
// error={errors.firstName ? true : false}
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<TextField
id="topics"
name="topics"
label="topics"
className={classes.textField}
value={this.state.topics}
// helperText={errors.firstName}
// error={errors.firstName ? true : false}
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<TextField
id="content"
name="content"
label="content"
className={classes.textField}
value={this.state.content}
// helperText={errors.bio}
// error={errors.bio ? true : false}
multiline
rows="8"
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
</form>
</div> </div>
); );
} }
} }
export default Writing_Microblogs; // export default Writing_Microblogs;
export default withStyles(styles)(Writing_Microblogs);

View File

@ -31,6 +31,11 @@ class Home extends Component {
.catch(err => console.log(err)); .catch(err => console.log(err));
} }
formatDate(dateString) {
let newDate = new Date(Date.parse(dateString));
return newDate.toDateString();
}
render() { render() {
let authenticated = this.props.user.authenticated; let authenticated = this.props.user.authenticated;
@ -44,8 +49,8 @@ class Home extends Component {
(<img src={noImage} height="50" width="50"/>) (<img src={noImage} height="50" width="50"/>)
} }
</Typography> </Typography>
<Typography variant="h7"><b>{post.userHandle}</b></Typography> <Typography variant="h5"><b>{post.userHandle}</b></Typography>
<Typography variant="body2" color={"textSecondary"}>{post.createdAt}</Typography> <Typography variant="body2" color={"textSecondary"}>{this.formatDate(post.createdAt)}</Typography>
<br /> <br />
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography> <Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
<Typography variant="body2">{post.body}</Typography> <Typography variant="body2">{post.body}</Typography>

View File

@ -97,6 +97,11 @@ class user extends Component {
.catch(err => console.log(err)); .catch(err => console.log(err));
} }
formatDate(dateString) {
let newDate = new Date(Date.parse(dateString));
return newDate.toDateString();
}
render() { render() {
let authenticated = this.props.user.authenticated; let authenticated = this.props.user.authenticated;
let classes = this.props; let classes = this.props;
@ -132,7 +137,7 @@ class user extends Component {
} }
</Typography> </Typography>
<Typography variant="h7"><b>{post.userHandle}</b></Typography> <Typography variant="h7"><b>{post.userHandle}</b></Typography>
<Typography variant="body2" color={"textSecondary"}>{post.createdAt}</Typography> <Typography variant="body2" color={"textSecondary"}>{this.formatDate(post.createdAt)}</Typography>
<br /> <br />
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography> <Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
<Typography variant="body2">{post.body}</Typography> <Typography variant="body2">{post.body}</Typography>