DongyoungKwon

Add event handling && Modify layout

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

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