@ogds/elements 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/UswdsTheme.js +11 -0
- package/.storybook/blocks/SiteNote.jsx +5 -0
- package/.storybook/main.js +38 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/preview.js +37 -0
- package/.storybook/test-runner.js +23 -0
- package/README.md +201 -0
- package/build/css/breakpoints.css +15 -0
- package/build/css/colors.css +490 -0
- package/build/css/spacing.css +16 -0
- package/build/scss/_breakpoints.scss +12 -0
- package/build/scss/_colors.scss +487 -0
- package/build/scss/_spacing.scss +13 -0
- package/dist/components/frameworks/react/OgdsAccordion.d.ts +69 -0
- package/dist/components/frameworks/react/OgdsAccordion.js +22 -0
- package/dist/components/frameworks/react/OgdsAccordionToggle.d.ts +60 -0
- package/dist/components/frameworks/react/OgdsAccordionToggle.js +23 -0
- package/dist/components/frameworks/react/UsaBanner.d.ts +82 -0
- package/dist/components/frameworks/react/UsaBanner.js +25 -0
- package/dist/components/frameworks/react/UsaLink.d.ts +60 -0
- package/dist/components/frameworks/react/UsaLink.js +21 -0
- package/dist/components/frameworks/react/index.d.ts +4 -0
- package/dist/components/frameworks/react/index.js +4 -0
- package/dist/components/frameworks/react/react-utils.js +34 -0
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/usa-banner/index.d.ts +82 -0
- package/dist/components/usa-banner/usa-banner.spec.d.ts +0 -0
- package/dist/components/usa-banner/usa-banner.stories.d.ts +95 -0
- package/dist/components/usa-banner.cjs +95 -0
- package/dist/components/usa-banner.cjs.map +1 -0
- package/dist/components/usa-banner.js +189 -0
- package/dist/components/usa-banner.js.map +1 -0
- package/dist/components/usa-header/index.d.ts +6 -0
- package/dist/components/usa-link/index.d.ts +30 -0
- package/dist/components/usa-link/usa-link.spec.d.ts +0 -0
- package/dist/components/usa-link.cjs +5 -0
- package/dist/components/usa-link.cjs.map +1 -0
- package/dist/components/usa-link.js +32 -0
- package/dist/components/usa-link.js.map +1 -0
- package/dist/core/OgdsElement.d.ts +3 -0
- package/dist/index-7kIMQwBw.cjs +1 -0
- package/dist/index-7kIMQwBw.cjs.map +1 -0
- package/dist/index-BrHk1-6T.js +10 -0
- package/dist/index-BrHk1-6T.js.map +1 -0
- package/dist/types/custom-element-jsx.d.ts +175 -0
- package/dist/types/custom-element-solidjs.d.ts +185 -0
- package/dist/types/custom-element-svelte.d.ts +157 -0
- package/dist/types/custom-element-vuejs.d.ts +127 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.test.d.ts +1 -0
- package/package.json +119 -0
- package/src/components/index.ts +5 -0
- package/src/components/ogds-accordion/.claude/settings.local.json +7 -0
- package/src/components/ogds-accordion/docs.mdx +90 -0
- package/src/components/ogds-accordion/index.ts +132 -0
- package/src/components/ogds-accordion/ogds-accordion.css +99 -0
- package/src/components/ogds-accordion/ogds-accordion.spec.ts +175 -0
- package/src/components/ogds-accordion/ogds-accordion.stories.ts +77 -0
- package/src/components/ogds-accordion-toggle/index.ts +80 -0
- package/src/components/usa-banner/docs.mdx +108 -0
- package/src/components/usa-banner/index.ts +290 -0
- package/src/components/usa-banner/usa-banner.css +511 -0
- package/src/components/usa-banner/usa-banner.spec.ts +76 -0
- package/src/components/usa-banner/usa-banner.stories.ts +136 -0
- package/src/components/usa-header/index.ts +50 -0
- package/src/components/usa-header/usa-header.css +1 -0
- package/src/components/usa-link/index.ts +66 -0
- package/src/components/usa-link/usa-link.css +24 -0
- package/src/components/usa-link/usa-link.spec.ts +50 -0
- package/src/core/colors.css +8 -0
- package/src/core/fonts.css +213 -0
- package/src/core/index.css +2 -0
- package/src/core/token-styles.ts +26 -0
- package/src/declaration.d.ts +75 -0
- package/src/shared/icons/accessibility_new.svg +1 -0
- package/src/shared/icons/accessible_forward.svg +1 -0
- package/src/shared/icons/account_balance.svg +1 -0
- package/src/shared/icons/account_box.svg +1 -0
- package/src/shared/icons/account_circle.svg +1 -0
- package/src/shared/icons/add.svg +1 -0
- package/src/shared/icons/add_circle.svg +1 -0
- package/src/shared/icons/add_circle_outline.svg +1 -0
- package/src/shared/icons/alarm.svg +1 -0
- package/src/shared/icons/alternate_email.svg +1 -0
- package/src/shared/icons/announcement.svg +1 -0
- package/src/shared/icons/api.svg +1 -0
- package/src/shared/icons/arrow_back.svg +1 -0
- package/src/shared/icons/arrow_downward.svg +1 -0
- package/src/shared/icons/arrow_drop_down.svg +1 -0
- package/src/shared/icons/arrow_drop_up.svg +1 -0
- package/src/shared/icons/arrow_forward.svg +1 -0
- package/src/shared/icons/arrow_upward.svg +1 -0
- package/src/shared/icons/assessment.svg +1 -0
- package/src/shared/icons/attach_file.svg +1 -0
- package/src/shared/icons/attach_money.svg +1 -0
- package/src/shared/icons/autorenew.svg +1 -0
- package/src/shared/icons/backpack.svg +1 -0
- package/src/shared/icons/bathtub.svg +1 -0
- package/src/shared/icons/bedding.svg +1 -0
- package/src/shared/icons/bookmark.svg +1 -0
- package/src/shared/icons/bug_report.svg +1 -0
- package/src/shared/icons/build.svg +1 -0
- package/src/shared/icons/calendar_today.svg +1 -0
- package/src/shared/icons/campaign.svg +1 -0
- package/src/shared/icons/camping.svg +1 -0
- package/src/shared/icons/cancel.svg +1 -0
- package/src/shared/icons/chat.svg +1 -0
- package/src/shared/icons/check.svg +1 -0
- package/src/shared/icons/check_box_outline_blank.svg +1 -0
- package/src/shared/icons/check_circle.svg +1 -0
- package/src/shared/icons/check_circle_outline.svg +1 -0
- package/src/shared/icons/checkroom.svg +1 -0
- package/src/shared/icons/chevron_left.svg +1 -0
- package/src/shared/icons/chevron_right.svg +1 -0
- package/src/shared/icons/clean_hands.svg +1 -0
- package/src/shared/icons/close.svg +1 -0
- package/src/shared/icons/closed_caption.svg +1 -0
- package/src/shared/icons/clothes.svg +1 -0
- package/src/shared/icons/cloud.svg +1 -0
- package/src/shared/icons/code.svg +1 -0
- package/src/shared/icons/comment.svg +1 -0
- package/src/shared/icons/connect_without_contact.svg +1 -0
- package/src/shared/icons/construction.svg +1 -0
- package/src/shared/icons/construction_worker.svg +1 -0
- package/src/shared/icons/contact_page.svg +1 -0
- package/src/shared/icons/content_copy.svg +1 -0
- package/src/shared/icons/coronavirus.svg +1 -0
- package/src/shared/icons/credit_card.svg +1 -0
- package/src/shared/icons/deck.svg +1 -0
- package/src/shared/icons/delete.svg +1 -0
- package/src/shared/icons/device_thermostat.svg +1 -0
- package/src/shared/icons/directions.svg +1 -0
- package/src/shared/icons/directions_bike.svg +1 -0
- package/src/shared/icons/directions_bus.svg +1 -0
- package/src/shared/icons/directions_car.svg +1 -0
- package/src/shared/icons/directions_walk.svg +1 -0
- package/src/shared/icons/do_not_disturb.svg +1 -0
- package/src/shared/icons/do_not_touch.svg +1 -0
- package/src/shared/icons/drag_handle.svg +1 -0
- package/src/shared/icons/eco.svg +1 -0
- package/src/shared/icons/edit.svg +1 -0
- package/src/shared/icons/electrical_services.svg +1 -0
- package/src/shared/icons/emoji_events.svg +1 -0
- package/src/shared/icons/error.svg +1 -0
- package/src/shared/icons/error_outline.svg +1 -0
- package/src/shared/icons/event.svg +1 -0
- package/src/shared/icons/expand_less.svg +1 -0
- package/src/shared/icons/expand_more.svg +1 -0
- package/src/shared/icons/facebook.svg +1 -0
- package/src/shared/icons/fast_forward.svg +1 -0
- package/src/shared/icons/fast_rewind.svg +1 -0
- package/src/shared/icons/favorite.svg +1 -0
- package/src/shared/icons/favorite_border.svg +1 -0
- package/src/shared/icons/fax.svg +1 -0
- package/src/shared/icons/file_download.svg +1 -0
- package/src/shared/icons/file_present.svg +1 -0
- package/src/shared/icons/file_upload.svg +1 -0
- package/src/shared/icons/filter_alt.svg +1 -0
- package/src/shared/icons/filter_list.svg +1 -0
- package/src/shared/icons/fingerprint.svg +1 -0
- package/src/shared/icons/first_page.svg +1 -0
- package/src/shared/icons/flag.svg +1 -0
- package/src/shared/icons/flickr.svg +1 -0
- package/src/shared/icons/flight.svg +1 -0
- package/src/shared/icons/flooding.svg +1 -0
- package/src/shared/icons/folder.svg +1 -0
- package/src/shared/icons/folder_open.svg +1 -0
- package/src/shared/icons/format_quote.svg +1 -0
- package/src/shared/icons/format_size.svg +1 -0
- package/src/shared/icons/forum.svg +1 -0
- package/src/shared/icons/github.svg +1 -0
- package/src/shared/icons/grid_view.svg +1 -0
- package/src/shared/icons/group_add.svg +1 -0
- package/src/shared/icons/groups.svg +1 -0
- package/src/shared/icons/hearing.svg +1 -0
- package/src/shared/icons/help.svg +1 -0
- package/src/shared/icons/help_outline.svg +1 -0
- package/src/shared/icons/highlight_off.svg +1 -0
- package/src/shared/icons/history.svg +1 -0
- package/src/shared/icons/home.svg +1 -0
- package/src/shared/icons/hospital.svg +1 -0
- package/src/shared/icons/hotel.svg +1 -0
- package/src/shared/icons/hourglass_empty.svg +1 -0
- package/src/shared/icons/hurricane.svg +1 -0
- package/src/shared/icons/identification.svg +1 -0
- package/src/shared/icons/image.svg +1 -0
- package/src/shared/icons/info.svg +1 -0
- package/src/shared/icons/info_outline.svg +1 -0
- package/src/shared/icons/insights.svg +1 -0
- package/src/shared/icons/instagram.svg +1 -0
- package/src/shared/icons/keyboard.svg +1 -0
- package/src/shared/icons/label.svg +1 -0
- package/src/shared/icons/language.svg +1 -0
- package/src/shared/icons/last_page.svg +1 -0
- package/src/shared/icons/launch.svg +1 -0
- package/src/shared/icons/lightbulb.svg +1 -0
- package/src/shared/icons/lightbulb_outline.svg +1 -0
- package/src/shared/icons/link.svg +1 -0
- package/src/shared/icons/link_off.svg +1 -0
- package/src/shared/icons/linkedin.svg +1 -0
- package/src/shared/icons/list.svg +1 -0
- package/src/shared/icons/local_cafe.svg +1 -0
- package/src/shared/icons/local_fire_department.svg +1 -0
- package/src/shared/icons/local_gas_station.svg +1 -0
- package/src/shared/icons/local_grocery_store.svg +1 -0
- package/src/shared/icons/local_hospital.svg +1 -0
- package/src/shared/icons/local_laundry_service.svg +1 -0
- package/src/shared/icons/local_library.svg +1 -0
- package/src/shared/icons/local_offer.svg +1 -0
- package/src/shared/icons/local_parking.svg +1 -0
- package/src/shared/icons/local_pharmacy.svg +1 -0
- package/src/shared/icons/local_police.svg +1 -0
- package/src/shared/icons/local_taxi.svg +1 -0
- package/src/shared/icons/location_city.svg +1 -0
- package/src/shared/icons/location_on.svg +1 -0
- package/src/shared/icons/lock.svg +1 -0
- package/src/shared/icons/lock_open.svg +1 -0
- package/src/shared/icons/lock_outline.svg +1 -0
- package/src/shared/icons/login.svg +1 -0
- package/src/shared/icons/logout.svg +1 -0
- package/src/shared/icons/loop.svg +1 -0
- package/src/shared/icons/mail.svg +1 -0
- package/src/shared/icons/mail_outline.svg +1 -0
- package/src/shared/icons/map.svg +1 -0
- package/src/shared/icons/masks.svg +1 -0
- package/src/shared/icons/medical_services.svg +1 -0
- package/src/shared/icons/menu.svg +1 -0
- package/src/shared/icons/military_tech.svg +1 -0
- package/src/shared/icons/more_horiz.svg +1 -0
- package/src/shared/icons/more_vert.svg +1 -0
- package/src/shared/icons/my_location.svg +1 -0
- package/src/shared/icons/navigate_before.svg +1 -0
- package/src/shared/icons/navigate_far_before.svg +1 -0
- package/src/shared/icons/navigate_far_next.svg +1 -0
- package/src/shared/icons/navigate_next.svg +1 -0
- package/src/shared/icons/near_me.svg +1 -0
- package/src/shared/icons/notifications.svg +1 -0
- package/src/shared/icons/notifications_active.svg +1 -0
- package/src/shared/icons/notifications_none.svg +1 -0
- package/src/shared/icons/notifications_off.svg +1 -0
- package/src/shared/icons/park.svg +1 -0
- package/src/shared/icons/people.svg +1 -0
- package/src/shared/icons/person.svg +1 -0
- package/src/shared/icons/pets.svg +1 -0
- package/src/shared/icons/phone.svg +1 -0
- package/src/shared/icons/photo_camera.svg +1 -0
- package/src/shared/icons/print.svg +1 -0
- package/src/shared/icons/priority_high.svg +1 -0
- package/src/shared/icons/public.svg +1 -0
- package/src/shared/icons/push_pin.svg +1 -0
- package/src/shared/icons/radio_button_unchecked.svg +1 -0
- package/src/shared/icons/rain.svg +1 -0
- package/src/shared/icons/reduce_capacity.svg +1 -0
- package/src/shared/icons/remove.svg +1 -0
- package/src/shared/icons/remove_circle.svg +1 -0
- package/src/shared/icons/report.svg +1 -0
- package/src/shared/icons/restaurant.svg +1 -0
- package/src/shared/icons/rss_feed.svg +1 -0
- package/src/shared/icons/safety_divider.svg +1 -0
- package/src/shared/icons/sanitizer.svg +1 -0
- package/src/shared/icons/save_alt.svg +1 -0
- package/src/shared/icons/schedule.svg +1 -0
- package/src/shared/icons/school.svg +1 -0
- package/src/shared/icons/science.svg +1 -0
- package/src/shared/icons/search.svg +1 -0
- package/src/shared/icons/security.svg +1 -0
- package/src/shared/icons/send.svg +1 -0
- package/src/shared/icons/sentiment_dissatisfied.svg +1 -0
- package/src/shared/icons/sentiment_neutral.svg +1 -0
- package/src/shared/icons/sentiment_satisfied.svg +1 -0
- package/src/shared/icons/sentiment_satisfied_alt.svg +1 -0
- package/src/shared/icons/sentiment_very_dissatisfied.svg +1 -0
- package/src/shared/icons/settings.svg +1 -0
- package/src/shared/icons/severe_weather.svg +1 -0
- package/src/shared/icons/share.svg +1 -0
- package/src/shared/icons/shield.svg +1 -0
- package/src/shared/icons/shopping_basket.svg +1 -0
- package/src/shared/icons/snow.svg +1 -0
- package/src/shared/icons/soap.svg +1 -0
- package/src/shared/icons/social_distance.svg +1 -0
- package/src/shared/icons/sort_arrow.svg +1 -0
- package/src/shared/icons/spellcheck.svg +1 -0
- package/src/shared/icons/star.svg +1 -0
- package/src/shared/icons/star_half.svg +1 -0
- package/src/shared/icons/star_outline.svg +1 -0
- package/src/shared/icons/store.svg +1 -0
- package/src/shared/icons/support.svg +1 -0
- package/src/shared/icons/support_agent.svg +1 -0
- package/src/shared/icons/text_fields.svg +1 -0
- package/src/shared/icons/thumb_down_alt.svg +1 -0
- package/src/shared/icons/thumb_up_alt.svg +1 -0
- package/src/shared/icons/timer.svg +1 -0
- package/src/shared/icons/toggle_off.svg +1 -0
- package/src/shared/icons/toggle_on.svg +1 -0
- package/src/shared/icons/topic.svg +1 -0
- package/src/shared/icons/tornado.svg +1 -0
- package/src/shared/icons/translate.svg +1 -0
- package/src/shared/icons/trending_down.svg +1 -0
- package/src/shared/icons/trending_up.svg +1 -0
- package/src/shared/icons/twitter.svg +1 -0
- package/src/shared/icons/undo.svg +1 -0
- package/src/shared/icons/unfold_less.svg +1 -0
- package/src/shared/icons/unfold_more.svg +1 -0
- package/src/shared/icons/update.svg +1 -0
- package/src/shared/icons/upload_file.svg +1 -0
- package/src/shared/icons/verified.svg +1 -0
- package/src/shared/icons/verified_user.svg +1 -0
- package/src/shared/icons/visibility.svg +1 -0
- package/src/shared/icons/visibility_off.svg +1 -0
- package/src/shared/icons/volume_off.svg +1 -0
- package/src/shared/icons/warning.svg +1 -0
- package/src/shared/icons/wash.svg +1 -0
- package/src/shared/icons/wifi.svg +1 -0
- package/src/shared/icons/work.svg +1 -0
- package/src/shared/icons/x.svg +1 -0
- package/src/shared/icons/youtube.svg +1 -0
- package/src/shared/icons/zoom_in.svg +1 -0
- package/src/shared/icons/zoom_out.svg +1 -0
- package/src/shared/icons/zoom_out_map.svg +1 -0
- package/src/utils/index.test.ts +34 -0
- package/src/utils/index.ts +8 -0
- package/src/vite-env.d.ts +17 -0
- package/storybook/contributing.mdx +115 -0
- package/storybook/framework-guidance.mdx +96 -0
- package/storybook/index.css +70 -0
- package/storybook/readme.mdx +6 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Meta,
|
|
3
|
+
Title,
|
|
4
|
+
Primary,
|
|
5
|
+
Controls,
|
|
6
|
+
Stories,
|
|
7
|
+
} from "@storybook/addon-docs/blocks";
|
|
8
|
+
import { SiteNote } from "../../../.storybook/blocks/SiteNote.jsx";
|
|
9
|
+
|
|
10
|
+
<Meta isTemplate />
|
|
11
|
+
|
|
12
|
+
<Title />
|
|
13
|
+
|
|
14
|
+
Banners identify official websites of government organizations in the United States. They also help visitors understand whether a website is official and secure.
|
|
15
|
+
|
|
16
|
+
## About the banner component
|
|
17
|
+
|
|
18
|
+
<SiteNote>
|
|
19
|
+
<strong>Note:</strong> Banners and identifiers are core components. We
|
|
20
|
+
recommend using both core components on most sites. Together, they are the
|
|
21
|
+
most recognizable and standardized design elements of a government site.
|
|
22
|
+
</SiteNote>
|
|
23
|
+
|
|
24
|
+
You should use the banner to identify your site as an official government site.
|
|
25
|
+
|
|
26
|
+
The banner explains how to identify an official `.gov` or `.mil` domain and that these sites have secure HTTPS connections. Using the banner component is the best way to assure visitors that they’re connected to an official site.
|
|
27
|
+
|
|
28
|
+
Most government sites should use the banner, but some should not use the banner. Do NOT use the banner on non-government domains such as a `.com` or `.org`.
|
|
29
|
+
|
|
30
|
+
[//]: # "If you are unable to update to USWDS 2.8.0 (described on GitHub) or higher but still want to include the new language in your banner, we recommend editing your content to the language outlined in the component preview."
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Default
|
|
35
|
+
|
|
36
|
+
This is the default banner as it appears when no additional properties or slots are passed to the component.
|
|
37
|
+
|
|
38
|
+
<Primary />
|
|
39
|
+
|
|
40
|
+
## Inputs
|
|
41
|
+
|
|
42
|
+
The component accepts the following inputs (props). You can change the values below to see how the component changes.
|
|
43
|
+
|
|
44
|
+
<Controls />
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Variations
|
|
49
|
+
|
|
50
|
+
Listed below are additional variations of the component.
|
|
51
|
+
|
|
52
|
+
<Stories />
|
|
53
|
+
|
|
54
|
+
## Guidance
|
|
55
|
+
|
|
56
|
+
### About
|
|
57
|
+
|
|
58
|
+
This version of `usa-banner` (i.e. using web components) became available in [USWDS v3.13.0](https://github.com/uswds/uswds/releases/tag/v3.13.0). It is now part of the `@uswds/uswds-elements` package
|
|
59
|
+
|
|
60
|
+
### When to use the default banner
|
|
61
|
+
|
|
62
|
+
_To identify as an official government site._ Most government sites should use the banner, though non-federal government sites will need to change the text to be more accurate.
|
|
63
|
+
|
|
64
|
+
### When to consider something else
|
|
65
|
+
|
|
66
|
+
_If you don’t use a .gov/.mil domain and HTTPS._ The Design System’s banner text identifies `.gov` and `.mil` domains and HTTPS as indicators that a website is an official government website. Use this banner only if your site uses both the proper top-level domain (TLD) and HTTPS.
|
|
67
|
+
|
|
68
|
+
_Any time it would be misleading._ The banner should be used to reduce confusion. Avoid using the banner on any site meant only for testing or otherwise not meant to be identified as an official government website.
|
|
69
|
+
|
|
70
|
+
### Usability guidance
|
|
71
|
+
|
|
72
|
+
_Use the provided text without customization._ The banner is most effective as an identifier and a learning tool when its message is consistent across government sites. With only a few exceptions (described in our Implementation guidance), sites should use the top-level domain (TLD)-appropriate text provided, unaltered. Use the Spanish version of the banner for Spanish-language websites.
|
|
73
|
+
|
|
74
|
+
_Use the version appropriate to your website’s top-level domain (TLD)._ If your project uses a .mil top-level domain, use the .mil banner text.
|
|
75
|
+
Show the banner on every page. Use the banner at the top of every page of a site. It can be confusing or misleading if it appears on some pages and not others.
|
|
76
|
+
|
|
77
|
+
_Avoid distraction._ The banner should appear on every page of your site. Choose background colors that fit with your site theme, and avoid color combinations that draw excessive attention to the banner.
|
|
78
|
+
|
|
79
|
+
_Keep the text up to date._ Use the most current version of the banner.
|
|
80
|
+
|
|
81
|
+
### Accessibility guidance
|
|
82
|
+
|
|
83
|
+
The component provides default labels for English and Spanish when `lang="en"` or `lang="es"` is passed to the component. If no `lang` attribute is passed, the English label will be used.
|
|
84
|
+
|
|
85
|
+
If the default labels are not appropriate, you can pass a custom label to the component, which will be used instead and rendered as an `aria-label` attribute inside the banner.
|
|
86
|
+
|
|
87
|
+
For example, if you were providing a French version of the banner, you should also add a label in French to distinguish the banner header from the main header.
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<usa-banner label="Un site Web officiel du gouvernement américain">
|
|
91
|
+
<!-- rest of the banner markup -->
|
|
92
|
+
</usa-banner>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Some `.gov` websites don’t represent the federal level of the U.S. government. These sites should adapt the An official website of the United States government and Official websites use `.gov` sections to use more accurate language specific to the site.
|
|
96
|
+
|
|
97
|
+
Some `.mil` websites don’t belong to an official U.S. Department of War organization. These sites should adapt the Official websites use `.mil` section to use more technically accurate language: “A .mil website operates under the approval of the U.S. Department of War.”
|
|
98
|
+
|
|
99
|
+
The banner should directly follow the `skipnav` component.
|
|
100
|
+
|
|
101
|
+
<SiteNote>
|
|
102
|
+
<strong>Note:</strong> As this is the first Web Component shipping in USWDS,
|
|
103
|
+
we are still working on the best way to document its usage. We want to hear
|
|
104
|
+
from users about challenges with adding this component to your projects.
|
|
105
|
+
Please let us know what works, what doesn’t, and what additional documentation
|
|
106
|
+
might be helpful in this [discussion
|
|
107
|
+
thread](https://github.com/uswds/uswds/discussions/6477).
|
|
108
|
+
</SiteNote>
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { LitElement, html, css, unsafeCSS } from "lit";
|
|
2
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
3
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
4
|
+
|
|
5
|
+
import colorTokens from "@ogds/tokens/styles/css/colors.css";
|
|
6
|
+
import spacingTokens from "@ogds/tokens/styles/css/spacing.css";
|
|
7
|
+
import breakpointTokens from "@ogds/tokens/styles/css/breakpoints.css";
|
|
8
|
+
import styles from "./usa-banner.css";
|
|
9
|
+
|
|
10
|
+
import usFlagSmall from "@uswds/uswds/img/us_flag_small.png";
|
|
11
|
+
import iconDotGov from "@uswds/uswds/img/icon-dot-gov.svg";
|
|
12
|
+
import iconHttps from "@uswds/uswds/img/icon-https.svg";
|
|
13
|
+
import iconClose from "../../shared/icons/close.svg";
|
|
14
|
+
import iconExpandMore from "../../shared/icons/expand_more.svg";
|
|
15
|
+
import iconExpandLess from "../../shared/icons/expand_less.svg";
|
|
16
|
+
import { defineCustomElement } from "../../utils";
|
|
17
|
+
|
|
18
|
+
interface UsaBannerTranslations {
|
|
19
|
+
banner: {
|
|
20
|
+
label: string;
|
|
21
|
+
text: string;
|
|
22
|
+
action: string;
|
|
23
|
+
};
|
|
24
|
+
domain: {
|
|
25
|
+
heading: string;
|
|
26
|
+
text1: string;
|
|
27
|
+
text2: string;
|
|
28
|
+
};
|
|
29
|
+
https: {
|
|
30
|
+
heading1: string;
|
|
31
|
+
heading2: string;
|
|
32
|
+
text1: string;
|
|
33
|
+
text2: string;
|
|
34
|
+
text3: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type SupportedLanguage = "en" | "es";
|
|
39
|
+
|
|
40
|
+
const USA_BANNER_TRANSLATIONS: Record<
|
|
41
|
+
SupportedLanguage,
|
|
42
|
+
UsaBannerTranslations
|
|
43
|
+
> = {
|
|
44
|
+
en: {
|
|
45
|
+
banner: {
|
|
46
|
+
label: "Official website of the United States government",
|
|
47
|
+
text: "An official website of the United States government",
|
|
48
|
+
action: "Here’s how you know",
|
|
49
|
+
},
|
|
50
|
+
domain: {
|
|
51
|
+
heading: "Official websites use",
|
|
52
|
+
text1: "A",
|
|
53
|
+
text2:
|
|
54
|
+
"website belongs to an official government organization in the United States.",
|
|
55
|
+
},
|
|
56
|
+
https: {
|
|
57
|
+
heading1: "Secure",
|
|
58
|
+
heading2: "websites use HTTPS",
|
|
59
|
+
text1: "A <strong>lock</strong>",
|
|
60
|
+
text2:
|
|
61
|
+
"or <strong>https://</strong> means you’ve safely connected to the",
|
|
62
|
+
text3:
|
|
63
|
+
"website. Share sensitive information only on official, secure websites.",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
es: {
|
|
67
|
+
banner: {
|
|
68
|
+
label: "Un sitio oficial del Gobierno de Estados Unidos",
|
|
69
|
+
text: "Un sitio oficial del Gobierno de Estados Unidos",
|
|
70
|
+
action: "Así es como usted puede verificarlo",
|
|
71
|
+
},
|
|
72
|
+
domain: {
|
|
73
|
+
heading: "Los sitios web oficiales usan",
|
|
74
|
+
text1: "Un sitio web",
|
|
75
|
+
text2:
|
|
76
|
+
"pertenece a una organización oficial del Gobierno de Estados Unidos.",
|
|
77
|
+
},
|
|
78
|
+
https: {
|
|
79
|
+
heading1: "Los sitios web seguros",
|
|
80
|
+
heading2: "usan HTTPS",
|
|
81
|
+
text1: "Un <strong>candado</strong>",
|
|
82
|
+
text2:
|
|
83
|
+
"o <strong>https://</strong> significa que usted se conectó de forma segura a un sitio web",
|
|
84
|
+
text3:
|
|
85
|
+
"Comparta información sensible sólo en sitios web oficiales y seguros.",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @summary The usa-banner component.
|
|
92
|
+
*
|
|
93
|
+
* @attribute {string} lang - The element's language.
|
|
94
|
+
* @attribute {string} label - The custom aria label users can override.
|
|
95
|
+
* @attribute {string} tld - The top level domain for the site.
|
|
96
|
+
*
|
|
97
|
+
* @cssprop --ogds-banner-background-color - Sets banner background color.
|
|
98
|
+
* @cssprop --ogds-banner-button-close-background-color - Sets the background color for the close control on smaller viewports.
|
|
99
|
+
* @cssprop --ogds-banner-focus-outline-color - Sets banner focus outline color.
|
|
100
|
+
* @cssprop --ogds-banner-font-family - Sets banner font family.
|
|
101
|
+
* @cssprop --ogds-banner-icon-gov-color - Sets the color for the official government domain icon in the expanded state of the banner.
|
|
102
|
+
* @cssprop --ogds-banner-icon-https-color - Sets the color for the https icon in the expanded state of the banner.
|
|
103
|
+
* @cssprop --ogds-banner-link-color - Sets the default link color.
|
|
104
|
+
* @cssprop --ogds-banner-link-hover-color - Sets the default link color.
|
|
105
|
+
* @cssprop --ogds-banner-text-color - Sets the default text color.
|
|
106
|
+
*
|
|
107
|
+
* @slot banner-text - The text for official government website text.
|
|
108
|
+
* @slot banner-action - Action text label "Here's how you know."
|
|
109
|
+
* @slot domain-heading - Heading text for the domain section.
|
|
110
|
+
* @slot domain-text - Body text for domain section.
|
|
111
|
+
* @slot https-heading - Heading for HTTPs section.
|
|
112
|
+
* @slot https-text - Body text for HTTPs section.
|
|
113
|
+
*
|
|
114
|
+
* @element usa-banner
|
|
115
|
+
*/
|
|
116
|
+
export class UsaBanner extends LitElement {
|
|
117
|
+
static properties = {
|
|
118
|
+
flagSrc: { type: String },
|
|
119
|
+
lang: { type: String, reflect: true },
|
|
120
|
+
isOpen: { state: true },
|
|
121
|
+
label: { type: String },
|
|
122
|
+
tld: { type: String, reflect: true },
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Property declarations
|
|
126
|
+
flagSrc!: string;
|
|
127
|
+
lang!: "en" | "es";
|
|
128
|
+
isOpen!: boolean;
|
|
129
|
+
label!: string;
|
|
130
|
+
tld!: "gov" | "mil";
|
|
131
|
+
|
|
132
|
+
toggle() {
|
|
133
|
+
this.isOpen = !this.isOpen;
|
|
134
|
+
const contentElement = this.shadowRoot?.querySelector(".content");
|
|
135
|
+
if (contentElement) {
|
|
136
|
+
contentElement.toggleAttribute("hidden");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
constructor() {
|
|
141
|
+
super();
|
|
142
|
+
this.flagSrc = usFlagSmall;
|
|
143
|
+
this.lang = "en";
|
|
144
|
+
this.isOpen = false;
|
|
145
|
+
this.tld = "gov";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Get English or Spanish strings. Default to English if an unknown `lang` is passed.
|
|
149
|
+
// Ex: <usa-banner lang="zy"></usa-banner>
|
|
150
|
+
protected get _bannerText() {
|
|
151
|
+
return USA_BANNER_TRANSLATIONS[this.lang] || USA_BANNER_TRANSLATIONS["en"];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Get the action text and use for both mobile & desktop buttons.
|
|
155
|
+
protected get _actionText() {
|
|
156
|
+
const bannerActionText = this.querySelector('[slot="banner-action"]');
|
|
157
|
+
|
|
158
|
+
return bannerActionText?.textContent;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
domainTemplate(tld: string) {
|
|
162
|
+
const { domain } = this._bannerText;
|
|
163
|
+
|
|
164
|
+
return html`
|
|
165
|
+
<div class="icon-gov">
|
|
166
|
+
<p>
|
|
167
|
+
<strong>
|
|
168
|
+
<slot name="domain-heading"> ${domain.heading} .${tld} </slot>
|
|
169
|
+
</strong>
|
|
170
|
+
<br />
|
|
171
|
+
<slot name="domain-text">
|
|
172
|
+
${domain.text1} <strong>.${tld}</strong> ${domain.text2}
|
|
173
|
+
</slot>
|
|
174
|
+
</p>
|
|
175
|
+
</div>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
lockIcon() {
|
|
180
|
+
return html`
|
|
181
|
+
<span
|
|
182
|
+
class="icon-lock"
|
|
183
|
+
role="img"
|
|
184
|
+
aria-label="Locked padlock icon"
|
|
185
|
+
></span>
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
httpsTemplate(tld: string) {
|
|
190
|
+
const { https } = this._bannerText;
|
|
191
|
+
|
|
192
|
+
return html`
|
|
193
|
+
<div class="icon-https">
|
|
194
|
+
<p>
|
|
195
|
+
<strong>
|
|
196
|
+
<slot name="https-heading">
|
|
197
|
+
${https.heading1} .${tld} ${https.heading2}
|
|
198
|
+
</slot> </strong
|
|
199
|
+
><br />
|
|
200
|
+
<slot name="https-text">
|
|
201
|
+
${unsafeHTML(https.text1)} (${this.lockIcon()})
|
|
202
|
+
${unsafeHTML(https.text2)} .${tld} ${https.text3}
|
|
203
|
+
</slot>
|
|
204
|
+
</p>
|
|
205
|
+
</div>
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static styles = [
|
|
210
|
+
css`
|
|
211
|
+
:host {
|
|
212
|
+
/** Icons */
|
|
213
|
+
--ogds-icon-close: url("${unsafeCSS(iconClose)}");
|
|
214
|
+
--ogds-icon-expand-less: url("${unsafeCSS(iconExpandLess)}");
|
|
215
|
+
--ogds-icon-expand-more: url("${unsafeCSS(iconExpandMore)}");
|
|
216
|
+
--ogds-icon-gov: url("${unsafeCSS(iconDotGov)}");
|
|
217
|
+
--ogds-icon-https: url("${unsafeCSS(iconHttps)}");
|
|
218
|
+
}
|
|
219
|
+
`,
|
|
220
|
+
breakpointTokens,
|
|
221
|
+
colorTokens,
|
|
222
|
+
spacingTokens,
|
|
223
|
+
styles,
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
render() {
|
|
227
|
+
const classes = { ["expanded"]: this.isOpen };
|
|
228
|
+
// ? Is there a better way to fallback to a default value is passed value doesn't match?
|
|
229
|
+
// Example: User passes `tld="zzz"` --> uses "gov" domain instead of `zzz`.
|
|
230
|
+
const tld = this.tld === "mil" ? "mil" : "gov";
|
|
231
|
+
const { banner } = this._bannerText;
|
|
232
|
+
|
|
233
|
+
return html`
|
|
234
|
+
<section aria-label=${this.label || banner.label}>
|
|
235
|
+
<div class="usa-accordion">
|
|
236
|
+
<header class="${classMap(classes)}">
|
|
237
|
+
<div class="inner">
|
|
238
|
+
<div class="grid-col-auto">
|
|
239
|
+
<img
|
|
240
|
+
aria-hidden="true"
|
|
241
|
+
class="header-flag"
|
|
242
|
+
src=${this.flagSrc}
|
|
243
|
+
alt=""
|
|
244
|
+
/>
|
|
245
|
+
</div>
|
|
246
|
+
<div
|
|
247
|
+
class="grid-col-fill tablet:grid-col-auto"
|
|
248
|
+
aria-hidden="true"
|
|
249
|
+
>
|
|
250
|
+
<p class="header-text">
|
|
251
|
+
<slot name="banner-text">${banner.text}</slot>
|
|
252
|
+
</p>
|
|
253
|
+
<!--
|
|
254
|
+
Since the header-action text below is underlined, the slot and p
|
|
255
|
+
need to be on the same line to avoid one extra space of underline
|
|
256
|
+
before the expand icon.
|
|
257
|
+
-->
|
|
258
|
+
<!-- prettier-ignore -->
|
|
259
|
+
<p class="header-action"><slot name="banner-action">${banner.action}</slot></p>
|
|
260
|
+
</div>
|
|
261
|
+
<button
|
|
262
|
+
type="button"
|
|
263
|
+
class="usa-accordion__button"
|
|
264
|
+
aria-expanded="${this.isOpen}"
|
|
265
|
+
aria-controls="gov-banner-default"
|
|
266
|
+
@click="${this.toggle}"
|
|
267
|
+
>
|
|
268
|
+
<span class="button-text">
|
|
269
|
+
${this._actionText || banner.action}
|
|
270
|
+
</span>
|
|
271
|
+
</button>
|
|
272
|
+
</div>
|
|
273
|
+
</header>
|
|
274
|
+
<div class="content usa-accordion__content" hidden>
|
|
275
|
+
<div class="grid-row grid-gap-lg">
|
|
276
|
+
<div class="guidance tablet:grid-col-6">
|
|
277
|
+
${this.domainTemplate(tld)}
|
|
278
|
+
</div>
|
|
279
|
+
<div class="guidance tablet:grid-col-6">
|
|
280
|
+
${this.httpsTemplate(tld)}
|
|
281
|
+
</div>
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
</section>
|
|
286
|
+
`;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
defineCustomElement("usa-banner", UsaBanner);
|