@@ -39,6 +39,8 @@ export default function Stepper({
39
39
const animationDiv = document . getElementById ( 'loading' ) ;
40
40
const animationBackground = document . getElementById ( 'loading-background' ) ;
41
41
const [ minusBt , setMinusBt ] = useState ( { } ) ;
42
+ const [ plusBt , setPlusBt ] = useState ( { } ) ;
43
+ const [ inputBt , setInputBt ] = useState ( { } ) ;
42
44
43
45
const handleIncrementBtProps = {
44
46
className : classnames ( baseClass , [ { disabled } , { theme } ] ) ,
@@ -49,7 +51,7 @@ export default function Stepper({
49
51
style : { }
50
52
} ;
51
53
const inputProps = {
52
- className : classnames ( baseClass , [ { disableInput } ] ) ,
54
+ className : classnames ( baseClass , [ { disableInput } , { theme } ] ) ,
53
55
style : { }
54
56
} ;
55
57
@@ -135,67 +137,50 @@ export default function Stepper({
135
137
}
136
138
} , [ disabled , value , max , min , handleDecrementProps , handleIncrementBtProps ] ) ;
137
139
useEffect ( ( ) => {
138
- if ( value === 0 ) {
139
- const btStyle = { cursor : 'not-allowed' , opacity : '0.2' } ;
140
- setMinusBt ( btStyle ) ;
140
+ if ( size ) {
141
+ const Size = `${ size } px` ;
142
+ setMinusBt ( { width : Size , height : Size } ) ;
143
+ setInputBt ( { width : Size , height : Size } ) ;
144
+ setPlusBt ( { width : Size , height : Size } ) ;
145
+ if ( value === 0 || value === min ) {
146
+ const btStyle = {
147
+ cursor : 'not-allowed' ,
148
+ width : Size ,
149
+ height : Size ,
150
+ opacity : '0.2'
151
+ } ;
152
+ setMinusBt ( btStyle ) ;
153
+ } else if ( value === max ) {
154
+ const btStyle = {
155
+ cursor : 'not-allowed' ,
156
+ width : Size ,
157
+ height : Size ,
158
+ opacity : '0.2'
159
+ } ;
160
+ setPlusBt ( btStyle ) ;
161
+ } else {
162
+ setMinusBt ( { width : Size , height : Size } ) ;
163
+ setInputBt ( { width : Size , height : Size } ) ;
164
+ setPlusBt ( { width : Size , height : Size } ) ;
165
+ }
141
166
} else {
142
- setMinusBt ( { } ) ;
167
+ if ( value === 0 || value === min ) {
168
+ const btStyle = { cursor : 'not-allowed' , opacity : '0.2' } ;
169
+ setMinusBt ( btStyle ) ;
170
+ } else if ( value === max ) {
171
+ const btStyle = { cursor : 'not-allowed' , opacity : '0.2' } ;
172
+ setPlusBt ( btStyle ) ;
173
+ } else {
174
+ setMinusBt ( { } ) ;
175
+ setPlusBt ( { } ) ;
176
+ }
143
177
}
144
178
} , [ value ] ) ;
145
179
146
180
if ( disabled ) {
147
181
Object . assign ( handleDecrementProps , { disabled } ) ;
148
182
Object . assign ( handleIncrementBtProps , { disabled } ) ;
149
183
}
150
- if ( theme ) {
151
- Object . assign ( handleIncrementBtProps , {
152
- style : {
153
- ...handleIncrementBtProps . style ,
154
- background : '#ee0a24' ,
155
- color : 'white'
156
- }
157
- } ) ;
158
- Object . assign ( handleDecrementProps , {
159
- style : {
160
- ...handleDecrementProps . style ,
161
- border : '1px solid #ee0a24' ,
162
- color : '#ee0a24' ,
163
- background : 'white'
164
- }
165
- } ) ;
166
- Object . assign ( inputProps , {
167
- style : {
168
- ...inputProps . style ,
169
- background : 'white'
170
- }
171
- } ) ;
172
- }
173
-
174
- if ( size ) {
175
- const Size = `${ size } px` ;
176
-
177
- Object . assign ( handleDecrementProps , {
178
- style : {
179
- ...handleDecrementProps . style ,
180
- width : Size ,
181
- height : Size
182
- }
183
- } ) ;
184
- Object . assign ( handleIncrementBtProps , {
185
- style : {
186
- ...handleIncrementBtProps . style ,
187
- width : Size ,
188
- height : Size
189
- }
190
- } ) ;
191
- Object . assign ( inputProps , {
192
- style : {
193
- ...inputProps . style ,
194
- width : Size ,
195
- height : Size
196
- }
197
- } ) ;
198
- }
199
184
200
185
useEffect ( ( ) => {
201
186
if ( disableInput ) {
@@ -222,12 +207,14 @@ export default function Stepper({
222
207
{ ...inputProps }
223
208
onChange = { handleInputChange }
224
209
disabled = { isInput }
210
+ style = { inputBt }
225
211
/>
226
212
227
213
< button
228
214
onClick = { handleIncrement }
229
215
{ ...handleIncrementBtProps }
230
216
disabled = { isPlus }
217
+ style = { plusBt }
231
218
>
232
219
< img
233
220
src = 'https://res.cloudinary.com/dlapk94rx/image/upload/v1595307854/icons8-plus-24_wnv2uo.png'
0 commit comments