-
Notifications
You must be signed in to change notification settings - Fork 166
Document components JavaScript package and exclude feature-specific components #6756
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
This file contains hidden or 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,17 @@ | ||
| # `@18f/identity-components` | ||
|
|
||
| React components for common UI interactions. These components are intended to be general-purpose and | ||
| reusable, whereas domain-specific React components should be found in the package corresponding to | ||
| the specific page or feature. | ||
|
|
||
| Many of these components are React implementations for components of the [Login.gov Design System](https://design.login.gov/). | ||
|
|
||
| ## Example | ||
|
|
||
| ```tsx | ||
| import { Button } from '@18f/identity-components'; | ||
|
|
||
| function MyComponent() { | ||
| return <Button isUnstyled>Continue</Button>; | ||
| } | ||
| ``` | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,12 +1,9 @@ | ||
| import { useState, useEffect, useCallback, useRef } from 'react'; | ||
| import { useI18n } from '@18f/identity-react-i18n'; | ||
| import { | ||
| PageHeading, | ||
| LocationCollectionItem, | ||
| LocationCollection, | ||
| SpinnerDots, | ||
| } from '@18f/identity-components'; | ||
| import { PageHeading, SpinnerDots } from '@18f/identity-components'; | ||
| import BackButton from './back-button'; | ||
| import LocationCollection from './location-collection'; | ||
| import LocationCollectionItem from './location-collection-item'; | ||
|
|
||
| interface PostOffice { | ||
| address: string; | ||
|
|
@@ -160,33 +157,36 @@ function InPersonLocationStep({ onChange, toPreviousStep }) { | |
| }; | ||
| }, []); | ||
|
|
||
| let locationItems: React.ReactNode; | ||
| let locationsContent: React.ReactNode; | ||
| if (!isLoadingComplete) { | ||
| locationItems = <SpinnerDots />; | ||
| locationsContent = <SpinnerDots />; | ||
| } else if (locationData.length < 1) { | ||
| locationItems = <h4>{t('in_person_proofing.body.location.none_found')}</h4>; | ||
| locationsContent = <h4>{t('in_person_proofing.body.location.none_found')}</h4>; | ||
| } else { | ||
| locationItems = locationData.map((item, index) => ( | ||
| <LocationCollectionItem | ||
| key={`${index}-${item.name}`} | ||
| handleSelect={handleLocationSelect} | ||
| name={`${item.name} — ${t('in_person_proofing.body.location.post_office')}`} | ||
| streetAddress={item.streetAddress} | ||
| selectId={item.id} | ||
| formattedCityStateZip={item.formattedCityStateZip} | ||
| weekdayHours={item.weekdayHours} | ||
| saturdayHours={item.saturdayHours} | ||
| sundayHours={item.sundayHours} | ||
| /> | ||
| )); | ||
| locationsContent = ( | ||
| <LocationCollection> | ||
| {locationData.map((item, index) => ( | ||
| <LocationCollectionItem | ||
| key={`${index}-${item.name}`} | ||
| handleSelect={handleLocationSelect} | ||
| name={`${item.name} — ${t('in_person_proofing.body.location.post_office')}`} | ||
| streetAddress={item.streetAddress} | ||
| selectId={item.id} | ||
| formattedCityStateZip={item.formattedCityStateZip} | ||
| weekdayHours={item.weekdayHours} | ||
| saturdayHours={item.saturdayHours} | ||
| sundayHours={item.sundayHours} | ||
| /> | ||
| ))} | ||
| </LocationCollection> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <PageHeading>{t('in_person_proofing.headings.location')}</PageHeading> | ||
|
|
||
| <p>{t('in_person_proofing.body.location.location_step_about')}</p> | ||
| <LocationCollection>{locationItems}</LocationCollection> | ||
| {locationsContent} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change here fixes issue where previously we were rendering invalid content inside the
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul |
||
| <BackButton onClick={toPreviousStep} /> | ||
| </> | ||
| ); | ||
|
|
||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.
this seems like a rule we could enforce/lint on if we wanted, maybe. Like each React component in this dir should have a comment/metadata attribute of some sort that links to its corresponding LGDS component?
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.
It's not a hard rule, since we have some components which don't map directly to a design system component (e.g.
PageHeader). Conversely, we have some design system components which live elsewhere (e.g.step-indicator).In an ideal world, I'd like to move more toward per-component packages (also aligns with newer USWDS direction). But I also think that might be a bit too much overhead and may be on the more extreme side of granularity, impacting usability.
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.
On the other hand, the overhead could be a good thing to require more conscious effort to introducing these generalized components, since I think this current components package is too much at risk of including any and all sorts of React components. Plus, it would resolve the current inconsistency of some components living in this package, while others have their own package.