Skip to content

Commit aa8eede

Browse files
committed
Adjust styling
1 parent 14614b0 commit aa8eede

File tree

2 files changed

+78
-83
lines changed

2 files changed

+78
-83
lines changed

src/components/CommitBox.tsx

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import * as React from 'react';
22
import TextareaAutosize from 'react-textarea-autosize';
33
import { classes } from 'typestyle';
44
import {
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
*

src/style/CommitBox.ts

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,65 @@
11
import { style } from 'typestyle';
22

3-
// need to override font-size from user agent stylesheet
4-
export const stagedCommitButtonStyle = style({
5-
backgroundColor: 'var(--jp-brand-color1)',
6-
backgroundImage: 'var(--jp-checkmark)',
7-
backgroundSize: '100%',
8-
backgroundRepeat: 'no-repeat',
9-
backgroundPosition: 'center',
10-
border: '0',
11-
color: 'white',
12-
flex: '1 1 auto',
13-
fontSize: 'var(--jp-ui-font-size1)',
14-
height: 'calc(2 * (1.25em - 1px))',
15-
padding: 'calc(var(--jp-code-padding) + 1px) 7px',
16-
width: '40px'
17-
});
18-
19-
export const stagedCommitButtonReadyStyle = style({
20-
opacity: 0.3
21-
});
3+
export const commitFormClass = style({
4+
display: 'flex',
5+
flexWrap: 'wrap',
226

23-
export const stagedCommitButtonDisabledStyle = style({
24-
backgroundColor: 'lightgray'
25-
});
7+
position: 'absolute',
8+
bottom: 0,
9+
left: 0,
2610

27-
export const textInputStyle = style({
28-
outline: 'none'
29-
});
11+
padding: '8px',
12+
paddingTop: '1em',
3013

31-
export const stagedCommitStyle = style({
32-
resize: 'none',
33-
display: 'flex',
3414
alignItems: 'flex-start',
35-
margin: '8px'
15+
16+
borderTop: 'var(--jp-border-width) solid var(--jp-border-color2)'
3617
});
3718

38-
// need to override font-size from user agent stylesheet
39-
export const stagedCommitMessageStyle = style({
40-
backgroundColor: 'var(--jp-layout-color1)',
41-
border: 'var(--jp-border-width) solid var(--jp-border-color2)',
19+
export const commitSummaryClass = style({
20+
width: '100%',
21+
height: '1.5em',
22+
23+
marginBottom: '1em',
24+
padding: 'var(--jp-code-padding)',
25+
26+
outline: 'none',
27+
overflowX: 'auto',
28+
4229
color: 'var(--jp-ui-font-color0)',
4330
fontSize: 'var(--jp-ui-font-size1)',
4431
fontWeight: 300,
45-
flex: '20 1 auto',
46-
overflowX: 'auto',
32+
33+
backgroundColor: 'var(--jp-layout-color1)',
34+
border: 'var(--jp-border-width) solid var(--jp-border-color2)',
35+
borderRadius: '3px'
36+
});
37+
38+
export const commitDescriptionClass = style({
39+
width: '100%',
40+
41+
marginBottom: '1em',
4742
padding: 'var(--jp-code-padding)',
43+
44+
outline: 'none',
45+
overflowX: 'auto',
4846
resize: 'none',
49-
width: '75%',
47+
48+
color: 'var(--jp-ui-font-color0)',
49+
fontSize: 'var(--jp-ui-font-size1)',
50+
fontWeight: 300,
51+
52+
backgroundColor: 'var(--jp-layout-color1)',
53+
border: 'var(--jp-border-width) solid var(--jp-border-color2)',
54+
borderRadius: '3px',
5055

5156
$nest: {
5257
'&:focus': {
5358
outline: 'none'
5459
},
60+
'&::placeholder': {
61+
color: 'var(--jp-ui-font-color3)'
62+
},
5563
'&::-webkit-input-placeholder': {
5664
color: 'var(--jp-ui-font-color3)'
5765
},
@@ -63,3 +71,19 @@ export const stagedCommitMessageStyle = style({
6371
}
6472
}
6573
});
74+
75+
export const commitButtonClass = style({
76+
width: '100%',
77+
height: '2em',
78+
79+
color: 'white',
80+
fontSize: 'var(--jp-ui-font-size1)',
81+
82+
backgroundColor: 'var(--jp-brand-color1)',
83+
border: '0',
84+
borderRadius: '3px'
85+
});
86+
87+
export const commitButtonDisabledClass = style({
88+
backgroundColor: '#d3d3d3' // lightgrey
89+
});

0 commit comments

Comments
 (0)