Toggle navigation
Toggle navigation
This project
Loading...
Sign in
DongyoungKwon
/
Teleprompter-SST
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
DongyoungKwon
2020-12-07 18:51:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4404b612b3560bdc2860ed2ba15d460f0f8c2b59
4404b612
1 parent
67b61b33
Complete Project for Local Server
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
117 deletions
README.md
client/src/App.js
client/src/components/Teleprompter.js
client/src/pages/MainPage.js
client/src/pages/PrompterPage.js
client/src/styles.js
server.js
README.md
View file @
4404b61
...
...
@@ -15,7 +15,7 @@
```
bash
Teleprompter-SST
βββ client ---> Front-end
βββ client ---> Front-end
[
React]
β βββ public ---> μ μ νμΌ λ³΄κ΄
β β βββ favicon.ico
β β βββ index.html
...
...
@@ -46,7 +46,7 @@ Teleprompter-SST
βββ package-lock.json
βββ package.json
βββ README.md
βββ server.js ---> Back-end
βββ server.js ---> Back-end
[
Node Express]
βββ yarn.lock
```
...
...
client/src/App.js
View file @
4404b61
...
...
@@ -2,15 +2,14 @@ import React, { Component } from 'react';
import
{
Route
}
from
'react-router-dom'
;
import
MainPage
from
'./pages/MainPage'
;
import
PrompterPage
from
'./pages/PrompterPage'
;
// import test from './pages/test';
class
App
extends
Component
{
render
()
{
return
(
<>
<
Route
path
=
"/"
component
=
{
MainPage
}
exact
=
{
true
}
/
>
<
Route
path
=
"/prompter"
component
=
{
PrompterPage
}
exact
=
{
true
}
/
>
{
/* <Route path="/prompter" component={test} exact={true} /> */
}
<
Route
path
=
"/prompter:script"
component
=
{
PrompterPage
}
exact
=
{
true
}
/
>
<
/
>
);
}
...
...
client/src/components/Teleprompter.js
View file @
4404b61
...
...
@@ -7,7 +7,7 @@ const StyledTeleprompter = styled.div`
width: 100%;
height: 56rem;
scroll-behavior: smooth;
overflow:
scroll
;
overflow:
auto
;
display: block;
margin-bottom: 1rem;
`
...
...
client/src/pages/MainPage.js
View file @
4404b61
import
React
,
{
Component
,
Fragment
}
from
'react'
;
import
{
post
}
from
'axios'
;
import
{
withStyles
,
Typography
,
Paper
,
Button
,
TextField
}
from
'@material-ui/core'
;
// import PrompterPage from './PrompterPage';
const
styles
=
theme
=>
({
root
:
{
...
...
@@ -71,12 +70,12 @@ class MainPage extends Component {
this
.
setState
({
script
:
''
})
this
.
props
.
history
.
push
(
'/prompter'
);
this
.
props
.
history
.
push
(
`/prompter:
${
this
.
script
}
`
);
}
// Send script to Server
addScript
=
()
=>
{
const
url
=
'/api/script'
;
const
url
=
`/api/this.props.script`
;
let
scriptJSON
=
{
script
:
this
.
script
};
const
config
=
{
headers
:
{
...
...
client/src/pages/PrompterPage.js
View file @
4404b61
import
React
,
{
Fragment
}
from
'react'
;
import
axios
from
'axios'
import
{
withStyles
,
Button
}
from
'@material-ui/core'
;
import
{
GlobalStyles
,
StyledApp
,
StyledTeleprompter
as
Teleprompter
,
Controls
,
Buttons
,
Button
,
}
from
"../styles"
;
// import { withStyles, Typography, Paper, Button, TextField} from '@material-ui/core';
// const styles = theme => ({
// root: {
// '& .MuiTextField-root': {
// margin: theme.spacing(1),
// width: '100%',
// minWidth: 1080
// },
// },
// title: {
// marginTop: theme.spacing.unit * 5,
// textAlign: 'center',
// display: 'none',
// fontSize: '2.0rem',
// [theme.breakpoints.up('sm')]: {
// display: 'block',
// }
// },
// paper: {
// marginTop: theme.spacing.unit * 5,
// marginLeft: theme.spacing.unit * 20,
// marginRight: theme.spacing.unit * 20
// },
// button: {
// marginTop: theme.spacing.unit * 1,
// marginLeft: theme.spacing.unit * 20,
// fontSize: '1rem',
// },
// });
const
styles
=
theme
=>
({
button
:
{
fontSize
:
'1.2rem'
,
},
});
// const INITIAL_TEXT = ``;
function
PrompterPage
()
{
function
PrompterPage
({
match
})
{
const
classes
=
styles
();
const
[
listening
,
setListening
]
=
React
.
useState
(
false
);
const
[
words
,
setWords
]
=
React
.
useState
(
""
.
split
(
" "
));
// const [words, setWords] = React.useState("");
const
[
progress
,
setProgress
]
=
React
.
useState
(
0
);
// Serverλ‘λΆν° Script λ°μμ΄
axios
.
get
(
"api/script"
)
axios
.
get
(
`api/
${
match
.
params
[
"script"
].
slice
(
1
)}
`
)
.
then
(
res
=>
{
// .then : μλ΅(μνμ½λ200~300λ―Έλ§)μ±κ³΅μ
console
.
log
(
res
.
data
);
setWords
(
res
.
data
.
split
(
" "
));
// λ°μμ¨ Script λ¬Έμμ΄ μ²λ¦¬
...
...
@@ -57,12 +30,6 @@ function PrompterPage() {
console
.
log
(
error
);
});
// const handleInput = (e) => {
// setWords(e.target.value.split(" "));
// progress && setProgress(0);
// };
const
handleListening
=
()
=>
{
if
(
listening
)
{
setListening
(
false
);
...
...
@@ -78,18 +45,14 @@ function PrompterPage() {
return
(
<>
<
Button
className
=
{
classes
.
button
}
variant
=
"contained"
color
=
"primary"
size
=
"medium"
onClick
=
{
handleListening
}
>
{
listening
?
"Stop"
:
"Start"
}
<
/Button
>
<
Button
className
=
{
classes
.
button
}
variant
=
"contained"
color
=
"secondary"
size
=
"medium"
disabled
=
{
listening
}
onClick
=
{
handleReset
}
>
Reset
<
/Button
>
<
GlobalStyles
/>
<
StyledApp
>
<
Controls
>
<
Buttons
>
<
Button
onClick
=
{
handleListening
}
>
{
listening
?
"Stop"
:
"Start"
}
<
/Button
>
<
Button
onClick
=
{
handleReset
}
disabled
=
{
listening
}
secondary
>
Reset
<
/Button
>
<
/Buttons
>
<
/Controls
>
<
Teleprompter
words
=
{
words
}
listening
=
{
listening
}
progress
=
{
progress
}
onChange
=
{
handleChange
}
/
>
<
/StyledApp
>
<
/
>
);
}
export
default
PrompterPage
;
\ No newline at end of file
export
default
withStyles
(
styles
)(
PrompterPage
);
\ No newline at end of file
...
...
client/src/styles.js
View file @
4404b61
import
styled
,
{
createGlobalStyle
,
css
}
from
"styled-components"
;
import
styled
,
{
createGlobalStyle
}
from
"styled-components"
;
import
Teleprompter
from
"./components/Teleprompter"
;
export
const
GlobalStyles
=
createGlobalStyle
`
...
...
@@ -29,60 +29,5 @@ export const StyledTeleprompter = styled(Teleprompter)`
flex-direction: column;
justify-content: space-around;
height: 100%;
`
;
export
const
Controls
=
styled
.
div
`
display: flex;
flex-direction: column;
margin-bottom: 1rem;
`
;
export
const
Buttons
=
styled
.
div
`
display: flex;
justify-content: flex-start;
`
;
export
const
Input
=
styled
.
textarea
`
height: 5rem;
border: 1px solid rgb(0, 0, 0, 0.25);
padding: 0.5rem;
font-family: Tahoma, sans-serif;
background: transparent;
margin-bottom: 1rem;
width: 100%;
`
;
export
const
Button
=
styled
.
button
`
display: inline-block;
border: none;
padding: 0.5rem 1rem;
margin: 0;
text-decoration: none;
background: #666ba5;
border: 1px solid rgb(0, 0, 0, 0.25);
color: white;
font-size: 1rem;
cursor: pointer;
text-align: center;
transition: background 250ms ease-in-out, transform 150ms ease;
margin-right: 1rem;
min-width: 5rem;
${(
p
)
=>
p
.
secondary
&&
css
`
background: #666;
`
}
&:last-child {
margin-right: 0;
}
&:hover,
&:focus {
transform: scale(1.1);
}
&:focus {
outline: 1px solid #fff;
}
&:active {
transform: scale(0.99);
}
`
;
`
;
\ No newline at end of file
...
...
server.js
View file @
4404b61
...
...
@@ -9,13 +9,13 @@ app.use(bodyParser.urlencoded({ extended: true}));
let
scriptReceived
=
""
;
app
.
get
(
'/api/script'
,
(
req
,
res
)
=>
{
app
.
get
(
'/api/
:
script'
,
(
req
,
res
)
=>
{
res
.
send
(
scriptReceived
)
});
app
.
post
(
'/api/script'
,
(
req
,
res
)
=>
{
app
.
post
(
'/api/
:
script'
,
(
req
,
res
)
=>
{
scriptReceived
=
req
.
body
.
script
;
});
...
...
Please
register
or
login
to post a comment