Skip to content

Commit d3b284b

Browse files
author
Marco Cesarato
committed
style: reformat code
1 parent 85844f1 commit d3b284b

File tree

5 files changed

+23
-59
lines changed

5 files changed

+23
-59
lines changed

.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 180,
2+
"printWidth": 80,
33
"tabWidth": 2,
44
"useTabs": true,
55
"semi": true,

PROPS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
| `colorRight` | Custom color of the Spinner right button | String | `#3E525F` | |
3131
| `color` | Custom color of the Spinner | String | `#3E525F` | |
3232
| `disabled` | Disable the Spinner or not | Boolean | `false` | |
33-
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
33+
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
3434
| `fontFamily` | Custom fontFamily of the text input of the Spinner | String | System Default | |
3535
| `fontSize` | Custom fontSize of the text input of the Spinner | Number | `14` | |
3636
| `height` | Custom height of the Spinner | Number | `50` | |

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Check the "[Props List](PROPS.md)" file to have the complete list of component p
105105
| `append` | Custom element before right button | Component | | |
106106
| `autofocus` | If `true`, focuses the input on `componentDidMount`. | | `false` | |
107107
| `disabled` | Disable the Spinner or not | Boolean | `false` | |
108-
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
108+
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
109109
| `initialValue` | Initial value of the Spinner | String<br>Number | `0` | |
110110
| `inputProps` | Customized TextInput Component props | Object | `null` | Could overwrite other props |
111111
| `leftButtonProps` | Customized left button (Touchable Component) props | Object | `null` | Could overwrite other props |
@@ -122,7 +122,7 @@ Check the "[Props List](PROPS.md)" file to have the complete list of component p
122122
| `selectTextOnFocus` | If `true`, all text will automatically be selected on focus. | Bool | `false` | |
123123
| `selectionColor` | The highlight and cursor color of the text input. | String | `null` | |
124124
| `step` | Value to increment or decrement the current spinner value | String<br>Number | `1` |
125-
| `type` | Type of spinner | String | `int` | Can be `int` or `real`/`float`... |
125+
| `type` | Type of spinner | String | `int` | Can be `int` or `real`/`float`... |
126126
| `value` | Controlled value of the Spinner | String<br>Number | `0` | |
127127

128128
#### Screenshots
@@ -131,8 +131,8 @@ Check the "[Props List](PROPS.md)" file to have the complete list of component p
131131

132132
##### Description
133133

134-
- Top spinner with a child
135-
- Bottom spinner with `prepend` and `append`
134+
- Top spinner with a child
135+
- Bottom spinner with `prepend` and `append`
136136

137137
### Props Styles
138138

@@ -164,7 +164,7 @@ Check the "[Props List](PROPS.md)" file to have the complete list of component p
164164

165165
##### Description
166166

167-
- Spinner with `color`, `buttonTextColor`, `colorPress` and `buttonPressTextColor` custom colors
167+
- Spinner with `color`, `buttonTextColor`, `colorPress` and `buttonPressTextColor` custom colors
168168

169169
### Props Container Style
170170

index.js

+15-40
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ class InputSpinner extends Component {
3535
spinnerStep = 1;
3636
}
3737

38-
const min =
39-
this.props.min != null ? this.parseNum(this.props.min) : null;
40-
const max =
41-
this.props.max != null ? this.parseNum(this.props.max) : null;
38+
const min = this.props.min != null ? this.parseNum(this.props.min) : null;
39+
const max = this.props.max != null ? this.parseNum(this.props.max) : null;
4240

