Skip to content

Commit afd30d7

Browse files
fix(NumberInput): deprecate mobile variant (#7919)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 46d2a1f commit afd30d7

File tree

3 files changed

+29
-101
lines changed

3 files changed

+29
-101
lines changed

packages/components/src/components/number-input/_number-input.scss

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -381,54 +381,6 @@
381381
background-color: $hover-light-ui;
382382
}
383383

384-
.#{$prefix}--number--mobile {
385-
width: auto;
386-
min-width: rem(144px);
387-
388-
.#{$prefix}--number__control-btn,
389-
&.#{$prefix}--number--light .#{$prefix}--number__control-btn {
390-
position: static;
391-
width: rem(40px);
392-
height: rem(40px);
393-
background-color: $ui-01;
394-
395-
&:hover,
396-
&:focus {
397-
background-color: $hover-ui;
398-
}
399-
400-
&:focus {
401-
outline-width: 2px;
402-
outline-offset: -2px;
403-
}
404-
405-
svg {
406-
position: static;
407-
}
408-
}
409-
410-
input[type='number'] {
411-
width: auto;
412-
min-width: rem(64px);
413-
margin: 0;
414-
padding: 0;
415-
text-align: center;
416-
background-color: $field-01;
417-
border-right: 1px solid $ui-03;
418-
border-left: 1px solid $ui-03;
419-
}
420-
421-
&.#{$prefix}--number--light {
422-
input[type='number'] {
423-
background-color: $field-02;
424-
}
425-
426-
.#{$prefix}--number__control-btn {
427-
background-color: $ui-02;
428-
}
429-
}
430-
}
431-
432384
// Size Variant styles
433385
.#{$prefix}--number--xl input[type='number'] {
434386
height: rem(48px);
@@ -448,12 +400,6 @@
448400
}
449401
}
450402

451-
.#{$prefix}--number--xl.#{$prefix}--number--mobile
452-
.#{$prefix}--number__control-btn {
453-
width: rem(48px);
454-
height: rem(48px);
455-
}
456-
457403
.#{$prefix}--number--sm input[type='number'] {
458404
height: rem(32px);
459405
}
@@ -472,12 +418,6 @@
472418
}
473419
}
474420

475-
.#{$prefix}--number--sm.#{$prefix}--number--mobile
476-
.#{$prefix}--number__control-btn {
477-
width: rem(32px);
478-
height: rem(32px);
479-
}
480-
481421
//No label positioning adjustment
482422
.#{$prefix}--number--nolabel .bx--label + .bx--form__helper-text {
483423
margin-top: 0;

