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

USWDS - Web components: Beta 2 banner additions #65

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0fd8c4a
Create global stylesheets for shared CSS vars
mejiaj Sep 4, 2024
193708b
Create and document Banner settings
mejiaj Sep 4, 2024
ca79783
Move lock icon from markup to CSS
mejiaj Sep 4, 2024
d9167dd
Reflect lang attribute
mejiaj Sep 4, 2024
6f95fef
Remove redundant story
mejiaj Sep 4, 2024
fc1f243
Update dependencies
mejiaj Sep 4, 2024
521a121
Remove test exclamation
mejiaj Sep 4, 2024
c6c9553
Remove commented code
mejiaj Sep 4, 2024
b837937
Fix hover color
mejiaj Sep 4, 2024
370d1f0
Add quotes to background images
mejiaj Sep 4, 2024
d11629f
Add core stylesheets to exports
mejiaj Sep 4, 2024
b52ceef
Add colors and minimum story requirements to docs
mejiaj Sep 5, 2024
36de343
Add eslint plugin for vitest
mejiaj Sep 30, 2024
2c7f43b
Separate lock icon to improve HTTPS text readability
mejiaj Oct 1, 2024
ac0024d
Improve custom content story
mejiaj Oct 1, 2024
14524a9
Create unit tests
mejiaj Oct 1, 2024
c44331a
Update deps; add patch updates to axe playwright and vite
mejiaj Oct 1, 2024
2eab5b5
Merge branch 'develop' of github.com:uswds/web-components into jm/bet…
mejiaj Oct 3, 2024
7c25830
Regen custom elements manifest
mejiaj Oct 3, 2024
4430699
Add font declarations to font stylesheet
mejiaj Oct 3, 2024
0bc0f39
Run custom element manifest task in parallel with start command
mejiaj Oct 3, 2024
72887f4
Fix name `TLD` comment
mejiaj Oct 3, 2024
a599f72
Remove duplicate fallback properties
mejiaj Oct 4, 2024
7a4628a
Merge branch 'develop' of github.com:uswds/web-components into jm/bet…
mejiaj Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import "../storybook/index.css";
// Documentation overrides.
import "./index.css";

// USWDS Core props.
import "../src/core/index.css";