4341
let initialValue =
4442
this.props.initialValue != null && !isNaN(12)
@@ -72,19 +70,13 @@ class InputSpinner extends Component {
7270
// Parse Min
7371
if (this.props.min !== prevProps.min) {
7472
this.setState({
75-
min:
76-
this.props.min != null
77-
? this.parseNum(this.props.min)
78-
: null,
73+
min: this.props.min != null ? this.parseNum(this.props.min) : null,
7974
});
8075
}
8176
// Parse Max
8277
if (this.props.max !== prevProps.max) {
8378
this.setState({
84-
max:
85-
this.props.max != null
86-
? this.parseNum(this.props.max)
87-
: null,
79+
max: this.props.max != null ? this.parseNum(this.props.max) : null,
8880
});
8981
}
9082
// Parse Step
@@ -198,10 +190,8 @@ class InputSpinner extends Component {
198190
*/
199191
parseNum(num) {
200192
num = String(num).replace(
201-
!isEmpty(this.props.decimalSeparator)
202-
? this.props.decimalSeparator
203-
: ".",
204-
"."
193+
!isEmpty(this.props.decimalSeparator) ? this.props.decimalSeparator : ".",
194+
".",
205195
);
206196
if (this.typeDecimal()) {
207197
num = parseFloat(num);
@@ -226,9 +216,7 @@ class InputSpinner extends Component {
226216
value = this.parseNum(value).toFixed(1).replace(/0+$/, "");
227217
} else if (this.typeDecimal()) {
228218
value = String(
229-
this.parseNum(
230-
this.parseNum(value).toFixed(this.props.precision)
231-
)
219+
this.parseNum(this.parseNum(value).toFixed(this.props.precision)),
232220
);
233221
} else {
234222
value = String(this.parseNum(value));
@@ -240,7 +228,7 @@ class InputSpinner extends Component {
240228
".",
241229
!isEmpty(this.props.decimalSeparator)
242230
? this.props.decimalSeparator
243-
: "."
231+
: ".",
244232
);
245233
}
246234

@@ -284,8 +272,7 @@ class InputSpinner extends Component {
284272
*/
285273
increase() {
286274
if (this._isDisabledButtonRight()) return;
287-
let num =
288-
this.parseNum(this.state.value) + this.parseNum(this.state.step);
275+
let num = this.parseNum(this.state.value) + this.parseNum(this.state.step);
289276
if (this.props.onIncrease) {
290277
let increased_num = num;
291278
if (this.maxReached(num)) {
@@ -308,8 +295,7 @@ class InputSpinner extends Component {
308295
*/
309296
decrease() {
310297
if (this._isDisabledButtonLeft()) return;
311-
let num =
312-
this.parseNum(this.state.value) - this.parseNum(this.state.step);
298+
let num = this.parseNum(this.state.value) - this.parseNum(this.state.step);
313299
if (this.props.onDecrease) {
314300
let decreased_num = num;
315301
if (this.minReached(num)) {
@@ -564,9 +550,7 @@ class InputSpinner extends Component {
564550
*/
565551
_getColorLeftButton() {
566552
const color = this._getColor();
567-
return this.props.colorLeft !== defaultColor
568-
? this.props.colorLeft
569-
: color;
553+
return this.props.colorLeft !== defaultColor ? this.props.colorLeft : color;
570554
}
571555

572556
/**
@@ -590,9 +574,7 @@ class InputSpinner extends Component {
590574
return [
591575
Style.container,
592576
{
593-
borderColor: this.props.showBorder
594-
? this._getColor()
595-
: "transparent",
577+
borderColor: this.props.showBorder ? this._getColor() : "transparent",
596578
width: this.props.width,
597579
},
598580
this.props.style,
@@ -611,9 +593,7 @@ class InputSpinner extends Component {
611593
color: this.props.textColor,
612594
fontSize: this.props.fontSize,
613595
fontFamily: this.props.fontFamily,
614-
borderColor: this.props.showBorder
615-
? this._getColor()
616-
: "transparent",
596+
borderColor: this.props.showBorder ? this._getColor() : "transparent",
617597
backgroundColor: this.props.background,
618598
height: this.props.height,
619599
},
@@ -702,10 +682,7 @@ class InputSpinner extends Component {
702682
_renderLeftButtonElement() {
703683
if (this.props.buttonLeftImage) {
704684
return this.props.buttonLeftImage;
705-
} else if (
706-
this._isLeftButtonPressed() &&
707-
this.props.buttonPressLeftImage
708-
) {
685+
} else if (this._isLeftButtonPressed() && this.props.buttonPressLeftImage) {
709686
return this.props.buttonPressLeftImage;
710687
} else {
711688
const text =
@@ -820,9 +797,7 @@ class InputSpinner extends Component {
820797
*/
821798
render() {
822799
return (
823-
<View
824-
style={this._getContainerStyle()}
825-
{...this.props.containerProps}>
800+
<View style={this._getContainerStyle()} {...this.props.containerProps}>
826801
{this._renderLeftButton()}
827802

828803
{this.props.prepend}

package.json

+1-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "React native input with increase and decrease buttons",
55
"main": "index.js",
66
"scripts": {
7+
"prettify": "prettier --write './*.{ts,json,md,yml,js}'",
78
"test": "echo \"Error: no test specified\" && exit 1"
89
},
910
"repository": {
@@ -26,18 +27,6 @@
2627
"integer",
2728
"decimal"
2829
],
29-
"prettier": {
30-
"tabWidth": 4,
31-
"useTabs": true,
32-
"semi": true,
33-
"singleQuote": false,
34-
"trailingComma": "es5",
35-
"bracketSpacing": false,
36-
"jsxBracketSameLine": true,
37-
"arrowParens": "always",
38-
"requirePragma": false,
39-
"insertPragma": false
40-
},
4130
"peerDependencies": {
4231
"react": "*",
4332
"react-native": "*"

0 commit comments

Comments
 (0)