-
Notifications
You must be signed in to change notification settings - Fork 167
LG-8349: Move AddressSearch component into own package #8386
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
12 commits
Select commit
Hold shift + click to select a range
5b2bd5a
LG-8349: Move AddressSearch component into own package
dawei-nava 17fef8b
LG-8439: remove old component.
dawei-nava 1a3d240
LG-8439: package information.
dawei-nava 060b6ae
LG-8439: change log file.
dawei-nava 3ab0334
LG-8439: address comments
dawei-nava 421664c
Update app/javascript/packages/address-search/README.md
dawei-nava d7b8dc6
Update app/javascript/packages/address-search/index-spec.tsx
dawei-nava 8bdb521
LG-8439: extra / not needed.
dawei-nava 1053212
Add support for per-component stylesheets (#8375)
aduth 80614a8
LG-8439: resolve conflict
dawei-nava b180aa3
LG-8439: address comments
dawei-nava 359f3d8
Updating how gpo pending is set in dummy profile (#8434)
eric-gade 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
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
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,2 +1,2 @@ | ||
| @forward 'required'; | ||
| @forward 'uswds-core'; | ||
| @forward '../../javascript/packages/document-capture/styles'; |
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,4 +1,3 @@ | ||
| @forward 'required'; | ||
| @use 'uswds-core' as *; | ||
| @import 'variables/app'; | ||
| @import 'variables/email'; | ||
|
|
||
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,21 +1,48 @@ | ||
| class BaseComponent < ViewComponent::Base | ||
| def before_render | ||
| return if @rendered_scripts | ||
| @rendered_scripts = true | ||
| if helpers.respond_to?(:enqueue_component_scripts) && self.class.scripts.present? | ||
| helpers.enqueue_component_scripts(*self.class.scripts) | ||
| end | ||
| render_assets unless rendered_assets? | ||
| end | ||
|
|
||
| def self.scripts | ||
| @scripts ||= begin | ||
| scripts = sidecar_files(['js', 'ts']).map { |file| File.basename(file, '.*') } | ||
| scripts = sidecar_files_basenames(['js', 'ts']) | ||
| scripts.concat superclass.scripts if superclass.respond_to?(:scripts) | ||
| scripts | ||
| end | ||
| end | ||
|
|
||
| def self.stylesheets | ||
| @stylesheets ||= begin | ||
| stylesheets = sidecar_files_basenames(['scss']) | ||
| stylesheets.concat superclass.stylesheets if superclass.respond_to?(:stylesheets) | ||
| stylesheets | ||
| end | ||
| end | ||
|
|
||
| def unique_id | ||
| @unique_id ||= SecureRandom.hex(4) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| attr_accessor :rendered_assets | ||
| alias_method :rendered_assets?, :rendered_assets | ||
|
|
||
| class << self | ||
| def sidecar_files_basenames(extensions) | ||
| sidecar_files(extensions).map { |file| File.basename(file, '.*') } | ||
| end | ||
| end | ||
|
|
||
| def render_assets | ||
| if helpers.respond_to?(:enqueue_component_scripts) && self.class.scripts.present? | ||
| helpers.enqueue_component_scripts(*self.class.scripts) | ||
| end | ||
|
|
||
| if helpers.respond_to?(:enqueue_component_stylesheets) && self.class.stylesheets.present? | ||
| helpers.enqueue_component_stylesheets(*self.class.stylesheets) | ||
| end | ||
|
|
||
| @rendered_assets = true | ||
| end | ||
| end |
1 change: 1 addition & 0 deletions
1
...sets/stylesheets/components/_tooltip.scss → ...omponents/clipboard_button_component.scss
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
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 @@ | ||
| # rubocop:disable Rails/HelperInstanceVariable | ||
| module StylesheetHelper | ||
| def stylesheet_tag_once(*names) | ||
| @stylesheets ||= [] | ||
| @stylesheets |= names | ||
| nil | ||
| end | ||
|
|
||
| alias_method :enqueue_component_stylesheets, :stylesheet_tag_once | ||
|
|
||
| def render_stylesheet_once_tags(*names) | ||
| stylesheet_tag_once(*names) if names.present? | ||
| return if @stylesheets.blank? | ||
| safe_join(@stylesheets.map { |stylesheet| stylesheet_link_tag(stylesheet) }) | ||
| end | ||
| end | ||
| # rubocop:enable Rails/HelperInstanceVariable |
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,5 @@ | ||
| # `Change Log` | ||
|
|
||
| ## 1.0.0 | ||
|
|
||
| - Initial release |
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,21 @@ | ||
| # License | ||
|
|
||
| As a work of the [United States government](https://www.usa.gov/), this project is in the public domain within the United States of America. | ||
|
|
||
| Additionally, we waive copyright and related rights in the work worldwide through the CC0 1.0 Universal public domain dedication. | ||
|
|
||
| ## CC0 1.0 Universal Summary | ||
|
|
||
| This is a human-readable summary of the [Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode). | ||
|
|
||
| ### No Copyright | ||
|
|
||
| The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. | ||
|
|
||
| You can copy, modify, distribute, and perform the work, even for commercial purposes, all without asking permission. | ||
|
|
||
| ### Other Information | ||
|
|
||
| In no way are the patent or trademark rights of any person affected by CC0, nor are the rights that other persons may have in the work or in how the work is used, such as publicity or privacy rights. | ||
|
|
||
| Unless expressly stated otherwise, the person who associated a work with this deed makes no warranties about the work, and disclaims liability for all uses of the work, to the fullest extent permitted by applicable law. When using or citing the work, you should not imply endorsement by the author or the affirmer. |
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,42 @@ | ||
| # `@18f/identity-address-search` | ||
|
|
||
| This is a npm module that provides a React UI component to search for USPS (United States Postal Service) locations using the ArcGIS API. It allows you to retrieve USPS location information based on a full address. | ||
|
|
||
| Additionally, this module depends on existing backend services from the Login.gov project. Make sure to have the required backend services or mock services set up and running before using this module. | ||
|
|
||
| ## Installation | ||
|
|
||
| You can install this module using npm: | ||
|
|
||
| ```shell | ||
| npm install @18f/identity-address-search | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| To use this component, provide callbacks to it for desired behaviors. | ||
|
|
||
| ```typescript jsx | ||
| import AddressSearch from '@18f/identity-address-search'; | ||
|
|
||
| // Render UI component | ||
|
|
||
| return( | ||
| <> | ||
| <AddressSearch | ||
| registerField={registerFieldCallback} | ||
| onFoundAddress={setFoundAddressCallback} | ||
| onFoundLocations={setLocationResultsCallback} | ||
| onLoadingLocations={setLoadingLocationsCallback} | ||
| onError={setApiErrorCallback} | ||
| disabled={disabledAddressSearchCallback} | ||
| /> | ||
| </> | ||
| ); | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/). | ||
|
|
||
| All contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest. |
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
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,25 @@ | ||
| { | ||
| "name": "@18f/identity-address-search", | ||
| "private": true, | ||
| "version": "1.0.0", | ||
| "type": "module", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/18f/identity-idp.git", | ||
| "directory": "app/javascript/packages/address-search" | ||
| }, | ||
| "files": [ | ||
| "index.tsx" | ||
| ], | ||
| "license": "CC0-1.0", | ||
| "bugs": { | ||
| "url": "https://github.com/18f/identity-idp/issues" | ||
| }, | ||
| "homepage": "https://github.com/18f/identity-idp", | ||
| "dependencies": { | ||
| "swr": "^2.0.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^17.0.2" | ||
| } | ||
| } |
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.