-
Notifications
You must be signed in to change notification settings - Fork 88
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
[WNMGDS-2843] Add ds-text-field
component
#3172
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks great! Mostly just some discrepancies I noticed in the Story plus some questions about how some props (well, actually just one prop) are/is being passed in.
...system/src/components/web-components/ds-text-field/__snapshots__/ds-text-field.test.tsx.snap
Show resolved
Hide resolved
...system/src/components/web-components/ds-text-field/__snapshots__/ds-text-field.test.tsx.snap
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.tsx
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
}, | ||
'error-placement': { | ||
description: 'Location of the error message relative to the field input', | ||
options: [undefined, 'top', 'bottom'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: If it's undefined the default behavior is to place the location on top, can/should this detail be captured here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By "captured here" do you mean explaining that in the description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Default position is different for different child design systems.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! I do mean explaining that in the description.
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this looks great to me! I left a few non-blocking questions.
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.stories.tsx
Outdated
Show resolved
Hide resolved
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.test.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some small comments you can disregard or accept
packages/design-system/src/components/web-components/ds-text-field/ds-text-field.test.tsx
Show resolved
Hide resolved
expect(input).not.toHaveAttribute('disabled'); | ||
}); | ||
|
||
it('applies additional classes to the wrapper', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following is probably more philosophical than the scope of this ticket warrants. Feel free to disregard my stream-of-conscious take here:
This test initially confused me because I associate "wrapper" with the host for 🚾, and having a special prop to apply a class to a host is unnecessary because it's HTML and class
would work fine.
Anyways... I had to do a double-take and read what the test was actually doing and realized "wrapper" means something different because it's querying the clearfix style in the test, which is the internal div
within the host wrapper. Is this div
even needed? Who clearfixes in the era of flexbox and grid?
Do we need better language when talking about these sorts of tags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might very well be able to remove that "wrapper" div now. I agree that it's beyond the scope here, but it's worth considering for the future (@kim-cmsds).
That's a great point about the wording here being confusing. I think I'll change it to "root element" or something like that.
description: | ||
'Text showing the requirement (ie. "Optional", or "Required").\nIn most cases, this should be used to indicate which fields are optional.\nSee the [form guidelines](https://design.cms.gov/patterns/Forms/forms/) for more info.', | ||
description: ( | ||
<> | ||
Text showing the requirement (ie. "Optional", or "Required").\nIn most | ||
cases, this should be used to indicate which fields are optional.\nSee the{' '} | ||
<a href="https://design.cms.gov/patterns/Forms/forms/">form guidelines</a> for more info. | ||
</> | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this change fixes the doc pages but breaks the story pages (probably an error when rendering the Storybook controls). I think Storybook must not like rendering non-strings in the control descriptions.
This was fine on our docs page with our custom attributes table, but Storybook crashed trying to render these values in story controls. The error was completely unhelpful and the stack trace was all through minified code, so I had to guess and test to find the problem here. Now we know these can only be strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…rapper And honestly we might not even need this element anymore. Sarah brought that up, and it's worth considering.
Summary
WNMGDS-2843
Adds a new
ds-text-field
web component.How to test
Checklist
[WNMGDS-####] Title
or [NO-TICKET] if this is unticketed work.Type
(only one) label for this PR, if it is a breaking change, label should only beType: Breaking
Impacts
, multiple can be selected.If this is a change to code:
yarn test:unit:update
) and browser-test snapshots (yarn test:browser:update
)If this is a change to documentation: