@stackoverflow/stacks 2.7.3 → 2.7.4

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 (83) hide show
  1. package/LICENSE.MD +9 -9
  2. package/README.md +158 -180
  3. package/dist/css/stacks.css +6 -0
  4. package/dist/js/stacks.min.js +1 -1
  5. package/lib/atomic/border.less +139 -139
  6. package/lib/atomic/color.less +36 -36
  7. package/lib/atomic/flex.less +426 -426
  8. package/lib/atomic/gap.less +44 -44
  9. package/lib/atomic/grid.less +139 -139
  10. package/lib/atomic/misc.less +374 -374
  11. package/lib/atomic/spacing.less +98 -98
  12. package/lib/atomic/typography.less +266 -264
  13. package/lib/atomic/width-height.less +194 -194
  14. package/lib/base/body.less +44 -44
  15. package/lib/base/configuration-static.less +61 -61
  16. package/lib/base/fieldset.less +5 -5
  17. package/lib/base/icon.less +11 -11
  18. package/lib/base/internal.less +220 -220
  19. package/lib/base/reset-meyer.less +64 -64
  20. package/lib/base/reset-normalize.less +449 -449
  21. package/lib/base/reset.less +20 -20
  22. package/lib/components/activity-indicator/activity-indicator.less +53 -53
  23. package/lib/components/avatar/avatar.less +108 -108
  24. package/lib/components/award-bling/award-bling.less +31 -31
  25. package/lib/components/banner/banner.less +44 -44
  26. package/lib/components/banner/banner.ts +149 -149
  27. package/lib/components/block-link/block-link.less +82 -82
  28. package/lib/components/breadcrumbs/breadcrumbs.less +41 -41
  29. package/lib/components/button-group/button-group.less +82 -82
  30. package/lib/components/card/card.less +37 -37
  31. package/lib/components/check-control/check-control.less +17 -17
  32. package/lib/components/check-group/check-group.less +19 -19
  33. package/lib/components/checkbox_radio/checkbox_radio.less +159 -159
  34. package/lib/components/code-block/code-block.fixtures.ts +88 -88
  35. package/lib/components/code-block/code-block.less +116 -116
  36. package/lib/components/description/description.less +9 -9
  37. package/lib/components/empty-state/empty-state.less +16 -16
  38. package/lib/components/expandable/expandable.less +118 -118
  39. package/lib/components/input-fill/input-fill.less +35 -35
  40. package/lib/components/input-icon/input-icon.less +45 -45
  41. package/lib/components/input-message/input-message.less +49 -49
  42. package/lib/components/label/label.less +110 -110
  43. package/lib/components/link-preview/link-preview.less +148 -148
  44. package/lib/components/menu/menu.less +41 -41
  45. package/lib/components/modal/modal.less +118 -118
  46. package/lib/components/modal/modal.ts +383 -383
  47. package/lib/components/navigation/navigation.less +136 -136
  48. package/lib/components/navigation/navigation.ts +128 -128
  49. package/lib/components/page-title/page-title.less +51 -51
  50. package/lib/components/popover/popover.less +159 -159
  51. package/lib/components/popover/popover.ts +651 -651
  52. package/lib/components/post-summary/post-summary.less +457 -457
  53. package/lib/components/progress-bar/progress-bar.less +291 -291
  54. package/lib/components/prose/prose.less +452 -452
  55. package/lib/components/select/select.less +138 -138
  56. package/lib/components/spinner/spinner.less +103 -103
  57. package/lib/components/table/table.ts +296 -296
  58. package/lib/components/table-container/table-container.less +4 -4
  59. package/lib/components/tag/tag.less +186 -186
  60. package/lib/components/toast/toast.less +35 -35
  61. package/lib/components/toast/toast.ts +357 -357
  62. package/lib/components/toggle-switch/toggle-switch.less +104 -104
  63. package/lib/components/topbar/topbar.less +553 -553
  64. package/lib/components/uploader/uploader.less +205 -205
  65. package/lib/components/user-card/user-card.less +129 -129
  66. package/lib/controllers.ts +33 -33
  67. package/lib/exports/color-mixins.less +283 -283
  68. package/lib/exports/constants-helpers.less +108 -108
  69. package/lib/exports/constants-type.less +155 -155
  70. package/lib/exports/exports.less +15 -15
  71. package/lib/exports/mixins.less +334 -333
  72. package/lib/exports/spacing-mixins.less +67 -67
  73. package/lib/index.ts +32 -32
  74. package/lib/input-utils.less +41 -41
  75. package/lib/stacks-dynamic.less +24 -24
  76. package/lib/stacks-static.less +93 -93
  77. package/lib/stacks.less +13 -13
  78. package/lib/test/assertions.ts +36 -36
  79. package/lib/test/less-test-utils.ts +28 -28
  80. package/lib/test/open-wc-testing-patch.d.ts +26 -26
  81. package/lib/tsconfig.build.json +4 -4
  82. package/lib/tsconfig.json +17 -17
  83. package/package.json +26 -22