packages/react/src/components/NumberInput/NumberInput-story.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const props = () => ({
4040
disabled: boolean('Disabled (disabled)', false),
4141
readOnly: boolean('Read only (readOnly)', false),
4242
invalid: boolean('Show form validation UI (invalid)', false),
43-
isMobile: boolean('Mobile variant', false),
4443
invalidText: text(
4544
'Form validation UI content (invalidText)',
4645
'Number is not valid'

packages/react/src/components/NumberInput/NumberInput.js

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import mergeRefs from '../../tools/mergeRefs';
1919
import requiredIfValueExists from '../../prop-types/requiredIfValueExists';
2020
import { useControlledStateWithValue } from '../../internal/FeatureFlags';
21+
import deprecate from '../../prop-types/deprecate';
2122

2223
const { prefix } = settings;
2324

@@ -46,67 +47,86 @@ class NumberInput extends Component {
4647
* `true` to allow empty string.
4748
*/
4849
allowEmpty: PropTypes.bool,
50+
4951
/**
5052
* Provide a description that would be used to best describe the use case of the NumberInput component
5153
*/
5254
ariaLabel: PropTypes.string,
55+
5356
/**
5457
* Specify an optional className to be applied to the wrapper node
5558
*/
5659
className: PropTypes.string,
60+
5761
/**
5862
* Optional starting value for uncontrolled state
5963
*/
6064
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
65+
6166
/**
6267
* Specify if the control should be disabled, or not
6368
*/
6469
disabled: PropTypes.bool,
70+
6571
/**
6672
* Provide text that is used alongside the control label for additional help
6773
*/
6874
helperText: PropTypes.node,
75+
6976
/**
7077
* Specify whether you want the underlying label to be visually hidden
7178
*/
7279
hideLabel: PropTypes.bool,
80+
7381
/**
7482
* Provide a description for up/down icons that can be read by screen readers
7583
*/
7684
iconDescription: PropTypes.string.isRequired,
85+
7786
/**
7887
* Specify a custom `id` for the input
7988
*/
8089
id: PropTypes.string.isRequired,
90+
8191
/**
8292
* Specify if the currently value is invalid.
8393
*/
8494
invalid: PropTypes.bool,
95+
8596
/**
8697
* Message which is displayed if the value is invalid.
8798
*/
8899
invalidText: PropTypes.node,
100+
89101
/**
90102
* `true` to use the mobile variant.
91103
*/
92-
isMobile: PropTypes.bool,
104+
isMobile: deprecate(
105+
PropTypes.bool,
106+
`The \`isMobile\` prop no longer needed as the default NumberInput styles are now identical to the mobile variant styles. This prop will be removed in the next major version of \`carbon-components-react\``
107+
),
108+
93109
/**
94110
* Generic `label` that will be used as the textual representation of what
95111
* this field is for
96112
*/
97113
label: PropTypes.node,
114+
98115
/**
99116
* `true` to use the light version.
100117
*/
101118
light: PropTypes.bool,
119+
102120
/**
103121
* The maximum value.
104122
*/
105123
max: PropTypes.number,
124+
106125
/**
107126
* The minimum value.
108127
*/
109128
min: PropTypes.number,
129+
110130
/**
111131
* The new value is available in 'imaginaryTarget.value'
112132
* i.e. to get the value: evt.imaginaryTarget.value
@@ -120,34 +140,42 @@ class NumberInput extends Component {
120140
onChange: !useControlledStateWithValue
121141
? PropTypes.func
122142
: requiredIfValueExists(PropTypes.func),
143+
123144
/**
124145
* Provide an optional function to be called when the up/down button is clicked
125146
*/
126147
onClick: PropTypes.func,
148+
127149
/**
128150
* Specify if the component should be read-only
129151
*/
130152
readOnly: PropTypes.bool,
153+
131154
/**
132155
* Specify the size of the Number Input. Currently supports either `sm` or `xl` as an option.
133156
*/
134157
size: PropTypes.oneOf(['sm', 'xl']),
158+
135159
/**
136160
* Specify how much the valus should increase/decrease upon clicking on up/down button
137161
*/
138162
step: PropTypes.number,
163+
139164
/**
140165
* Provide custom text for the component for each translation id
141166
*/
142167
translateWithId: PropTypes.func.isRequired,
168+
143169
/**
144170
* Specify the value of the input
145171
*/
146172
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
173+
147174
/**
148175
* Specify whether the control is currently in warning state
149176
*/
150177
warn: PropTypes.bool,
178+
151179
/**
152180
* Provide the text that is displayed when the control is in warning state
153181
*/
@@ -411,45 +439,6 @@ class NumberInput extends Component {
411439
<div className={`${prefix}--form-item`}>
412440
<div className={numberInputClasses} {...inputWrapperProps}>
413441
{(() => {
414-
if (isMobile) {
415-
return (
416-
<>
417-
{labelText}
418-
{helper}
419-
<div className={`${prefix}--number__input-wrapper`}>
420-
<button
421-
type="button"
422-
className={`${prefix}--number__control-btn down-icon`}
423-
{...buttonProps}
424-
onClick={(evt) => this.handleArrowClick(evt, 'down')}
425-
title={decrementNumLabel}
426-
aria-label={decrementNumLabel || iconDescription}
427-
aria-live="polite"
428-
aria-atomic="true">
429-
<Subtract16 className="down-icon" />
430-
</button>
431-
<input
432-
type="number"
433-
pattern="[0-9]*"
434-
{...other}
435-
{...props}
436-
ref={mergeRefs(ref, this._handleInputRef)}
437-
/>
438-
<button
439-
type="button"
440-
className={`${prefix}--number__control-btn up-icon`}
441-
{...buttonProps}
442-
onClick={(evt) => this.handleArrowClick(evt, 'up')}
443-
title={incrementNumLabel}
444-
aria-label={incrementNumLabel || iconDescription}
445-
aria-live="polite"
446-
aria-atomic="true">
447-
<Add16 className="up-icon" />
448-
</button>
449-
</div>
450-
</>
451-
);
452-
}
453442
return (
454443
<>
455444
{labelText}

0 commit comments

Comments
 (0)