Skip to content

Commit

Permalink
feat(text-input): add height variations to text input (#5076)
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan authored and asudoh committed Jan 21, 2020
1 parent d36f6ba commit 7011d0b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
}
}

.#{$prefix}--text-input--large {
height: rem(48px);
}

.#{$prefix}--text-input--small {
height: rem(32px);
}

.#{$prefix}--password-input {
padding-right: $carbon--spacing-08;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const ControlledPasswordInput = React.forwardRef(
togglePasswordVisibility,
tooltipPosition = 'bottom',
tooltipAlignment = 'center',
size,
...other
},
ref
Expand All @@ -37,6 +38,7 @@ const ControlledPasswordInput = React.forwardRef(
{
[`${prefix}--text-input--light`]: light,
[`${prefix}--text-input--invalid`]: invalid,
[`${prefix}--text-input--${size}`]: size,
}
);
const sharedTextInputProps = {
Expand Down Expand Up @@ -218,6 +220,11 @@ ControlledPasswordInput.propTypes = {
* Can be one of: start, center, or end.
*/
tooltipAlignment: PropTypes.oneOf(['start', 'center', 'end']),

/**
* Specify the size of the Text Input. Currently supports either `small` or `large` as an option. If omitted, defaults to standard size
*/
size: PropTypes.string,
};

ControlledPasswordInput.defaultProps = {
Expand All @@ -229,6 +236,7 @@ ControlledPasswordInput.defaultProps = {
invalidText: '',
helperText: '',
light: false,
size: '',
};

export default ControlledPasswordInput;
8 changes: 8 additions & 0 deletions packages/react/src/components/TextInput/PasswordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function PasswordInput({
tooltipAlignment = 'center',
hidePasswordLabel = 'Hide password',
showPasswordLabel = 'Show password',
size,
...other
}) {
const [inputType, setInputType] = useState('password');
Expand All @@ -36,6 +37,7 @@ export default function PasswordInput({
{
[`${prefix}--text-input--light`]: light,
[`${prefix}--text-input--invalid`]: invalid,
[`${prefix}--text-input--${size}`]: size,
}
);
const sharedTextInputProps = {
Expand Down Expand Up @@ -223,6 +225,11 @@ PasswordInput.propTypes = {
* "Show password" tooltip text on password visibility toggle
*/
showPasswordLabel: PropTypes.string,

/**
* Specify the size of the Text Input. Currently supports either `small` or `large` as an option. If omitted, defaults to standard size
*/
size: PropTypes.string,
};

PasswordInput.defaultProps = {
Expand All @@ -234,4 +241,5 @@ PasswordInput.defaultProps = {
invalidText: '',
helperText: '',
light: false,
size: '',
};
7 changes: 7 additions & 0 deletions packages/react/src/components/TextInput/TextInput-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const types = {
'For password (password)': 'password',
};

const sizes = {
Large: 'large',
Default: '',
Small: 'small',
};

function ControlledPasswordInputApp(props) {
const [type, setType] = useState('password');
const togglePasswordVisibility = () => {
Expand All @@ -45,6 +51,7 @@ const props = {
'Default value (defaultValue)',
'This is not a default value'
),
size: select('Field size (size)', sizes, '') || undefined,
labelText: text('Label text (labelText)', 'Text Input label'),
placeholder: text('Placeholder text (placeholder)', 'Placeholder text'),
light: boolean('Light variant (light)', false),
Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const TextInput = React.forwardRef(function TextInput(
invalidText,
helperText,
light,
size,
...other
},
ref
Expand All @@ -37,6 +38,7 @@ const TextInput = React.forwardRef(function TextInput(
const textInputClasses = classNames(`${prefix}--text-input`, className, {
[`${prefix}--text-input--light`]: light,
[`${prefix}--text-input--invalid`]: invalid,
[`${prefix}--text-input--${size}`]: size,
});
const sharedTextInputProps = {
id,
Expand Down Expand Up @@ -143,6 +145,11 @@ TextInput.propTypes = {
*/
placeholder: PropTypes.string,

/**
* Specify the size of the Text Input. Currently supports either `small` or `large` as an option. If omitted, defaults to standard size
*/
size: PropTypes.string,

/**
* Specify the type of the <input>
*/
Expand Down Expand Up @@ -188,6 +195,7 @@ TextInput.defaultProps = {
invalidText: '',
helperText: '',
light: false,
size: '',
};

export default TextInput;

0 comments on commit 7011d0b

Please sign in to comment.