@@ -2,12 +2,11 @@ import * as React from 'react';
22import TextareaAutosize from 'react-textarea-autosize' ;
33import { classes } from 'typestyle' ;
44import {
5- stagedCommitButtonDisabledStyle ,
6- stagedCommitButtonReadyStyle ,
7- stagedCommitButtonStyle ,
8- stagedCommitMessageStyle ,
9- stagedCommitStyle ,
10- textInputStyle
5+ commitFormClass ,
6+ commitSummaryClass ,
7+ commitDescriptionClass ,
8+ commitButtonClass ,
9+ commitButtonDisabledClass
1110} from '../style/CommitBox' ;
1211
1312/**
@@ -70,49 +69,39 @@ export class CommitBox extends React.Component<
7069 * @returns fragment
7170 */
7271 render ( ) {
72+ const disabled = ! ( this . props . hasFiles && this . state . summary ) ;
7373 return (
74- < form className = { stagedCommitStyle } >
75- < textarea
76- className = { classes ( textInputStyle , stagedCommitMessageStyle ) }
74+ < form className = { commitFormClass } >
75+ < input
76+ className = { commitSummaryClass }
77+ type = "text"
7778 placeholder = "Summary (required)"
7879 value = { this . state . summary }
7980 onChange = { this . _onSummaryChange }
8081 onKeyPress = { this . _onSummaryKeyPress }
8182 />
8283 < TextareaAutosize
83- className = { classes ( textInputStyle , stagedCommitMessageStyle ) }
84- minRows = { 2 }
84+ className = { commitDescriptionClass }
85+ minRows = { 5 }
8586 placeholder = "Description"
8687 value = { this . state . description }
8788 onChange = { this . _onDescriptionChange }
88- onKeyPress = { this . _onDescriptionKeyPress }
8989 />
9090 < input
91- className = { this . _commitButtonStyle ( ) }
91+ className = { classes (
92+ commitButtonClass ,
93+ disabled ? commitButtonDisabledClass : null
94+ ) }
9295 type = "button"
9396 title = "Commit"
94- disabled = { ! ( this . props . hasFiles && this . state . summary ) }
97+ value = "Commit"
98+ disabled = { disabled }
9599 onClick = { this . _onCommitClick }
96100 />
97101 </ form >
98102 ) ;
99103 }
100104
101- /**
102- * Returns classes for toggling (and styling) the commit button.
103- *
104- * @returns classes to apply
105- */
106- private _commitButtonStyle = ( ) : string => {
107- if ( this . props . hasFiles ) {
108- if ( this . state . summary . length === 0 ) {
109- return classes ( stagedCommitButtonStyle , stagedCommitButtonReadyStyle ) ;
110- }
111- return stagedCommitButtonStyle ;
112- }
113- return classes ( stagedCommitButtonStyle , stagedCommitButtonDisabledStyle ) ;
114- } ;
115-
116105 /**
117106 * Callback invoked upon clicking a commit message submit button.
118107 *
@@ -137,24 +126,6 @@ export class CommitBox extends React.Component<
137126 } ) ;
138127 } ;
139128
140- /**
141- * Callback invoked upon a `'keypress'` event when entering a commit message description.
142- *
143- * ## Notes
144- *
145- * - Prevents triggering a `'submit'` action when hitting the `ENTER` key while entering a commit message description.
146- *
147- * @param event - event object
148- */
149- private _onDescriptionKeyPress ( event : any ) : void {
150- if ( event . which === 13 ) {
151- event . preventDefault ( ) ;
152- this . setState ( {
153- description : this . state . description + '\n'
154- } ) ;
155- }
156- }
157-
158129 /**
159130 * Callback invoked upon updating a commit message summary.
160131 *
0 commit comments