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

chore(PasswordInput): updated size props #10612

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 0 additions & 22 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4766,17 +4766,6 @@ Map {
},
"PasswordInput" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"className": "\${prefix}--text__input",
"disabled": false,
"helperText": "",
"invalid": false,
"invalidText": "",
"light": false,
"onChange": [Function],
"onClick": [Function],
"size": "",
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down Expand Up @@ -7075,17 +7064,6 @@ Map {
},
"PasswordInput": Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"className": "\${prefix}--text__input",
"disabled": false,
"helperText": "",
"invalid": false,
"invalidText": "",
"light": false,
"onChange": [Function],
"onClick": [Function],
"size": "",
},
"propTypes": Object {
"className": Object {
"type": "string",
Expand Down
49 changes: 20 additions & 29 deletions packages/react/src/components/TextInput/PasswordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,35 @@ import { View16, ViewOff16 } from '@carbon/icons-react';
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps';
import { textInputProps } from './util';
import { FormContext } from '../FluidForm';
import * as FeatureFlags from '@carbon/feature-flags';

const { prefix } = settings;

const PasswordInput = React.forwardRef(function PasswordInput(
{
labelText,
className,
disabled,
id,
placeholder,
onChange,
onClick,
disabled = false,
helperText,
hideLabel,
hidePasswordLabel = 'Hide password',
id,
inline,
invalid,
invalid = false,
invalidText,
helperText,
light,
labelText,
light = false,
onChange = () => {},
onClick = () => {},
onTogglePasswordVisibility,
placeholder,
size = 'md',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, last thing. I thought md was just for v11? Would we need a ternary here for v10 sizes: small & large?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp, good call. Should I go empty string since there was no default in v10?

Copy link
Member Author

@sstrubberg sstrubberg Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can also wait to see if Percy finishes out. Md might already be default since before it was just asking for a string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there are any styles for md in v10/v11 since there are no styles for ${prefix}--text-input--md in /styles or /components so I guess in a way the default is md size wise, it's just never called out specifically?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abbeyhrt Totally. That's what I was assuming as well. The fact the Percy didn't yell at me for setting md is pretty telling, i think. @joshblack can we get some confirmation on these assumptions?

Copy link
Contributor

@abbeyhrt abbeyhrt Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I would go for an empty for the size prop since md doesn't have any meaning but it's also something we can change later on since it wouldn't break anything.

showPasswordLabel = 'Show password',
tooltipPosition = 'bottom',
tooltipAlignment = 'center',
type = 'password',
hidePasswordLabel = 'Hide password',
showPasswordLabel = 'Show password',
size,
onTogglePasswordVisibility,
warn,
warnText,
...other
...rest
},
ref
) {
Expand Down Expand Up @@ -78,7 +79,7 @@ const PasswordInput = React.forwardRef(function PasswordInput(
type: inputType,
className: textInputClasses,
ref,
...other,
...rest,
};
const inputWrapperClasses = classNames(
`${prefix}--form-item`,
Expand Down Expand Up @@ -298,9 +299,11 @@ PasswordInput.propTypes = {
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
* Specify the size of the Text Input. Supports `sm`, `md`, or `lg`.
*/
size: PropTypes.string,
size: FeatureFlags.enabled('enable-v11-release')
? PropTypes.oneOf(['sm', 'md', 'lg'])
: PropTypes.string,

/**
* Specify the alignment of the tooltip to the icon-only button.
Expand Down Expand Up @@ -335,16 +338,4 @@ PasswordInput.propTypes = {
warnText: PropTypes.node,
};

PasswordInput.defaultProps = {
className: '${prefix}--text__input',
disabled: false,
onChange: () => {},
onClick: () => {},
invalid: false,
invalidText: '',
helperText: '',
light: false,
size: '',
};

export default PasswordInput;