Skip to content

Commit 0b20b85

Browse files
authored
feat(input): add counter example (#3096)
1 parent 245492e commit 0b20b85

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

ui/components/input/base/_index.scss

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@
6161
}
6262
}
6363

64+
/**
65+
* @summary Modifier for number input with increment and decrement buttons
66+
*
67+
* @selector .slds-input_counter
68+
* @restrict .slds-input, input
69+
* @modifier
70+
*/
71+
&_counter {
72+
text-align: center;
73+
padding: 0 $spacing-xx-large;
74+
75+
&[type='number'] {
76+
appearance: textfield;
77+
}
78+
79+
&::-webkit-outer-spin-button,
80+
&::-webkit-inner-spin-button {
81+
appearance: none;
82+
margin: 0;
83+
}
84+
}
85+
6486
/**
6587
* Used to apply an input size to another element thats a non input
6688
* Because sometimes I need elements the same height as inputs
@@ -287,3 +309,27 @@
287309
color: $color-text-error;
288310
}
289311
}
312+
313+
/**
314+
* @summary Positions decrement button within counter input field
315+
*
316+
* @selector .slds-input__button_decrement
317+
* @restrict button
318+
*/
319+
.slds-input__button_decrement {
320+
position: absolute;
321+
bottom: 0.25rem;
322+
left: 0.75rem;
323+
}
324+
325+
/**
326+
* @summary Positions increment button within counter input field
327+
*
328+
* @selector .slds-input__button_increment
329+
* @restrict button
330+
*/
331+
.slds-input__button_increment {
332+
position: absolute;
333+
bottom: 0.25rem;
334+
right: 0.75rem;
335+
}

ui/components/input/base/example.jsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import React from 'react';
55
import SvgIcon from '../../../shared/svg-icon';
6+
import ButtonIcon from '../../button-icons/';
67
import classNames from 'classnames';
78
import { SpinnerContainer, Spinner } from '../../spinners/base/example';
89

@@ -369,5 +370,36 @@ export let examples = [
369370
</div>
370371
</div>
371372
)
373+
},
374+
{
375+
id: 'counter',
376+
label: 'Counter',
377+
element: (
378+
<FormElement className="slds-text-align_center">
379+
<ButtonIcon
380+
className="slds-button_icon-small slds-input__button_decrement"
381+
symbol="error"
382+
assistiveText={'Decrement counter'}
383+
title={'Decrement counter'}
384+
/>
385+
<FormElementLabel id="user-count-01" className="slds-m-right_none">
386+
Input Label
387+
</FormElementLabel>
388+
<FormElementControl>
389+
<Input
390+
className="slds-input_counter"
391+
id="user-count-01"
392+
type="number"
393+
placeholder={1}
394+
/>
395+
</FormElementControl>
396+
<ButtonIcon
397+
className="slds-button_icon-small slds-input__button_increment"
398+
symbol="new"
399+
assistiveText={'Increment counter'}
400+
title={'Increment counter'}
401+
/>
402+
</FormElement>
403+
)
372404
}
373405
];

0 commit comments

Comments
 (0)