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

Web-components: Create usa-identifier web component #21

Open
wants to merge 64 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
44495b4
Add identifier component in storybook
amyleadem Jun 17, 2024
299b123
Comment out "an official" wrapper to prevent storybook error
amyleadem Jun 18, 2024
973de11
Use latest vite config to fix SCSS import errors
Jun 19, 2024
e25ca97
Add css preprocessor to vite config
amyleadem Jun 21, 2024
ec9bd87
Merge branch 'al/add-identifier-storybook' of https://github.com/uswd…
amyleadem Jun 21, 2024
26b0497
Create indiv link objects in storybook; rename stories
amyleadem Jun 21, 2024
dfdc3c9
Add starter tests to identifier.spec.js
amyleadem Jun 21, 2024
0603ca8
Update test for logos
amyleadem Jun 21, 2024
b2264c8
Add lang data and control; add default usagov
amyleadem Jun 25, 2024
5fd129e
Add custom content usagov; move lang data to json
amyleadem Jun 25, 2024
21c5c23
Create default link; add taxpayer attribute
amyleadem Jun 25, 2024
0ae101e
Consolidate aria-labels; rename controls
amyleadem Jun 26, 2024
5187659
Use map for required links
amyleadem Jun 28, 2024
3e35676
Use kebab case for slot names
amyleadem Jun 28, 2024
701aea8
Add default content in masthead
amyleadem Jun 28, 2024
5870445
Update taxpayer prop name
amyleadem Jun 28, 2024
36aebe9
Merge branch 'develop' of https://github.com/uswds/uswds-next into al…
amyleadem Jul 3, 2024
11146d5
Clean up code
amyleadem Jul 3, 2024
2300129
Add styles for second logo
amyleadem Jul 3, 2024
972e137
Replace aria-label prop with label
amyleadem Jul 5, 2024
3295148
Add custom docs
amyleadem Jul 16, 2024
20f6be0
Install remark-gfm
amyleadem Jul 16, 2024
a29a5fc
Add font-face for source sans
amyleadem Jul 17, 2024
311c8b4
Add system and theme css vars files
amyleadem Jul 17, 2024
aea6026
Add css custom props; format css
amyleadem Jul 17, 2024
a4be4bc
Merge branch 'develop' of https://github.com/uswds/uswds-next into al…
amyleadem Jul 31, 2024
ff13947
Add missing spacing units
amyleadem Jul 31, 2024
00cc022
Translate french data; remove unused json import
amyleadem Jul 31, 2024
1cb07c6
Remove masthead and nav wrappers
amyleadem Aug 1, 2024
8a3afcb
Include target attribute
amyleadem Aug 1, 2024
87287be
Run prettier
amyleadem Aug 1, 2024
95e034c
Add info to identifier README
amyleadem Aug 2, 2024
926b3ae
Move installation below implementation example
amyleadem Aug 2, 2024
c61b751
Add css parts to elements
amyleadem Aug 2, 2024
cfe4d5a
Change usagov element from div to p
amyleadem Aug 2, 2024
dec6453
Remove nav and disclaimer aria labels
amyleadem Aug 7, 2024
bcc13b1
Update identifier docs
amyleadem Aug 7, 2024
ccfc05f
Replace aria_labels -> aria_label
amyleadem Aug 7, 2024
4a731f9
Add slots table to readme
amyleadem Aug 7, 2024
83c1d62
More updates to implement single aria-label
amyleadem Aug 7, 2024
026ea11
Move slots table and update table headers
amyleadem Aug 8, 2024
8c4b5df
Rebuild required link list to use native element
amyleadem Aug 8, 2024
d820043
Alphabetize table data
amyleadem Aug 8, 2024
676561d
Update JSdocs
amyleadem Aug 8, 2024
6a94ffc
Replace req'd link slots with usa-link
amyleadem Aug 12, 2024
f20b3b8
Replace logo slots with usa-link
amyleadem Aug 12, 2024
bc8e74a
Merge branch 'develop' of https://github.com/uswds/uswds-next into al…
amyleadem Aug 13, 2024
622c0f9
Run prettier
amyleadem Aug 13, 2024
7e1f4a7
Remove identifier.spec.js
amyleadem Aug 13, 2024
a4c3508
Use props for req'd links urls; remove custom translation story (for …
amyleadem Aug 14, 2024
a72ef76
Add custom link text props; fix taxpayer_custom control
amyleadem Aug 14, 2024
7c43d59
Clean up storybook controls and jsdocs
amyleadem Aug 14, 2024
2096376
Remove usa-link import
amyleadem Aug 14, 2024
89d281e
Run prettier
amyleadem Aug 14, 2024
1d023af
Alphabetize props in docs
amyleadem Aug 14, 2024
c7a2ade
Add explicit color styles for disclaimer and usagov
amyleadem Aug 16, 2024
79f63e5
Merge branch 'develop' of https://github.com/uswds/uswds-next into al…
amyleadem Aug 16, 2024
61a01d9
Add --usa-theme-identifier-text-color & set to white
amyleadem Aug 20, 2024
f64f2ee
Run prettier
amyleadem Aug 20, 2024
0c5dc99
Run prettier
amyleadem Aug 20, 2024
37ba970
Merge branch 'develop' of https://github.com/uswds/uswds-next into al…
amyleadem Aug 20, 2024
089fe47
Add CSS var controls; rename text color vars
amyleadem Aug 20, 2024
5876e4b
Add basic unit tests
amyleadem Aug 20, 2024
8c67e36
Run prettier
amyleadem Aug 20, 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
5 changes: 5 additions & 0 deletions .storybook/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
.toc-list-item {
font-size: 1rem !important;
}

