Skip to content

Commit

Permalink
feat(text-input): add height variations to text input
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Jan 16, 2020
1 parent fb349c6 commit 023b69c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
}
}

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

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

.#{$prefix}--password-input {
padding-right: $carbon--spacing-08;
}
Expand Down
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 = {
'Extra large size (xl)': 'xl',
'Regular size (lg)': '',
'Small size (sm)': 'sm',
};

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 `sm`, `lg` or `xl` as an option.
*/
size: PropTypes.string,

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

export default TextInput;

0 comments on commit 023b69c

Please sign in to comment.