Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] feat(NumericInput, FileInput): add "small" modifier prop #6071

Merged
merged 11 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/core/src/components/forms/fileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export interface IFileInputProps extends React.LabelHTMLAttributes<HTMLLabelElem
*/
onInputChange?: React.FormEventHandler<HTMLInputElement>;

/**
* Whether the file input should appear with small styling.
*/
small?: boolean;

/**
* The text to display.
*
Expand Down Expand Up @@ -108,6 +113,7 @@ export class FileInput extends AbstractPureComponent2<FileInputProps> {
inputProps,
large,
onInputChange,
small,
text,
...htmlProps
} = this.props;
Expand All @@ -119,6 +125,7 @@ export class FileInput extends AbstractPureComponent2<FileInputProps> {
[Classes.DISABLED]: disabled,
[Classes.FILL]: fill,
[Classes.LARGE]: large,
[Classes.SMALL]: small,
},
className,
);
Expand Down
19 changes: 17 additions & 2 deletions packages/core/src/components/forms/numericInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ export interface INumericInputProps extends InputSharedProps {
*/
selectAllOnIncrement?: boolean;

/**
* If set to `true`, the input will display with smaller styling.
* This is equivalent to setting `Classes.SMALL` via className on the
* parent control group and on the child input group.
*
* @default false
*/
small?: boolean;

/**
* The increment between successive values when no modifier keys are held.
*
Expand Down Expand Up @@ -218,6 +227,7 @@ export class NumericInput extends AbstractPureComponent2<HTMLInputProps & Numeri
minorStepSize: 0.1,
selectAllOnFocus: false,
selectAllOnIncrement: false,
small: false,
stepSize: 1,
};

Expand Down Expand Up @@ -305,8 +315,12 @@ export class NumericInput extends AbstractPureComponent2<HTMLInputProps & Numeri
private getCurrentValueAsNumber = () => Number(parseStringToStringNumber(this.state.value, this.props.locale));

public render() {
const { buttonPosition, className, fill, large } = this.props;
const containerClasses = classNames(Classes.NUMERIC_INPUT, { [Classes.LARGE]: large }, className);
const { buttonPosition, className, fill, large, small } = this.props;
const containerClasses = classNames(
Classes.NUMERIC_INPUT,
{ [Classes.LARGE]: large, [Classes.SMALL]: small },
className,
);
const buttons = this.renderButtons();
return (
<ControlGroup className={containerClasses} fill={fill}>
Expand Down Expand Up @@ -452,6 +466,7 @@ export class NumericInput extends AbstractPureComponent2<HTMLInputProps & Numeri
onKeyPress={this.handleInputKeyPress}
onPaste={this.handleInputPaste}
rightElement={this.props.rightElement}
small={this.props.small}
value={this.state.value}
/>
);
Expand Down