@noctuatech/uswds 0.0.3 → 0.0.5

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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/assets/uswds.min.js +1 -1
  3. package/package.json +4 -4
  4. package/src/lib/accordion/accordion.element.ts +147 -0
  5. package/src/lib/accordion/accordion.stories.ts +49 -0
  6. package/src/lib/accordion/accordion.test.ts +160 -0
  7. package/src/lib/checkbox/checkbox.element.ts +4 -1
  8. package/src/lib/define.ts +4 -0
  9. package/src/lib/link/link.element.ts +6 -2
  10. package/src/lib/radio/radio-option.element.ts +31 -13
  11. package/src/lib/radio/radio.element.ts +28 -40
  12. package/src/lib/radio/radio.stories.ts +18 -8
  13. package/src/lib/select/select-option.element.ts +10 -11
  14. package/src/lib/select/select.element.ts +7 -21
  15. package/src/lib/side-nav/side-nav-item.element.ts +86 -0
  16. package/src/lib/side-nav/side-nav.element.ts +25 -0
  17. package/src/lib/side-nav/side-nav.stories.ts +62 -0
  18. package/src/lib/side-nav/side-nav.test.ts +110 -0
  19. package/src/lib.ts +2 -0
  20. package/target/lib/accordion/accordion.element.d.ts +19 -0
  21. package/target/lib/accordion/accordion.element.js +172 -0
  22. package/target/lib/accordion/accordion.element.js.map +1 -0
  23. package/target/lib/accordion/accordion.stories.d.ts +12 -0
  24. package/target/lib/accordion/accordion.stories.js +42 -0
  25. package/target/lib/accordion/accordion.stories.js.map +1 -0
  26. package/target/lib/accordion/accordion.test.d.ts +1 -0
  27. package/target/lib/accordion/accordion.test.js +113 -0
  28. package/target/lib/accordion/accordion.test.js.map +1 -0
  29. package/target/lib/checkbox/checkbox.element.js +4 -1
  30. package/target/lib/checkbox/checkbox.element.js.map +1 -1
  31. package/target/lib/define.d.ts +4 -0
  32. package/target/lib/define.js +4 -0
  33. package/target/lib/define.js.map +1 -1
  34. package/target/lib/link/link.element.js +6 -2
  35. package/target/lib/link/link.element.js.map +1 -1
  36. package/target/lib/radio/radio-option.element.d.ts +5 -2
  37. package/target/lib/radio/radio-option.element.js +37 -15
  38. package/target/lib/radio/radio-option.element.js.map +1 -1
  39. package/target/lib/radio/radio.element.d.ts +2 -3
  40. package/target/lib/radio/radio.element.js +31 -36
  41. package/target/lib/radio/radio.element.js.map +1 -1
  42. package/target/lib/radio/radio.stories.d.ts +7 -2
  43. package/target/lib/radio/radio.stories.js +13 -7
  44. package/target/lib/radio/radio.stories.js.map +1 -1
  45. package/target/lib/select/select-option.element.d.ts +2 -1
  46. package/target/lib/select/select-option.element.js +8 -11
  47. package/target/lib/select/select-option.element.js.map +1 -1
  48. package/target/lib/select/select.element.d.ts +1 -3
  49. package/target/lib/select/select.element.js +10 -19
  50. package/target/lib/select/select.element.js.map +1 -1
  51. package/target/lib/side-nav/side-nav-item.element.d.ts +8 -0
  52. package/target/lib/side-nav/side-nav-item.element.js +109 -0
  53. package/target/lib/side-nav/side-nav-item.element.js.map +1 -0
  54. package/target/lib/side-nav/side-nav.element.d.ts +8 -0
  55. package/target/lib/side-nav/side-nav.element.js +36 -0
  56. package/target/lib/side-nav/side-nav.element.js.map +1 -0
  57. package/target/lib/side-nav/side-nav.stories.d.ts +12 -0
  58. package/target/lib/side-nav/side-nav.stories.js +55 -0
  59. package/target/lib/side-nav/side-nav.stories.js.map +1 -0
  60. package/target/lib/side-nav/side-nav.test.d.ts +2 -0
  61. package/target/lib/side-nav/side-nav.test.js +92 -0
  62. package/target/lib/side-nav/side-nav.test.js.map +1 -0
  63. package/target/lib.d.ts +2 -0
  64. package/target/lib.js +2 -0
  65. package/target/lib.js.map +1 -1
