Skip to content

Commit

Permalink
chore(Field.Number): use default size for when showStepControls is us…
Browse files Browse the repository at this point in the history
…ed (#3233)

Following up of PR #3229
  • Loading branch information
tujoworker authored Jan 17, 2024
1 parent ee5014f commit b886ad9
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,18 @@ export const Widths = () => {
value={1234}
/>
<Field.Number label="Small" value={1234} width="small" />
<Field.Number label="Medium" value={1234} width="medium" />
<Field.Number label="Large" value={1234} width="large" />
<Field.Number
label="Medium (and medium size)"
value={1234}
width="medium"
size="medium"
/>
<Field.Number
label="Large (and large size)"
value={1234}
width="large"
size="large"
/>
<Field.Number label="Stretch" value={1234} width="stretch" />
<Form.SubHeading>With step controls</Form.SubHeading>
<Field.Number
Expand All @@ -132,15 +142,17 @@ export const Widths = () => {
/>
<Field.Number
showStepControls
label="Medium"
label="Medium (and medium size)"
value={1234}
width="medium"
size="medium"
/>
<Field.Number
showStepControls
label="Large"
label="Large (and large size)"
value={1234}
width="large"
size="large"
/>
<Field.Number
showStepControls
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 2 additions & 11 deletions packages/dnb-eufemia/src/extensions/forms/Field/Number/Number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function NumberComponent(props: Props) {
className: 'dnb-button--control-after',
variant: 'secondary',
icon: 'add',
size: convertInputSizeToButtonSize(size),
size: (size || 'small') as ButtonSize,
tabIndex: -1,
disabled: disabled || value >= maximum,
onClick: () => {
Expand All @@ -265,6 +265,7 @@ function NumberComponent(props: Props) {
...increaseProps,
className: 'dnb-button--control-before',
icon: 'subtract',
size: (size || 'small') as ButtonSize,
disabled: disabled || value <= minimum,
onClick: () => {
handleChange({
Expand Down Expand Up @@ -325,15 +326,5 @@ function NumberComponent(props: Props) {
)
}

const convertInputSizeToButtonSize = (
inputSize: InputSize
): ButtonSize => {
const buttonSize =
['small', 'medium', 'large'].indexOf(inputSize as string) > -1
? inputSize
: 'medium'
return buttonSize as ButtonSize
}

NumberComponent._supportsSpacingProps = true
export default NumberComponent
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import '../../../../../style/core/utilities.scss';
@import '../../style/field-sizes.scss';

.dnb-forms-field-number {
--number-control-button-border-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
&--has-controls {
background-color: #1c1b4e;
border-radius: 3rem;

// There is no small size in Sbanken
.dnb-button.dnb-button--size-small {
--button-height--small: 2.5rem;
--button-width--small: 2.5rem;
}

.dnb-input {
position: relative;
&::before,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@
--number-control-button-color--active: var(--color-sea-green);
--number-control-button--error: var(--color-fire-red);
--number-control-button--error-contrast: var(--color-fire-red-8);

&__contents {
&--has-controls {
.dnb-button.dnb-button--size-small {
--button-height--small: 2rem;
--button-width--small: 2rem;
}
}
}
}

0 comments on commit b886ad9

Please sign in to comment.