@stackoverflow/stacks 2.0.0-rc.1 → 2.0.0-rc.11
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 -0
- package/dist/components/code-block/code-block.fixtures.d.ts +2 -0
- package/dist/css/stacks.css +816 -778
- package/dist/css/stacks.min.css +1 -1
- package/dist/js/stacks.js +265 -110
- package/dist/js/stacks.min.js +1 -1
- package/lib/atomic/__snapshots__/color.less.test.ts.snap +246 -0
- package/lib/atomic/typography.less +4 -0
- package/lib/base/body.less +2 -2
- package/lib/components/activity-indicator/activity-indicator.a11y.test.ts +1 -1
- package/lib/components/activity-indicator/activity-indicator.less +17 -4
- package/lib/components/anchor/anchor.less +10 -6
- package/lib/components/anchor/anchor.visual.test.ts +0 -4
- package/lib/components/avatar/avatar.visual.test.ts +0 -3
- package/lib/components/badge/badge.a11y.test.ts +2 -2
- package/lib/components/badge/badge.less +31 -39
- package/lib/components/banner/banner.less +2 -2
- package/lib/components/block-link/block-link.less +5 -4
- package/lib/components/button/button.a11y.test.ts +1 -4
- package/lib/components/button/button.less +48 -78
- package/lib/components/button/button.visual.test.ts +1 -4
- package/lib/components/card/card.less +8 -0
- package/lib/components/code-block/code-block.a11y.test.ts +30 -0
- package/lib/components/code-block/code-block.fixtures.ts +88 -0
- package/lib/components/code-block/code-block.visual.test.ts +20 -0
- package/lib/components/description/description.a11y.test.ts +1 -0
- package/lib/components/description/description.less +1 -1
- package/lib/components/expandable/expandable.a11y.test.ts +27 -0
- package/lib/components/expandable/expandable.visual.test.ts +27 -0
- package/lib/components/input-icon/input-icon.less +1 -1
- package/lib/components/input-message/input-message.less +4 -3
- package/lib/components/input_textarea/input_textarea.a11y.test.ts +112 -0
- package/lib/components/input_textarea/input_textarea.less +1 -1
- package/lib/components/input_textarea/input_textarea.visual.test.ts +98 -0
- package/lib/components/label/label.less +4 -14
- package/lib/components/link/link.less +12 -12
- package/lib/components/link-preview/link-preview.a11y.test.ts +48 -0
- package/lib/components/link-preview/link-preview.less +16 -7
- package/lib/components/link-preview/link-preview.visual.test.ts +52 -0
- package/lib/components/modal/modal.less +1 -0
- package/lib/components/navigation/navigation.a11y.test.ts +78 -0
- package/lib/components/navigation/navigation.visual.test.ts +101 -0
- package/lib/components/notice/notice.a11y.test.ts +17 -0
- package/lib/components/notice/notice.less +45 -82
- package/lib/components/notice/notice.visual.test.ts +26 -0
- package/lib/components/page-title/page-title.a11y.test.ts +29 -0
- package/lib/components/page-title/page-title.less +1 -1
- package/lib/components/page-title/page-title.visual.test.ts +59 -0
- package/lib/components/pagination/pagination.a11y.test.ts +20 -0
- package/lib/components/pagination/pagination.less +2 -2
- package/lib/components/pagination/pagination.visual.test.ts +26 -0
- package/lib/components/post-summary/post-summary.less +16 -16
- package/lib/components/progress-bar/progress-bar.less +2 -2
- package/lib/components/prose/prose.less +2 -2
- package/lib/components/select/select.less +1 -1
- package/lib/components/sidebar-widget/sidebar-widget.less +3 -3
- package/lib/components/spinner/spinner.a11y.test.ts +15 -0
- package/lib/components/spinner/spinner.visual.test.ts +43 -0
- package/lib/components/tag/tag.a11y.test.ts +29 -0
- package/lib/components/tag/tag.less +29 -29
- package/lib/components/tag/tag.visual.test.ts +46 -0
- package/lib/components/toast/toast.a11y.test.ts +30 -0
- package/lib/components/toast/toast.visual.test.ts +10 -6
- package/lib/components/toggle-switch/toggle-switch.less +2 -5
- package/lib/components/topbar/topbar.less +60 -44
- package/lib/components/uploader/uploader.less +19 -13
- package/lib/components/user-card/user-card.less +3 -3
- package/lib/exports/__snapshots__/color-mixins.less.test.ts.snap +17 -10
- package/lib/exports/__snapshots__/color.less.test.ts.snap +197 -185
- package/lib/exports/color-mixins.less +1 -1
- package/lib/exports/color-sets.less +130 -81
- package/lib/exports/color.less +14 -6
- package/lib/exports/v1/__snapshots__/constants-colors.less.test.ts.snap +3 -3
- package/lib/exports/v1/constants-colors.less +2 -2
- package/lib/input-utils.less +1 -1
- package/lib/test/axe-apca/README.md +19 -0
- package/lib/test/axe-apca/src/axe-apca.test.ts +77 -1
- package/lib/test/axe-apca/src/axe-apca.ts +16 -8
- package/lib/test/test-utils.ts +8 -6
- package/package.json +14 -14
- package/lib/exports/theme.less +0 -85
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { html } from "@open-wc/testing";
|
|
2
|
+
import { runComponentTests } from "../../test/test-utils";
|
|
3
|
+
import "../../index";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
const template = ({ component, testid, classes = "", icon }: any) => html`
|
|
7
|
+
<div data-testid="${testid}" class="p8 ws4 ${classes}">
|
|
8
|
+
${component}${icon}
|
|
9
|
+
</div>
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const customAttributes = [
|
|
13
|
+
{
|
|
14
|
+
placeholder: "Enter your text here",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
readonly: "",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
disabled: "",
|
|
21
|
+
},
|
|
22
|
+
] as Record<string, string>[];
|
|
23
|
+
|
|
24
|
+
const states = ["has-error", "has-warning", "has-success", "is-readonly"];
|
|
25
|
+
const sizes = ["sm", "md", "lg", "xl"];
|
|
26
|
+
const otherModifiers = ["creditcard", "search"];
|
|
27
|
+
|
|
28
|
+
["input", "textarea"].map((type) => {
|
|
29
|
+
const children =
|
|
30
|
+
type === "textarea" ? { default: "Enter your text here" } : undefined;
|
|
31
|
+
|
|
32
|
+
describe(type, () => {
|
|
33
|
+
// Base styles w/ value, modifiers
|
|
34
|
+
runComponentTests({
|
|
35
|
+
type: "visual",
|
|
36
|
+
baseClass: `s-${type}`,
|
|
37
|
+
modifiers: {
|
|
38
|
+
primary: [...sizes, ...otherModifiers],
|
|
39
|
+
},
|
|
40
|
+
tag: type,
|
|
41
|
+
attributes:
|
|
42
|
+
type === "input"
|
|
43
|
+
? {
|
|
44
|
+
type: "text",
|
|
45
|
+
value: "Text input value",
|
|
46
|
+
}
|
|
47
|
+
: {},
|
|
48
|
+
children,
|
|
49
|
+
template,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Base styles w/o value; w/ readonly attr; w/ disabled attr
|
|
53
|
+
customAttributes.forEach((attributes) => {
|
|
54
|
+
const attrString = Object.keys(attributes).sort().join("-");
|
|
55
|
+
let attr = attributes;
|
|
56
|
+
if (type === "input") {
|
|
57
|
+
attr = {
|
|
58
|
+
type: "text",
|
|
59
|
+
...attributes,
|
|
60
|
+
};
|
|
61
|
+
if (!attributes.placeholder) {
|
|
62
|
+
attr = {
|
|
63
|
+
value: "Text input value",
|
|
64
|
+
...attr,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
runComponentTests({
|
|
69
|
+
type: "visual",
|
|
70
|
+
baseClass: `s-${type} ${attrString}`,
|
|
71
|
+
tag: type,
|
|
72
|
+
attributes: attr,
|
|
73
|
+
children,
|
|
74
|
+
template,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// w/ state classes; .is-readonly
|
|
79
|
+
states.forEach((state) => {
|
|
80
|
+
runComponentTests({
|
|
81
|
+
type: "visual",
|
|
82
|
+
baseClass: `s-${type} state-${state}`,
|
|
83
|
+
tag: type,
|
|
84
|
+
attributes:
|
|
85
|
+
type === "input"
|
|
86
|
+
? {
|
|
87
|
+
type: "text",
|
|
88
|
+
value: "Text input value",
|
|
89
|
+
}
|
|
90
|
+
: {},
|
|
91
|
+
children,
|
|
92
|
+
template: ({ component, testid }) =>
|
|
93
|
+
template({ component, testid, classes: state }),
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
// TODO interaction (focus) states?
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -53,28 +53,18 @@
|
|
|
53
53
|
|
|
54
54
|
// TODO: include child component class (without variant) on selector
|
|
55
55
|
&__beta {
|
|
56
|
-
--_la-status-bg: var(--blue-
|
|
56
|
+
--_la-status-bg: var(--blue-200);
|
|
57
57
|
--_la-status-fc: var(--blue-500);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
&__new {
|
|
61
|
-
--_la-status-bg: var(--green-
|
|
61
|
+
--_la-status-bg: var(--green-200);
|
|
62
62
|
--_la-status-fc: var(--green-500);
|
|
63
|
-
|
|
64
|
-
.dark-mode({
|
|
65
|
-
--_la-status-bg: var(--green-200);
|
|
66
|
-
--_la-status-fc: var(--green-600);
|
|
67
|
-
});
|
|
68
63
|
}
|
|
69
64
|
|
|
70
65
|
&__required {
|
|
71
|
-
--_la-status-bg: var(--red-
|
|
66
|
+
--_la-status-bg: var(--red-200);
|
|
72
67
|
--_la-status-fc: var(--red-500);
|
|
73
|
-
|
|
74
|
-
.dark-mode({
|
|
75
|
-
--_la-status-bg: var(--red-200);
|
|
76
|
-
--_la-status-fc: var(--red-600);
|
|
77
|
-
});
|
|
78
68
|
}
|
|
79
69
|
|
|
80
70
|
background-color: var(--_la-status-bg);
|
|
@@ -99,7 +89,7 @@
|
|
|
99
89
|
|
|
100
90
|
font-size: var(--_la-fs);
|
|
101
91
|
|
|
102
|
-
color: var(--fc-
|
|
92
|
+
color: var(--fc-medium);
|
|
103
93
|
font-family: inherit;
|
|
104
94
|
font-weight: 600;
|
|
105
95
|
padding: 0 var(--su2); // Helps the label visually line up with inputs
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// it's tech debt that'll take some doing in consumer's code to pay down.
|
|
3
3
|
a,
|
|
4
4
|
.s-link {
|
|
5
|
-
--_li-fc: var(--theme-link-color);
|
|
6
|
-
--_li-fc-hover: var(--theme-link-color-hover);
|
|
7
|
-
--_li-fc-visited: var(--theme-link-color-visited);
|
|
5
|
+
--_li-fc: var(--theme-link-color, var(--theme-secondary-400));
|
|
6
|
+
--_li-fc-hover: var(--theme-link-color-hover, var(--theme-secondary-500));
|
|
7
|
+
--_li-fc-visited: var(--theme-link-color-visited, var(--theme-secondary-600));
|
|
8
8
|
|
|
9
9
|
// CONTEXTUAL STYLES
|
|
10
10
|
.highcontrast-mode({
|
|
@@ -53,22 +53,22 @@ a,
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
&__visited { // TODO can we get rid of this? It's only in 3 places in Core and seems to me it doesn't even serve a purpose.
|
|
56
|
-
--_li-fc: var(--theme-link-color-visited);
|
|
57
|
-
--_li-fc-hover: var(--theme-link-color-hover);
|
|
58
|
-
--_li-fc-visited: var(--theme-link-color-visited);
|
|
56
|
+
--_li-fc: var(--theme-link-color-visited, var(--theme-secondary-500));
|
|
57
|
+
--_li-fc-hover: var(--theme-link-color-hover, var(--theme-secondary-400));
|
|
58
|
+
--_li-fc-visited: var(--theme-link-color-visited, var(--theme-secondary-500));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// VARIANTS
|
|
62
62
|
&__danger {
|
|
63
63
|
--_li-fc: var(--red-400);
|
|
64
|
-
--_li-fc-hover: var(--red-
|
|
65
|
-
--_li-fc-visited: var(--red-
|
|
64
|
+
--_li-fc-hover: var(--red-500);
|
|
65
|
+
--_li-fc-visited: var(--red-600);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
&__grayscale {
|
|
69
|
-
--_li-fc: var(--black-
|
|
70
|
-
--_li-fc-hover: var(--black-
|
|
71
|
-
--_li-fc-visited: var(--black-
|
|
69
|
+
--_li-fc: var(--black-500);
|
|
70
|
+
--_li-fc-hover: var(--black-400);
|
|
71
|
+
--_li-fc-visited: var(--black-600);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
&__inherit {
|
|
@@ -80,7 +80,7 @@ a,
|
|
|
80
80
|
&__muted {
|
|
81
81
|
--_li-fc: var(--black-400);
|
|
82
82
|
--_li-fc-hover: var(--black-500);
|
|
83
|
-
--_li-fc-visited: var(--black-
|
|
83
|
+
--_li-fc-visited: var(--black-600);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { runComponentTests } from "../../test/test-utils";
|
|
2
|
+
import "../../index";
|
|
3
|
+
|
|
4
|
+
const getChild = (child?: string): string => {
|
|
5
|
+
return `
|
|
6
|
+
<div class="s-link-preview--header">
|
|
7
|
+
<div class="s-link-preview--icon">👋</div>
|
|
8
|
+
<div>
|
|
9
|
+
<a href="#" class="s-link-preview--title">
|
|
10
|
+
Using hooks for a simple fetch request and breaking the rules of hooks, unsure how?
|
|
11
|
+
</a>
|
|
12
|
+
<div class="s-link-preview--details">
|
|
13
|
+
Issue submitted by Ricky Otero on <relative-time datetime="2019-08-12T04:05:22Z" title="Aug 12, 2019, 12:05 AM EDT">Aug 12, 2019</relative-time> • <strong>RESOLVED</strong>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
${
|
|
18
|
+
child
|
|
19
|
+
? child
|
|
20
|
+
: `
|
|
21
|
+
<div class="s-link-preview--body">
|
|
22
|
+
<p>I'm trying to create a simple fetch with hooks from an AWS database. At the moment it errors out and the only reason I can see is because it breaks the rules of hooks but I'm not sure how. It's at the top level of this functional component and it's not called inside an event handler.</p>
|
|
23
|
+
<p>The result of this call (an array of user data), needs to be exported as a function and called in another file.</p>
|
|
24
|
+
<p>If anyone can spot something I have missed and can highlighted how I'm breaking the rules of hooks I'd be grateful!</p>
|
|
25
|
+
<p>Thanks!</p>
|
|
26
|
+
</div>
|
|
27
|
+
`
|
|
28
|
+
}
|
|
29
|
+
<div class="s-link-preview--footer">
|
|
30
|
+
<a href="#" class="s-link-preview--url">https://stackoverflow.atlassian.net/projects/SREREQ/queues/custom/1</a>
|
|
31
|
+
<a href="#" class="s-link-preview--misc">Privacy notice</a>
|
|
32
|
+
</div>
|
|
33
|
+
`;
|
|
34
|
+
};
|
|
35
|
+
describe("link preview", () => {
|
|
36
|
+
runComponentTests({
|
|
37
|
+
type: "a11y",
|
|
38
|
+
baseClass: "s-link-preview",
|
|
39
|
+
children: {
|
|
40
|
+
default: getChild(),
|
|
41
|
+
code: getChild(`
|
|
42
|
+
<div class="s-link-preview--code">
|
|
43
|
+
<pre class="language-js s-code-block" tabindex="0"><code class="language-js s-code-block"><span class="hljs-meta">'use strict'</span>;</code></pre>
|
|
44
|
+
</div>
|
|
45
|
+
`),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
.s-link-preview {
|
|
2
|
+
--_lp-details-fc: var(--black-400);
|
|
2
3
|
--_lp-details-mt: var(--su2);
|
|
4
|
+
--_lp-footer-bg: var(--black-100);
|
|
3
5
|
--_lp-footer-fd: unset;
|
|
6
|
+
--_lp-header-bg: var(--black-100);
|
|
4
7
|
--_lp-misc-pl: var(--su4);
|
|
5
8
|
--_lp-misc-pt: unset;
|
|
6
9
|
|
|
@@ -12,6 +15,12 @@
|
|
|
12
15
|
--_lp-misc-pt: var(--su2);
|
|
13
16
|
});
|
|
14
17
|
|
|
18
|
+
.highcontrast-mode({
|
|
19
|
+
--_lp-details-fc: var(--black-600);
|
|
20
|
+
--_lp-footer-bg: var(--black-050);
|
|
21
|
+
--_lp-header-bg: var(--black-050);
|
|
22
|
+
});
|
|
23
|
+
|
|
15
24
|
// CHILD ELEMENTS
|
|
16
25
|
& &--details,
|
|
17
26
|
& &--footer {
|
|
@@ -25,7 +34,7 @@
|
|
|
25
34
|
color: var(--black-500);
|
|
26
35
|
}
|
|
27
36
|
|
|
28
|
-
color: var(--black-
|
|
37
|
+
color: var(--black-600);
|
|
29
38
|
cursor: pointer;
|
|
30
39
|
text-decoration: none;
|
|
31
40
|
}
|
|
@@ -49,16 +58,16 @@
|
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
& &--details {
|
|
61
|
+
color: var(--_lp-details-fc);
|
|
52
62
|
margin-top: var(--_lp-details-mt);
|
|
53
63
|
|
|
54
|
-
color: var(--black-400);
|
|
55
64
|
font-size: var(--fs-caption);
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
& &--footer {
|
|
68
|
+
background: var(--_lp-footer-bg);
|
|
59
69
|
flex-direction: var(--_lp-footer-fd);
|
|
60
70
|
|
|
61
|
-
background: var(--black-100);
|
|
62
71
|
border-bottom-left-radius: var(--br-sm);
|
|
63
72
|
border-bottom-right-radius: var(--br-sm);
|
|
64
73
|
border-top: var(--su-static1) solid var(--bc-medium);
|
|
@@ -69,7 +78,7 @@
|
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
& &--header {
|
|
72
|
-
background: var(--
|
|
81
|
+
background: var(--_lp-header-bg);
|
|
73
82
|
border-bottom: var(--su-static1) solid var(--bc-medium);
|
|
74
83
|
border-top-left-radius: var(--br-sm);
|
|
75
84
|
border-top-right-radius: var(--br-sm);
|
|
@@ -100,7 +109,7 @@
|
|
|
100
109
|
&:hover{
|
|
101
110
|
&,
|
|
102
111
|
&.s-link__visited {
|
|
103
|
-
color: var(--theme-link-color-hover);
|
|
112
|
+
color: var(--theme-link-color-hover, var(--theme-secondary-500));
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
|
|
@@ -117,10 +126,10 @@
|
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
&.s-link__visited:visited {
|
|
120
|
-
color: var(--theme-link-color);
|
|
129
|
+
color: var(--theme-link-color, var(--theme-secondary-600));
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
color: var(--theme-link-color);
|
|
132
|
+
color: var(--theme-link-color, var(--theme-secondary-400));
|
|
124
133
|
cursor: pointer;
|
|
125
134
|
text-decoration: none;
|
|
126
135
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { html } from "@open-wc/testing";
|
|
2
|
+
import { runComponentTests } from "../../test/test-utils";
|
|
3
|
+
import "../../index";
|
|
4
|
+
|
|
5
|
+
const getChild = (child?: string): string => {
|
|
6
|
+
return `
|
|
7
|
+
<div class="s-link-preview--header">
|
|
8
|
+
<div class="s-link-preview--icon">👋</div>
|
|
9
|
+
<div>
|
|
10
|
+
<a href="#" class="s-link-preview--title">
|
|
11
|
+
Using hooks for a simple fetch request and breaking the rules of hooks, unsure how?
|
|
12
|
+
</a>
|
|
13
|
+
<div class="s-link-preview--details">
|
|
14
|
+
Issue submitted by Ricky Otero on <relative-time datetime="2019-08-12T04:05:22Z" title="Aug 12, 2019, 12:05 AM EDT">Aug 12, 2019</relative-time> • <strong>RESOLVED</strong>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
${
|
|
19
|
+
child
|
|
20
|
+
? child
|
|
21
|
+
: `
|
|
22
|
+
<div class="s-link-preview--body">
|
|
23
|
+
<p>I'm trying to create a simple fetch with hooks from an AWS database. At the moment it errors out and the only reason I can see is because it breaks the rules of hooks but I'm not sure how. It's at the top level of this functional component and it's not called inside an event handler.</p>
|
|
24
|
+
<p>The result of this call (an array of user data), needs to be exported as a function and called in another file.</p>
|
|
25
|
+
<p>If anyone can spot something I have missed and can highlighted how I'm breaking the rules of hooks I'd be grateful!</p>
|
|
26
|
+
<p>Thanks!</p>
|
|
27
|
+
</div>
|
|
28
|
+
`
|
|
29
|
+
}
|
|
30
|
+
<div class="s-link-preview--footer">
|
|
31
|
+
<a href="#" class="s-link-preview--url">https://stackoverflow.atlassian.net/projects/SREREQ/queues/custom/1</a>
|
|
32
|
+
<a href="#" class="s-link-preview--misc">Privacy notice</a>
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
};
|
|
36
|
+
describe("link preview", () => {
|
|
37
|
+
runComponentTests({
|
|
38
|
+
type: "visual",
|
|
39
|
+
baseClass: "s-link-preview",
|
|
40
|
+
children: {
|
|
41
|
+
default: getChild(),
|
|
42
|
+
code: getChild(`
|
|
43
|
+
<div class="s-link-preview--code">
|
|
44
|
+
<pre class="language-js s-code-block" tabindex="0"><code class="language-js s-code-block"><span class="hljs-meta">'use strict'</span>;</code></pre>
|
|
45
|
+
</div>
|
|
46
|
+
`),
|
|
47
|
+
},
|
|
48
|
+
template: ({ component, testid }) => html`
|
|
49
|
+
<div class="ws8 p8" data-testid="${testid}">${component}</div>
|
|
50
|
+
`,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { html } from "@open-wc/testing";
|
|
2
|
+
import { runComponentTests } from "../../test/test-utils";
|
|
3
|
+
import "../../index";
|
|
4
|
+
|
|
5
|
+
const items = [
|
|
6
|
+
{
|
|
7
|
+
label: "Group 1",
|
|
8
|
+
title: true,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: "Product",
|
|
12
|
+
selected: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Email",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: "Group 2",
|
|
19
|
+
title: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Content",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Brand",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "Marketing",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "More selected",
|
|
32
|
+
dropdown: true,
|
|
33
|
+
selected: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "More",
|
|
37
|
+
dropdown: true,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const getChildren = (includeTitles = false): string =>
|
|
42
|
+
items
|
|
43
|
+
.map((item) => {
|
|
44
|
+
if (item.title) {
|
|
45
|
+
return includeTitles
|
|
46
|
+
? `<li class="s-navigation--title">${item.label}</li>`
|
|
47
|
+
: "";
|
|
48
|
+
}
|
|
49
|
+
const classes = `s-navigation--item${
|
|
50
|
+
item.selected ? " is-selected" : ""
|
|
51
|
+
}${item.dropdown ? " s-navigation--item__dropdown" : ""}`;
|
|
52
|
+
return `<li><a href="#" class="${classes}">${item.label}</a></li>`;
|
|
53
|
+
})
|
|
54
|
+
.join("");
|
|
55
|
+
|
|
56
|
+
describe("navigation", () => {
|
|
57
|
+
runComponentTests({
|
|
58
|
+
type: "a11y",
|
|
59
|
+
baseClass: "s-navigation",
|
|
60
|
+
variants: ["vertical", "muted"],
|
|
61
|
+
modifiers: {
|
|
62
|
+
primary: ["scroll", "sm"],
|
|
63
|
+
},
|
|
64
|
+
tag: "ul",
|
|
65
|
+
children: {
|
|
66
|
+
default: getChildren(true),
|
|
67
|
+
},
|
|
68
|
+
template: ({ component, testid }) => html`
|
|
69
|
+
<nav
|
|
70
|
+
class="d-inline-block p8 wmx3"
|
|
71
|
+
aria-label="example-navigation"
|
|
72
|
+
data-testid="${testid}"
|
|
73
|
+
>
|
|
74
|
+
${component}
|
|
75
|
+
</nav>
|
|
76
|
+
`,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { html } from "@open-wc/testing";
|
|
2
|
+
import { defaultOptions, runComponentTests } from "../../test/test-utils";
|
|
3
|
+
import "../../index";
|
|
4
|
+
|
|
5
|
+
const items = [
|
|
6
|
+
{
|
|
7
|
+
label: "Group 1",
|
|
8
|
+
title: true,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: "Product",
|
|
12
|
+
selected: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Email",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: "Group 2",
|
|
19
|
+
title: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Content",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Brand",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "Marketing",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "More selected",
|
|
32
|
+
dropdown: true,
|
|
33
|
+
selected: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "More",
|
|
37
|
+
dropdown: true,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const getChildren = (includeTitles = false): string =>
|
|
42
|
+
items
|
|
43
|
+
.map((item) => {
|
|
44
|
+
if (item.title) {
|
|
45
|
+
return includeTitles
|
|
46
|
+
? `<li class="s-navigation--title">${item.label}</li>`
|
|
47
|
+
: "";
|
|
48
|
+
}
|
|
49
|
+
const classes = `s-navigation--item${
|
|
50
|
+
item.selected ? " is-selected" : ""
|
|
51
|
+
}${item.dropdown ? " s-navigation--item__dropdown" : ""}`;
|
|
52
|
+
return `<li><a href="#" class="${classes}">${item.label}</a></li>`;
|
|
53
|
+
})
|
|
54
|
+
.join("");
|
|
55
|
+
|
|
56
|
+
describe("navigation", () => {
|
|
57
|
+
runComponentTests({
|
|
58
|
+
type: "visual",
|
|
59
|
+
baseClass: "s-navigation",
|
|
60
|
+
variants: ["muted"],
|
|
61
|
+
modifiers: {
|
|
62
|
+
primary: ["scroll", "sm"],
|
|
63
|
+
},
|
|
64
|
+
tag: "ul",
|
|
65
|
+
children: {
|
|
66
|
+
default: getChildren(),
|
|
67
|
+
},
|
|
68
|
+
template: ({ component, testid }) => html`
|
|
69
|
+
<nav
|
|
70
|
+
class="d-inline-block p8 wmx3"
|
|
71
|
+
aria-label="example-navigation"
|
|
72
|
+
data-testid="${testid}"
|
|
73
|
+
>
|
|
74
|
+
${component}
|
|
75
|
+
</nav>
|
|
76
|
+
`,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
runComponentTests({
|
|
80
|
+
type: "visual",
|
|
81
|
+
baseClass: "s-navigation",
|
|
82
|
+
variants: ["vertical"],
|
|
83
|
+
tag: "ul",
|
|
84
|
+
children: {
|
|
85
|
+
default: getChildren(true),
|
|
86
|
+
},
|
|
87
|
+
template: ({ component, testid }) => html`
|
|
88
|
+
<nav
|
|
89
|
+
class="d-inline-block p8 ws2"
|
|
90
|
+
aria-label="example-navigation"
|
|
91
|
+
data-testid="${testid}"
|
|
92
|
+
>
|
|
93
|
+
${component}
|
|
94
|
+
</nav>
|
|
95
|
+
`,
|
|
96
|
+
options: {
|
|
97
|
+
...defaultOptions,
|
|
98
|
+
includeNullVariant: false,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { runComponentTests } from "../../test/test-utils";
|
|
2
|
+
import "../../index";
|
|
3
|
+
|
|
4
|
+
describe("notice", () => {
|
|
5
|
+
runComponentTests({
|
|
6
|
+
type: "a11y",
|
|
7
|
+
baseClass: "s-notice",
|
|
8
|
+
variants: ["info", "success", "warning", "danger"],
|
|
9
|
+
modifiers: {
|
|
10
|
+
primary: ["important"],
|
|
11
|
+
},
|
|
12
|
+
children: {
|
|
13
|
+
default: `Test notice`,
|
|
14
|
+
},
|
|
15
|
+
tag: "aside",
|
|
16
|
+
});
|
|
17
|
+
});
|