package/src/lib/define.ts CHANGED
@@ -3,6 +3,7 @@ import "./alert/alert.element.js";
3
3
  import "./button/button.element.js";
4
4
  import "./checkbox/checkbox.element.js";
5
5
  import "./description/description.element.js";
6
+ import "./file-input/file-input.element.js";
6
7
  import "./file-input/file-input-preview.element.js";
7
8
  import "./icon/icon.element.js";
8
9
  import "./input/input.element.js";
@@ -10,5 +11,8 @@ import "./input-mask/input-mask.element.js";
10
11
  import "./link/link.element.js";
11
12
  import "./radio/radio.element.js";
12
13
  import "./radio/radio-option.element.js";
14
+ import "./select/select.element.js";
13
15
  import "./select/select-option.element.js";
14
16
  import "./tag/tag.element.js";
17
+ import "./accordion/accordion.element.js";
18
+ import "./side-nav/side-nav.element.js";
@@ -11,13 +11,15 @@ declare global {
11
11
  shadowDom: [
12
12
  css`
13
13
  :host {
14
- display: inline;
14
+ display: inline-flex;
15
15
  color: #005ea2;
16
16
  text-decoration: underline;
17
17
  }
18
18
 
19
19
  a {
20
20
  color: inherit;
21
+ text-decoration: inherit;
22
+ display: inherit;
21
23
  }
22
24
  `,
23
25
  html`
@@ -37,7 +39,9 @@ export class USALinkElement extends HTMLElement {
37
39
  @attr()
38
40
  accessor title = "";
39
41
 
40
- @attr()
42
+ @attr({
43
+ observed: false,
44
+ })
41
45
  accessor disabled = false;
42
46
 
43
47
  #anchor = query("a");
@@ -1,10 +1,8 @@
1
1
  import { attr, css, element, html } from "@joist/element";
2
2
 
3
- import { USARadioElement } from "./radio.element.js";
4
-
5
3
  declare global {
6
4
  interface HTMLElementTagNameMap {
7
- "usa-radio-option": USARadioElement;
5
+ "usa-radio-option": USARadioOptionElement;
8
6
  }
9
7
  }
10
8
 
@@ -13,8 +11,9 @@ declare global {
13
11
  shadowDom: [
14
12
  css`
15
13
  :host {
16
- display: inline-flex;
14
+ display: flex;
17
15
  flex-direction: column;
16
+ margin-top: 0.05rem;
18
17
  }
19
18
  `,
20
19
  html`<slot></slot>`,
@@ -24,23 +23,42 @@ export class USARadioOptionElement extends HTMLElement {
24
23
  @attr()
25
24
  accessor value = "";
26
25
 
27
- #parent: USARadioElement | null = null;
26
+ @attr()
27
+ accessor name = "";
28
+
29
+ @attr()
30
+ accessor checked = false;
31
+
32
+ readonly radio = document.createElement("label");
33
+
34
+ readonly #input = document.createElement("input");
35
+ readonly #slotEl = document.createElement("slot");
36
+
37
+ constructor() {
38
+ super();
39
+
40
+ this.#input.type = "radio";
41
+
42
+ this.radio.append(this.#input, this.#slotEl);
43
+ }
28
44
 
29
45
  attributeChangedCallback() {
30
46
  this.slot = this.value;
47
+
48
+ this.#input.name = this.name;
49
+ this.#input.value = this.value;
50
+ this.#input.checked = this.checked;
51
+
52
+ this.#slotEl.name = this.value;
31
53
  }
32
54
 
33
55
  connectedCallback() {
34
- if (this.parentElement instanceof USARadioElement) {
35
- this.#parent = this.parentElement;
36
-
37
- this.parentElement.onOptionAdded(this);
38
- }
56
+ this.dispatchEvent(
57
+ new Event("usa::radio::option::added", { bubbles: true })
58
+ );
39
59
  }
40
60
 
41
61
  disconnectedCallback() {
42
- if (this.#parent) {
43
- this.#parent.onOptionRemoved(this);
44
- }
62
+ this.radio.remove();
45
63
  }
46
64
  }
@@ -1,6 +1,6 @@
1
- import { attr, css, element, html, listen, query } from "@joist/element";
1
+ import { attr, css, element, html, listen } from "@joist/element";
2
2
 
3
- import type { USARadioOptionElement } from "./radio-option.element.js";
3
+ import { USARadioOptionElement } from "./radio-option.element.js";
4
4
 
5
5
  declare global {
6
6
  interface HTMLElementTagNameMap {
@@ -13,13 +13,10 @@ declare global {
13
13
  shadowDom: [
14
14
  css`
15
15
  :host {
16
- display: block;
17
- }
18
-
19
- .radios {
20
16
  display: flex;
21
17
  flex-direction: column;
22
18
  gap: 1rem;
19
+ max-width: 30rem;
23
20
  }
24
21
 
25
22
  label {
@@ -43,6 +40,7 @@ declare global {
43
40
  width: 1.25rem;
44
41
  background: #fff;
45
42
  box-shadow: 0 0 0 2px #1b1b1b;
43
+ flex: 0 0 1.25rem;
46
44
  }
47
45
 
48
46
  label:has(input:checked)::before {
@@ -57,7 +55,7 @@ declare global {
57
55
  outline-offset: 0.25rem;
58
56
  }
59
57
 
60
- :host([tiled]) .radios {
58
+ :host([tiled]) {
61
59
  gap: 0.5rem;
62
60
  }
63
61
 
@@ -73,12 +71,16 @@ declare global {
73
71
  background-color: rgba(0, 94, 162, 0.1);
74
72
  border-color: #005ea2;
75
73
  }
76
- `,
77
- html`
78
- <slot></slot>
79
74
 
80
- <div class="radios"></div>
75
+ slot {
76
+ display: flex;
77
+ }
78
+
79
+ slot#main {
80
+ margin-bottom: 0.5rem;
81
+ }
81
82
  `,
83
+ html`<slot id="main"></slot>`,
82
84
  ],
83
85
  })
84
86
  export class USARadioElement extends HTMLElement {
@@ -90,10 +92,15 @@ export class USARadioElement extends HTMLElement {
90
92
  @attr()
91
93
  accessor name = "";
92
94
 
93
- @attr()
95
+ @attr({
96
+ observed: false,
97
+ })
94
98
  accessor tiled = false;
95
99
 
96
- #radios = query(".radios");
100
+ get shadow() {
101
+ return this.shadowRoot!;
102
+ }
103
+
97
104
  #internals = this.attachInternals();
98
105
 
99
106
  @listen("change")
@@ -113,40 +120,21 @@ export class USARadioElement extends HTMLElement {
113
120
  }
114
121
 
115
122
  attributeChangedCallback() {
116
- const radios = this.#radios();
117
-
118
- for (let radio of radios.querySelectorAll("input")) {
123
+ for (let radio of this.shadow.querySelectorAll("usa-radio-option")) {
119
124
  radio.checked = radio.value === this.value;
120
125
  radio.name = this.name;
121
126
  }
122
127
  }
123
128
 
124
- onOptionAdded(el: USARadioOptionElement) {
125
- const radios = this.#radios();
126
-
127
- const radioLabel = document.createElement("label");
128
- radioLabel.id = el.value;
129
-
130
- const input = document.createElement("input");
131
- input.type = "radio";
132
- input.name = this.name;
133
- input.value = el.value;
134
- input.checked = this.value === el.value;
135
-
136
- const slot = document.createElement("slot");
137
- slot.name = el.value;
138
-
139
- radioLabel.append(input, slot);
140
-
141
- radios.append(radioLabel);
142
- }
129
+ @listen("usa::radio::option::added", (el) => el)
130
+ onOptionAdded(e: Event) {
131
+ if (e.target instanceof USARadioOptionElement) {
132
+ e.stopPropagation();
143
133
 
144
- onOptionRemoved(el: USARadioOptionElement) {
145
- const radios = this.#radios();
146
- const option = radios.querySelector(`#${el.value}`);
134
+ e.target.checked = e.target.value === this.value;
135
+ e.target.name = this.name;
147
136
 
148
- if (option) {
149
- option.remove();
137
+ this.shadow.append(e.target.radio);
150
138
  }
151
139
  }
152
140
  }
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "@storybook/web-components";
2
2
  import { html } from "lit";
3
3
 
4
4
  import type { USARadioElement } from "./radio.element.js";
5
+ import { when } from "lit/directives/when.js";
5
6
 
6
7
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
8
  const meta = {
@@ -9,18 +10,23 @@ const meta = {
9
10
  tags: ["autodocs"],
10
11
  render(args) {
11
12
  return html`
12
- <usa-radio name="historical-figures" value="frederick-douglass" tiled>
13
+ <usa-radio
14
+ name="historical-figures"
15
+ value="frederick-douglass"
16
+ ?tiled=${args.tiled}
17
+ >
18
+ <legend>Select one historical figure</legend>
19
+
13
20
  <usa-radio-option value="sojourner-truth">
14
21
  Sojourner Truth
15
22
  </usa-radio-option>
16
23
 
17
24
  <usa-radio-option value="frederick-douglass">
18
25
  Frederick Douglass
19
-
20
- <usa-description>
21
- This is optional text that can be used to describe the label in more
22
- detail.
23
- </usa-description>
26
+ ${when(
27
+ args.description,
28
+ () => html`<usa-description>${args.description}</usa-description>`
29
+ )}
24
30
  </usa-radio-option>
25
31
 
26
32
  <usa-radio-option value="booker-t-washington">
@@ -34,8 +40,12 @@ const meta = {
34
40
  `;
35
41
  },
36
42
  argTypes: {},
37
- args: {},
38
- } satisfies Meta<USARadioElement>;
43
+ args: {
44
+ tiled: true,
45
+ description:
46
+ "This is optional text that can be used to describe the label in more detail.",
47
+ },
48
+ } satisfies Meta<USARadioElement & { description: string }>;
39
49
 
40
50
  export default meta;
41
51
 
@@ -1,7 +1,5 @@
1
1
  import { attr, css, element } from "@joist/element";
2
2
 
3
- import { USASelectElement } from "./select.element.js";
4
-
5
3
  declare global {
6
4
  interface HTMLElementTagNameMap {
7
5
  "usa-select-option": USASelecOptionElement;
@@ -22,19 +20,20 @@ export class USASelecOptionElement extends HTMLElement {
22
20
  @attr()
23
21
  accessor value = "";
24
22
 
25
- #parent: USASelectElement | null = null;
23
+ readonly option = document.createElement("option");
26
24
 
27
- connectedCallback() {
28
- if (this.parentElement instanceof USASelectElement) {
29
- this.#parent = this.parentElement;
25
+ attributeChangedCallback() {
26
+ this.option.textContent = this.textContent;
27
+ this.option.value = this.value;
28
+ }
30
29
 
31
- this.parentElement.onOptionAdded(this);
32
- }
30
+ connectedCallback() {
31
+ this.dispatchEvent(
32
+ new Event("usa::select::option::added", { bubbles: true })
33
+ );
33
34
  }
34
35
 
35
36
  disconnectedCallback() {
36
- if (this.#parent) {
37
- this.#parent.onOptionRemoved(this);
38
- }
37
+ this.option.remove();
39
38
  }
40
39
  }
@@ -1,6 +1,6 @@
1
1
  import { attr, css, element, html, listen, query } from "@joist/element";
2
2
 
3
- import type { USASelecOptionElement } from "./select-option.element.js";
3
+ import { USASelecOptionElement } from "./select-option.element.js";
4
4
 
5
5
  declare global {
6
6
  interface HTMLElementTagNameMap {
@@ -95,27 +95,13 @@ export class USASelectElement extends HTMLElement {
95
95
  this.#internals.setFormValue(select.value);
96
96
  }
97
97
 
98
- onOptionAdded(el: USASelecOptionElement) {
99
- const option = document.createElement("option");
100
- option.value = el.value;
101
- option.innerHTML = el.innerHTML;
102
- option.id = this.#createId(el.value);
98
+ @listen("usa::select::option::added")
99
+ onOptionAdded(e: Event) {
100
+ if (e.target instanceof USASelecOptionElement) {
101
+ e.stopPropagation();
103
102
 
104
- const select = this.#select();
105
-
106
- select.append(option);
107
- }
108
-
109
- onOptionRemoved(el: USASelecOptionElement) {
110
- const select = this.#select();
111
- const option = select.querySelector(`#${this.#createId(el.value)}`);
112
-
113
- if (option) {
114
- option.remove();
103
+ const select = this.#select();
104
+ select.append(e.target.option);
115
105
  }
116
106
  }
117
-
118
- #createId(val: string) {
119
- return val.split(" ").join("-").toLowerCase();
120
- }
121
107
  }
@@ -0,0 +1,86 @@
1
+ import { attr, css, element, html } from "@joist/element";
2
+
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ "usa-side-nav-item": USASideNavItemElement;
6
+ }
7
+ }
8
+
9
+ @element({
10
+ tagName: "usa-side-nav-item",
11
+ shadowDom: [
12
+ css`
13
+ :host {
14
+ --usa-nav-item-padding-left: 2rem;
15
+
16
+ display: block;
17
+ border-top: 1px solid #e6e6e6;
18
+ }
19
+
20
+ .side-nav-item {
21
+ display: flex;
22
+ padding: 0.5rem 1rem;
23
+ text-decoration: none;
24
+ position: relative;
25
+ }
26
+
27
+ .side-nav-item:hover {
28
+ background-color: #f0f0f0;
29
+ color: #005ea2;
30
+ }
31
+
32
+ ::slotted(*) {
33
+ color: #5c5c5c;
34
+ text-decoration: none;
35
+ display: block;
36
+ width: 100%;
37
+ }
38
+
39
+ :host(:hover) ::slotted(*) {
40
+ color: #005ea2;
41
+ }
42
+
43
+ :host([current]) ::slotted(*:not(usa-side-nav-item)) {
44
+ color: #005ea2;
45
+ font-weight: 700;
46
+ }
47
+
48
+ :host([current]) .side-nav-item::after {
49
+ background-color: #005ea2;
50
+ border-radius: 99rem;
51
+ content: "";
52
+ display: block;
53
+ position: absolute;
54
+ bottom: 0.25rem;
55
+ top: 0.25rem;
56
+ width: 0.25rem;
57
+ left: 0;
58
+ }
59
+
60
+ :host([slot="children"]) .side-nav-item {
61
+ padding-left: var(--usa-nav-item-padding-left);
62
+ }
63
+
64
+ :host([slot="children"]) ::slotted(usa-side-nav-item) {
65
+ --usa-nav-item-padding-left: 3rem;
66
+ }
67
+
68
+ :host([slot="children"]) .side-nav-item::after {
69
+ display: none;
70
+ }
71
+ `,
72
+ html`
73
+ <div class="side-nav-item">
74
+ <slot></slot>
75
+ </div>
76
+
77
+ <slot name="children"></slot>
78
+ `,
79
+ ],
80
+ })
81
+ export class USASideNavItemElement extends HTMLElement {
82
+ @attr({
83
+ observed: false,
84
+ })
85
+ accessor current = false;
86
+ }
@@ -0,0 +1,25 @@
1
+ import "./side-nav-item.element.js";
2
+
3
+ import { css, element, html } from "@joist/element";
4
+
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ "usa-side-nav": USASideNavElement;
8
+ }
9
+ }
10
+
11
+ @element({
12
+ tagName: "usa-side-nav",
13
+ shadowDom: [
14
+ css`
15
+ :host {
16
+ display: block;
17
+ font-size: 1.06rem;
18
+ line-height: 1.3;
19
+ border-bottom: 1px solid #e6e6e6;
20
+ }
21
+ `,
22
+ html`<slot></slot>`,
23
+ ],
24
+ })
25
+ export class USASideNavElement extends HTMLElement {}
@@ -0,0 +1,62 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components";
2
+ import { html } from "lit";
3
+
4
+ import type { USASideNavElement } from "./side-nav.element.js";
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
+ const meta = {
8
+ title: "usa-side-nav",
9
+ tags: ["autodocs"],
10
+ render(args) {
11
+ return html`
12
+ <usa-side-nav>
13
+ <usa-side-nav-item current>
14
+ <usa-link href="#">Current Page</usa-link>
15
+
16
+ <usa-side-nav-item slot="children">
17
+ <usa-link href="#">Child</usa-link>
18
+ </usa-side-nav-item>
19
+
20
+ <usa-side-nav-item slot="children" current>
21
+ <usa-link href="#">Child</usa-link>
22
+
23
+ <usa-side-nav-item slot="children">
24
+ <usa-link href="#">Grandchild</usa-link>
25
+ </usa-side-nav-item>
26
+
27
+ <usa-side-nav-item slot="children" current>
28
+ <usa-link href="#">Grandchild</usa-link>
29
+ </usa-side-nav-item>
30
+
31
+ <usa-side-nav-item slot="children">
32
+ <usa-link href="#">Grandchild</usa-link>
33
+ </usa-side-nav-item>
34
+ </usa-side-nav-item>
35
+
36
+ <usa-side-nav-item slot="children">
37
+ <usa-link href="#">Child</usa-link>
38
+ </usa-side-nav-item>
39
+ </usa-side-nav-item>
40
+
41
+ <usa-side-nav-item>
42
+ <usa-link href="#">Parent</usa-link>
43
+ </usa-side-nav-item>
44
+
45
+ <usa-side-nav-item>
46
+ <usa-link href="#">Parent</usa-link>
47
+ </usa-side-nav-item>
48
+ </usa-side-nav>
49
+ `;
50
+ },
51
+ argTypes: {},
52
+ args: {},
53
+ } satisfies Meta<USASideNavElement>;
54
+
55
+ export default meta;
56
+
57
+ type Story = StoryObj<USASideNavElement>;
58
+
59
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
60
+ export const Primary: Story = {
61
+ args: {},
62
+ };
@@ -0,0 +1,110 @@
1
+ import "../link/link.element.js";
2
+ import "./side-nav.element.js";
3
+
4
+ import { fixture, html, assert } from "@open-wc/testing";
5
+
6
+ import { USASideNavElement } from "./side-nav.element.js";
7
+
8
+ describe("usa-side-nav", () => {
9
+ it("should be accessible", async () => {
10
+ const sideNav = await fixture<USASideNavElement>(html`
11
+ <usa-side-nav>
12
+ <usa-side-nav-item current>
13
+ <usa-link href="#">Current Page</usa-link>
14
+
15
+ <usa-side-nav-item slot="children">
16
+ <usa-link href="#">Child</usa-link>
17
+ </usa-side-nav-item>
18
+
19
+ <usa-side-nav-item slot="children" current>
20
+ <usa-link href="#">Child</usa-link>
21
+
22
+ <usa-side-nav-item slot="children">
23
+ <usa-link href="#">Grandchild</usa-link>
24
+ </usa-side-nav-item>
25
+
26
+ <usa-side-nav-item slot="children" current>
27
+ <usa-link href="#">Grandchild</usa-link>
28
+ </usa-side-nav-item>
29
+
30
+ <usa-side-nav-item slot="children">
31
+ <usa-link href="#">Grandchild</usa-link>
32
+ </usa-side-nav-item>
33
+ </usa-side-nav-item>
34
+
35
+ <usa-side-nav-item slot="children">
36
+ <usa-link href="#">Child</usa-link>
37
+ </usa-side-nav-item>
38
+ </usa-side-nav-item>
39
+
40
+ <usa-side-nav-item>
41
+ <usa-link href="#">Parent</usa-link>
42
+ </usa-side-nav-item>
43
+
44
+ <usa-side-nav-item>
45
+ <usa-link href="#">Parent</usa-link>
46
+ </usa-side-nav-item>
47
+ </usa-side-nav>
48
+ `);
49
+
50
+ return assert.isAccessible(sideNav);
51
+ });
52
+
53
+ it("should set child padding correctly", async () => {
54
+ const sideNav = await fixture<USASideNavElement>(html`
55
+ <usa-side-nav>
56
+ <usa-side-nav-item current>
57
+ <usa-link href="#">Current Page</usa-link>
58
+
59
+ <usa-side-nav-item slot="children">
60
+ <usa-link href="#">Child</usa-link>
61
+ </usa-side-nav-item>
62
+
63
+ <usa-side-nav-item slot="children" current>
64
+ <usa-link href="#">Child</usa-link>
65
+
66
+ <usa-side-nav-item slot="children">
67
+ <usa-link href="#">Grandchild</usa-link>
68
+ </usa-side-nav-item>
69
+
70
+ <usa-side-nav-item slot="children" current>
71
+ <usa-link href="#">Grandchild</usa-link>
72
+ </usa-side-nav-item>
73
+
74
+ <usa-side-nav-item slot="children">
75
+ <usa-link href="#">Grandchild</usa-link>
76
+ </usa-side-nav-item>
77
+ </usa-side-nav-item>
78
+
79
+ <usa-side-nav-item slot="children">
80
+ <usa-link href="#">Child</usa-link>
81
+ </usa-side-nav-item>
82
+ </usa-side-nav-item>
83
+
84
+ <usa-side-nav-item>
85
+ <usa-link href="#">Parent</usa-link>
86
+ </usa-side-nav-item>
87
+
88
+ <usa-side-nav-item>
89
+ <usa-link href="#">Parent</usa-link>
90
+ </usa-side-nav-item>
91
+ </usa-side-nav>
92
+ `);
93
+
94
+ const items = sideNav.querySelectorAll("usa-side-nav-item");
95
+
96
+ assert.equal(
97
+ getComputedStyle(items[1]).getPropertyValue(
98
+ "--usa-nav-item-padding-left"
99
+ ),
100
+ "2rem"
101
+ );
102
+
103
+ assert.equal(
104
+ getComputedStyle(items[3]).getPropertyValue(
105
+ "--usa-nav-item-padding-left"
106
+ ),
107
+ "3rem"
108
+ );
109
+ });
110
+ });
package/src/lib.ts CHANGED
@@ -11,3 +11,5 @@ export { USARadioOptionElement } from "./lib/radio/radio-option.element.js";
11
11
  export { USASelectElement } from "./lib/select/select.element.js";
12
12
  export { USASelecOptionElement } from "./lib/select/select-option.element.js";
13
13
  export { USATagElement } from "./lib/tag/tag.element.js";
14
+ export { USAAccordionElement } from "./lib/accordion/accordion.element.js";
15
+ export { USASideNavElement } from "./lib/side-nav/side-nav.element.js";
@@ -0,0 +1,19 @@
1
+ declare global {
2
+ interface HTMLElementTagNameMap {
3
+ "usa-accordion": USAAccordionElement;
4
+ }
5
+ }
6
+ export declare class USAAccordionElement extends HTMLElement {
7
+ #private;
8
+ accessor name: string;
9
+ accessor open: boolean;
10
+ attributeChangedCallback(): void;
11
+ onClick(e: Event): void;
12
+ onAccordionToggle(e: USAAccordionToggleEvent): void;
13
+ }
14
+ declare class USAAccordionToggleEvent extends Event {
15
+ open: boolean;
16
+ get target(): USAAccordionElement;
17
+ constructor(open: boolean);
18
+ }
19
+ export {};