-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
va-file-input: Adding a V3-compatible (USWDS) version (#1017)
* WIP switching branches * USWDS V3-compatible File Input * Adding missing asterisk * Version bump * Adding tests * Removing onChange call * Attempt at improving change event handling * Changing file input storybook to use React binding * Style updates * Fixes to event handling and testing (from Jami) * Fixes for drag-and-drop and change events * Update package.json * Removing changelistnerid No longer needed * Style fixes * Fix to 'generic' preview image sizes when uploading * Removing no-longer-needed styles * Fixing version bump * Change sr-only to usa-sr-only * Removing uswds reflectivity * Couple more formation overrides * Fixing usa-sr-only span * Skipping flaky event listener test
- Loading branch information
Showing
10 changed files
with
1,143 additions
and
85 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
packages/storybook/stories/va-file-input-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,101 @@ | ||
/* eslint-disable react/prop-types */ | ||
import React from 'react'; | ||
import { VaFileInput } from '@department-of-veterans-affairs/web-components/react-bindings'; | ||
import { getWebComponentDocs, propStructure, StoryDocs } from './wc-helpers'; | ||
|
||
const fileInputDocs = getWebComponentDocs('va-file-input'); | ||
|
||
export default { | ||
title: 'USWDS/File input USWDS', | ||
id: 'uswds/va-file-input', | ||
parameters: { | ||
componentSubtitle: `va-file-input web component`, | ||
docs: { | ||
page: () => <StoryDocs data={fileInputDocs} />, | ||
}, | ||
}, | ||
}; | ||
|
||
const defaultArgs = { | ||
'label': 'Input accepts a single file', | ||
'name': 'my-file-input', | ||
'accept': null, | ||
'required': false, | ||
'error': '', | ||
'enable-analytics': false, | ||
'hint': null, | ||
'multiple': false, | ||
'uswds': true, | ||
'vaChange': event => | ||
alert(`File change event received: ${event?.detail?.files[0]?.name}`), | ||
}; | ||
|
||
const Template = ({ | ||
label, | ||
name, | ||
accept, | ||
error, | ||
required, | ||
hint, | ||
multiple, | ||
'enable-analytics': enableAnalytics, | ||
uswds, | ||
vaChange, | ||
}) => { | ||
return ( | ||
<VaFileInput | ||
label={label} | ||
name={name} | ||
accept={accept} | ||
required={required} | ||
error={error} | ||
hint={hint} | ||
multiple={multiple} | ||
enable-analytics={enableAnalytics} | ||
onVaChange={vaChange} | ||
uswds={uswds} | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind(null); | ||
Default.args = { ...defaultArgs }; | ||
Default.argTypes = propStructure(fileInputDocs); | ||
|
||
export const Required = Template.bind(null); | ||
Required.args = { ...defaultArgs, required: true }; | ||
|
||
export const AcceptsOnlySpecificFileTypes = Template.bind(null); | ||
AcceptsOnlySpecificFileTypes.args = { | ||
...defaultArgs, | ||
label: 'Input accepts only specific file types', | ||
hint: 'Select PDF or TXT files', | ||
accept: '.pdf,.txt', | ||
}; | ||
|
||
export const AcceptsAnyKindOfImage = Template.bind(null); | ||
AcceptsAnyKindOfImage.args = { | ||
...defaultArgs, | ||
label: 'Input accepts any kind of image', | ||
hint: 'Select any type of image format', | ||
accept: 'image/*', | ||
}; | ||
|
||
export const AcceptsMultipleFiles = Template.bind(null); | ||
AcceptsMultipleFiles.args = { | ||
...defaultArgs, | ||
label: 'Input accepts multiple files', | ||
hint: 'Select one or more files', | ||
multiple: true, | ||
}; | ||
|
||
export const ErrorMessage = Template.bind(null); | ||
ErrorMessage.args = { | ||
...defaultArgs, | ||
label: 'Input has an error', | ||
hint: 'Select any valid file', | ||
error: 'Display a helpful error message', | ||
}; | ||
|
||
export const WithAnalytics = Template.bind(null); | ||
WithAnalytics.args = { ...defaultArgs, 'enable-analytics': 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,4 +66,4 @@ | |
"i18next": "*", | ||
"i18next-browser-languagedetector": "*" | ||
} | ||
} | ||
} |
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
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.