-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
va-combo-box: add new component (#1373)
* initial component plot * tweaks and styling * adding label * adding disabled prop * adding defaultValue prop * placeholder prop * format and cleanup * handle label and value change * handle required prop * update doc attributes + cleanup * update default value prop * handling hint text and aria * docs * build * styling cleanup * update docs * e2e tests * cleanup * remove disabled state from docs * focus style mixin * remove analytics props * showError prop non applicable * input styling * buttons positioning * max-width for high zoom * redo message-aria-describedby * remove not needed styling * update maturity level * console log cleanup * remove analytics event emitter * remove irrelevant error * Update components.d.ts * non-used props * e2e tests * style updates
- Loading branch information
1 parent
28824e7
commit 08ed91f
Showing
6 changed files
with
1,551 additions
and
0 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
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,117 @@ | ||
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, | ||
messageAriaDescribedby: 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, | ||
messageAriaDescribedby, | ||
}) => { | ||
|
||
return ( | ||
<va-combo-box | ||
label={label} | ||
name={name} | ||
value={value} | ||
required={required} | ||
error={error} | ||
hint={hint} | ||
placeholder={placeholder} | ||
disabled={disabled} | ||
message-aria-describedby={messageAriaDescribedby} | ||
> | ||
{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 WithMessageAriaDescribedBy = Template.bind({}); | ||
WithMessageAriaDescribedBy.args = { | ||
...defaultArgs, | ||
messageAriaDescribedby: 'This is example aria message', | ||
}; |
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.