/** @type { import('@storybook/web-components').Preview } */
const preview = {
parameters: {
Expand Down
131 changes: 85 additions & 46 deletions custom-elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{
"kind": "class",
"description": "",
"name": "R",
"name": "I",
"members": [
{
"kind": "method",
Expand All @@ -54,10 +54,6 @@
"name": "_actionText",
"readonly": true
},
{
"kind": "method",
"name": "svgLock"
},
{
"kind": "method",
"name": "domainTemplate",
Expand All @@ -67,6 +63,10 @@
}
]
},
{
"kind": "method",
"name": "lockIcon"
},
{
"kind": "method",
"name": "httpsTemplate",
Expand Down Expand Up @@ -110,7 +110,7 @@
}
],
"superclass": {
"name": "oe",
"name": "re",
"package": "lit"
},
"tagName": "usa-banner",
Expand All @@ -122,15 +122,15 @@
"kind": "custom-element-definition",
"name": "usa-banner",
"declaration": {
"name": "R",
"name": "I",
"module": "dist/components/usa-banner.js"
}
},
{
"kind": "js",
"name": "UsaBanner",
"declaration": {
"name": "R",
"name": "I",
"module": "dist/components/usa-banner.js"
}
}
Expand Down Expand Up @@ -208,6 +208,12 @@
}
]
},
{
"kind": "javascript-module",
"path": "src/components/usa-banner/banner.spec.js",
"declarations": [],
"exports": []
},
{
"kind": "javascript-module",
"path": "src/components/usa-banner/banner.stories.js",
Expand All @@ -220,21 +226,13 @@
},
"default": "{}"
},
{
"kind": "variable",
"name": "CustomAriaLabel",
"type": {
"text": "object"
},
"default": "{ args: { label: \"A custom aria label\", }, }"
},
{
"kind": "variable",
"name": "CustomContent",
"type": {
"text": "object"
},
"default": "{ args: { bannerText: \"Un site Web officiel du gouvernement américain\", bannerAction: \"Voici comment vous le savez\", domainHeading: \"Les sites Web officiels utilisent\", domainText: \"Un site Web .gov appartient à une organisation gouvernementale officielle aux États-Unis.\", httpsHeading: \"Les sites Web .gov sécurisés utilisent HTTPS\", httpsText: `Un verrou ou (lock) https:// signifie que vous êtes connecté(e) en toute sécurité au site Web .gov. Assurez-vous de ne partager des informations sensibles que sur des sites Web officiels et sécurisés.`, }, render: ({ bannerText, bannerAction, domainHeading, domainText, httpsHeading, httpsText, }) => html` <usa-banner> <span slot=\"banner-text\">${bannerText}</span> <span slot=\"banner-action\">${bannerAction}</span> <span slot=\"domain-heading\">${domainHeading}</span> <span slot=\"domain-text\">${domainText}</span> <span slot=\"https-heading\">${httpsHeading}</span> <span slot=\"https-text\">${httpsText}</span> </usa-banner> `, }"
"default": "{ argTypes: { tld: { table: { disable: true } }, lang: { table: { disable: true } }, }, args: { label: \"Un site Web officiel du gouvernement américain\", bannerText: \"Un site Web officiel du gouvernement américain\", bannerAction: \"Voici comment vous le savez\", domainHeading: \"Les sites Web officiels utilisent\", domainText: \"Un site Web .gov appartient à une organisation gouvernementale officielle aux États-Unis.\", httpsHeading: \"Les sites Web .gov sécurisés utilisent HTTPS\", httpsText: `Un <strong>verrou</strong> (<span class=\"usa-banner__icon-lock\" role=\"img\" aria-label=\"Locked padlock icon\"></span>) ou <strong>https://</strong> signifie que vous êtes connecté(e) en toute sécurité au site Web .gov. Assurez-vous de ne partager des informations sensibles que sur des sites Web officiels et sécurisés.`, tld: \"mil\", }, render: ({ label, bannerText, bannerAction, domainHeading, domainText, httpsHeading, httpsText, }) => html` <usa-banner label=${label || nothing}> <span slot=\"banner-text\">${bannerText}</span> <span slot=\"banner-action\">${bannerAction}</span> <span slot=\"domain-heading\">${domainHeading}</span> <span slot=\"domain-text\">${domainText}</span> <span slot=\"https-heading\">${httpsHeading}</span> <span slot=\"https-text\">${unsafeHTML(httpsText)}</span> </usa-banner> `, }"
},
{
"kind": "variable",
Expand Down Expand Up @@ -285,14 +283,6 @@
"module": "src/components/usa-banner/banner.stories.js"
}
},
{
"kind": "js",
"name": "CustomAriaLabel",
"declaration": {
"name": "CustomAriaLabel",
"module": "src/components/usa-banner/banner.stories.js"
}
},
{
"kind": "js",
"name": "CustomContent",
Expand Down Expand Up @@ -343,6 +333,50 @@
"kind": "class",
"description": "",
"name": "UsaBanner",
"cssProperties": [
{
"description": "Sets banner background color.",
"name": "--theme-banner-background-color"
},
{
"description": "Sets banner font family.",
"name": "--theme-banner-font-family"
},
{
"description": "Sets the default link color.",
"name": "--theme-banner-link-color"
},
{
"description": "Sets the default link color.",
"name": "--theme-banner-link-hover-color"
}
],
"slots": [
{
"description": "The text for official government website text.",
"name": "banner-text"
},
{
"description": "Action text label \"Here's how you know.\"",
"name": "banner-action"
},
{
"description": "Heading text for the domain section.",
"name": "domain-heading"
},
{
"description": "Body text for domain section.",
"name": "domain-text"
},
{
"description": "Heading for HTTPs section.",
"name": "https-heading"
},
{
"description": "Body text for HTTPs section.",
"name": "https-text"
}
],
"members": [
{
"kind": "method",
Expand All @@ -358,10 +392,6 @@
"name": "_actionText",
"readonly": true
},
{
"kind": "method",
"name": "svgLock"
},
{
"kind": "method",
"name": "domainTemplate",
Expand All @@ -371,6 +401,10 @@
}
]
},
{
"kind": "method",
"name": "lockIcon"
},
{
"kind": "method",
"name": "httpsTemplate",
Expand All @@ -388,7 +422,8 @@
"text": "string"
},
"default": "\"en\"",
"attribute": "lang"
"attribute": "lang",
"reflects": true
},
{
"kind": "field",
Expand Down Expand Up @@ -438,46 +473,50 @@
],
"attributes": [
{
"name": "lang",
"type": {
"text": "string"
},
"description": "The element's language.",
"name": "lang",
"default": "\"en\"",
"fieldName": "lang"
},
{
"name": "isOpen",
"type": {
"text": "boolean"
},
"default": "false",
"fieldName": "isOpen"
},
{
"name": "classes",
"fieldName": "classes"
},
{
"name": "label",
"type": {
"text": "string"
},
"description": "The custom aria label users can override.",
"name": "label",
"fieldName": "label"
},
{
"name": "tld",
"type": {
"text": "string"
},
"description": "The top level domain for the site.",
"name": "tld",
"default": "\"gov\"",
"fieldName": "tld"
},
{
"name": "isOpen",
"type": {
"text": "boolean"
},
"default": "false",
"fieldName": "isOpen"
},
{
"name": "classes",
"fieldName": "classes"
}
],
"superclass": {
"name": "LitElement",
"package": "lit"
},
"tagName": "usa-banner",
"summary": "The usa-banner component.",
"customElement": true
}
],
Expand Down Expand Up @@ -510,7 +549,7 @@
"type": {
"text": "array"
},
"default": "[ unsafeCSS(usaBannerStyle), css` * { box-sizing: border-box; } .usa-banner__inner { flex-wrap: nowrap; } .usa-accordion__button { cursor: pointer; } `, //* In USWDS close icon is set via max-width media query, flipped it here. css` .usa-banner__button::after, .usa-banner__header-action::after { background-image: url(${unsafeCSS(expandMore)}); mask-image: url(${unsafeCSS(expandMore)}); } .usa-banner__button[aria-expanded=\"true\"]::after { background-image: url(${unsafeCSS(close)}); mask-image: url(${unsafeCSS(close)}); } @media all and (min-width: 40em) { .usa-banner__button[aria-expanded=\"true\"]::after { background-image: url(${unsafeCSS(expandLess)}); mask-image: url(${unsafeCSS(expandLess)}); } } `, ]"
"default": "[ unsafeCSS(usaBannerStyle), css` :host { --theme-banner-background-color: var(--usa-base-lightest, #f0f0f0); --theme-banner-font-family: var(--usa-font-ui, system-ui, sans-serif); --theme-banner-link-color: var(--theme-link-color, #005ea2); --theme-banner-link-color-hover: var(--theme-link-hover-color, #1a4480); // Missing theme-banner-max-width because we can't pass custom property to media queries. } * { box-sizing: border-box; } .usa-banner { background-color: var(--theme-banner-background-color); font-family: var(--theme-banner-font-family); } .usa-banner__inner { flex-wrap: nowrap; } /* Allows banner action to inherit font variable. */ .usa-banner .usa-accordion { font-family: inherit; } .usa-banner__button { color: var(--theme-banner-link-color); cursor: pointer; font-family: inherit; } .usa-banner__button:hover { color: var(--theme-banner-link-hover-color); } /* In USWDS close icon is set via max-width media query, flipped it here. */ .usa-banner__button::after, .usa-banner__header-action::after { background-image: url(\"${unsafeCSS(expandMore)}\"); mask-image: url(\"${unsafeCSS(expandMore)}\"); } .usa-banner__button[aria-expanded=\"true\"]::after { background-image: url(\"${unsafeCSS(close)}\"); mask-image: url(\"${unsafeCSS(close)}\"); } /** * HTTPS section lock icon. * * Rewrote styles to avoid reliance of SASS mixins & functions. * * Height and width taken from calculated output in USWDS 3 banner. */ .usa-banner__icon-lock { background-image: url(\"${unsafeCSS(lock)}\"); background-position: center; background-repeat: no-repeat; background-size: cover; display: inline-block; height: 1.5ex; mask-image: url(\"${unsafeCSS(lock)}\"); mask-position: center; mask-repeat: no-repeat; mask-size: cover; vertical-align: middle; width: 1.21875ex; } @media all and (min-width: 40em) { .usa-banner__button[aria-expanded=\"true\"]::after { background-image: url(\"${unsafeCSS(expandLess)}\"); mask-image: url(\"${unsafeCSS(expandLess)}\"); } } `, ]"
}
],
"exports": [
Expand Down
13 changes: 12 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import js from "@eslint/js";
import eslintConfigPrettierRecommended from "eslint-config-prettier";
import vitest from "vitest";

export default [js.configs.recommended, eslintConfigPrettierRecommended];
export default [
js.configs.recommended,
eslintConfigPrettierRecommended,
{
files: ["**/*.spec.js"],
plugins: { vitest },
rules: {
...vitest.configs.recommended.rules,
},
},
];
Loading
Loading