11import React from 'react' ;
2- import * as classes from './new-text.styles' ;
3- // Material UI ~ components
2+ import { cx } from 'emotion' ;
43import ArrowForwardRoundedIcon from '@material-ui/icons/ArrowForwardRounded' ;
54import Button from '@material-ui/core/Button' ;
65import TextareaAutosize from '@material-ui/core/TextareaAutosize' ;
6+ import * as innerClasses from './new-text.styles' ;
77
88interface Props {
99 handleAppendTrainerText : ( trainerText : string ) => void ;
10+ className ?: string ;
1011}
1112
1213export const NewTextComponent : React . FC < Props > = props => {
13- const { handleAppendTrainerText } = props ;
14+ const { handleAppendTrainerText, className } = props ;
1415 const [ trainerText , setTrainerText ] = React . useState < string > ( '' ) ;
15- const {
16- newTextContainer,
17- labelTextarea,
18- editTextArea,
19- sendBtn,
20- sendBtnDisabled,
21- sendIcon,
22- } = classes ;
2316
2417 const trainerTextRef = React . useRef < string > ( trainerText ) ;
2518
@@ -45,31 +38,30 @@ export const NewTextComponent: React.FC<Props> = props => {
4538 } , [ ] ) ;
4639
4740 return (
48- < div className = { newTextContainer } >
49- < form >
50- < label className = { labelTextarea } htmlFor = "new-text" >
51- New text
52- </ label >
53- < TextareaAutosize
54- rowsMax = { 10 }
55- rowsMin = { 10 }
56- className = { editTextArea }
57- onChange = { e => handleOnChange ( e ) }
58- value = { trainerText }
59- />
60- < Button
61- variant = "contained"
62- color = "primary"
63- className = { trainerText ? sendBtn : sendBtnDisabled }
64- onClick = { ( ) => trainerText && handleAppendTrainerTextInternal ( ) }
65- aria-disabled = { ! trainerText }
66- disableRipple = { ! trainerText }
67- disableElevation
68- >
69- Send
70- < ArrowForwardRoundedIcon className = { sendIcon } />
71- </ Button >
72- </ form >
73- </ div >
41+ < form className = { cx ( innerClasses . root , className ) } >
42+ < label className = { innerClasses . label } htmlFor = "new-text" >
43+ New text
44+ </ label >
45+ < TextareaAutosize
46+ rowsMax = { 10 }
47+ rowsMin = { 10 }
48+ className = { innerClasses . textarea }
49+ onChange = { e => handleOnChange ( e ) }
50+ value = { trainerText }
51+ />
52+ < Button
53+ variant = "contained"
54+ color = "primary"
55+ className = { innerClasses . button }
56+ onClick = { ( ) => trainerText && handleAppendTrainerTextInternal ( ) }
57+ disabled = { ! trainerText }
58+ aria-disabled = { ! trainerText }
59+ disableRipple = { ! trainerText }
60+ disableElevation
61+ >
62+ Send
63+ < ArrowForwardRoundedIcon className = { innerClasses . buttonIcon } />
64+ </ Button >
65+ </ form >
7466 ) ;
7567} ;
0 commit comments