@@ -112,7 +112,7 @@ export default function Stepper({
112
112
ReactDOM . findDOMNode ( animationDiv ) . style . opacity = 1 ;
113
113
ReactDOM . findDOMNode ( animationBackground ) . style . opacity = 1 ;
114
114
const changeInput = ( ) => {
115
- setValue ( result ) ;
115
+ setValue ( Number ( result ) ) ;
116
116
ReactDOM . findDOMNode ( animationDiv ) . style . opacity = 0 ;
117
117
ReactDOM . findDOMNode ( animationBackground ) . style . opacity = 0 ;
118
118
} ;
@@ -121,35 +121,39 @@ export default function Stepper({
121
121
setValue ( Number ( e . target . value ) ) ;
122
122
}
123
123
} ;
124
+
124
125
useEffect ( ( ) => {
125
126
if ( disabled ) {
127
+ const btStyle = {
128
+ cursor : 'not-allowed' ,
129
+ opacity : '0.2'
130
+ } ;
131
+ setMinusBt ( btStyle ) ;
132
+ setPlusBt ( btStyle ) ;
126
133
setIsPlus ( true ) ;
127
134
setIsMinus ( true ) ;
128
- } else {
129
- if ( value === 0 || value === min ) {
130
- setIsMinus ( true ) ;
131
- } else if ( value === max ) {
132
- setIsPlus ( true ) ;
133
- } else {
134
- setIsMinus ( false ) ;
135
- setIsPlus ( false ) ;
136
- }
137
- }
138
- } , [ disabled , value , max , min , handleDecrementProps , handleIncrementBtProps ] ) ;
139
- useEffect ( ( ) => {
140
- if ( size ) {
135
+ Object . assign ( handleDecrementProps , { disabled } ) ;
136
+ Object . assign ( handleIncrementBtProps , { disabled } ) ;
137
+ } else if ( size ) {
141
138
const Size = `${ size } px` ;
142
139
setMinusBt ( { width : Size , height : Size } ) ;
143
140
setInputBt ( { width : Size , height : Size } ) ;
144
- setPlusBt ( { width : Size , height : Size } ) ;
141
+ setPlusBt ( { cursor : 'pointer' } ) ;
142
+
145
143
if ( value === 0 || value === min ) {
146
144
const btStyle = {
147
145
cursor : 'not-allowed' ,
148
146
width : Size ,
149
147
height : Size ,
150
148
opacity : '0.2'
151
149
} ;
150
+ const btnStyle = {
151
+ cursor : 'pointer' ,
152
+ width : Size ,
153
+ height : Size
154
+ } ;
152
155
setMinusBt ( btStyle ) ;
156
+ setPlusBt ( btnStyle ) ;
153
157
} else if ( value === max ) {
154
158
const btStyle = {
155
159
cursor : 'not-allowed' ,
@@ -159,20 +163,30 @@ export default function Stepper({
159
163
} ;
160
164
setPlusBt ( btStyle ) ;
161
165
} else {
162
- setMinusBt ( { width : Size , height : Size } ) ;
163
- setInputBt ( { width : Size , height : Size } ) ;
164
- setPlusBt ( { width : Size , height : Size } ) ;
166
+ const btnStyle = {
167
+ cursor : 'pointer' ,
168
+ width : Size ,
169
+ height : Size
170
+ } ;
171
+ setMinusBt ( btnStyle ) ;
172
+ setInputBt ( btnStyle ) ;
173
+ setPlusBt ( btnStyle ) ;
165
174
}
166
175
} else {
167
176
if ( value === 0 || value === min ) {
168
177
const btStyle = { cursor : 'not-allowed' , opacity : '0.2' } ;
178
+ const btnStyle = { cursor : 'pointer' } ;
169
179
setMinusBt ( btStyle ) ;
180
+ setPlusBt ( btnStyle ) ;
170
181
} else if ( value === max ) {
171
182
const btStyle = { cursor : 'not-allowed' , opacity : '0.2' } ;
172
183
setPlusBt ( btStyle ) ;
173
184
} else {
174
- setMinusBt ( { } ) ;
175
- setPlusBt ( { } ) ;
185
+ const btnStyle = {
186
+ cursor : 'pointer'
187
+ } ;
188
+ setMinusBt ( btnStyle ) ;
189
+ setPlusBt ( btnStyle ) ;
176
190
}
177
191
}
178
192
} , [ value ] ) ;
@@ -187,15 +201,13 @@ export default function Stepper({
187
201
return (
188
202
< div className = 'step-container' >
189
203
< button
204
+ id = 'minus'
190
205
onClick = { handleDecrement }
191
206
{ ...handleDecrementProps }
192
207
disabled = { isMinus }
193
208
style = { minusBt }
194
209
>
195
- < img
196
- src = 'https://res.cloudinary.com/dlapk94rx/image/upload/v1595307854/icons8-minus-24_y8dnmc.png'
197
- alt = ''
198
- /> { ' ' }
210
+ < div className = 'minus' />
199
211
</ button >
200
212
< input
201
213
value = { value }
@@ -204,23 +216,19 @@ export default function Stepper({
204
216
disabled = { isInput }
205
217
style = { inputBt }
206
218
/>
207
-
219
+ { loading && (
220
+ < div id = 'loading-background' className = 'load' >
221
+ < div id = 'loading' className = 'load-background' />
222
+ </ div >
223
+ ) }
208
224
< button
209
225
onClick = { handleIncrement }
210
226
{ ...handleIncrementBtProps }
211
227
disabled = { isPlus }
212
228
style = { plusBt }
213
229
>
214
- < img
215
- src = 'https://res.cloudinary.com/dlapk94rx/image/upload/v1595307854/icons8-plus-24_wnv2uo.png'
216
- alt = ''
217
- />
230
+ < div className = 'add' />
218
231
</ button >
219
- { loading && (
220
- < div id = 'loading-background' className = 'load' >
221
- < div id = 'loading' className = 'load-background' />
222
- </ div >
223
- ) }
224
232
</ div >
225
233
) ;
226
234
}
0 commit comments