-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: develop
Are you sure you want to change the base?
Conversation
Following pattern from uswds/uswds#5829.
Following plugin guidance[^1] to avoid ESLint errors in unit tests [^1]: https://github.com/vitest-dev/eslint-plugin-vitest
Improve defaults, disable unused controls, and improve content.
…a-banner-component
@@ -57,8 +58,9 @@ | |||
"@storybook/theming": "^8.2.9", | |||
"@storybook/web-components": "^8.2.9", | |||
"@storybook/web-components-vite": "^8.2.9", | |||
"@vitest/eslint-plugin": "^1.1.4", |
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.
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.
Looked into this while doing some POAM for this repo. Good addition 👍
@@ -4,58 +4,59 @@ import { html, nothing } from "lit"; | |||
|
|||
import { userEvent, expect, waitFor } from "@storybook/test"; | |||
import { within } from "shadow-dom-testing-library"; | |||
import { unsafeHTML } from "lit/directives/unsafe-html.js"; |
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.
Tip
Helps render custom slotted content in HTTPS body because it includes HTML.
src/core/colors.css
Outdated
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.
Tip
Will look into @property
now that it has baseline support.
<ColorPalette> | ||
<ColorItem | ||
title="Base" | ||
subtitle="Grayscale colors" | ||
colors={{ | ||
White: "#FFFFFF", | ||
"Longer custom text": "#F3F3F3", | ||
Black: "#000", | ||
"--usa-base-lightest": "#F0F0F0", | ||
}} | ||
/> | ||
</ColorPalette> | ||
|
||
## Global | ||
|
||
<ColorPalette> | ||
<ColorItem | ||
title="Link" | ||
subtitle="Link colors" | ||
colors={{ | ||
"--usa-theme-link-color": "#005EA2", | ||
"--usa-theme-link-hover-color": "#1A4480", |
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.
Tip
Starting to document the shared properties here.
|
||
- Variants | ||
- Properties | ||
- CSS Custom Properties |
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.
Tip
We'll need to remove this if we continue with custom elements manifest.
* @summary The usa-banner component. | ||
* | ||
* @attribute {string} lang - The element's language. | ||
* @attribute {string} label - The custom aria label users can override. | ||
* @attribute {string} tld - The top level domain for the site. | ||
* | ||
* @cssprop --theme-banner-background-color - Sets banner background color. | ||
* @cssprop --theme-banner-font-family - Sets banner font family. | ||
* @cssprop --theme-banner-link-color - Sets the default link color. | ||
* @cssprop --theme-banner-link-hover-color - Sets the default link color. | ||
* | ||
* @slot banner-text - The text for official government website text. | ||
* @slot banner-action - Action text label "Here's how you know." | ||
* @slot domain-heading - Heading text for the domain section. | ||
* @slot domain-text - Body text for domain section. | ||
* @slot https-heading - Heading for HTTPs section. | ||
* @slot https-text - Body text for HTTPs section. | ||
* | ||
* @tagname usa-banner |
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.
…a-banner-component
Summary
Improvements to Banner. Added JSDocs and component is now configurable via CSS custom properties.
Related issue
Closes #39.
Preview link
Preview link:
Banner preview →
Problem statement
Banner was missing:
Additionally, the HTTPS lock icon was using unsafe SVG.
Solution
Added all the items above and swapped the SVG icon for a background image.
Major changes
Global CSS properties
Shared global properties created in a new
core
directory. They contain global token values and theme settings. They're meant to be attached at:root
level and leaves:host
for component-level settings.Core stylesheets also added as an export in
package.json
.Example
Component properties
Caution
Missing the theme setting
theme-banner-max-width
because media queries don't allow custom props as a value. Potential solutions: SASS, PostCSS custom media queries, or Lightning CSS each requires additional dependencies for everyone.--usa-base-lightest
#f0f0f0
--usa-font-ui
system-ui, sans-serif
--theme-link-color
#005ea2
--theme-link-hover-color
#1a4480
Link settings and names match those defined in USA Link component.
Lock icon replaced
The icon is added via CSS on a class. This allows users to not worry about pasting in a big block of SVG markup. Especially useful when adding custom content via slots.
Following pattern set by @aduth in uswds/uswds#5829.
Testing and review
Dependency updates
2.0.22.0.35.4.35.4.8