@noctuatech/uswds 0.2.1 → 1.0.0
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.
- package/README.md +5 -6
- package/package.json +1 -1
- package/src/GETTING_STARTED.mdx +77 -0
- package/src/lib/breadcrumbs/breadcrumb/breadcrumb.element.ts +59 -0
- package/src/lib/breadcrumbs/breadcrumbs.element.ts +42 -0
- package/src/lib/breadcrumbs/breadcrumbs.stories.ts +31 -0
- package/src/lib/breadcrumbs/breadcrumbs.test.ts +21 -0
- package/src/lib/button-group/button-group.element.ts +33 -0
- package/src/lib/button-group/button-group.stories.ts +29 -0
- package/src/lib/button-group/button-group.test.ts +15 -0
- package/src/lib/define.ts +6 -0
- package/src/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.ts +4 -0
- package/src/lib/in-page-nav/in-page-nav.element.ts +7 -4
- package/src/lib/in-page-nav/in-page-nav.stories.ts +12 -10
- package/src/lib/in-page-nav/in-page-nav.test.ts +27 -1
- package/src/lib/link/link.element.ts +2 -1
- package/src/lib/modal/modal.element.ts +5 -5
- package/src/lib/pagination/pagination-item/pagination-item.element.ts +35 -0
- package/src/lib/pagination/pagination-no/pagination-no.element.ts +59 -0
- package/src/lib/pagination/pagination.element.ts +31 -0
- package/src/lib/pagination/pagination.stories.ts +62 -0
- package/src/lib/pagination/pagination.test.ts +15 -0
- package/src/lib.ts +6 -0
- package/target/lib/breadcrumbs/breadcrumb/breadcrumb.element.d.ts +11 -0
- package/target/lib/breadcrumbs/breadcrumb/breadcrumb.element.js +48 -0
- package/target/lib/breadcrumbs/breadcrumb/breadcrumb.element.js.map +1 -0
- package/target/lib/breadcrumbs/breadcrumbs.element.d.ts +9 -0
- package/target/lib/breadcrumbs/breadcrumbs.element.js +48 -0
- package/target/lib/breadcrumbs/breadcrumbs.element.js.map +1 -0
- package/target/lib/breadcrumbs/breadcrumbs.stories.d.ts +12 -0
- package/target/lib/breadcrumbs/breadcrumbs.stories.js +17 -0
- package/target/lib/breadcrumbs/breadcrumbs.stories.js.map +1 -0
- package/target/lib/breadcrumbs/breadcrumbs.test.d.ts +2 -0
- package/target/lib/breadcrumbs/breadcrumbs.test.js +10 -0
- package/target/lib/breadcrumbs/breadcrumbs.test.js.map +1 -0
- package/target/lib/button-group/button-group.element.d.ts +7 -0
- package/target/lib/button-group/button-group.element.js +28 -0
- package/target/lib/button-group/button-group.element.js.map +1 -0
- package/target/lib/button-group/button-group.stories.d.ts +12 -0
- package/target/lib/button-group/button-group.stories.js +17 -0
- package/target/lib/button-group/button-group.stories.js.map +1 -0
- package/target/lib/button-group/button-group.test.d.ts +1 -0
- package/target/lib/button-group/button-group.test.js +9 -0
- package/target/lib/button-group/button-group.test.js.map +1 -0
- package/target/lib/define.d.ts +6 -0
- package/target/lib/define.js +6 -0
- package/target/lib/define.js.map +1 -1
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.js +1 -1
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.js.map +1 -1
- package/target/lib/in-page-nav/in-page-nav.element.d.ts +2 -0
- package/target/lib/in-page-nav/in-page-nav.element.js +12 -4
- package/target/lib/in-page-nav/in-page-nav.element.js.map +1 -1
- package/target/lib/in-page-nav/in-page-nav.stories.js +1 -1
- package/target/lib/in-page-nav/in-page-nav.stories.js.map +1 -1
- package/target/lib/in-page-nav/in-page-nav.test.d.ts +1 -0
- package/target/lib/in-page-nav/in-page-nav.test.js +2 -1
- package/target/lib/in-page-nav/in-page-nav.test.js.map +1 -1
- package/target/lib/link/link.element.js +1 -1
- package/target/lib/link/link.element.js.map +1 -1
- package/target/lib/modal/modal.element.d.ts +0 -1
- package/target/lib/modal/modal.element.js +6 -5
- package/target/lib/modal/modal.element.js.map +1 -1
- package/target/lib/pagination/pagination-item/pagination-item.element.d.ts +7 -0
- package/target/lib/pagination/pagination-item/pagination-item.element.js +28 -0
- package/target/lib/pagination/pagination-item/pagination-item.element.js.map +1 -0
- package/target/lib/pagination/pagination-no/pagination-no.element.d.ts +11 -0
- package/target/lib/pagination/pagination-no/pagination-no.element.js +48 -0
- package/target/lib/pagination/pagination-no/pagination-no.element.js.map +1 -0
- package/target/lib/pagination/pagination.element.d.ts +7 -0
- package/target/lib/pagination/pagination.element.js +28 -0
- package/target/lib/pagination/pagination.element.js.map +1 -0
- package/target/lib/pagination/pagination.stories.d.ts +12 -0
- package/target/lib/pagination/pagination.stories.js +17 -0
- package/target/lib/pagination/pagination.stories.js.map +1 -0
- package/target/lib/pagination/pagination.test.d.ts +1 -0
- package/target/lib/pagination/pagination.test.js +9 -0
- package/target/lib/pagination/pagination.test.js.map +1 -0
- package/target/lib.d.ts +6 -0
- package/target/lib.js +6 -0
- package/target/lib.js.map +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ npm run gen element
|
|
|
72
72
|
|
|
73
73
|
### Form Components
|
|
74
74
|
- [x] Button
|
|
75
|
-
- [
|
|
75
|
+
- [x] Button group
|
|
76
76
|
- [x] Checkbox
|
|
77
77
|
- [x] Combo box
|
|
78
78
|
- [ ] Date picker
|
|
@@ -90,10 +90,10 @@ npm run gen element
|
|
|
90
90
|
|
|
91
91
|
### Navigation Components
|
|
92
92
|
- [x] Accordion
|
|
93
|
-
- [
|
|
94
|
-
- [
|
|
93
|
+
- [x] Breadcrumb
|
|
94
|
+
- [x] In-page navigation
|
|
95
95
|
- [x] Link
|
|
96
|
-
- [
|
|
96
|
+
- [x] Pagination
|
|
97
97
|
- [x] Side navigation
|
|
98
98
|
- [x] Step indicator
|
|
99
99
|
|
|
@@ -105,10 +105,9 @@ npm run gen element
|
|
|
105
105
|
- [ ] Footer
|
|
106
106
|
- [ ] Header
|
|
107
107
|
- [x] Icon
|
|
108
|
-
- [ ] Identifier
|
|
109
108
|
- [ ] List
|
|
110
109
|
- [x] Modal
|
|
111
|
-
- [
|
|
110
|
+
- [x] Process list
|
|
112
111
|
- [ ] Prose
|
|
113
112
|
- [x] Site alert
|
|
114
113
|
- [x] Summary box
|
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
Getting started is easy! In just two simple steps, you'll be up and running with Noctua's US Web Design System, making it easy to build accessible, fast, and consistent websites. Let's get started!
|
|
4
|
+
|
|
5
|
+
## Install USWDS
|
|
6
|
+
|
|
7
|
+
Either install USWDS directly from NPM.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @noctuatech/uswds
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or from a CDN.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script type="module" src="https://esm.sh/@noctuatech/uswds/define.js?bundle"></script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Use components directly in your HTML
|
|
20
|
+
|
|
21
|
+
After installing USWDS, you can start using the components in your HTML.
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<!-- USWDS needs to be told where to find static assets such as icons -->
|
|
25
|
+
<usa-config icon-path="https://esm.sh/@noctuatech/uswds/assets/usa-icons/">
|
|
26
|
+
<form>
|
|
27
|
+
<usa-input name="name" placeholder="Bob Smith">Name</usa-input>
|
|
28
|
+
<usa-input name="email" placeholder="my@email.com">Email</usa-input>
|
|
29
|
+
|
|
30
|
+
<usa-input-mask mask="(999) 999-9999">
|
|
31
|
+
<usa-input name="phone" placeholder="(xxx) xxx-xxxx">
|
|
32
|
+
Phone
|
|
33
|
+
</usa-input>
|
|
34
|
+
</usa-input-mask>
|
|
35
|
+
|
|
36
|
+
<usa-button type="submit">Submit</usa-button>
|
|
37
|
+
</form>
|
|
38
|
+
</usa-config>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Configuration
|
|
42
|
+
|
|
43
|
+
There are two ways to confifure UWDS for your application. There is currently only one configuration option, but there will be more in the future.
|
|
44
|
+
|
|
45
|
+
1. The `usa-config` element is used to configure the USWDS components. This element will most comonly be at the root of your application.
|
|
46
|
+
But you can have multiple instances if you have different needs in different parts of your document. Configuration will be scoped to children of the `usa-config` element.
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<body>
|
|
50
|
+
<usa-config icon-path="https://esm.sh/@noctuatech/uswds/assets/usa-icons/">
|
|
51
|
+
<!-- Your application -->
|
|
52
|
+
</usa-config>
|
|
53
|
+
</body>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
2. JavaScript API. This version of USWDS is built with [Joist](https://github.com/joist-framework/joist), a dependency injection framework for JavaScript.
|
|
57
|
+
Knowing this we can provide our own configuration to USWDS components.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { DOMInjector } from "@joist/di";
|
|
61
|
+
import { USAConfig } from "@noctuatech/uswds";
|
|
62
|
+
|
|
63
|
+
const app = new DOMInjector([
|
|
64
|
+
[
|
|
65
|
+
USAConfig,
|
|
66
|
+
{
|
|
67
|
+
factory() {
|
|
68
|
+
return {
|
|
69
|
+
iconPath: "https://esm.sh/@noctuatech/uswds/assets/usa-icons/",
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
app.attach(document.body);
|
|
77
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { attr, css, element, html, query } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-breadcrumb": USABreadcrumbElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-breadcrumb",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
position: relative;
|
|
15
|
+
right: auto;
|
|
16
|
+
display: inline;
|
|
17
|
+
max-width: unset;
|
|
18
|
+
padding-right: 1.5rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:host(:last-child) usa-icon {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
a[href] {
|
|
26
|
+
color: #005ea2;
|
|
27
|
+
display: inline;
|
|
28
|
+
text-decoration: underline;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
usa-icon {
|
|
32
|
+
height: 1rem;
|
|
33
|
+
width: 1.5rem;
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: .075rem;
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
html`
|
|
39
|
+
<a>
|
|
40
|
+
<slot></slot>
|
|
41
|
+
</a>
|
|
42
|
+
|
|
43
|
+
<usa-icon icon="navigate_next"></usa-icon>
|
|
44
|
+
`,
|
|
45
|
+
],
|
|
46
|
+
})
|
|
47
|
+
export class USABreadcrumbElement extends HTMLElement {
|
|
48
|
+
@attr()
|
|
49
|
+
accessor href = "";
|
|
50
|
+
|
|
51
|
+
@attr()
|
|
52
|
+
accessor role = "listitem";
|
|
53
|
+
|
|
54
|
+
#a = query("a");
|
|
55
|
+
|
|
56
|
+
attributeChangedCallback() {
|
|
57
|
+
this.#a({ href: this.href });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { attr, css, element, html } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-breadcrumbs": USABreadcrumbsElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-breadcrumbs",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
text-overflow: ellipsis;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
margin-bottom: 0;
|
|
18
|
+
margin-top: 0;
|
|
19
|
+
list-style-type: none;
|
|
20
|
+
padding-left: 0;
|
|
21
|
+
display: block;
|
|
22
|
+
padding: .25rem;
|
|
23
|
+
margin-left: -.25rem;
|
|
24
|
+
margin-right: -.25rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([wrap]) {
|
|
28
|
+
white-space: normal;
|
|
29
|
+
}
|
|
30
|
+
`,
|
|
31
|
+
html`
|
|
32
|
+
<slot></slot>
|
|
33
|
+
`,
|
|
34
|
+
],
|
|
35
|
+
})
|
|
36
|
+
export class USABreadcrumbsElement extends HTMLElement {
|
|
37
|
+
@attr()
|
|
38
|
+
accessor role = "list";
|
|
39
|
+
|
|
40
|
+
@attr()
|
|
41
|
+
accessor wrap = false;
|
|
42
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/web-components";
|
|
2
|
+
import { html } from "lit";
|
|
3
|
+
|
|
4
|
+
import type { USABreadcrumbsElement } from "./breadcrumbs.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-breadcrumbs",
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
render() {
|
|
11
|
+
return html`
|
|
12
|
+
<usa-breadcrumbs>
|
|
13
|
+
<usa-breadcrumb href="/">Home</usa-breadcrumb>
|
|
14
|
+
<usa-breadcrumb href="/">Federal Contracting</usa-breadcrumb>
|
|
15
|
+
<usa-breadcrumb href="/">Contracting assistance programs</usa-breadcrumb>
|
|
16
|
+
<usa-breadcrumb>Economically disadvantaged women-owned small business federal contracting program</usa-breadcrumb>
|
|
17
|
+
</usa-breadcrumbs>
|
|
18
|
+
`;
|
|
19
|
+
},
|
|
20
|
+
argTypes: {},
|
|
21
|
+
args: {},
|
|
22
|
+
} satisfies Meta<USABreadcrumbsElement>;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<USABreadcrumbsElement>;
|
|
27
|
+
|
|
28
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
29
|
+
export const Primary: Story = {
|
|
30
|
+
args: {},
|
|
31
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./breadcrumbs.element.js";
|
|
2
|
+
import "./breadcrumb/breadcrumb.element.js";
|
|
3
|
+
|
|
4
|
+
import { assert, fixture, html } from "@open-wc/testing";
|
|
5
|
+
|
|
6
|
+
import type { USABreadcrumbsElement } from "./breadcrumbs.element.js";
|
|
7
|
+
|
|
8
|
+
describe("usa-breadcrumbs", () => {
|
|
9
|
+
it("should be accessible", async () => {
|
|
10
|
+
const breadcrumbs = await fixture<USABreadcrumbsElement>(html`
|
|
11
|
+
<usa-breadcrumbs>
|
|
12
|
+
<usa-breadcrumb href="/">Home</usa-breadcrumb>
|
|
13
|
+
<usa-breadcrumb href="/">Federal Contracting</usa-breadcrumb>
|
|
14
|
+
<usa-breadcrumb href="/">Contracting assistance programs</usa-breadcrumb>
|
|
15
|
+
<usa-breadcrumb>Economically disadvantaged women-owned small business federal contracting program</usa-breadcrumb>
|
|
16
|
+
</usa-breadcrumbs>
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
return assert.isAccessible(breadcrumbs);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { css, element, html } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-button-group": USAButtonGroupElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-button-group",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: 0.5rem;
|
|
16
|
+
margin-top: 0.25rem;
|
|
17
|
+
margin-bottom: 0.25rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@media (min-width: 30em) {
|
|
21
|
+
:host {
|
|
22
|
+
flex-wrap: nowrap;
|
|
23
|
+
align-items: stretch;
|
|
24
|
+
flex-direction: row;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
html`
|
|
29
|
+
<slot></slot>
|
|
30
|
+
`,
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
export class USAButtonGroupElement extends HTMLElement {}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/web-components";
|
|
2
|
+
import { html } from "lit";
|
|
3
|
+
|
|
4
|
+
import type { USAButtonGroupElement } from "./button-group.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-button-group",
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
render() {
|
|
11
|
+
return html`
|
|
12
|
+
<usa-button-group>
|
|
13
|
+
<usa-button variant="outline">Back</usa-button>
|
|
14
|
+
<usa-button variant="primary">Continue</usa-button>
|
|
15
|
+
</usa-button-group>
|
|
16
|
+
`;
|
|
17
|
+
},
|
|
18
|
+
argTypes: {},
|
|
19
|
+
args: {},
|
|
20
|
+
} satisfies Meta<USAButtonGroupElement>;
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj<USAButtonGroupElement>;
|
|
25
|
+
|
|
26
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
27
|
+
export const Primary: Story = {
|
|
28
|
+
args: {},
|
|
29
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./button-group.element.js";
|
|
2
|
+
|
|
3
|
+
import { assert, fixture, html } from "@open-wc/testing";
|
|
4
|
+
|
|
5
|
+
import type { USAButtonGroupElement } from "./button-group.element.js";
|
|
6
|
+
|
|
7
|
+
describe("usa-button-group", () => {
|
|
8
|
+
it("should be accessible", async () => {
|
|
9
|
+
const buttonGroup = await fixture<USAButtonGroupElement>(html`
|
|
10
|
+
<usa-button-group>Hello World</usa-button-group>
|
|
11
|
+
`);
|
|
12
|
+
|
|
13
|
+
return assert.isAccessible(buttonGroup);
|
|
14
|
+
});
|
|
15
|
+
});
|
package/src/lib/define.ts
CHANGED
|
@@ -41,3 +41,9 @@ import "./process-list/process-list.element.js";
|
|
|
41
41
|
import "./process-list/process-list-item/process-list-item.element.js";
|
|
42
42
|
import "./in-page-nav/in-page-nav.element.js";
|
|
43
43
|
import "./in-page-nav/in-page-nav-item/in-page-nav-item.element.js";
|
|
44
|
+
import "./button-group/button-group.element.js";
|
|
45
|
+
import "./breadcrumbs/breadcrumbs.element.js";
|
|
46
|
+
import "./breadcrumbs/breadcrumb/breadcrumb.element.js";
|
|
47
|
+
import "./pagination/pagination.element.js";
|
|
48
|
+
import "./pagination/pagination-item/pagination-item.element.js";
|
|
49
|
+
import "./pagination/pagination-no/pagination-no.element.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, element, html, queryAll } from "@joist/element";
|
|
1
|
+
import { attr, css, element, html, queryAll } from "@joist/element";
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
interface HTMLElementTagNameMap {
|
|
@@ -25,13 +25,16 @@ declare global {
|
|
|
25
25
|
],
|
|
26
26
|
})
|
|
27
27
|
export class USAInPageNavElement extends HTMLElement {
|
|
28
|
-
|
|
28
|
+
@attr()
|
|
29
|
+
accessor role = "list";
|
|
30
|
+
|
|
31
|
+
items = queryAll("usa-in-page-nav-item", this);
|
|
29
32
|
|
|
30
33
|
#observer = new IntersectionObserver(
|
|
31
34
|
(entries) => {
|
|
32
35
|
for (const entry of entries) {
|
|
33
36
|
if (entry.isIntersecting) {
|
|
34
|
-
for (const item of this
|
|
37
|
+
for (const item of this.items()) {
|
|
35
38
|
item.active = entry.target === item.targetElement;
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -43,7 +46,7 @@ export class USAInPageNavElement extends HTMLElement {
|
|
|
43
46
|
);
|
|
44
47
|
|
|
45
48
|
connectedCallback() {
|
|
46
|
-
const items = this
|
|
49
|
+
const items = this.items();
|
|
47
50
|
|
|
48
51
|
for (const item of items) {
|
|
49
52
|
if (item.targetElement) {
|
|
@@ -11,16 +11,18 @@ const meta = {
|
|
|
11
11
|
return html`
|
|
12
12
|
<div class="usa-in-page-nav-container">
|
|
13
13
|
<aside style="position: fixed; right: 1rem; top: 2rem;">
|
|
14
|
-
<
|
|
15
|
-
<usa-in-page-nav
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
<nav>
|
|
15
|
+
<usa-in-page-nav>
|
|
16
|
+
<usa-in-page-nav-item target="lorem-ipsum-dolor" primary>Lorem ipsum dolor</usa-in-page-nav-item>
|
|
17
|
+
<usa-in-page-nav-item target="consectetuer-adipiscing-elit" primary>Consectetuer adipiscing elit</usa-in-page-nav-item>
|
|
18
|
+
<usa-in-page-nav-item target="nullam-sit-amet-enim">Nullam sit amet enim</usa-in-page-nav-item>
|
|
19
|
+
<usa-in-page-nav-item target="vivamus-pharetra-posuere-sapien">Vivamus pharetra posuere sapien</usa-in-page-nav-item>
|
|
20
|
+
<usa-in-page-nav-item target="suspendisse-id-velit">Suspendisse id velit</usa-in-page-nav-item>
|
|
21
|
+
<usa-in-page-nav-item target="orci-magna-rhoncus-neque">Orci magna rhoncus neque</usa-in-page-nav-item>
|
|
22
|
+
<usa-in-page-nav-item target="aliquam-erat-volutpat-velit-vitae-ligula-volutpat" primary>Aliquam erat volutpat: velit vitae ligula volutpat</usa-in-page-nav-item>
|
|
23
|
+
<usa-in-page-nav-item target="vitae-ligula">Vitae ligula</usa-in-page-nav-item>
|
|
24
|
+
</usa-in-page-nav>
|
|
25
|
+
</nav>
|
|
24
26
|
</aside>
|
|
25
27
|
|
|
26
28
|
<main style="padding-right: 16rem; max-width: 68ex;">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./in-page-nav.element.js";
|
|
2
|
+
import "./in-page-nav-item/in-page-nav-item.element.js";
|
|
2
3
|
|
|
3
4
|
import { assert, fixture, html } from "@open-wc/testing";
|
|
4
5
|
|
|
@@ -7,7 +8,32 @@ import type { USAInPageNavElement } from "./in-page-nav.element.js";
|
|
|
7
8
|
describe("usa-in-page-nav", () => {
|
|
8
9
|
it("should be accessible", async () => {
|
|
9
10
|
const inPageNav = await fixture<USAInPageNavElement>(html`
|
|
10
|
-
<usa-in-page-nav>
|
|
11
|
+
<usa-in-page-nav>
|
|
12
|
+
<usa-in-page-nav-item target="lorem-ipsum-dolor" primary>
|
|
13
|
+
Lorem ipsum dolor
|
|
14
|
+
</usa-in-page-nav-item>
|
|
15
|
+
<usa-in-page-nav-item target="consectetuer-adipiscing-elit" primary>
|
|
16
|
+
Consectetuer adipiscing elit
|
|
17
|
+
</usa-in-page-nav-item>
|
|
18
|
+
<usa-in-page-nav-item target="nullam-sit-amet-enim">
|
|
19
|
+
Nullam sit amet enim
|
|
20
|
+
</usa-in-page-nav-item>
|
|
21
|
+
<usa-in-page-nav-item target="vivamus-pharetra-posuere-sapien">
|
|
22
|
+
Vivamus pharetra posuere sapien
|
|
23
|
+
</usa-in-page-nav-item>
|
|
24
|
+
<usa-in-page-nav-item target="suspendisse-id-velit">
|
|
25
|
+
Suspendisse id velit
|
|
26
|
+
</usa-in-page-nav-item>
|
|
27
|
+
<usa-in-page-nav-item target="orci-magna-rhoncus-neque">
|
|
28
|
+
Orci magna rhoncus neque
|
|
29
|
+
</usa-in-page-nav-item>
|
|
30
|
+
<usa-in-page-nav-item target="aliquam-erat-volutpat-velit-vitae-ligula-volutpat" primary>
|
|
31
|
+
Aliquam erat volutpat: velit vitae ligula volutpat
|
|
32
|
+
</usa-in-page-nav-item>
|
|
33
|
+
<usa-in-page-nav-item target="vitae-ligula">
|
|
34
|
+
Vitae ligula
|
|
35
|
+
</usa-in-page-nav-item>
|
|
36
|
+
</usa-in-page-nav>
|
|
11
37
|
`);
|
|
12
38
|
|
|
13
39
|
return assert.isAccessible(inPageNav);
|
|
@@ -11,7 +11,7 @@ declare global {
|
|
|
11
11
|
shadowDom: [
|
|
12
12
|
css`
|
|
13
13
|
:host {
|
|
14
|
-
display:
|
|
14
|
+
display: contents;
|
|
15
15
|
color: #005ea2;
|
|
16
16
|
text-decoration: underline;
|
|
17
17
|
}
|
|
@@ -20,6 +20,7 @@ declare global {
|
|
|
20
20
|
color: inherit;
|
|
21
21
|
text-decoration: inherit;
|
|
22
22
|
display: inherit;
|
|
23
|
+
text-overflow: inherit
|
|
23
24
|
}
|
|
24
25
|
`,
|
|
25
26
|
html`
|
|
@@ -45,8 +45,6 @@ declare global {
|
|
|
45
45
|
],
|
|
46
46
|
})
|
|
47
47
|
export class USAModalElement extends HTMLElement {
|
|
48
|
-
modalAction: null | string = null;
|
|
49
|
-
|
|
50
48
|
#dialog = query("dialog");
|
|
51
49
|
|
|
52
50
|
openModal() {
|
|
@@ -75,11 +73,13 @@ export class USAModalElement extends HTMLElement {
|
|
|
75
73
|
@listen("click", (host) => host)
|
|
76
74
|
onModalAction(e: Event) {
|
|
77
75
|
if (e.target instanceof Element) {
|
|
78
|
-
|
|
76
|
+
const modalAction = e.target.getAttribute("modal-action");
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
if (modalAction === "close") {
|
|
79
|
+
this.closeModal();
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
this.dispatchEvent(new Event("usa::modal::close"));
|
|
82
|
+
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { css, element, html } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-pagination-item": USAPaginationItemElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-pagination-item",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
height: 2.5rem;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
line-height: 1;
|
|
18
|
+
min-width: 2.5rem;
|
|
19
|
+
align-items: center;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host(:first-child) {
|
|
23
|
+
margin-right: 1rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host(:last-child) {
|
|
27
|
+
margin-left: 1rem;
|
|
28
|
+
}
|
|
29
|
+
`,
|
|
30
|
+
html`
|
|
31
|
+
<slot></slot>
|
|
32
|
+
`,
|
|
33
|
+
],
|
|
34
|
+
})
|
|
35
|
+
export class USAPaginationItemElement extends HTMLElement {}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { attr, css, element, html, query } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-pagination-no": USAPaginationNoElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-pagination-no",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
align-items: center;
|
|
15
|
+
border-color: rgba(27, 27, 27, .2);
|
|
16
|
+
border-radius: .25rem;
|
|
17
|
+
border-style: solid;
|
|
18
|
+
border-width: 1px;
|
|
19
|
+
color: #005ea2;
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
a {
|
|
26
|
+
display: inline-flex;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
text-decoration: underline;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
padding: .5rem;
|
|
31
|
+
color: inherit;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([active]) {
|
|
35
|
+
background-color: #1b1b1b;
|
|
36
|
+
border-color: transparent;
|
|
37
|
+
color: #fff;
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
html`
|
|
41
|
+
<a>
|
|
42
|
+
<slot></slot>
|
|
43
|
+
</a>
|
|
44
|
+
`,
|
|
45
|
+
],
|
|
46
|
+
})
|
|
47
|
+
export class USAPaginationNoElement extends HTMLElement {
|
|
48
|
+
@attr()
|
|
49
|
+
accessor href = "#";
|
|
50
|
+
|
|
51
|
+
@attr()
|
|
52
|
+
accessor active = false;
|
|
53
|
+
|
|
54
|
+
#a = query("a");
|
|
55
|
+
|
|
56
|
+
attributeChangedCallback() {
|
|
57
|
+
this.#a({ href: this.href });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { css, element, html } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-pagination": USAPaginationElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-pagination",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
margin-top: 0;
|
|
16
|
+
list-style-type: none;
|
|
17
|
+
padding-left: 0;
|
|
18
|
+
align-items: center;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-flow: row nowrap;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
width: auto;
|
|
23
|
+
gap: .5rem;
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
html`
|
|
27
|
+
<slot></slot>
|
|
28
|
+
`,
|
|
29
|
+
],
|
|
30
|
+
})
|
|
31
|
+
export class USAPaginationElement extends HTMLElement {}
|