.sbdocs-content ul li,
.sbdocs p {
font-size: 1rem !important;
}
12 changes: 12 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type { import('@storybook/web-components-vite').StorybookConfig } */
import remarkGfm from 'remark-gfm';

const config = {
stories: [
"../storybook/**/*.mdx",
Expand All @@ -9,6 +11,16 @@ const config = {
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-a11y",
{
name: '@storybook/addon-docs',
options: {
mdxPluginOptions: {
mdxCompileOptions: {
remarkPlugins: [remarkGfm],
},
},
},
},
Comment on lines +14 to +23
Copy link
Contributor Author

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

  1. https://storybook.js.org/docs/writing-docs/mdx#markdown-tables-arent-rendering-correctly

],
framework: {
name: "@storybook/web-components-vite",
Expand Down
7,653 changes: 4,690 additions & 2,963 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor Author

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

  1. https://storybook.js.org/docs/writing-docs/mdx#markdown-tables-arent-rendering-correctly

"@storybook/blocks": "^8.2.7",
"@storybook/manager-api": "^8.2.7",
"@storybook/test": "^8.2.7",
Expand Down
102 changes: 102 additions & 0 deletions src/components/usa-identifier/_readme.mdx
Copy link
Contributor Author

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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import {
Meta,
Story,
Canvas,
Stories,
Controls,
Primary,
Source,
} from "@storybook/blocks";
import * as IdentifierStories from "./identifier.stories";

# Identifier

The identifier communicates a site's parent agency and displays agency links required by federal laws and policies.

**Related links:**

- [Using the identifier component](https://designsystem.digital.gov/components/identifier/) (designsystem.digital.gov)
- [Identifier accessibility tests](https://designsystem.digital.gov/components/identifier/accessibility-tests) (designsystem.digital.gov)

## Element name

`<usa-identifier>`

## Implementation example

<Canvas of={IdentifierStories.Default} />

## Importing identifier

- [`@import ...`] (TK)

Learn more about [installing and using USWDS web components] (Link TK).

## Properties

| Property | Element | Type | Description |
| :------------------ | :----------------- | :-------- | :--------------------------------------------------------------------------------------- |
| `label` | `<usa-identifier>` | `string` | Set a custom aria label for the identifier component. Default value: "Agency identifier" |
| `lang` | `<usa-identifier>` | `string` | Set the language for the default component text. Expected values: "en", "es" |
| `taxpayer` | `<usa-identifier>` | `boolean` | Include the "Produced and published at taxpayer expense" text |
| `textAbout` | `<usa-identifier>` | `string` | Custom translation text for the "Accessibility statement" link |
| `textAccessibility` | `<usa-identifier>` | `string` | Custom translation text for the "About" link |
| `textFOIA` | `<usa-identifier>` | `string` | Custom translation text for the "FOIA Requests" link |
| `textNoFEAR` | `<usa-identifier>` | `string` | Custom translation text for the "No FEAR Act data" link |
| `textOIG` | `<usa-identifier>` | `string` | Custom translation text for the "Office of the Inspector General" link |
| `textPerformance` | `<usa-identifier>` | `string` | Custom translation text for the "Performance reports" link |
| `textPrivacy` | `<usa-identifier>` | `string` | Custom translation text for the "Privacy policy" link |
| `urlAbout` | `<usa-identifier>` | `string` | The url for the parent agency's "About" page |
| `urlAccessibility` | `<usa-identifier>` | `string` | The url for the parent agency's "Accesibility statement" page |
| `urlFOIA` | `<usa-identifier>` | `string` | The url for the parent agency's "FOIA requests" page |
| `urlNoFEAR` | `<usa-identifier>` | `string` | The url for the parent agency's No FEAR Act data" page |
| `urlOIG` | `<usa-identifier>` | `string` | The url for the parent agency's "Office of the inspector general" page |
| `urlPerformance` | `<usa-identifier>` | `string` | The url for the parent agency's "Performance reports" page |
| `urlPrivacy` | `<usa-identifier>` | `string` | The url for the parent agency's "Privacy policy" page |

Learn more about [using properties on custom elements] (Link TK)

## CSS parts

| CSS Part | Description |
| :---------------- | :------------------------------------------------------------------------------- |
| `disclaimer` | The `<p>` element that wraps the "An official website of the..." disclaimer text |
| `disclaimer-link` | The `<a>` element inside the disclaimer text |
| `domain` | The `<p>` element that wraps your site's domain name |
| `logo-image` | The agency logo `<img>` element |
| `logo-wrapper` | The `<div>` element that wraps all logos |
| `logo` | The `<a>` elements that wrap each logo |
| `required-link` | The `<a>` elements in the required links list |
| `usagov` | The `<p>` element that wraps the USA.gov text |
| `usagov-link` | The `<a>` element inside the usagov text |

Learn more about [adding custom styles with CSS Parts] (Link TK).

## CSS variables

| CSS variable | Default value | Description |
| :-------------------------------------------- | :------------------------------------- | :---------------------------------------------------------------------------------------------- |
| `--usa-theme-identifier-background-color` | `--usa-system-color-ink` | Background color of the identifier |
| `--usa-theme-identifier-font-family` | `--usa-theme-font-body` | Font family of the identifier |
| `--usa-theme-identifier-max-width` | `--usa-theme-grid-container-max-width` | Maximum width of the content within the identifier. Use the same max-width as your site footer. |
| `--usa-theme-identifier-text-color` | `--usa-system-color-white` | Text color used in the disclaimer and USA.gov statement |
| `--usa-theme-identifier-secondary-text-color` | `--usa-system-color-gray-cool-10` | Link color used in the disclaimer and USA.gov statement |
| `--usa-theme-identifier-link-list-color` | `--usa-system-color-gray-cool-30` | Link color used required link list |

Learn more about [customizing component styles with CSS custom properties] (TK).

## Slots

| Name | Element | Expected content | Attributes |
| :---------------------------- | :------- | :---------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- |
| `agency-intro` (optional) | `<span>` | Custom text: "An official website of the" | `href`: url for your parent agency's home page |
| `agency-primary` | `<a>` | Text: Parent agency full name | `href`: url for your parent agency's home page |
| `agency-secondary` (optional) | `<a>` | Text: Secondary parent agency full name | `href`: url for your secondary parent agency's home page |
| `agency-taxpayer` (optional) | `<span>` | Custom text: "Produced and published at taxpayer expense." | `href`: url for your secondary parent agency's home page |
| `domain` | `<p>` | Text: Your site's domain name | -- |
| `logo` | `<a>` | Image: An `<a>` element wrapping the the parent agency logo `<img>` element | `href`: url for your parent agency's home page. |
| `usagov` (optional) | `<a>` | Custom text: "Looking for U.S. government information and services?" <br/> `<a>`: Visit USA.gov | `href`: url for the relevant translation of the usa.gov home page |

## All variants

<Stories />
46 changes: 46 additions & 0 deletions src/components/usa-identifier/identifier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"en": {
"masthead": {
"intro": "An official website of the",
"conjunction": "and"
},
"taxpayer": "Produced and published at taxpayer expense.",
"required_links": {
"about": "About",
"accessibility": "Accessibility statement",
"foia": "FOIA requests",
"no_fear": "No FEAR Act data",
"oig": "Office of the Inspector General",
"performance": "Performance reports",
"privacy": "Privacy policy"
},
"usagov": {
"description": "Looking for U.S. government information and services?",
"link_label": "Visit USA.gov",
"link_url": "https://www.usa.gov/"
},
"aria_label": "Agency identifier"
},
"es": {
"masthead": {
"intro": "Un sitio web oficial de",
"conjunction": "y"
},
"taxpayer": "Producdo y publicado con dinero de los contribuyentes de impuestos.",
"required_links": {
"about": "Acerca de",
"accessibility": "Declaración de accesibilidad",
"foia": "Solicitud a través de FOIA",
"no_fear": "Datos de la ley No FEAR",
"oig": "Oficina del Inspector General",
"performance": "Informes de desempeño",
"privacy": "Política de privacidad"
},
"usagov": {
"description": "¿Necesita información y servicios del Gobierno?",
"link_label": "Visite USA.gov en Español",
"link_url": "https://www.usa.gov/espanol/"
},
"aria_label": "Identificador de la agencia"
}
}
Loading