@@ -1,67 +1,67 @@
1
- /**
2
- * Generate base and responsive atomic spacing classes.
3
- *
4
- * Usage example:
5
- * .generate-spacing('.m', margin, true);
6
- * .generate-spacing('.ml', margin-left, true, percent);
7
- * .generate-spacing('.mx'; margin-left, margin-right; true);
8
- * .generate-spacing('.pr', padding-right);
9
- *
10
- * @prefix - (required) What prefix to generate (e.g. `.m`, `.pr`, etc).
11
- * @properties - (required) What CSS properties to generate (e.g. `margin`, `margin-right, margin-left`, etc).
12
- * @includeNegative: bool - Boolean to include generation of negative value classes.
13
- * @type: px | percent - What set of value to generate.
14
- */
15
- .generate-spacing(@prefix, @properties, @includeNegative: false, @type: px) {
16
- & when (@type = px) {
17
- #stacks-internals #build-classes(
18
- responsive,
19
- @prefix,
20
- { .template(@value) {
21
- each(@properties, #(@prop) {
22
- @{prop}: var(~"--su@{value}") !important;
23
- })
24
- } },
25
- 0 1 2 4 6 8 12 16 24 32 48 64 96 128
26
- );
27
-
28
- & when (@includeNegative = true) {
29
- #stacks-internals #build-classes(
30
- responsive,
31
- ~"@{prefix}n",
32
- { .template(@value) {
33
- each(@properties, #(@prop) {
34
- @{prop}: calc(var(~"--su@{value}") * -1) !important;
35
- })
36
- } },
37
- 1 2 4 6 8 12 16 24 32 48 64 96 128
38
- );
39
- }
40
- }
41
-
42
- & when (@type = percent) {
43
- #stacks-internals #build-classes(
44
- responsive,
45
- @prefix,
46
- { .template(@value) {
47
- each(@properties, #(@prop) {
48
- @{prop}: @value !important;
49
- })
50
- } },
51
- 50% 100%
52
- );
53
-
54
- & when (@includeNegative = true) {
55
- #stacks-internals #build-classes(
56
- responsive,
57
- ~"@{prefix}n",
58
- { .template(@value) {
59
- each(@properties, #(@prop) {
60
- @{prop}: -@value !important;
61
- })
62
- } },
63
- 50% 100%
64
- );
65
- }
66
- }
67
- }
1
+ /**
2
+ * Generate base and responsive atomic spacing classes.
3
+ *
4
+ * Usage example:
5
+ * .generate-spacing('.m', margin, true);
6
+ * .generate-spacing('.ml', margin-left, true, percent);
7
+ * .generate-spacing('.mx'; margin-left, margin-right; true);
8
+ * .generate-spacing('.pr', padding-right);
9
+ *
10
+ * @prefix - (required) What prefix to generate (e.g. `.m`, `.pr`, etc).
11
+ * @properties - (required) What CSS properties to generate (e.g. `margin`, `margin-right, margin-left`, etc).
12
+ * @includeNegative: bool - Boolean to include generation of negative value classes.
13
+ * @type: px | percent - What set of value to generate.
14
+ */
15
+ .generate-spacing(@prefix, @properties, @includeNegative: false, @type: px) {
16
+ & when (@type = px) {
17
+ #stacks-internals #build-classes(
18
+ responsive,
19
+ @prefix,
20
+ { .template(@value) {
21
+ each(@properties, #(@prop) {
22
+ @{prop}: var(~"--su@{value}") !important;
23
+ })
24
+ } },
25
+ 0 1 2 4 6 8 12 16 24 32 48 64 96 128
26
+ );
27
+
28
+ & when (@includeNegative = true) {
29
+ #stacks-internals #build-classes(
30
+ responsive,
31
+ ~"@{prefix}n",
32
+ { .template(@value) {
33
+ each(@properties, #(@prop) {
34
+ @{prop}: calc(var(~"--su@{value}") * -1) !important;
35
+ })
36
+ } },
37
+ 1 2 4 6 8 12 16 24 32 48 64 96 128
38
+ );
39
+ }
40
+ }
41
+
42
+ & when (@type = percent) {
43
+ #stacks-internals #build-classes(
44
+ responsive,
45
+ @prefix,
46
+ { .template(@value) {
47
+ each(@properties, #(@prop) {
48
+ @{prop}: @value !important;
49
+ })
50
+ } },
51
+ 50% 100%
52
+ );
53
+
54
+ & when (@includeNegative = true) {
55
+ #stacks-internals #build-classes(
56
+ responsive,
57
+ ~"@{prefix}n",
58
+ { .template(@value) {
59
+ each(@properties, #(@prop) {
60
+ @{prop}: -@value !important;
61
+ })
62
+ } },
63
+ 50% 100%
64
+ );
65
+ }
66
+ }
67
+ }
package/lib/index.ts CHANGED
@@ -1,32 +1,32 @@
1
- import "./stacks.less";
2
- import {
3
- BannerController,
4
- ExpandableController,
5
- ModalController,
6
- PopoverController,
7
- TableController,
8
- TabListController,
9
- ToastController,
10
- TooltipController,
11
- UploaderController,
12
- } from "./controllers";
13
- import { application, StacksApplication } from "./stacks";
14
-
15
- // register all built-in controllers
16
- application.register("s-banner", BannerController);
17
- application.register("s-expandable-control", ExpandableController);
18
- application.register("s-modal", ModalController);
19
- application.register("s-toast", ToastController);
20
- application.register("s-navigation-tablist", TabListController);
21
- application.register("s-popover", PopoverController);
22
- application.register("s-table", TableController);
23
- application.register("s-tooltip", TooltipController);
24
- application.register("s-uploader", UploaderController);
25
-
26
- // finalize the application to guard our controller namespace
27
- StacksApplication.finalize();
28
-
29
- // export all controllers w/ helpers
30
- export * from "./controllers";
31
- // export the entirety of the contents of stacks.ts
32
- export * from "./stacks";
1
+ import "./stacks.less";
2
+ import {
3
+ BannerController,
4
+ ExpandableController,
5
+ ModalController,
6
+ PopoverController,
7
+ TableController,
8
+ TabListController,
9
+ ToastController,
10
+ TooltipController,
11
+ UploaderController,
12
+ } from "./controllers";
13
+ import { application, StacksApplication } from "./stacks";
14
+
15
+ // register all built-in controllers
16
+ application.register("s-banner", BannerController);
17
+ application.register("s-expandable-control", ExpandableController);
18
+ application.register("s-modal", ModalController);
19
+ application.register("s-toast", ToastController);
20
+ application.register("s-navigation-tablist", TabListController);
21
+ application.register("s-popover", PopoverController);
22
+ application.register("s-table", TableController);
23
+ application.register("s-tooltip", TooltipController);
24
+ application.register("s-uploader", UploaderController);
25
+
26
+ // finalize the application to guard our controller namespace
27
+ StacksApplication.finalize();
28
+
29
+ // export all controllers w/ helpers
30
+ export * from "./controllers";
31
+ // export the entirety of the contents of stacks.ts
32
+ export * from "./stacks";
@@ -1,41 +1,41 @@
1
- .input-states(@rules) {
2
- .is-disabled &,
3
- .is-readonly &,
4
- .has-success &,
5
- .has-error &,
6
- .has-warning & {
7
- @rules();
8
- }
9
- };
10
-
11
- .validation-states(@prefix, @error: {}, @success: {}, @warning: {}) {
12
- .has-error &,
13
- .has-success &,
14
- .has-warning & {
15
- --_@{prefix}-bc-focus: ~"var(--_@{prefix}-bc)";
16
- }
17
-
18
- .has-error & {
19
- --_@{prefix}-bc: var(--red-400);
20
- @error();
21
- }
22
-
23
- .has-success & {
24
- --_@{prefix}-bc: var(--green-400);
25
- @success();
26
- }
27
-
28
- .has-warning & {
29
- --_@{prefix}-bc: var(--yellow-500);
30
- @warning();
31
- }
32
- }
33
-
34
- .is-disabled,
35
- .is-readonly,
36
- .has-success,
37
- .has-error,
38
- .has-warning {
39
- position: relative;
40
- }
41
-
1
+ .input-states(@rules) {
2
+ .is-disabled &,
3
+ .is-readonly &,
4
+ .has-success &,
5
+ .has-error &,
6
+ .has-warning & {
7
+ @rules();
8
+ }
9
+ };
10
+
11
+ .validation-states(@prefix, @error: {}, @success: {}, @warning: {}) {
12
+ .has-error &,
13
+ .has-success &,
14
+ .has-warning & {
15
+ --_@{prefix}-bc-focus: ~"var(--_@{prefix}-bc)";
16
+ }
17
+
18
+ .has-error & {
19
+ --_@{prefix}-bc: var(--red-400);
20
+ @error();
21
+ }
22
+
23
+ .has-success & {
24
+ --_@{prefix}-bc: var(--green-400);
25
+ @success();
26
+ }
27
+
28
+ .has-warning & {
29
+ --_@{prefix}-bc: var(--yellow-500);
30
+ @warning();
31
+ }
32
+ }
33
+
34
+ .is-disabled,
35
+ .is-readonly,
36
+ .has-success,
37
+ .has-error,
38
+ .has-warning {
39
+ position: relative;
40
+ }
41
+
@@ -1,24 +1,24 @@
1
- //
2
- // STACK OVERFLOW
3
- // DYNAMIC STACK ITEMS
4
- //
5
- // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
- // Stack Overflow. For documentation of all these classes and how to contribute,
7
- // visit https://stackoverflow.design/
8
- //
9
- // This is where all the magic happens.
10
- //
11
- //
12
- // ============================================================================
13
- // $ DYNAMIC ELEMENTS
14
- // The following items are elements which we allow communities to modify
15
- // via variables.
16
- // ----------------------------------------------------------------------------
17
- // -- SET BASIC STYLES FOR BODY
18
- @import "base/body.less";
19
- // -- LESS CONSTANTS AND MIXINS
20
- @import "exports/exports.less";
21
-
22
- // -- CONFIG
23
- @import "base/configuration-static.less";
24
- @import "base/internal.less";
1
+ //
2
+ // STACK OVERFLOW
3
+ // DYNAMIC STACK ITEMS
4
+ //
5
+ // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
+ // Stack Overflow. For documentation of all these classes and how to contribute,
7
+ // visit https://stackoverflow.design/
8
+ //
9
+ // This is where all the magic happens.
10
+ //
11
+ //
12
+ // ============================================================================
13
+ // $ DYNAMIC ELEMENTS
14
+ // The following items are elements which we allow communities to modify
15
+ // via variables.
16
+ // ----------------------------------------------------------------------------
17
+ // -- SET BASIC STYLES FOR BODY
18
+ @import "base/body.less";
19
+ // -- LESS CONSTANTS AND MIXINS
20
+ @import "exports/exports.less";
21
+
22
+ // -- CONFIG
23
+ @import "base/configuration-static.less";
24
+ @import "base/internal.less";
@@ -1,93 +1,93 @@
1
- // stacks-static.less contains styles which we DO NOT allow communities to modify via variables
2
- // BASE
3
- @import "base/reset.less";
4
- @import "base/fieldset.less";
5
- @import "base/icon.less";
6
- @import "input-utils.less";
7
-
8
- // -- COMPONENTS
9
- @import "components/activity-indicator/activity-indicator.less";
10
- @import "components/anchor/anchor.less";
11
- @import "components/avatar/avatar.less";
12
- @import "components/award-bling/award-bling.less";
13
- @import "components/badge/badge.less";
14
- @import "components/banner/banner.less";
15
- @import "components/block-link/block-link.less";
16
- @import "components/breadcrumbs/breadcrumbs.less";
17
- @import "components/button/button.less";
18
- @import "components/button-group/button-group.less";
19
- @import "components/card/card.less";
20
- @import "components/check-control/check-control.less";
21
- @import "components/check-group/check-group.less";
22
- @import "components/checkbox_radio/checkbox_radio.less";
23
- @import "components/code-block/code-block.less";
24
- @import "components/description/description.less";
25
- @import "components/empty-state/empty-state.less";
26
- @import "components/expandable/expandable.less";
27
- @import "components/input_textarea/input_textarea.less";
28
- @import "components/input-fill/input-fill.less";
29
- @import "components/input-icon/input-icon.less";
30
- @import "components/input-message/input-message.less";
31
- @import "components/label/label.less";
32
- @import "components/link/link.less";
33
- @import "components/link-preview/link-preview.less";
34
- @import "components/menu/menu.less";
35
- @import "components/modal/modal.less";
36
- @import "components/navigation/navigation.less";
37
- @import "components/notice/notice.less";
38
- @import "components/page-title/page-title.less";
39
- @import "components/pagination/pagination.less";
40
- @import "components/popover/popover.less";
41
- @import "components/post-summary/post-summary.less";
42
- @import "components/progress-bar/progress-bar.less";
43
- @import "components/prose/prose.less";
44
- @import "components/select/select.less";
45
- @import "components/sidebar-widget/sidebar-widget.less";
46
- @import "components/spinner/spinner.less";
47
- @import "components/table/table.less";
48
- @import "components/table-container/table-container.less";
49
- @import "components/tag/tag.less";
50
- @import "components/toast/toast.less";
51
- @import "components/toggle-switch/toggle-switch.less";
52
- @import "components/topbar/topbar.less";
53
- @import "components/uploader/uploader.less";
54
- @import "components/user-card/user-card.less";
55
-
56
- // LESS CONSTANTS AND MIXINS
57
- @import "exports/exports.less";
58
-
59
- // -- ATOMIC CLASSES
60
- @import "atomic/border.less";
61
- @import "atomic/color.less";
62
- @import "atomic/flex.less";
63
- @import "atomic/gap.less";
64
- @import "atomic/grid.less";
65
- @import "atomic/spacing.less";
66
- @import "atomic/typography.less";
67
- @import "atomic/misc.less";
68
- @import "atomic/width-height.less";
69
-
70
- /* stylelint-disable */
71
- #stacks-internals #screen-lg({
72
- #stacks-internals-collect-large();
73
- });
74
- #stacks-internals #screen-md({
75
- #stacks-internals-collect-medium();
76
- });
77
- #stacks-internals #screen-sm({
78
- #stacks-internals-collect-small();
79
- });
80
-
81
- @media print { // We need printing styles to be last so they can override all other styles.
82
- .print\:d-block & {
83
- display: block !important;
84
- }
85
- .print\:d-none & {
86
- display: none !important;
87
- }
88
- }
89
- /* stylelint-enable */
90
-
91
- // CONFIG
92
- @import "base/configuration-static.less";
93
- @import "base/internal.less";
1
+ // stacks-static.less contains styles which we DO NOT allow communities to modify via variables
2
+ // BASE
3
+ @import "base/reset.less";
4
+ @import "base/fieldset.less";
5
+ @import "base/icon.less";
6
+ @import "input-utils.less";
7
+
8
+ // -- COMPONENTS
9
+ @import "components/activity-indicator/activity-indicator.less";
10
+ @import "components/anchor/anchor.less";
11
+ @import "components/avatar/avatar.less";
12
+ @import "components/award-bling/award-bling.less";
13
+ @import "components/badge/badge.less";
14
+ @import "components/banner/banner.less";
15
+ @import "components/block-link/block-link.less";
16
+ @import "components/breadcrumbs/breadcrumbs.less";
17
+ @import "components/button/button.less";
18
+ @import "components/button-group/button-group.less";
19
+ @import "components/card/card.less";
20
+ @import "components/check-control/check-control.less";
21
+ @import "components/check-group/check-group.less";
22
+ @import "components/checkbox_radio/checkbox_radio.less";
23
+ @import "components/code-block/code-block.less";
24
+ @import "components/description/description.less";
25
+ @import "components/empty-state/empty-state.less";
26
+ @import "components/expandable/expandable.less";
27
+ @import "components/input_textarea/input_textarea.less";
28
+ @import "components/input-fill/input-fill.less";
29
+ @import "components/input-icon/input-icon.less";
30
+ @import "components/input-message/input-message.less";
31
+ @import "components/label/label.less";
32
+ @import "components/link/link.less";
33
+ @import "components/link-preview/link-preview.less";
34
+ @import "components/menu/menu.less";
35
+ @import "components/modal/modal.less";
36
+ @import "components/navigation/navigation.less";
37
+ @import "components/notice/notice.less";
38
+ @import "components/page-title/page-title.less";
39
+ @import "components/pagination/pagination.less";
40
+ @import "components/popover/popover.less";
41
+ @import "components/post-summary/post-summary.less";
42
+ @import "components/progress-bar/progress-bar.less";
43
+ @import "components/prose/prose.less";
44
+ @import "components/select/select.less";
45
+ @import "components/sidebar-widget/sidebar-widget.less";
46
+ @import "components/spinner/spinner.less";
47
+ @import "components/table/table.less";
48
+ @import "components/table-container/table-container.less";
49
+ @import "components/tag/tag.less";
50
+ @import "components/toast/toast.less";
51
+ @import "components/toggle-switch/toggle-switch.less";
52
+ @import "components/topbar/topbar.less";
53
+ @import "components/uploader/uploader.less";
54
+ @import "components/user-card/user-card.less";
55
+
56
+ // LESS CONSTANTS AND MIXINS
57
+ @import "exports/exports.less";
58
+
59
+ // -- ATOMIC CLASSES
60
+ @import "atomic/border.less";
61
+ @import "atomic/color.less";
62
+ @import "atomic/flex.less";
63
+ @import "atomic/gap.less";
64
+ @import "atomic/grid.less";
65
+ @import "atomic/spacing.less";
66
+ @import "atomic/typography.less";
67
+ @import "atomic/misc.less";
68
+ @import "atomic/width-height.less";
69
+
70
+ /* stylelint-disable */
71
+ #stacks-internals #screen-lg({
72
+ #stacks-internals-collect-large();
73
+ });
74
+ #stacks-internals #screen-md({
75
+ #stacks-internals-collect-medium();
76
+ });
77
+ #stacks-internals #screen-sm({
78
+ #stacks-internals-collect-small();
79
+ });
80
+
81
+ @media print { // We need printing styles to be last so they can override all other styles.
82
+ .print\:d-block & {
83
+ display: block !important;
84
+ }
85
+ .print\:d-none & {
86
+ display: none !important;
87
+ }
88
+ }
89
+ /* stylelint-enable */
90
+
91
+ // CONFIG
92
+ @import "base/configuration-static.less";
93
+ @import "base/internal.less";
package/lib/stacks.less CHANGED
@@ -1,13 +1,13 @@
1
- //
2
- // STACK OVERFLOW
3
- // THE COMPLETE STANDALONE STACKS
4
- //
5
- // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
- // Stack Overflow. For documentation of all these classes and how to contribute,
7
- // visit https://stackoverflow.design/
8
- //
9
- // This is where all the magic happens.
10
- //
11
- // ============================================================================
12
- @import "stacks-static.less";
13
- @import "stacks-dynamic.less";
1
+ //
2
+ // STACK OVERFLOW
3
+ // THE COMPLETE STANDALONE STACKS
4
+ //
5
+ // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
+ // Stack Overflow. For documentation of all these classes and how to contribute,
7
+ // visit https://stackoverflow.design/
8
+ //
9
+ // This is where all the magic happens.
10
+ //
11
+ // ============================================================================
12
+ @import "stacks-static.less";
13
+ @import "stacks-dynamic.less";
@@ -1,36 +1,36 @@
1
- import { expect } from "@open-wc/testing";
2
- import Color from "colorjs.io";
3
-
4
- type AdditionalAssertion = {
5
- description: string;
6
- assertion: (node: HTMLElement) => Promise<void> | void;
7
- };
8
-
9
- // TODO: evaluate if we can do this check against all the components
10
- // automatically instead of having to add the assertion manually
11
- const WCAGNonTextContrast: AdditionalAssertion = {
12
- description:
13
- "should pass WCAG22 1.4.11 non-text-contrast success criterion (https://www.w3.org/TR/WCAG22/#non-text-contrast)",
14
- assertion: (node) => {
15
- const selectedNode = node.querySelector(".is-selected") as HTMLElement;
16
- const selectedNodeStyles = window.getComputedStyle(selectedNode);
17
- const bodyStyles = window.getComputedStyle(document.body);
18
- const bgBodyColor = new Color(
19
- bodyStyles.getPropertyValue("background-color")
20
- );
21
- const bgSelectedNodeColor = new Color(
22
- selectedNodeStyles.getPropertyValue("background-color")
23
- );
24
-
25
- // we are specifing WCAG21 because of colorjs.io API
26
- // WCAG21 and WCAG22 algoirthms are the same
27
- const WCAGcontrast = bgSelectedNodeColor.contrast(
28
- bgBodyColor,
29
- "WCAG21"
30
- );
31
- expect(WCAGcontrast).to.be.at.least(3);
32
- },
33
- };
34
-
35
- export type { AdditionalAssertion };
36
- export { WCAGNonTextContrast };
1
+ import { expect } from "@open-wc/testing";
2
+ import Color from "colorjs.io";
3
+
4
+ type AdditionalAssertion = {
5
+ description: string;
6
+ assertion: (node: HTMLElement) => Promise<void> | void;
7
+ };
8
+
9
+ // TODO: evaluate if we can do this check against all the components
10
+ // automatically instead of having to add the assertion manually
11
+ const WCAGNonTextContrast: AdditionalAssertion = {
12
+ description:
13
+ "should pass WCAG22 1.4.11 non-text-contrast success criterion (https://www.w3.org/TR/WCAG22/#non-text-contrast)",
14
+ assertion: (node) => {
15
+ const selectedNode = node.querySelector(".is-selected") as HTMLElement;
16
+ const selectedNodeStyles = window.getComputedStyle(selectedNode);
17
+ const bodyStyles = window.getComputedStyle(document.body);
18
+ const bgBodyColor = new Color(
19
+ bodyStyles.getPropertyValue("background-color")
20
+ );
21
+ const bgSelectedNodeColor = new Color(
22
+ selectedNodeStyles.getPropertyValue("background-color")
23
+ );
24
+
25
+ // we are specifing WCAG21 because of colorjs.io API
26
+ // WCAG21 and WCAG22 algoirthms are the same
27
+ const WCAGcontrast = bgSelectedNodeColor.contrast(
28
+ bgBodyColor,
29
+ "WCAG21"
30
+ );
31
+ expect(WCAGcontrast).to.be.at.least(3);
32
+ },
33
+ };
34
+
35
+ export type { AdditionalAssertion };
36
+ export { WCAGNonTextContrast };