Skip to content
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 the "Banner - Official Gov" web component #608

Merged
merged 17 commits into from
Feb 7, 2023

Conversation

jamigibbs
Copy link
Contributor

@jamigibbs jamigibbs commented Jan 23, 2023

Chromatic

https://1276-official-gov-site-banner--60f9b557105290003b387cd5.chromatic.com/?path=/docs/components-va-official-gov-banner--default

Description

This component was built based on the USWDS Banner component. The style and markup were taken directly from the USWDS example page linked above.

Even thought the USWDS v3 library is currently available within the component library package, this variation intentionally does not import the modules directly so that the component can be used immediately. USWDS v3 variations of components that use the v3 modules are not currently available for integrating with Formation.

Closes department-of-veterans-affairs/vets-design-system-documentation#1276

Testing done

Storybook

Screenshots

Screenshot 2023-02-01 at 2 23 55 PM

Screenshot 2023-02-01 at 2 24 08 PM

Screenshot 2023-02-01 at 2 24 19 PM

Screenshot 2023-02-01 at 2 24 28 PM

Mobile

Screenshot 2023-02-01 at 2 25 58 PM

Screenshot 2023-02-01 at 2 26 04 PM

Acceptance criteria

  • Component is written and added to Storybook

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

@jamigibbs jamigibbs added the minor For a minor Semantic Version change label Jan 23, 2023
}

.banner {
background-color: #f0f0f0;
Copy link
Contributor Author

@jamigibbs jamigibbs Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the hex colors hardcoded are from the USWDS v3 example. When this component is updated to use the v3 modules (ie. @use "usa-banner"), these colors should automatically map to the relevant classes in the markup and can eventually be removed. I did not think it was necessary to add these to the css-library package for that reason. We would just have to go back and clean them up out of that library as well.

background: 0 0;
background-color: #005ea2;
-webkit-mask: url("../../../../../node_modules/@uswds/uswds/dist/img/usa-icons/expand_more.svg") no-repeat center/contain;
mask: url("../../../../../node_modules/@uswds/uswds/dist/img/usa-icons/expand_more.svg") no-repeat center/contain;
Copy link
Contributor Author

@jamigibbs jamigibbs Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the hardcoded hex values, this direct link to the v3 icons will no longer be necessary once this component has been converted to use the v3 modules (ie. @use "usa-banner").

}

// Mobile display close icon.
@media (max-width: 768px) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The responsive width throughout is based on the Formation medium screen breakpoint. The USWDS v3 examples uses 40rem for a 16px base font so this would be the equivalent to 640px. I simply picked a breakpoint value from Formation that was closest to that value.


render() {
const { tld } = this;
if (tld === 'gov' || tld === 'mil') {
Copy link
Contributor Author

@jamigibbs jamigibbs Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I experimented with getting the top-level domain value programmatically within the component itself but found that it would be difficult to test or display the component on sites that weren't actually .gov or .mil sites (like Chromatic and Storybook). If we're not happy with relying on the developer to set the correct value here manually, then maybe we can discuss alternatives. The default prop value is .gov.


html = html.replace('SVG', lockSvg);
html = html.replace('lock', `<strong>lock</strong>`);
html = html.replace('candado', `<strong>candado</strong>`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word "lock" is bold which means that it also needs to be bold in the translations. Currently we only have Spanish translations so it is added here as part of the function that adds the strong element around it.

When we have Tagalog translations available, we will need to add that word here as well.

<div class="grid-row">
<div class="col">
<img
src="https://s3-us-gov-west-1.amazonaws.com/content.www.va.gov/img/icon-dot-gov.svg"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was taken directly from the existing VA.gov implementation. I sometimes see a slight delay with this is loaded because there's a call out to AWS for it so if we're not happy with that behavior, I can see if there is a way to load without hot linking.

Screenshot 2023-02-01 at 3 17 13 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to get this png image to load locally using the Stencil asset base path but wasn't successful. This might be a limitation of Stencil. For now we will probably need to keep the AWS link. We are able to import SVGs though.

@jamigibbs jamigibbs marked this pull request as ready for review February 1, 2023 21:23
@jamigibbs jamigibbs requested a review from a team as a code owner February 1, 2023 21:23
Copy link
Contributor

@Andrew565 Andrew565 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jamigibbs
Copy link
Contributor Author

@GnatalieH When you have a moment, do you mind providing design review for this new component?

@GnatalieH
Copy link

GnatalieH commented Feb 6, 2023

Looks good to me, @jamigibbs! Thanks! I prefer the updated USWDS look/feel in the mobile viewport.

One thing I'm wondering, is should we represent this component in the USWDS section on Storybook? I know we are creating it as a variation of Banner, so I understand why it's categorized as it is. But I feel like we should cross reference it in USWDS components. Thoughts?

@jamigibbs
Copy link
Contributor Author

One thing I'm wondering, is should we represent this component in the USWDS section on Storybook? I know we are creating it as a variation of Banner, so I understand why it's categorized as it is. But I feel like we should cross reference it in USWDS components. Thoughts?

@GnatalieH Good question. I intentionally have kept it out of that section because technically it has not been updated to use the actual USWDS v3 modules like the other components in that section are. We are not able to use those component variations in the USWDS section yet everywhere (there are technical limitations right now) but this component can be used as it is because it's not using their modules yet. So I didn't want to cause any confusion about its availability which is why it's in the regular section. We will still need to come back to this component at some point to make it an official v3 variation that's using the USWDS library directly.

@GnatalieH
Copy link

@jamigibbs that makes sense. It's good where it is, then. Thanks!

@jamigibbs jamigibbs merged commit a898c4e into main Feb 7, 2023
@jamigibbs jamigibbs deleted the 1276-official-gov-site-banner branch February 7, 2023 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor For a minor Semantic Version change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Banner - Official Gov site - Development
3 participants