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 /> v2 #47

Merged
merged 54 commits into from
Nov 13, 2019
Merged

<Input /> v2 #47

merged 54 commits into from
Nov 13, 2019

Conversation

juanca
Copy link
Contributor

@juanca juanca commented Jul 26, 2019

Type of work: component

Deployment URL: https://mavenlink.github.io/design-system/input

(Optional for outside contributions) Tracked work in Mavenlink: https://www.pivotaltracker.com/story/show/165360149

Motivation

In order to better support MavenPages, we need an input component that is already accessible and forward-looking with design.

Version 2 of the input will bake in better accessibility by enforcing a label. It will also remove the pass-through properties interface to avoid consumer applications from misusing the input -- for example, we have a case where a developer used the input as a checkbox.

Misuses of components will create a maintenance burden in the future and misdirect vital demand information about MDS.

Useful resources:

Acceptance Criteria

  • It looks great in our support browsers list
  • It is backwards compatible with existing usages in Mavenlink (or usages are changed for more appropriate inputs)

Change log entry

Implement <Input> version 2. More accessible and better defined property interface.
Improve <Button>: allow name and value properties.

juanca added 8 commits July 25, 2019 15:52
The pass-through technique might not be desirable in a library. It can create situations that make it hard to deprecate unforeseen usages of a given component. We should try to stick to supporting a minimal set of components which provide the look and feel of Mavenlink -- not an end-all developer tool.
@juanca
Copy link
Contributor Author

juanca commented Jul 31, 2019

Closes #34

@juanca juanca changed the base branch from master to all-svgs-in-internal-design-system-partII July 31, 2019 23:40
juanca and others added 7 commits August 2, 2019 14:19
…ut it. Add disabled example for us to implement and style later.
Avoids the icon overflowing the input when the label is too large.

Signed-off-by: Rob Levin <[email protected]>
Remove unnecessary <div> container on <Input>
Copy link
Contributor

@roblevintennis roblevintennis left a comment

Choose a reason for hiding this comment

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

@juanca I've added several questions and comments on the input api—I know you've mentioned you'll be perusing PRs while in your travels, but I'm not sure how often. Since this is meant to set a precedent from your email to me:

The button work and input work have set an interesting precedent of these. 

I think my questions are important to resolve before moving on to new things e.g. the file input component...

Also, I see the base branch is all-svgs-in-internal-design-system-partII, so I suppose that's meant to reinforce the relationship? and/or was your thought that since you'd be away, I should consider just merging it in to my work since we weren't able to get the <Input /> fully reviewed and merged before you left? I'm uncertain whether you considered this WIP or dev done.

src/components/input/input.jsx Show resolved Hide resolved
src/components/input/input.css Show resolved Hide resolved
src/components/input/input.jsx Show resolved Hide resolved
src/components/input/input.jsx Show resolved Hide resolved
src/components/input/input.jsx Show resolved Hide resolved
@roblevintennis

This comment has been minimized.

@juanca juanca changed the base branch from all-svgs-in-internal-design-system-partII to master August 23, 2019 19:10
juanca and others added 7 commits August 23, 2019 12:12
Otherwise, we add yet another requirement on host applications when using this library.
We want other to use each individual component. This makes it easier for static analysis. _Maybe_ in the future we will reverse this decision.
 Conflicts:
	src/components/button/button.jsx
	src/components/button/button.test.jsx
We want to only support text-like types. We might as well do it little by little. Otherwise, we could get into a situation where someone uses the input as a checkbox!
@juanca juanca requested a review from Bloodyaugust November 5, 2019 03:15
…t flows with its container.

Ideally, usages of MDS Input should provide their own layout -- or possibly a cssContainer class name with a width.
@juanca

This comment has been minimized.

.eslintrc.js Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
jest.config.js Show resolved Hide resolved
setup-enzyme.js Show resolved Hide resolved
</label>
<div className={props.cssContainer}>
<input
className={getClassName(props.className, props.invalid)}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned about the number of configurations here. Are there things we could do, like advocate for the usage of native handlers for some of these?

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 is an opinionated implementation.

As you can see from the code removed section, the MDS Input v1 was just that -- it passed through all props onto the <input> element. We thought that would be the best for MDS library but we saw incorrect usages of our MDS Input. Since we can just pass any kind of type into the MDS input, we ended up in a situation where a feature team used our MDS input as a checkbox -- which basically gutted the whole thing.

Now, I think I understand the whole battle between configuration vs composition. While we do see many configuration options, I do not think this is a "configurable" component -- I think that is usually applied to components that change their behavior based on their properties. In this case, we are whitelisting the configuration options to the <input> -- which means we want to control how much configuration is allowed for native elements.

Copy link
Contributor

@roblevintennis roblevintennis Nov 13, 2019

Choose a reason for hiding this comment

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

Time to have another look at typescript :) We're having same sorts of nuanced issues at my new place and have even gone so far as to throw a fatal Error if unrecognized props are passed in—this starts to make the code less readable and it's not fault tolerant per se. Typescript lets you know at compile time, you can just declare the interface you expect (prop-types is really not so great at enforcing and devs will just ignore warnings whereas an interface will be noisy at compile time and not let the application developers use incorrect props at all). It IS a PITA to configure TS at times though.

Something to maybe consider longer term I dunno :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm definitely not comfortable with the idea that implementation issues should be solved by just switching languages, there's a wealth of baggage for any language. 😄 I do like the opinionated approach, but perhaps we could forward native event handlers specifically? That way our interface maintains at least part of the underlying HTML native interface, and the part that we need for proper usage of the component while also supporting wrappers for more advanced behavior.

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 are no native event handles in React! React uses its own event system (and, sure, it ties it into native event handles but that is abstracted away from us React developers).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@roblevintennis Hello! 👋

Yeah, I'm on the same boat as always: I don't want to adopt yet another non-standard thing if I can post-pone it as long as possible. We adopted React and CSS Modules but we did wait a good 4 years before doing any of that. Hah, maybe in 4 years I'll consider TS. ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel ya kinda ;) In this spirit of coding towards standards, I'd be very curious if esnext et al introduce some sort of notion of interfaces; although it's sort of useless as a runtime only thing imo (main thing is to get compile / transpile knowledge of bad inputs).

If you think about it, really, Webpack is a very specific way to set things up and many folks consider it extremely painful (folks at my new gig are in favor of using create react app or gatsby or something because they've tired of fighting Webpack). React leaves itself around in your code (e.g. read the philosophy of Svelte which compiles itself away). CSS Modules is really just a nifty spec which ala css-loader and Webpack does some name munging tricks, and as we know does not work perfectly (although I'm still using it as it's the least of all unfortunate options).

All to say, our jobs and lives in web-land are still a mess and not really so standards-based 😋 I am sad that my new gig is still quite rooted in Sass but maybe we'll get on the PostCSS train in 2020.

Copy link
Contributor

@roblevintennis roblevintennis Nov 13, 2019

Choose a reason for hiding this comment

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

there's a wealth of baggage for any language

Typescript is not really a language but more of a superset of JavaScript. Yes, there's some baggage, but also some benefits. Especially if you like to use inversion of control (which I know you loathe from a particular meeting I recall where we brought up DI and you were a bigtime detractor) @Bloodyaugust :)

src/components/input/input.jsx Show resolved Hide resolved
Copy link
Contributor

@Bloodyaugust Bloodyaugust left a comment

Choose a reason for hiding this comment

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

LGTM! We'll keep an eye on component complexity going forward.

@juanca juanca merged commit 097d8ec into master Nov 13, 2019
@juanca juanca deleted the input branch November 13, 2019 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants