Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

AP-544 Implement Text Inputs #45

Merged
merged 3 commits into from
Aug 13, 2019
Merged

AP-544 Implement Text Inputs #45

merged 3 commits into from
Aug 13, 2019

Conversation

mayakoneval
Copy link
Contributor

@mayakoneval mayakoneval commented Aug 3, 2019

This PR includes:

  • Text Inputs
  • Steppers
  • Text Inputs with icons

Input Props

Stepper Props

Design

Ticket

Design Quip Doc

Points of conversation:

  • The Stepper onClick accepts a number, while the Input onClick accepts an HTMLInputEvent. This is because the Stepper should only call onChange when the number has actually changed, not when the user makes an action in the input. For example, they could try to decrease the number but the number is at min already, so we don't want to call onClick.
  • The Stepper is copy pasted from Tim's implementation and then emotionified. However, I took the responsibility of updating the value away from the consumer and into the component. @timbotnik curious as to what you think of this.
  • The PR does not include input masking, as Recurly does that for us when we need it.
  • @adamatorres the error and info states look like this (not filled in icons)

image

Is that okay? Note the icons are bottom aligned with the text, do you want the icons aligned display:flex style with the text so that when it wraps the icon is centered to the text like this?

image

Or would you rather it be in line with the text?

Copy link
Member

@cheapsteak cheapsteak left a comment

Choose a reason for hiding this comment

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

Looks great, didn't take too close a look at the stepper component though, hopefully Justin Tim and Trevor can help pick up. gonna go grab breakfast

src/Input/Input.tsx Outdated Show resolved Hide resolved
src/Input/InputWrapper.tsx Outdated Show resolved Hide resolved
src/Input/InputWrapper.tsx Outdated Show resolved Hide resolved
src/Input/Stepper.tsx Outdated Show resolved Hide resolved
src/Input/Input.tsx Outdated Show resolved Hide resolved
}: Props): ReturnType<React.FC> {
return (
<React.Fragment>
<label
Copy link
Member

Choose a reason for hiding this comment

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

We might want to have <label/> tag wrap the {label}, {description}, and {children} (not the error or info messages though), it would automatically associate the text we're using to describe the input with the input box for accessibility (more info). It'd also give focus to the input when clicking on the title, which is imo desirable

Alternatively, we could use aria-label or aria-labelledby, but those are more of a hassle (need to associate them by id, generating unique ids for association is a bit more of a hassle than associating via nesting hierarchy)

package.json Outdated Show resolved Hide resolved
src/Input/Input.story.tsx Outdated Show resolved Hide resolved
...typography.base.base,
textTransform: "uppercase",
fontWeight: 600,
margin: 6,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure where @adamatorres is on this, but 6 is not on the 4px grid. Considering this is a margin that will be applied on both sides of each axis, perhaps it's ok since the net effect is 12px 🤷‍♂

src/Input/Input.tsx Outdated Show resolved Hide resolved
src/Input/InputWrapper.tsx Outdated Show resolved Hide resolved
src/Input/Stepper.tsx Outdated Show resolved Hide resolved
} else if (newValue !== value) {
setValue(newValue);
}
onChange(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be newValue?

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 only want to call onChange with the value if it changes, and in this case newValue is the value the user has just tried to make the stepper. value willonly change if thats a valid value, so I call onChange(value) after all the logic determining if newValue is valid is done and value is set. Does that make sense?

src/Input/Stepper.tsx Outdated Show resolved Hide resolved
src/Input/Stepper.tsx Outdated Show resolved Hide resolved
src/Input/Stepper.tsx Outdated Show resolved Hide resolved
@adamatorres
Copy link
Contributor

adamatorres commented Aug 8, 2019

Hey @mayakoneval -- Here's some design feedback on the inputs:

  • text size in the small input should be 13px, looks like it's 15px.
  • placeholder text color grey-light, it looks a bit darker than it should
  • disabled place holder text is too dark, it should be grey-lighter
  • Helper text needs to support an icon (specifically in error cases) and no icon. We currently don't have an example of basic helper text without an icon.
  • When helper text below an input has an icon and the text wraps, we shouldn't wrap the text under the icon.
  • Let's use the filled icons with the helper text.
  • I'm also seeing a delay of the focus state of the input after clicking into it, not sure what's going on there, but it should feel more instantaneous.

@mayakoneval mayakoneval force-pushed the mkoneval/text-inputs branch 2 times, most recently from 3876d99 to 53b1bc8 Compare August 8, 2019 20:56
@mayakoneval mayakoneval added the minor Increment the minor version when merged label Aug 8, 2019
@jgzuke
Copy link
Contributor

jgzuke commented Aug 9, 2019

A few thoughts from using the new Inputs.

  • Its really awesome to have error states built in 🎉It'll make everything a lot more consistent and easier to build, I got to kill a bunch of code
  • Its a bit weird to have the input manage its own state instead of being a true managed/controlled component. It makes certain things impossible to use the new inputs with Ie recurly inputs (because recurly does dom manipulations), but it also means if the parent keeps the value in its own state as well we have extra render triggers.
  • Right now we pass the otherProps (classNames etc) to the inner input component which makes sense, however it means we cant pass any structure/position changing class names (w-full etc) since the input is wrapped. We can still position them by wrapping in divs or something, but it might make sense to take both props for the input, and for the outer wrapper. Or we could have the input live as a sibling to the label instead of inside, which might fix this problem

@mayakoneval
Copy link
Contributor Author

A few thoughts from using the new Inputs.

  • Its really awesome to have error states built in 🎉It'll make everything a lot more consistent and easier to build, I got to kill a bunch of code
  • Its a bit weird to have the input manage its own state instead of being a true managed/controlled component. It makes certain things impossible to use the new inputs with Ie recurly inputs (because recurly does dom manipulations), but it also means if the parent keeps the value in its own state as well we have extra render triggers.
  • Right now we pass the otherProps (classNames etc) to the inner input component which makes sense, however it means we cant pass any structure/position changing class names (w-full etc) since the input is wrapped. We can still position them by wrapping in divs or something, but it might make sense to take both props for the input, and for the outer wrapper. Or we could have the input live as a sibling to the label instead of inside, which might fix this problem

I believe I fixed this with inputProps on the input and spreading the rest of the props on the outer div. Let me know if I'm off target :)

<div {...otherProps}>
<label
css={{
paddingBottom: 8,
Copy link
Contributor

Choose a reason for hiding this comment

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

Imo in a component library, a components box should be no larger than it needs to be, padding/margins should be set by the people using the components. However, this is a lot less annoying once https://github.com/mdg-private/engine-frontend/pull/1577 or something analogous lands so 🤷‍♂

Copy link
Contributor Author

@mayakoneval mayakoneval Aug 12, 2019

Choose a reason for hiding this comment

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

@jgzuke From our space-kit meetings, it seems that all apollo products want the same spacing / font etc and that is why we decided to create a component library, to be able to use components that already have padding / margins etc and have builtin descriptions / error states. If you need to override this padding, either space-kit is wrong or the designs are not aligned! Let me know!

Copy link
Contributor

Choose a reason for hiding this comment

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

@mayakoneval the designs in https://app.zeplin.io/project/5d375cd742170577784b28ca/screen/5d41d60764e8c22bd5aeac20 have a smaller padding between them than two stacked inputs (with no labels)

@justinanastos justinanastos changed the title AP-544 Text Inputs AP-544 Implement Text Inputs Aug 13, 2019
This will stop us from getting errors in storybook while we're working. We
don't need them, we have them in VS Code and CI
@justinanastos justinanastos merged commit 445a7c2 into master Aug 13, 2019
@justinanastos
Copy link
Contributor

🚀 PR was released in v1.4.0 🚀

@justinanastos justinanastos added the released This issue/pull request has been released. label Aug 13, 2019
@@ -13,6 +13,7 @@
"clean:button": "rimraf Button",
"clean:colors": "rimraf colors",
"clean:fonts": "rimraf fonts",
"clean:formField": "rimraf FormField",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no FormField anymore, so this npm script won't do anything.

@@ -61,6 +61,7 @@ _From #57_
- Edit Modal prop descriptions, fix margin top on children [#41](https://github.com/apollographql/space-kit/pull/41)
- Export constant from `colors` instead of requiring `import * as colors` (#35)
- Add Card component (#34)
- Text Inputs and Steppers [(#45)](https://github.com/apollographql/space-kit/pull/45)
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 doesn't include Steppers, that file has been deleted

/**
* Visible title
*/
label: React.ReactNode;
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 don't think this should be necessary. Credit card form, for example

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants