1- import * as React from 'react'
2-
31import { Button , IconName , Intent } from '@blueprintjs/core'
2+ import * as React from 'react'
43
54import { sourceChapters } from '../../reducers/states'
65
@@ -14,48 +13,47 @@ export interface IReplControlProps {
1413 handleChapterSelect : ( e : React . ChangeEvent < HTMLSelectElement > ) => void
1514}
1615
17- const chapterSelect = ( handleSelect = ( e : React . ChangeEvent < HTMLSelectElement > ) => { } ) => (
18- < div className = "pt-select pt-select" >
19- < select defaultValue = { sourceChapters . slice ( - 1 ) [ 0 ] . toString ( ) } onChange = { handleSelect } >
20- { sourceChapters . map ( chap => (
21- < option key = { chap } value = { chap } >
22- { `Source \xa7${ chap } ` }
23- </ option >
24- ) ) }
25- </ select >
26- </ div >
27- )
28-
2916class ReplControl extends React . Component < IReplControlProps , { } > {
3017 public render ( ) {
31- const genericButton = (
32- label : string ,
33- icon : IconName ,
34- handleClick = ( ) => { } ,
35- intent = Intent . NONE ,
36- notMinimal = false
37- ) => (
38- < Button
39- onClick = { handleClick }
40- className = { ( notMinimal ? '' : 'pt-minimal' ) + ' col-xs-12' }
41- intent = { intent }
42- icon = { icon }
43- >
44- { label }
45- </ Button >
46- )
47- const evalButton = genericButton ( '' , 'code' , this . props . handleReplEval )
48- const clearButton = genericButton ( '' , 'remove' , this . props . handleReplOutputClear )
4918 return (
5019 < div className = "row end-xs" >
5120 < div className = "pt-control-group pt-fill" >
5221 { chapterSelect ( this . props . handleChapterSelect ) }
53- { evalButton }
54- { clearButton }
22+ { controlButton ( '' , 'code' , this . props . handleReplEval ) }
23+ { controlButton ( '' , 'remove' , this . props . handleReplOutputClear ) }
5524 </ div >
5625 </ div >
5726 )
5827 }
5928}
6029
30+ const controlButton = (
31+ label : string ,
32+ icon : IconName ,
33+ handleClick = ( ) => { } ,
34+ intent = Intent . NONE ,
35+ minimal = true
36+ ) => (
37+ < Button
38+ onClick = { handleClick }
39+ className = { ( minimal ? 'pt-minimal' : '' ) + ' col-xs-12' }
40+ intent = { intent }
41+ icon = { icon }
42+ >
43+ { label }
44+ </ Button >
45+ )
46+
47+ const chapterSelect = ( handleSelect = ( e : React . ChangeEvent < HTMLSelectElement > ) => { } ) => (
48+ < div className = "pt-select pt-select" >
49+ < select defaultValue = { sourceChapters . slice ( - 1 ) [ 0 ] . toString ( ) } onChange = { handleSelect } >
50+ { sourceChapters . map ( chap => (
51+ < option key = { chap } value = { chap } >
52+ { `Source \xa7${ chap } ` }
53+ </ option >
54+ ) ) }
55+ </ select >
56+ </ div >
57+ )
58+
6159export default ReplControl
0 commit comments