-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add uswds combo box #1373
Open
oleksii-morgun
wants to merge
18
commits into
main
Choose a base branch
from
add-uswds-combo-box
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add uswds combo box #1373
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9366703
initial component plot
oleksii-morgun 9fb721e
tweaks and styling
oleksii-morgun 4234bc1
adding label
oleksii-morgun cbb3448
adding disabled prop
oleksii-morgun fe3d3b2
adding defaultValue prop
oleksii-morgun dca10e7
placeholder prop
oleksii-morgun 19cccb5
format and cleanup
oleksii-morgun 4de0269
handle label and value change
oleksii-morgun 1d76b2a
handle required prop
oleksii-morgun 8b53d6e
update doc attributes + cleanup
oleksii-morgun b576a5f
update default value prop
oleksii-morgun d49393a
handling hint text and aria
oleksii-morgun 7d2e31e
docs
oleksii-morgun fdf834f
build
oleksii-morgun 5daf7e9
styling cleanup
oleksii-morgun f0dbdfb
update docs
oleksii-morgun 6fb10f8
e2e tests
oleksii-morgun 1af41e7
cleanup
oleksii-morgun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
115 changes: 115 additions & 0 deletions
115
packages/storybook/stories/va-combo-box-uswds.stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React from 'react'; | ||
import { getWebComponentDocs, propStructure, StoryDocs } from './wc-helpers'; | ||
|
||
const comboBoxDocs = getWebComponentDocs('va-combo-box'); | ||
|
||
export default { | ||
title: 'Components/Combo Box USWDS', | ||
id: 'uswds/va-combo-box', | ||
parameters: { | ||
componentSubtitle: 'va-combo-box web component', | ||
docs: { | ||
page: () => <StoryDocs storyDefault={Default} data={comboBoxDocs} />, | ||
}, | ||
}, | ||
}; | ||
|
||
const defaultArgs = { | ||
label: 'Select a fruit', | ||
name: 'fruit', | ||
value: '', | ||
required: false, | ||
error: undefined, | ||
options: [ | ||
<option value="apple">Apple</option>, | ||
<option value="banana">Banana</option>, | ||
<option value="blackberry">Blackberry</option>, | ||
<option value="blueberry">Blueberry</option>, | ||
<option value="boysenberry">Boysenberry</option>, | ||
<option value="cherry">Cherry</option>, | ||
<option value="crab apple">Crab Apple</option>, | ||
<option value="cranberry">Cranberry</option>, | ||
<option value="custard apple">Custard apple</option>, | ||
<option value="date">Date</option>, | ||
<option value="elderberry">Elderberry</option>, | ||
<option value="fig">Fig</option>, | ||
<option value="gooseberry">Gooseberry</option>, | ||
<option value="mango">Mango</option>, | ||
<option value="mangosteen">Mangosteen</option>, | ||
<option value="marionberry">Marionberry</option>, | ||
<option value="pineapple">Pineapple</option>, | ||
<option value="raspberry">Raspberry</option>, | ||
<option value="rambutan">Rambutan</option>, | ||
<option value="starfruit">Starfruit</option>, | ||
<option value="strawberry">Strawberry</option> | ||
], | ||
}; | ||
|
||
const Template = ({ | ||
label, | ||
name, | ||
value, | ||
required, | ||
error, | ||
hint, | ||
options, | ||
placeholder, | ||
disabled, | ||
}) => { | ||
|
||
return ( | ||
<va-combo-box | ||
label={label} | ||
name={name} | ||
value={value} | ||
required={required} | ||
error={error} | ||
hint={hint} | ||
placeholder={placeholder} | ||
disabled={disabled} | ||
> | ||
{options} | ||
</va-combo-box> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { ...defaultArgs }; | ||
Default.argTypes = propStructure(comboBoxDocs); | ||
|
||
export const WithDefaultValue = Template.bind({}); | ||
WithDefaultValue.args = { | ||
...defaultArgs, | ||
value: 'banana', | ||
}; | ||
|
||
export const WithError = Template.bind({}); | ||
WithError.args = { | ||
...defaultArgs, | ||
error: 'This field contains an error.', | ||
}; | ||
|
||
export const Required = Template.bind({}); | ||
Required.args = { | ||
...defaultArgs, | ||
required: true, | ||
}; | ||
|
||
export const WithPlaceholderText = Template.bind({}); | ||
WithPlaceholderText.args = { | ||
...defaultArgs, | ||
placeholder: '--Select--', | ||
}; | ||
|
||
export const WithHintText = Template.bind({}); | ||
WithHintText.args = { | ||
...defaultArgs, | ||
hint: 'This is example hint text', | ||
}; | ||
|
||
export const Disabled = Template.bind({}); | ||
Disabled.args = { | ||
...defaultArgs, | ||
value: 'elderberry', | ||
disabled: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think we want to advertise that there is a disabled state. There are a11y concerns with this functionality.
Or maybe we don't want to have this functionality in the component at all? I will let the design and a11y reviewers weigh in on that though. cc @department-of-veterans-affairs/platform-design-system-designers @rsmithadhoc
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.
Yeah, our stance on disabled states is that instead of disabling something, just don't show it if it serves no purpose. I'm okay with leaving it in for parity with USWDS, but just not advertising it.