-
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
Web-components: Create usa-identifier
web component
#21
base: develop
Are you sure you want to change the base?
Conversation
web-components/src/components/usa-identifier/identifier.stories.js
Outdated
Show resolved
Hide resolved
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.
Nice work so far! Added a few comments thinking about lessons learned in #12.
We don't have to follow that path, but we should consider what we can render by default in the component if users write <usa-identifier></usa-identifier>
.
web-components/src/components/usa-identifier/identifier.stories.js
Outdated
Show resolved
Hide resolved
web-components/src/components/usa-identifier/identifier.stories.js
Outdated
Show resolved
Hide resolved
web-components/src/components/usa-identifier/identifier.stories.js
Outdated
Show resolved
Hide resolved
web-components/src/components/usa-identifier/identifier.stories.js
Outdated
Show resolved
Hide resolved
import uswdsCoreStyle from "@uswds/uswds/scss/uswds-core?inline"; | ||
import usaIdentifierStyle from "@uswds/uswds/scss/usa-identifier?inline"; | ||
|
||
export class UsaIdentifier extends LitElement { |
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.
Lit recommends using component props as input. Source →
We should leverage reactive props if we're able to for defaults / configurable settings.
<a slot="logo" href="${primary_agency.url}"> | ||
<img src="${logo1}" alt="${primary_agency.name} logo" /> | ||
</a>`: null} |
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.
Seeing slot here, I'd expect to see <slot>
elements in the component template.
Example
<!-- Our template - [`identifier/index.js`] -->
<slot name="logo"></slot>
<!-- User overrides in markup -->
<span slot="logo">
<img src="logo-1.svg" />
<img src="logo-2.svg" />
<img src="logo-3.svg" />
</span>
…s/uswds-next into al/add-identifier-storybook
…/add-identifier-storybook
- Prevents axe-core error for invalid attribute
…/add-identifier-storybook
- This should fix color contrast errors in playwright
…/add-identifier-storybook
…/add-identifier-storybook
@@ -45,6 +45,7 @@ | |||
"@storybook/addon-a11y": "^8.2.7", | |||
"@storybook/addon-essentials": "^8.2.7", | |||
"@storybook/addon-links": "^8.2.7", | |||
"@storybook/addon-mdx-gfm": "^8.1.11", |
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.
Note
Added this dependency to enable markdown tables in the readme.mdx file 1. If we move forward without the docs tables, we can remove this dependency.
Footnotes
{ | ||
name: '@storybook/addon-docs', | ||
options: { | ||
mdxPluginOptions: { | ||
mdxCompileOptions: { | ||
remarkPlugins: [remarkGfm], | ||
}, | ||
}, | ||
}, | ||
}, |
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.
Note
Added this code to enable markdown tables in the readme.mdx file 1. If we move forward without the docs tables, we can remove this.
Footnotes
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.
Note
I manually added content to the tables on this page to demonstrate ideas for possible content in the storybook docs. In the future, we should explore ways to automatically generate this content from the JSDocs in index.js.
@mahoneycm @mejiaj @heymatthenry @thisisdano I just tagged you all for review on this PR. There is a lot here, so I'm proposing that before we dive into review of the structure of the .js and .css files, it would be good to first get feedback on the light DOM structure, the customization options, and the visuals and accessibility of the rendered component. I just don't want us spending time diving too deep into the JS or CSS then decide we want to restructure it all in favor of a different light DOM setup, for example. Let me know if you have any questions or comments! |
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.
Reviewing based on request for feedback on: structure, customization options, and visuals/accessibility of component.
I used our implementation of Identifier from USWDS-Site as a reference.
Structure
Listed a few ways I tried to create my own Identifier component.
Minimal markup
Note: Leaving out the required links intentionally to see what's generated.
Input
<usa-identifier>
<div slot="logo">
<a href="#">
<img
src="https://designsystem.digital.gov/img/gsa-logo.svg"
alt="GSA logo"
/>
</a>
</div>
<p slot="domain">designsystem.digital.gov</p>
<div slot="agency-primary">
<a href="#" agency-shortname="GSA">General Services Administration</a>
</div>
</usa-identifier>
Ouput
The output is pretty good and it looks exactly how I'd expect.
Quibble: There's no indication that I'm missing required link URLs.
A working version
Input
<usa-identifier
urlAbout="https://www.gsa.gov/about-us"
urlAccessibility="https://www.gsa.gov/website-information/accessibility-statement"
urlFOIA="https://www.gsa.gov/reference/freedom-of-information-act-foia"
urlNoFEAR="https://www.gsa.gov/reference/civil-rights-programs/notification-and-federal-employee-antidiscrimination-and-retaliation-act-of-2002"
urlOIG="https://www.gsaig.gov/"
urlPerformance="https://www.gsa.gov/reference/reports/budget-performance"
urlPrivacy="https://www.gsa.gov/website-information/website-policies"
>
<div slot="logo">
<a href="#">
<img
src="https://designsystem.digital.gov/img/gsa-logo.svg"
alt="GSA logo"
/>
</a>
</div>
<p slot="domain">designsystem.digital.gov</p>
<div slot="agency-primary">
<a href="#" agency-shortname="GSA">General Services Administration</a>
</div>
</usa-identifier>
Output
Visually, nothing changed — which is good.
Customizing strings
Input
Not sure if I did it right, but the visual output looks similar to what I'd expect.
<usa-identifier
urlAbout="https://www.gsa.gov/about-us"
urlAccessibility="https://www.gsa.gov/website-information/accessibility-statement"
urlFOIA="https://www.gsa.gov/reference/freedom-of-information-act-foia"
urlNoFEAR="https://www.gsa.gov/reference/civil-rights-programs/notification-and-federal-employee-antidiscrimination-and-retaliation-act-of-2002"
urlOIG="https://www.gsaig.gov/"
urlPerformance="https://www.gsa.gov/reference/reports/budget-performance"
urlPrivacy="https://www.gsa.gov/website-information/website-policies"
textAbout="Sobre vote.gov"
textAccessibility="Acessibilidade"
textFOIA="Pedidos de FOIA (em inglês)"
textPerformance="TK (em inglês)"
textOIG="TK (em inglês)"
textPrivacy="Política de privacidade (em inglês)"
>
<div slot="logo">
<a href="#">
<img
src="https://designsystem.digital.gov/img/gsa-logo.svg"
alt="GSA logo"
/>
</a>
</div>
<span slot="agency-intro">
Uma página web oficial da Administração dos Serviços Gerais (em
inglês)
</span>
<p slot="domain">designsystem.digital.gov</p>
<div slot="agency-primary">
<a href="#" agency-shortname="GSA">General Services Administration</a>
</div>
<!-- ! Docs say anchor, but demo uses div with an anchor. -->
<!-- <a slot="usagov">Você procura informação e serviços do governo dos EUA? Visite USA.gov (em inglês)</a> -->
<div slot="usagov">
Você procura informação e serviços do governo dos EUA? Visite USA.gov
(em inglês) <a href="https://www.usa.gov/">Visitez USA.gov</a>
</div>
</usa-identifier>
Output
I had to reference the documentation a lot.
My version is missing translated strings for aria labels. I'm not sure how to set those (except for 1st item), but capturing findings below.
Aria label | Description |
---|---|
usa-identifier |
This exists, but I forgot to change — maybe cue for us highlight in guidance. |
Agency description |
In the stable implementation this is set on usa-identifier__identity . |
Important links |
In stable this is set on usa-identifier__section--required-links . |
Recommendations
- Reduce # of props. This would improve readability. It's also consistent with components from landscape analysis and with patterns in existing component. For example, a single prop to set
urlAbout
andtextAbout
or move that to markup. - Allow aria labels to be set on description and important links. This could be on inner identifier markup.
- Prototype slots with the same name. This can help simplify the markup because they'll be placed one after the other. The user doesn't have to worry about grouping or setting containers.
Example
This is a rough example for discussion.
Before
<usa-identifier
urlAbout="https://www.gsa.gov/about-us"
urlAccessibility="https://www.gsa.gov/website-information/accessibility-statement"
urlFOIA="https://www.gsa.gov/reference/freedom-of-information-act-foia"
urlNoFEAR="https://www.gsa.gov/reference/civil-rights-programs/notification-and-federal-employee-antidiscrimination-and-retaliation-act-of-2002"
urlOIG="https://www.gsaig.gov/"
urlPerformance="https://www.gsa.gov/reference/reports/budget-performance"
urlPrivacy="https://www.gsa.gov/website-information/website-policies"
textAbout="Sobre vote.gov"
textAccessibility="Acessibilidade"
textFOIA="Pedidos de FOIA (em inglês)"
textPerformance="TK (em inglês)"
textOIG="TK (em inglês)"
textPrivacy="Política de privacidade (em inglês)"
>
<div slot="logo">
<a href="#">
<img
src="https://designsystem.digital.gov/img/gsa-logo.svg"
alt="GSA logo"
/>
</a>
</div>
<span slot="agency-intro">
Uma página web oficial da Administração dos Serviços Gerais (em
inglês)
</span>
<p slot="domain">designsystem.digital.gov</p>
<div slot="agency-primary">
<a href="#" agency-shortname="GSA">General Services Administration</a>
</div>
<!-- ! Docs say anchor, but demo uses div with an anchor. -->
<!-- <a slot="usagov">Você procura informação e serviços do governo dos EUA? Visite USA.gov (em inglês)</a> -->
<div slot="usagov">
Você procura informação e serviços do governo dos EUA? Visite USA.gov
(em inglês) <a href="https://www.usa.gov/">Visitez USA.gov</a>
</div>
</usa-identifier>
After
<usa-identifier>
<a href="#" slot="logo">
<img
src="https://designsystem.digital.gov/img/gsa-logo.svg"
alt="GSA logo"
/>
</a>
<!-- User would add this markup to customize. -->
<p slot="agency-disclaimer" aria-label="descrição">
Uma página web oficial da Administração dos Serviços Gerais (em inglês)
<a href=""><Parent agency></a>
</p>
<nav class="usa-identifier__section--required-links" aria-label="Importante">
<a href="#">Sobre GSA<a>
<a href="#">Acessibilidade</a>
<a href="#">Pedidos de FOIA (em inglês)</a>
<a href="#">Performance (em inglês)</a>
<a href="#">OIG (em inglês)</a>
<a href="#">Política de privacidade (em inglês)</a>
</nav>
<div slot="usagov">
Você procura informação e serviços do governo dos EUA? Visite USA.gov
(em inglês) <a href="https://www.usa.gov/">Visitez USA.gov</a>
</div>
</usa-identifier>
Customization
I was able to successfully override using CSS Custom Properties via usa-identifier
selector in devtools.
usa-identifier
web componentusa-identifier
web component
Summary
Create an alpha version of the
usa-identifier
web component.Related issue
Closes #26
Preview link
Identifier component (Storybook)
Related PRs
This is a cleaned up version of the "identifier playground" in PR #11.
Note
PR #11 explores alternative methods for implementing the identifier component, including a couple of options for an attribute-based implementation. There are a lot of files and options in there, so I created this second PR to minimize confusion as I focus on the declarative markup version of the component. Please add any comments about the identifier web component to this PR, not PR #11.
Task list