Writing_Microblogs to Material-UI and UI improvements

This commit is contained in:
Clayton Wilson 2019-11-03 15:17:14 -05:00
parent 3fa4cd7033
commit 2bd1c08c2c
5 changed files with 40 additions and 114 deletions

View File

@ -5,6 +5,7 @@ import axios from "axios";
// Material-UI // Material-UI
import TextField from '@material-ui/core/TextField'; import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import withStyles from "@material-ui/styles/withStyles"; import withStyles from "@material-ui/styles/withStyles";
@ -19,11 +20,8 @@ const styles = {
marginLeft: "50px" marginLeft: "50px"
}, },
textField: { textField: {
marginBottom: 20 marginBottom: 15
} }
// TextField: {
// marginBottom: "30px"
// }
} }
class Writing_Microblogs extends Component { class Writing_Microblogs extends Component {
@ -50,7 +48,7 @@ class Writing_Microblogs extends Component {
this.setState({ topics: event.target.value }); this.setState({ topics: event.target.value });
} }
handleSubmit(event) { handleSubmit = (event) => {
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value); // alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
const postData = { const postData = {
body: this.state.value, body: this.state.value,
@ -77,6 +75,7 @@ class Writing_Microblogs extends Component {
} }
handleChangeforPost(event) { handleChangeforPost(event) {
this.setState({ value: event.target.value }); this.setState({ value: event.target.value });
} }
@ -89,145 +88,66 @@ class Writing_Microblogs extends Component {
render() { render() {
const { classes } = this.props; const { classes } = this.props;
return ( return (
// <div className={classes.container}>
// <div className={classes.div}>
// <form>
// {/* <textarea
// placeholder="Enter Microblog Title"
// value={this.state.title}
// required
// onChange={this.handleChange}
// cols={30}
// rows={1}
// /> */}
// <TextField
// 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
// />
// </form>
// </div>
// <div style={{ width: "200px", height: "50px", marginLeft: "50px" }}>
// <form>
// {/* <textarea
// placeholder="Enter topics seperated by a comma"
// value={this.state.topics}
// required
// 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" }}>
// <form onSubmit={this.handleSubmit}>
// {/* <textarea
// value={this.state.value}
// required
// maxLength="250"
// placeholder="Write Microblog here..."
// onChange={e => {
// this.handleChangeforPost(e);
// this.handleChangeforCharacterCount(e);
// }}
// cols={40}
// rows={20}
// /> */}
// <TextField
// id="bio"
// name="bio"
// label="Bio"
// className={classes.textField}
// value={this.state.bio}
// // helperText={errors.bio}
// // 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}> <div className={classes.container}>
<form className={classes.form}> <form noValidate className={classes.form}>
<TextField <TextField
// style={{marginBottom: 20}}
id="title" id="title"
name="title" name="title"
label="Title" label="Title"
className={classes.textField} className={classes.textField}
value={this.state.title} value={this.state.title}
// helperText={errors.firstName}
// error={errors.firstName ? true : false}
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChange}
fullWidth fullWidth
autoComplete='off'
/> />
<TextField <TextField
id="topics" id="topics"
name="topics" name="topics"
label="topics" label="Topics"
className={classes.textField} className={classes.textField}
value={this.state.topics} value={this.state.topics}
// helperText={errors.firstName}
// error={errors.firstName ? true : false}
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChangeforTopics}
color="primary"
fullWidth fullWidth
autoComplete='off'
/> />
<TextField <TextField
id="content" id="content"
name="content" name="content"
label="content" label="Content"
color="primary"
className={classes.textField} className={classes.textField}
value={this.state.content} value={this.state.value}
// helperText={errors.bio} helperText={`${this.state.characterCount} characters left`}
// error={errors.bio ? true : false}
multiline multiline
rows="8" rows="9"
variant="outlined" variant="outlined"
onChange={this.handleChange} inputProps={{
maxLength: 250
}}
onChange={(e) => {
this.handleChangeforPost(e);
this.handleChangeforCharacterCount(e);
}}
fullWidth fullWidth
autoComplete='off'
/> />
<Button
onClick={this.handleSubmit}
// disabled={loading}
variant="outlined"
color="primary"
>
Share Post
</Button>
</form> </form>
</div> </div>
); );
} }
} }
// export default Writing_Microblogs;
export default withStyles(styles)(Writing_Microblogs); export default withStyles(styles)(Writing_Microblogs);

View File

@ -45,7 +45,7 @@ class Home extends Component {
<CardContent> <CardContent>
<Typography> <Typography>
{ {
this.state.imageUrl ? (<img src={this.state.imageUrl} height="250" width="250" />) : this.state.imageUrl ? (<img src={this.state.imageUrl} height="50" width="50" />) :
(<img src={noImage} height="50" width="50"/>) (<img src={noImage} height="50" width="50"/>)
} }
</Typography> </Typography>

View File

@ -111,7 +111,7 @@ export class Login extends Component {
<TextField <TextField
id="email" id="email"
name="email" name="email"
label="Email*" label="Email or Username*"
className={classes.textField} className={classes.textField}
value={this.state.email} value={this.state.email}
helperText={errors.email} helperText={errors.email}
@ -119,6 +119,7 @@ export class Login extends Component {
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChange}
fullWidth fullWidth
autoComplete='off'
/> />
<TextField <TextField
id="password" id="password"
@ -132,6 +133,7 @@ export class Login extends Component {
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChange}
fullWidth fullWidth
autoComplete='off'
/> />
<Button <Button
type="submit" type="submit"

View File

@ -107,6 +107,7 @@ export class Signup extends Component {
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChange}
fullWidth fullWidth
autoComplete='off'
/> />
<TextField <TextField
id="email" id="email"
@ -119,6 +120,7 @@ export class Signup extends Component {
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChange}
fullWidth fullWidth
autoComplete='off'
/> />
<TextField <TextField
id="password" id="password"
@ -132,6 +134,7 @@ export class Signup extends Component {
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChange}
fullWidth fullWidth
autoComplete='off'
/> />
<TextField <TextField
id="confirmPassword" id="confirmPassword"
@ -145,6 +148,7 @@ export class Signup extends Component {
variant="outlined" variant="outlined"
onChange={this.handleChange} onChange={this.handleChange}
fullWidth fullWidth
autoComplete='off'
/> />
<Button <Button
type="submit" type="submit"

View File

@ -132,7 +132,7 @@ class user extends Component {
<CardContent> <CardContent>
<Typography> <Typography>
{ {
this.state.imageUrl ? (<img src={this.state.imageUrl} height="250" width="250" />) : this.state.imageUrl ? (<img src={this.state.imageUrl} height="50" width="50" />) :
(<img src={noImage} height="50" width="50"/>) (<img src={noImage} height="50" width="50"/>)
} }
</Typography> </Typography>