DongyoungKwon

Add event handling && Modify layout

......@@ -16,7 +16,7 @@
- ๊น€๋‹ค์†” (2017110268)
####
#### Start
- `$ yarn global add create-react-app`
- `$ create-react-app teleprompt-sst`
- `$ yarn add @material-ui/core`
\ No newline at end of file
......
......@@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>ํ”„๋กฌํ”„ํ„ฐ ์„œ๋น„์Šค</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
......
import React, { Component, Fragment } from 'react';
import './App.css';
import { withStyles, Typography, Paper, Button} from '@material-ui/core';
import TextField from '@material-ui/core/TextField';
import { withStyles, Typography, Paper, Button, TextField} from '@material-ui/core';
const styles = theme => ({
root: {
......@@ -12,44 +11,56 @@ const styles = theme => ({
},
},
title: {
marginTop: 150,
marginTop: theme.spacing.unit * 5,
textAlign: 'center',
display: 'none',
fontSize: '3.0rem',
fontSize: '2.0rem',
[theme.breakpoints.up('sm')]: {
display: 'block',
// fontSize: '20',
}
},
paper: {
marginTop: 100,
marginLeft: 500,
marginRight: 500
marginTop: theme.spacing.unit * 5,
marginLeft: theme.spacing.unit * 20,
marginRight: theme.spacing.unit * 20
},
button: {
marginTop: 15,
marginLeft: 1320,
marginTop: theme.spacing.unit * 1,
marginLeft: theme.spacing.unit * 20,
fontSize: '1rem',
},
});
class App extends Component {
constructor(props) {
super(props);
this.state = {
script: ''
}
}
// Get Script
getScript = (e) => {
this.script = e.target.value;
}
// Send script to server && Move Next URL
handleScriptSubmit = (e) => {
console.log(this.script); // test
}
render() {
const { classes } = this.props;
return (
<>
<Typography className={classes.title} variant="h6" color="inherit" noWrap>
์Œ์„ฑ์— ๋งž์ถฐ ๋Œ€๋ณธ์„ ํ™”๋ฉด์— ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กฌํ”„ํ„ฐ ์„œ๋น„์Šค
</Typography>
<Fragment>
<Typography className={classes.title} variant="h6" color="inherit" noWrap>์Œ์„ฑ์— ๋งž์ถฐ ๋Œ€๋ณธ์„ ํ™”๋ฉด์— ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กฌํ”„ํ„ฐ ์„œ๋น„์Šค</Typography>
<Paper className={classes.paper} elevation={3}>
<TextField id="outlined-textarea" label="Script๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”." fullWidth="true" rows={20} placeholder="Script" multiline variant="outlined"/>
<TextField id="outlined-textarea" label="Script๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”." fullWidth="true" rows={20} placeholder="Script" multiline variant="outlined" onChange={this.getScript}/>
</Paper>
<Button className={classes.button} variant="contained" color="primary">์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.</Button>
</>
<Button className={classes.button} variant="contained" color="primary" size="medium" onClick={this.handleScriptSubmit}>์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.</Button>
</Fragment>
);
}
}
// export default makeStyles(useStyles)(App);
// export default App;
export default withStyles(styles)(App);
export default withStyles(styles)(App);
\ No newline at end of file
......
  • ๋ณ€๊ฒฝ ์‚ฌํ•ญ

    1. App.js์˜ TextField์— ์‚ฌ์šฉ์ž๊ฐ€ ๋Œ€๋ณธ์„ ์ž…๋ ฅํ•  ๋•Œ๋งˆ๋‹ค script ๋ณ€์ˆ˜์— ์ž๋™์ ์œผ๋กœ ํ• ๋‹นํ•ด์ฃผ๋Š” Event handling์ธ getScript() ์ถ”๊ฐ€
    2. App.js์˜ Button์„ ์‚ฌ์šฉ์ž๊ฐ€ ๋ˆ„๋ฅด๋ฉด getScript()๋กœ ์–ป์–ด์ง„ script๋ณ€์ˆ˜๋ฅผ ์ฒ˜๋ฆฌํ•ด์ฃผ๋Š” Event handling์ธ handleScriptSubmit() ์ถ”๊ฐ€
      • ํ˜„์žฌ ์ž„์‹œ๋กœ ์ฝ˜์†”์— script๊ฐ€ log ๋˜๋„๋ก ๊ตฌํ˜„ํ•˜์˜€๋‹ค.
      • ์•ž์œผ๋กœ script ๋ณ€์ˆ˜๋ฅผ Server๋กœ ์˜ฎ๊ฒจ ์ฒ˜๋ฆฌํ•ด์ฃผ๊ณ  ๋‹ค์Œ ํ™”๋ฉด์œผ๋กœ ๋„˜์–ด๊ฐ€๋„๋ก ๊ตฌํ˜„ ์˜ˆ์ •
    3. ๋ฉ”์ธํ™”๋ฉด์˜ ์ „์ฒด layout์„ ๋ณ€๊ฒฝํ•จ
    Edited