11import React from 'react' ;
22import TextareaAutosize from '@material-ui/core/TextareaAutosize' ;
33import Typography from '@material-ui/core/Typography' ;
4+
5+ import Checkbox from '@material-ui/core/Checkbox' ;
6+ import FormControlLabel from '@material-ui/core/FormControlLabel' ;
7+
48import * as innerClasses from './student.styles' ;
9+ import { useAutoScroll } from 'common/hooks/auto-scroll.hook' ;
510
611interface Props {
712 room : string ;
@@ -11,25 +16,41 @@ interface Props {
1116export const StudentComponent : React . FC < Props > = props => {
1217 const { room, log } = props ;
1318
19+ const { isAutoScrollEnabled, setIsAutoScrollEnabled, textAreaRef, doAutoScroll} = useAutoScroll ( ) ;
20+
21+ React . useEffect ( ( ) => {
22+ doAutoScroll ( ) ;
23+ } , [ log ] ) ;
24+
1425 return (
15- < main className = { innerClasses . root } >
16- < Typography
17- className = { innerClasses . sessionName }
18- variant = "body1"
19- role = "heading"
20- >
21- Session name: { room ?? '' }
22- </ Typography >
23- < label className = { innerClasses . label } htmlFor = "session" >
24- Content
25- </ label >
26- < TextareaAutosize
27- id = "session"
28- rowsMax = { 30 }
29- rowsMin = { 30 }
30- className = { innerClasses . textarea }
31- value = { log ?? '' }
32- />
33- </ main >
26+
27+ < >
28+ < main className = { innerClasses . root } >
29+ < Typography className = { innerClasses . sessionName } variant = "body1" role = "heading" >
30+ Session name: { room ?? '' }
31+ </ Typography >
32+ < label className = { innerClasses . label } htmlFor = "session" >
33+ Content
34+ </ label >
35+ < TextareaAutosize
36+ ref = { textAreaRef }
37+ id = "session"
38+ rowsMax = { 30 }
39+ rowsMin = { 30 }
40+ className = { innerClasses . textarea }
41+ value = { log ?? '' }
42+ />
43+ < FormControlLabel
44+ label = "Disable AutoScroll"
45+ control = {
46+ < Checkbox
47+ checked = { isAutoScrollEnabled }
48+ onChange = { e => setIsAutoScrollEnabled ( e . target . checked ) }
49+ color = "primary"
50+ />
51+ }
52+ />
53+ </ main >
54+ </ >
3455 ) ;
3556} ;
0 commit comments