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

Input validation styles #1831

Merged
merged 11 commits into from
Feb 10, 2022
Merged

Input validation styles #1831

merged 11 commits into from
Feb 10, 2022

Conversation

mperrotti
Copy link
Contributor

These changes render validation styles on form inputs that didn't previously have them, and shows those validation styles in Storybook.

Closes https://github.com/github/primer/issues/495

Merge checklist

  • [n/a] Added/updated tests
  • [n/a] Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@mperrotti mperrotti requested review from a team and jfuchs February 1, 2022 23:37
@changeset-bot
Copy link

changeset-bot bot commented Feb 1, 2022

🦋 Changeset detected

Latest commit: 6107154

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mperrotti mperrotti changed the title Validation styles Input validation styles Feb 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 62.67 KB (+0.08% 🔺)
dist/browser.umd.js 63.06 KB (+0.08% 🔺)

<PropsTable.Row
name="hideTokenRemoveButtons"
type="boolean"
defaultValue="false"
description="Whether the remove buttons should be rendered in the tokens"
/>
<PropsTableRow name="validationStatus" type="'warning' | 'error'" description="Style the input to match the status" />
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're not removing 'warning' as part of this issue, do we need to create another one or does it already exist?

Copy link
Contributor

Choose a reason for hiding this comment

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

Think you're missing 'success' from here too?

Suggested change
<PropsTableRow name="validationStatus" type="'warning' | 'error'" description="Style the input to match the status" />
<PropsTableRow name="validationStatus" type="'warning' | 'error' | 'success'" description="Style the input to match the status" />

Copy link
Contributor

Choose a reason for hiding this comment

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

Another one docs related one (sorry): Can we add an example showing validationStatus being applied?

Copy link
Contributor Author

@mperrotti mperrotti Feb 8, 2022

Choose a reason for hiding this comment

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

If we're not removing 'warning' as part of this issue, do we need to create another one or does it already exist?

We need to create one. I'm going to add this as a topic of conversation for the Primer patterns working session.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another one docs related one (sorry): Can we add an example showing validationStatus being applied?

Yes

type: 'radio'
}
},
inputSize: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Heads up.. this control doesn't seem to work as intended?

Screen.Recording.2022-02-03.at.11.25.04.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what happened there. Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The size difference isn't noticeable with most token sizes unless you have text in the input.

Maybe we should get rid of the inputSize prop altogether, and rely just on the size prop. Then we can manually pass the size to the TextInputWrapper depending on what was passed to size.

I'll push something up and you can let me know what you think.

Copy link
Contributor Author

@mperrotti mperrotti Feb 9, 2022

Choose a reason for hiding this comment

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

Before:

Kapture.2022-02-08.at.18.51.03.mp4

After:

Kapture.2022-02-08.at.19.03.42.mp4

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, I think this is a big improvement 👍 . Thanks for making this change.

On a side note, are there usage guidelines for this particular prop? Curious why / where you'd need some of these larger sizes. Could we be encouraging an anti-pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we would mostly use the larger sizes because they have a larger touch target. You would use different sizes depending on where you're rendering the input.

/**
* The size of the text input
*/
inputSize?: StyledWrapperProps['size']
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious about this one, could you provide some context on it please? I'm a bit confused about relationship to native size attribute on <input, which is a number? When I tried small or large it doesn't seem to make any noticeable difference either.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also think that given the component it named as a **TextInput**WithTokens, size prop should perhaps relate to input instead of tokens

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, size should refer to the input. When this component was made, we used variant for size.

I'll change it and update size to be tokenSize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This won't be an issue if we just remove inputSize as I'm recommending in #1831 (comment)

}
},
validationStatus: {
options: ['warning', 'error', undefined],
Copy link
Contributor

Choose a reason for hiding this comment

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

missing 'success' here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't use 'success' for TextInput, so I didn't add it for TextInputWithTokens.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it use TextInputWrapper under the hood? If so, it does support success now in the base component:

validationStatus?: FormValidationStatus

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, then let's accept "success" in both TextInput and TextInputWithTokens.

We're going to be discussing the "warning" and "success" statuses in next week's Primer patterns working session, so we can update if we need to.

Co-authored-by: Rez <rezrah@github.com>
Co-authored-by: Rez <rezrah@github.com>
@mperrotti mperrotti requested a review from rezrah February 9, 2022 14:54
@mperrotti mperrotti merged commit 96473f3 into main Feb 10, 2022
@mperrotti mperrotti deleted the mp/validation-styles branch February 10, 2022 14:07
@primer-css primer-css mentioned this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants