@stackoverflow/stacks 2.3.3 → 2.5.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.
Files changed (120) hide show
  1. package/dist/css/stacks.css +37 -4884
  2. package/dist/css/stacks.min.css +1 -1
  3. package/lib/components/button/button.less +0 -18
  4. package/lib/components/tag/tag.less +16 -68
  5. package/lib/components/topbar/topbar.less +33 -3
  6. package/lib/exports/color-mixins.less +0 -2
  7. package/lib/exports/exports.less +0 -1
  8. package/lib/stacks-static.less +0 -5
  9. package/package.json +12 -11
  10. package/lib/atomic/__snapshots__/color-new.less.test.ts.snap +0 -3015
  11. package/lib/atomic/__snapshots__/color.less.test.ts.snap +0 -3132
  12. package/lib/atomic/__snapshots__/misc.less.test.ts.snap +0 -893
  13. package/lib/atomic/__snapshots__/spacing.less.test.ts.snap +0 -1928
  14. package/lib/atomic/color.less.test.ts +0 -12
  15. package/lib/atomic/misc.less.test.ts +0 -12
  16. package/lib/atomic/spacing.less.test.ts +0 -12
  17. package/lib/atomic/v1/__snapshots__/border.less.test.ts.snap +0 -546
  18. package/lib/atomic/v1/__snapshots__/color.less.test.ts.snap +0 -6750
  19. package/lib/atomic/v1/__snapshots__/typography.less.test.ts.snap +0 -16
  20. package/lib/atomic/v1/border.less +0 -210
  21. package/lib/atomic/v1/border.less.test.ts +0 -14
  22. package/lib/atomic/v1/color.less +0 -183
  23. package/lib/atomic/v1/color.less.test.ts +0 -14
  24. package/lib/atomic/v1/typography.less +0 -8
  25. package/lib/atomic/v1/typography.less.test.ts +0 -14
  26. package/lib/components/activity-indicator/activity-indicator.a11y.test.ts +0 -13
  27. package/lib/components/activity-indicator/activity-indicator.visual.test.ts +0 -22
  28. package/lib/components/anchor/anchor.a11y.test.ts +0 -35
  29. package/lib/components/anchor/anchor.visual.test.ts +0 -47
  30. package/lib/components/avatar/avatar.a11y.test.ts +0 -35
  31. package/lib/components/avatar/avatar.visual.test.ts +0 -50
  32. package/lib/components/award-bling/award-bling.a11y.test.ts +0 -15
  33. package/lib/components/award-bling/award-bling.visual.test.ts +0 -24
  34. package/lib/components/badge/badge.a11y.test.ts +0 -143
  35. package/lib/components/badge/badge.visual.test.ts +0 -165
  36. package/lib/components/banner/banner.a11y.test.ts +0 -36
  37. package/lib/components/banner/banner.test.ts +0 -73
  38. package/lib/components/banner/banner.visual.test.ts +0 -36
  39. package/lib/components/block-link/block-link.a11y.test.ts +0 -57
  40. package/lib/components/block-link/block-link.visual.test.ts +0 -57
  41. package/lib/components/breadcrumbs/breadcrumbs.a11y.test.ts +0 -36
  42. package/lib/components/breadcrumbs/breadcrumbs.visual.test.ts +0 -36
  43. package/lib/components/button/button.a11y.test.ts +0 -21
  44. package/lib/components/button/button.test.setup.ts +0 -36
  45. package/lib/components/button/button.visual.test.ts +0 -18
  46. package/lib/components/button-group/button-group.a11y.test.ts +0 -12
  47. package/lib/components/button-group/button-group.test.setup.ts +0 -77
  48. package/lib/components/button-group/button-group.visual.test.ts +0 -7
  49. package/lib/components/card/card.a11y.test.ts +0 -12
  50. package/lib/components/card/card.visual.test.ts +0 -52
  51. package/lib/components/check-control/check-control.a11y.test.ts +0 -33
  52. package/lib/components/check-control/check-control.visual.test.ts +0 -36
  53. package/lib/components/check-group/check-group.a11y.test.ts +0 -49
  54. package/lib/components/check-group/check-group.visual.test.ts +0 -56
  55. package/lib/components/checkbox_radio/checkbox_radio.a11y.test.ts +0 -37
  56. package/lib/components/checkbox_radio/checkbox_radio.visual.test.ts +0 -33
  57. package/lib/components/code-block/code-block.a11y.test.ts +0 -27
  58. package/lib/components/code-block/code-block.visual.test.ts +0 -18
  59. package/lib/components/description/description.a11y.test.ts +0 -28
  60. package/lib/components/description/description.visual.test.ts +0 -28
  61. package/lib/components/empty-state/empty-state.a11y.test.ts +0 -16
  62. package/lib/components/empty-state/empty-state.visual.test.ts +0 -16
  63. package/lib/components/expandable/expandable.a11y.test.ts +0 -26
  64. package/lib/components/expandable/expandable.test.ts +0 -51
  65. package/lib/components/expandable/expandable.visual.test.ts +0 -26
  66. package/lib/components/input-fill/input-fill.a11y.test.ts +0 -21
  67. package/lib/components/input-fill/input-fill.visual.test.ts +0 -21
  68. package/lib/components/input-icon/input-icon.a11y.test.ts +0 -81
  69. package/lib/components/input-icon/input-icon.visual.test.ts +0 -92
  70. package/lib/components/input-message/input-message.a11y.test.ts +0 -57
  71. package/lib/components/input-message/input-message.visual.test.ts +0 -58
  72. package/lib/components/input_textarea/input_textarea.a11y.test.ts +0 -109
  73. package/lib/components/input_textarea/input_textarea.visual.test.ts +0 -95
  74. package/lib/components/label/label.a11y.test.ts +0 -47
  75. package/lib/components/label/label.visual.test.ts +0 -65
  76. package/lib/components/link/link.a11y.test.ts +0 -27
  77. package/lib/components/link/link.visual.test.ts +0 -31
  78. package/lib/components/link-preview/link-preview.a11y.test.ts +0 -47
  79. package/lib/components/link-preview/link-preview.visual.test.ts +0 -52
  80. package/lib/components/menu/menu.a11y.test.ts +0 -39
  81. package/lib/components/menu/menu.visual.test.ts +0 -39
  82. package/lib/components/modal/modal.a11y.test.ts +0 -41
  83. package/lib/components/modal/modal.test.ts +0 -155
  84. package/lib/components/modal/modal.visual.test.ts +0 -41
  85. package/lib/components/navigation/navigation.a11y.test.ts +0 -81
  86. package/lib/components/navigation/navigation.visual.test.ts +0 -98
  87. package/lib/components/notice/notice.a11y.test.ts +0 -16
  88. package/lib/components/notice/notice.visual.test.ts +0 -25
  89. package/lib/components/page-title/page-title.a11y.test.ts +0 -28
  90. package/lib/components/page-title/page-title.visual.test.ts +0 -58
  91. package/lib/components/pagination/pagination.a11y.test.ts +0 -21
  92. package/lib/components/pagination/pagination.visual.test.ts +0 -25
  93. package/lib/components/popover/tooltip.test.ts +0 -62
  94. package/lib/components/post-summary/post-summary.a11y.test.ts +0 -25
  95. package/lib/components/post-summary/post-summary.test.setup.ts +0 -435
  96. package/lib/components/post-summary/post-summary.visual.test.ts +0 -17
  97. package/lib/components/progress-bar/progress-bar.a11y.test.ts +0 -189
  98. package/lib/components/progress-bar/progress-bar.visual.test.ts +0 -188
  99. package/lib/components/select/select.a11y.test.ts +0 -72
  100. package/lib/components/select/select.visual.test.ts +0 -72
  101. package/lib/components/spinner/spinner.a11y.test.ts +0 -14
  102. package/lib/components/spinner/spinner.visual.test.ts +0 -40
  103. package/lib/components/table/table.a11y.test.ts +0 -112
  104. package/lib/components/table/table.test.ts +0 -366
  105. package/lib/components/table/table.visual.test.ts +0 -104
  106. package/lib/components/tag/tag.a11y.test.ts +0 -28
  107. package/lib/components/tag/tag.visual.test.ts +0 -43
  108. package/lib/components/toast/toast.a11y.test.ts +0 -29
  109. package/lib/components/toast/toast.test.ts +0 -64
  110. package/lib/components/toast/toast.visual.test.ts +0 -30
  111. package/lib/components/toggle-switch/toggle-switch.a11y.test.ts +0 -66
  112. package/lib/components/toggle-switch/toggle-switch.visual.test.ts +0 -70
  113. package/lib/components/topbar/topbar.visual.test.ts +0 -216
  114. package/lib/exports/__snapshots__/color-mixins.less.test.ts.snap +0 -558
  115. package/lib/exports/__snapshots__/color.less.test.ts.snap +0 -819
  116. package/lib/exports/color-mixins.less.test.ts +0 -150
  117. package/lib/exports/color.less.test.ts +0 -12
  118. package/lib/exports/v1/__snapshots__/constants-colors.less.test.ts.snap +0 -902
  119. package/lib/exports/v1/constants-colors.less +0 -893
  120. package/lib/exports/v1/constants-colors.less.test.ts +0 -12
@@ -1,435 +0,0 @@
1
- import { html } from "@open-wc/testing";
2
- import {
3
- IconArchiveSm,
4
- IconCheckmarkSm,
5
- IconEllipsisVertical,
6
- IconEyeSm,
7
- IconNotInterested,
8
- IconPencilSm,
9
- IconTackSm,
10
- IconTrashSm,
11
- } from "@stackoverflow/stacks-icons/icons";
12
- import type { TestVariationArgs } from "../../test/test-utils";
13
- import "../../index";
14
-
15
- type BadgeType =
16
- | "danger"
17
- | "danger-filled"
18
- | "info"
19
- | "muted"
20
- | "muted-filled"
21
- | "warning";
22
-
23
- type Stats = {
24
- votes: number;
25
- views: number;
26
- answers: number;
27
- accepted?: boolean;
28
- bounty?: number;
29
- badge?: BadgeType;
30
- };
31
-
32
- type Tags = { text: string; type?: "required" | "moderator" }[];
33
-
34
- type TruncationSizes = "sm" | "md" | "lg" | "";
35
-
36
- const formatNumber = (num: number) => {
37
- switch (true) {
38
- case num > 10000090:
39
- return (num / 1000000).toFixed(0) + "m";
40
- case num > 1000000:
41
- return (num / 1000000).toFixed(1) + "m";
42
- case num > 10000:
43
- return (num / 1000).toFixed(0) + "k";
44
- case num > 1000:
45
- return (num / 1000).toFixed(1) + "k";
46
- default:
47
- return num.toString();
48
- }
49
- };
50
-
51
- const getBadge = (type: BadgeType) => {
52
- const badgeClasses = type
53
- .split("-")
54
- .map((modifier) => `s-badge__${modifier}`)
55
- .join(" ");
56
- const getIcon = () => {
57
- switch (type) {
58
- case "danger":
59
- return IconNotInterested;
60
- case "danger-filled":
61
- return IconTrashSm;
62
- case "info":
63
- return IconPencilSm;
64
- case "muted":
65
- return IconArchiveSm;
66
- case "muted-filled":
67
- return IconTackSm;
68
- case "warning":
69
- return IconEyeSm;
70
- default:
71
- return "";
72
- }
73
- };
74
-
75
- const getText = () => {
76
- switch (type) {
77
- case "danger":
78
- return "Closed";
79
- case "danger-filled":
80
- return "Deleted";
81
- case "info":
82
- return "Draft";
83
- case "muted":
84
- return "Archived";
85
- case "muted-filled":
86
- return "Pinned";
87
- case "warning":
88
- return "Review";
89
- default:
90
- return "";
91
- }
92
- };
93
-
94
- return `
95
- <div
96
- class="s-post-summary--stats-item s-badge s-badge__icon ${badgeClasses}"
97
- >
98
- ${getIcon()}
99
- ${getText()}
100
- </div>`;
101
- };
102
-
103
- const getDescription = (truncation?: TruncationSizes, text?: string) => `
104
- <p class="s-post-summary--content-excerpt
105
- ${truncation ? `s-post-summary--content-excerpt__${truncation}` : ""}
106
- ">
107
- ${text ? text : "In the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities. Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creating the metamodel classes manually)? It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know)."}
108
- </p>
109
- `;
110
-
111
- const getHotnessClass = (num: number) => {
112
- switch (true) {
113
- case num > 100000:
114
- return "is-supernova";
115
- case num > 10000:
116
- return "is-hot";
117
- case num > 1000:
118
- return "is-warm";
119
- default:
120
- return "";
121
- }
122
- };
123
-
124
- const getStats = ({
125
- votes,
126
- views,
127
- answers,
128
- accepted,
129
- bounty,
130
- badge,
131
- }: Stats) => `
132
- <div class="s-post-summary--stats">
133
- ${badge ? getBadge(badge) : ""}
134
- <div class="s-post-summary--stats-item s-post-summary--stats-item__emphasized">
135
- <span class="s-post-summary--stats-item-number">${formatNumber(votes)}</span>
136
- <span class="s-post-summary--stats-item-unit">${votes === 1 ? "vote" : "votes"}</span>
137
- </div>
138
- <div class="s-post-summary--stats-item ${accepted ? "has-accepted-answer" : ""} ${answers > 0 ? "has-answers" : ""}">
139
- ${accepted ? IconCheckmarkSm : ""}
140
- <span class="s-post-summary--stats-item-number">${formatNumber(answers)}</span>
141
- <span class="s-post-summary--stats-item-unit">${answers === 1 ? "answer" : "answers"}</span>
142
- </div>
143
- <div class="s-post-summary--stats-item ${getHotnessClass(views)}">
144
- <span class="s-post-summary--stats-item-number">${formatNumber(views)}</span>
145
- <span class="s-post-summary--stats-item-unit">${views === 1 ? "view" : "views"}</span>
146
- </div>
147
- ${
148
- bounty
149
- ? `
150
- <div class="s-post-summary--stats-item s-badge s-badge__bounty">
151
- +${bounty}
152
- </div>
153
- `
154
- : ""
155
- }
156
- </div>
157
- `;
158
-
159
- const getTags = (tags?: Tags) => {
160
- const tagsArr = tags ?? [
161
- {
162
- text: "feature-request",
163
- type: "required",
164
- },
165
- {
166
- text: "status-complete",
167
- type: "moderator",
168
- },
169
- {
170
- text: "design",
171
- },
172
- ];
173
-
174
- const tagsHTML = tagsArr
175
- .map(
176
- ({ text, type }) => `
177
- <a class="s-tag ${type ? `s-tag__${type}` : ""}" href="/">${text}</a>
178
- `
179
- )
180
- .join("");
181
-
182
- return `<div class="s-post-summary--meta-tags">${tagsHTML}</div>`;
183
- };
184
-
185
- const getUser = () => `
186
- <div class="s-user-card s-user-card__minimal">
187
- <a href="#" class="s-avatar s-user-card--avatar">
188
- <img class="s-avatar--image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATwAAAE8CAMAAABq2/00AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABhQTFRF/3IA/////44y/8OS/+fU//Xs/6tn/9e2EhvbMQAABH9JREFUeNrs3e1y2ygAhWELJHH/d7zuJpN1XAnxoe408Ly/6xnnHXEOIEwfDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/gbAGEhrZl2VloY20PIk8tAzZbfkXA7eeuHyysVfdFMsXiY66ptiWF8Re05BdxF7HkBV7PUNW7FVx4E7sVSwrDjBw2+pC7NWwHtkTe3ULM7En9v6O2ONF7Ik9sSf2IPbEntgTexB7t8feTsynniD2Oh6tXex1hFoUe02kaxVi72JMZs+Rib0LLdkXFGLvaECWjkOxdxVmUex1rB6S2Kss2lcytSH2LnVkakPsXQ7E8xwTe5fuMrUh9vKj8CP4xN7lNOXc3mnwib1M2X7Z28VeS93mg0/sFZTG6WCMVSE51fqsYL4s9jpqQ+yV1caxErHXUxtir6c2xF5HbYRF7LXXhtjrqQ2x11MbYu9tLG4VtSH2empD7BUNxpPaSGKvPPh2sdcxX45i78baEHs18+X32hB7NfPl99oQex21MVHsxViaR8W1MU3s/XpMSvWF0tqYJfY+BmMq01dcG+scP6/6enTK9BW+1J0j9l5aYN0rP5BzM0XsbSUnAlpqY4LYezexFeRSbpslH3uDXdF64OG6est258PohXE8BK+7o6g29rJTQsPt1F3qK9qdTwMP2Wz2X1Vv0UvdbeQ53nl2Xesr2Z0Pww7Zs5lsafWW1MY+6JDNxv5/+kLb5/fXfzLirRdhKSGnr6A2tkGvJoxLGZnqva6NkAbdgA+pUN9a+QuWYYPu+98ee/W1/PJgoMG7lek7nW3UHiEdbKpcqu+kO2L9b4aG0rcWjt5jfWf2Z7kCeE891XtSG/O86A5d+tbZj1h0VW+c/ja90FG9uxMCFdWb/+SkZ1Oaq/d1vjzvXfvF+tLp+aiZT5S1Vm90lrFj02B3bW1d9X7T92u+7Aq9qk2D+Fob/v/Myu7YostC76xe9K966evfr5+7ekuXHVy1V6+R275pEMd3kPbGB+Syeod/8D7Sf41NBvPdMf7a4uXpaTGY0zd+4r0vDlKtwdPqHf/BOzzf8zQYqvRtcz54mXfUNUVyUL0T7AhcrBbKY/C36p1geVEy1y00+F3fBA9eKFxnlRXJa/XOcKxnqeF6Pv1VvTPc7RuXai6K5LN6Z9hQSUsb2Rh86pviUultaScTg/sMD15YeqmcT8/bFx1Foi/umk9P3hcMfqTenrabBT5j8DGTwHivwelOCTwNrnfJm/Ol2U0GZ74WdE+dBn9+Z/z2J9UZ7IjB7dZv8gPl9RRJIq89BiN57QZ38trn04G8k62E6xjcHuQ1D+JEXrvBnbz2+XQgr30+/SCveT69ktceg4m8doOBvDG/CXnkkTezvOXPQB555JFHHnnkkUceeeSRRx555JFHHnnkkWcnmTzyyCOPPPLII4888sgjjzzfhDzyyCOPPPL+9Ff+eyCPPPLII4888sgjjzzyyCOPPPLII4888sgDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPy//CPAAPiZOI3BPDFQAAAAAElFTkSuQmCC" alt="placeholder avatar">
189
- <span class="v-visible-sr">Tracy Smith</span>
190
- </a>
191
- <a href="#" class="s-user-card--link">Tracy Smith</a>
192
- <ul class="s-user-card--awards">
193
- <li class="s-user-card--rep">1350</li>
194
- </ul>
195
- <time class="s-user-card--time">asked just now</time>
196
- </div>
197
- `;
198
-
199
- const getChildren = ({
200
- show = {
201
- description: false,
202
- menuBtn: false,
203
- stats: false,
204
- tags: false,
205
- title: false,
206
- user: false,
207
- },
208
- description = {
209
- truncation: "",
210
- text: "",
211
- },
212
- stats,
213
- tags,
214
- title,
215
- }: {
216
- show?: {
217
- description?: boolean;
218
- menuBtn?: boolean;
219
- stats?: boolean;
220
- tags?: boolean;
221
- title?: boolean;
222
- user?: boolean;
223
- };
224
- description?: {
225
- truncation?: TruncationSizes;
226
- text?: string;
227
- };
228
- stats?: Stats;
229
- tags?: Tags;
230
- title?: string;
231
- }) => {
232
- const titleEl =
233
- show.title || title
234
- ? `
235
- <h3 class="s-post-summary--content-title">
236
- ${title ? title : "How to generate the JPA entity Metamodel?"}
237
- </h3>
238
- `
239
- : "";
240
- const descriptionEl =
241
- show.description || description.truncation || description.text
242
- ? description
243
- ? getDescription(description.truncation, description.text)
244
- : getDescription()
245
- : "";
246
- const tagsEl = show.tags || tags ? getTags(tags) : "";
247
- const userEl = show.user ? getUser() : "";
248
- const menuBtnEl = show.menuBtn
249
- ? `
250
- <a href="#" class="s-btn s-btn__muted s-post-summary--content-menu-button">
251
- ${IconEllipsisVertical}
252
- <span class="v-visible-sr">menu</span>
253
- </a>
254
- `
255
- : "";
256
-
257
- return `
258
- ${
259
- show.stats || stats
260
- ? getStats(
261
- stats
262
- ? stats
263
- : {
264
- votes: 95,
265
- views: 104123,
266
- answers: 5,
267
- accepted: true,
268
- bounty: 50,
269
- }
270
- )
271
- : ""
272
- }
273
- ${
274
- titleEl || descriptionEl || tagsEl || userEl || menuBtnEl
275
- ? `
276
- <div class="s-post-summary--content">
277
- ${titleEl}
278
- ${descriptionEl}
279
- <div class="s-post-summary--meta">
280
- ${tagsEl}
281
- ${userEl}
282
- </div>
283
- ${menuBtnEl}
284
- </div>`
285
- : ""
286
- }
287
- `;
288
- };
289
-
290
- const getBadgeChildren = (badge: BadgeType) => {
291
- return getChildren({
292
- show: {
293
- stats: true,
294
- },
295
- stats: {
296
- badge: badge,
297
- answers: 0,
298
- votes: 1,
299
- views: 20,
300
- },
301
- });
302
- };
303
-
304
- const getSizeChildren = (size: string) => {
305
- return getChildren({
306
- show: {
307
- description: true,
308
- menuBtn: true,
309
- stats: true,
310
- tags: true,
311
- title: true,
312
- user: true,
313
- },
314
- description: {
315
- truncation: size as TruncationSizes,
316
- },
317
- });
318
- };
319
-
320
- const getStatsChildren = ({
321
- accepted = false,
322
- answers = 1,
323
- views = 20,
324
- }: {
325
- accepted?: boolean;
326
- answers?: number;
327
- views?: number;
328
- }) =>
329
- getChildren({
330
- show: {
331
- stats: true,
332
- },
333
- stats: {
334
- votes: 1,
335
- answers,
336
- accepted,
337
- views,
338
- },
339
- });
340
-
341
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
342
- const template = ({ component, testid }: any) => html`
343
- <div class="d-flex ai-center jc-center p8 ws6" data-testid="${testid}">
344
- ${component}
345
- </div>
346
- `;
347
-
348
- const testArgs: {
349
- [key: string]: TestVariationArgs;
350
- } = {
351
- base: {
352
- baseClass: "s-post-summary",
353
- modifiers: {
354
- primary: ["deleted", "ignored", "watched"], // variants described as modifiers to test colliding modifiers
355
- secondary: ["minimal"],
356
- global: ["w100"],
357
- },
358
- children: {
359
- default: getChildren({
360
- show: {
361
- description: true,
362
- menuBtn: true,
363
- stats: true,
364
- tags: true,
365
- title: true,
366
- user: true,
367
- },
368
- }),
369
- sparce: getChildren({
370
- show: {
371
- stats: true,
372
- tags: true,
373
- title: true,
374
- user: true,
375
- },
376
- tags: [
377
- {
378
- text: "featured-request",
379
- type: "required",
380
- },
381
- ],
382
- title: "Short title",
383
- }),
384
- },
385
- options: {
386
- includeNullModifier: false,
387
- },
388
- template,
389
- },
390
- badges: {
391
- baseClass: "s-post-summary",
392
- children: {
393
- "badge-danger": getBadgeChildren("danger"),
394
- "badge-danger-filled": getBadgeChildren("danger-filled"),
395
- "badge-info": getBadgeChildren("info"),
396
- "badge-muted": getBadgeChildren("muted"),
397
- "badge-muted-filled": getBadgeChildren("muted-filled"),
398
- "badge-warning": getBadgeChildren("warning"),
399
- },
400
- template,
401
- },
402
- sizes: {
403
- baseClass: "s-post-summary",
404
- modifiers: {
405
- global: ["w100"],
406
- },
407
- children: {
408
- "description-sm": getSizeChildren("sm"),
409
- "description-md": getSizeChildren("md"),
410
- "description-lg": getSizeChildren("lg"),
411
- },
412
- options: {
413
- includeNullModifier: false,
414
- },
415
- template,
416
- },
417
- stats: {
418
- baseClass: "s-post-summary",
419
- children: {
420
- "stats-unanswered": getStatsChildren({ answers: 0 }),
421
- "stats-answered": getStatsChildren({ answers: 1 }),
422
- "stats-answered-accepted": getStatsChildren({
423
- answers: 10,
424
- accepted: true,
425
- }),
426
- "stats-views": getStatsChildren({ views: 1 }),
427
- "stats-views-warm": getStatsChildren({ views: 1001 }),
428
- "stats-views-hot": getStatsChildren({ views: 10001 }),
429
- "stats-views-supernova": getStatsChildren({ views: 100001 }),
430
- },
431
- template,
432
- },
433
- };
434
-
435
- export default testArgs;
@@ -1,17 +0,0 @@
1
- import { runVisualTests } from "../../test/visual-test-utils";
2
- import testArgs from "./post-summary.test.setup";
3
- import "../../index";
4
-
5
- describe("post-summary", () => {
6
- // Base, sparce
7
- runVisualTests(testArgs.base);
8
-
9
- // Truncated description sizes
10
- runVisualTests(testArgs.sizes);
11
-
12
- // Stats - answers, view hotness
13
- runVisualTests(testArgs.stats);
14
-
15
- // Badges
16
- runVisualTests(testArgs.badges);
17
- });
@@ -1,189 +0,0 @@
1
- import { html } from "@open-wc/testing";
2
- import {
3
- IconAchievementsSm,
4
- IconCheckmarkSm,
5
- } from "@stackoverflow/stacks-icons/icons";
6
- import { runA11yTests } from "../../test/a11y-test-utils";
7
- import "../../index";
8
-
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- const template = ({ component, testid }: any) => html`
11
- <div class="d-flex ai-center jc-center p8 ws2" data-testid="${testid}">
12
- ${component}
13
- </div>
14
- `;
15
-
16
- const steppedItems = [
17
- {
18
- complete: true,
19
- label: "Select plan",
20
- },
21
- {
22
- complete: true,
23
- label: "Team name",
24
- },
25
- {
26
- active: true,
27
- label: "Payment",
28
- },
29
- {
30
- label: "Create account",
31
- },
32
- ];
33
-
34
- const getChildren = (type: string) => {
35
- switch (type) {
36
- case "badge":
37
- return `<div class="s-progress--label" id="example-label">
38
- <div class="s-badge--label">Electorate</div>
39
- </div>
40
- <div class="s-progress--bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="75" aria-labelledby="example-label" style="width: 75%;"></div>`;
41
- case "circular":
42
- return `<svg class="s-progress-bar" role="progressbar" viewbox="0 0 32 32" aria-valuemin="0" aria-valuemax="100" aria-valuenow="75">
43
- <circle cx="16" cy="16" r="14"></circle>
44
- <circle cx="16" cy="16" r="14"></circle>
45
- </svg>`;
46
- case "privilege":
47
- return `
48
- <div class="s-progress--label" id="progress-label">
49
- ${IconAchievementsSm}
50
- Access Review Queues
51
- </div>
52
- <div class="s-progress--bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="75" aria-labelledby="progress-label" style="width: 75%;"></div>
53
- `;
54
- case "segmented":
55
- return `
56
- <div class="s-progress--bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="75" aria-label="…" style="width: 75%;"></div>
57
- <ol class="s-progress--segments">
58
- <li></li><li></li><li></li>
59
- </ol>
60
- `;
61
- case "stepped":
62
- return steppedItems
63
- .map((step, i) => {
64
- return `
65
- <div
66
- class="
67
- s-progress--step
68
- ${step.active ? "is-active" : ""}
69
- ${step.complete ? "is-complete" : ""}
70
- "
71
- >
72
- <a href="#" class="s-progress--stop">
73
- ${step.complete ? IconCheckmarkSm : ""}
74
- <span class="v-visible-sr">${step.label} ${
75
- step.complete ? "complete" : "incomplete"
76
- }</span>
77
- </a>
78
- ${
79
- i > 0
80
- ? '<div class="s-progress--bar s-progress--bar__left"></div>'
81
- : ""
82
- }
83
-
84
- ${
85
- i < steppedItems.length - 1
86
- ? '<div class="s-progress--bar s-progress--bar__right"></div>'
87
- : ""
88
- }
89
- <a class="s-progress--label">${step.label}</a>
90
- </div>
91
- `;
92
- })
93
- .join("");
94
- default:
95
- return `<div class="s-progress--bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="75" aria-label="progress" style="width: 75%"></div>`;
96
- }
97
- };
98
- describe("progress-bar", () => {
99
- // Base
100
- runA11yTests({
101
- baseClass: "s-progress",
102
- variants: ["brand", "info"],
103
- children: {
104
- default: getChildren(""),
105
- },
106
- template,
107
- });
108
-
109
- // Badge
110
- runA11yTests({
111
- baseClass: "s-progress",
112
- variants: ["badge"],
113
- modifiers: {
114
- primary: ["gold", "silver", "bronze"],
115
- },
116
- children: {
117
- default: getChildren("badge"),
118
- },
119
- template,
120
- options: {
121
- includeNullVariant: false,
122
- includeNullModifier: false,
123
- },
124
- });
125
-
126
- // Circular
127
- runA11yTests({
128
- baseClass: "s-progress",
129
- variants: ["circular"],
130
- modifiers: {
131
- global: ["fc-green-400", "fc-theme-primary"],
132
- },
133
- children: {
134
- default: getChildren("circular"),
135
- },
136
- template,
137
- attributes: {
138
- style: "--s-progress-value: .75",
139
- },
140
- options: {
141
- includeNullVariant: false,
142
- includeNullModifier: false,
143
- },
144
- });
145
-
146
- // Privilege
147
- runA11yTests({
148
- baseClass: "s-progress",
149
- variants: ["privilege"],
150
- children: {
151
- default: getChildren("privilege"),
152
- },
153
- template,
154
- options: {
155
- includeNullVariant: false,
156
- },
157
- });
158
-
159
- // Segmented
160
- runA11yTests({
161
- baseClass: "s-progress",
162
- variants: ["segmented"],
163
- children: {
164
- default: getChildren("segmented"),
165
- },
166
- template,
167
- options: {
168
- includeNullVariant: false,
169
- },
170
- });
171
-
172
- // Stepped
173
- runA11yTests({
174
- baseClass: "s-progress",
175
- variants: ["stepped"],
176
- children: {
177
- default: getChildren("stepped"),
178
- },
179
- template: ({ component, testid }) => html`
180
- <div class="d-block p8 ws5" data-testid="${testid}">
181
- ${component}
182
- </div>
183
- `,
184
- options: {
185
- includeNullVariant: false,
186
- },
187
- // TODO add skipped test ids
188
- });
189
- });