@stackoverflow/stacks 2.0.0 → 2.0.2

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.
@@ -102,20 +102,20 @@
102
102
  600: hsl(27, 80%, 93%);
103
103
  }
104
104
  .set-orange-hc() {
105
- 100: hsl(22, 85%, 97%);
106
- 200: hsl(22, 85%, 97%);
105
+ 100: hsl(23, 87%, 97%);
106
+ 200: hsl(23, 87%, 97%);
107
107
  300: hsl(27, 90%, 55%);
108
108
  400: hsl(27, 90%, 55%);
109
109
  500: hsl(27, 80%, 28%);
110
110
  600: hsl(27, 80%, 28%);
111
111
  }
112
112
  .set-orange-hc-dark() {
113
- 100: hsl(27, 29%, 19%);
114
- 200: hsl(27, 29%, 19%);
115
- 300: hsl(27, 80%, 64%);
113
+ 100: hsl(27, 30%, 19%);
114
+ 200: hsl(27, 30%, 19%);
115
+ 300: hsl(27, 80%, 72%);
116
116
  400: hsl(27, 80%, 72%);
117
- 500: hsl(27, 79%, 89%);
118
- 600: hsl(27, 80%, 93%);
117
+ 500: hsl(28, 78%, 93%);
118
+ 600: hsl(28, 78%, 93%);
119
119
  }
120
120
 
121
121
  // Blue
@@ -144,12 +144,12 @@
144
144
  600: hsl(210, 80%, 23%);
145
145
  }
146
146
  .set-blue-hc-dark() {
147
- 100: hsl(209, 29%, 19%);
148
- 200: hsl(209, 29%, 19%);
147
+ 100: hsl(209, 30%, 19%);
148
+ 200: hsl(209, 30%, 19%);
149
149
  300: hsl(210, 80%, 72%);
150
150
  400: hsl(210, 80%, 75%);
151
- 500: hsl(209, 79%, 87%);
152
- 600: hsl(210, 80%, 93%);
151
+ 500: hsl(210, 78%, 93%);
152
+ 600: hsl(210, 78%, 93%);
153
153
  }
154
154
 
155
155
  // Green
@@ -174,26 +174,26 @@
174
174
  200: hsl(147, 36%, 95%);
175
175
  300: hsl(148, 70%, 31%);
176
176
  400: hsl(148, 75%, 22%);
177
- 500: hsl(147, 74%, 15%);
178
- 600: hsl(147, 74%, 15%);
177
+ 500: hsl(146, 74%, 15%);
178
+ 600: hsl(146, 74%, 15%);
179
179
  }
180
180
  .set-green-hc-dark() {
181
- 100: hsl(147, 29%, 19%);
182
- 200: hsl(147, 29%, 19%);
181
+ 100: hsl(147, 30%, 19%);
182
+ 200: hsl(147, 30%, 19%);
183
183
  300: hsl(148, 40%, 62%);
184
184
  400: hsl(148, 40%, 68%);
185
- 500: hsl(148, 39%, 87%);
186
- 600: hsl(148, 40%, 93%);
185
+ 500: hsl(150, 39%, 93%);
186
+ 600: hsl(150, 39%, 93%);
187
187
  }
188
188
 
189
189
  // Red
190
190
  .set-red() {
191
191
  100: hsl(0, 72%, 96%);
192
192
  200: hsl(0, 70%, 93%);
193
- 300: hsl(0, 65%, 76%);
193
+ 300: hsl(0, 66%, 80%);
194
194
  400: hsl(0, 60%, 49%);
195
195
  500: hsl(0, 65%, 37%);
196
- 600: hsl(0, 65%, 24%);
196
+ 600: hsl(0, 65%, 22%);
197
197
  }
198
198
  .set-red-dark() {
199
199
  100: hsl(358, 29%, 19%);
@@ -204,20 +204,20 @@
204
204
  600: hsl(0, 73%, 95%);
205
205
  }
206
206
  .set-red-hc() {
207
- 100: hsl(0, 79%, 96%);
208
- 200: hsl(0, 79%, 96%);
207
+ 100: hsl(0, 80%, 96%);
208
+ 200: hsl(0, 80%, 96%);
209
209
  300: hsl(0, 60%, 49%);
210
210
  400: hsl(0, 65%, 37%);
211
- 500: hsl(0, 66%, 24%);
212
- 600: hsl(0, 66%, 24%);
211
+ 500: hsl(0, 65%, 22%);
212
+ 600: hsl(0, 65%, 22%);
213
213
  }
214
214
  .set-red-hc-dark() {
215
- 100: hsl(358, 29%, 19%);
216
- 200: hsl(358, 29%, 19%);
215
+ 100: hsl(358, 30%, 19%);
216
+ 200: hsl(358, 30%, 19%);
217
217
  300: hsl(0, 75%, 77%);
218
218
  400: hsl(0, 73%, 80%);
219
- 500: hsl(0, 70%, 92%);
220
- 600: hsl(0, 73%, 95%);
219
+ 500: hsl(0, 76%, 95%);
220
+ 600: hsl(0, 76%, 95%);
221
221
  }
222
222
 
223
223
  // Yellow
@@ -248,10 +248,10 @@
248
248
  .set-yellow-hc-dark() {
249
249
  100: hsl(43, 29%, 17%);
250
250
  200: hsl(43, 29%, 17%);
251
- 300: hsl(43, 59%, 64%);
251
+ 300: hsl(43, 75%, 75%);
252
252
  400: hsl(43, 75%, 75%);
253
253
  500: hsl(48, 74%, 91%);
254
- 600: hsl(43, 75%, 91%);
254
+ 600: hsl(44, 74%, 91%);
255
255
  }
256
256
 
257
257
  // Purple
@@ -264,8 +264,8 @@
264
264
  600: hsl(237, 50%, 32%);
265
265
  }
266
266
  .set-purple-dark() {
267
- 100: hsl(238, 24%, 23%);
268
- 200: hsl(238, 27%, 34%);
267
+ 100: hsl(237, 24%, 23%);
268
+ 200: hsl(237, 27%, 34%);
269
269
  300: hsl(237, 32%, 56%);
270
270
  400: hsl(237, 60%, 82%);
271
271
  500: hsl(237, 60%, 88%);
@@ -273,7 +273,7 @@
273
273
  }
274
274
  .set-purple-hc() {
275
275
  100: hsl(237, 83%, 98%);
276
- 200: hsl(237, 80%, 96%);
276
+ 200: hsl(237, 83%, 98%);
277
277
  300: hsl(237, 55%, 57%);
278
278
  400: hsl(237, 55%, 57%);
279
279
  500: hsl(237, 50%, 32%);
@@ -282,10 +282,10 @@
282
282
  .set-purple-hc-dark() {
283
283
  100: hsl(237, 24%, 23%);
284
284
  200: hsl(237, 24%, 23%);
285
- 300: hsl(237, 58%, 86%);
285
+ 300: hsl(237, 60%, 82%);
286
286
  400: hsl(237, 60%, 82%);
287
- 500: hsl(237, 65%, 96%);
288
- 600: hsl(237, 65%, 96%);
287
+ 500: hsl(237, 62%, 96%);
288
+ 600: hsl(237, 62%, 96%);
289
289
  }
290
290
 
291
291
  // gold
@@ -331,12 +331,12 @@
331
331
  100: hsl(0, 0%, 95%);
332
332
  200: hsl(0, 0%, 95%);
333
333
  300: hsl(210, 5%, 68%);
334
- 400: hsl(216, 2%, 40%);
334
+ 400: hsl(210, 2%, 40%);
335
335
  }
336
336
  .set-silver-hc-dark() {
337
337
  100: hsl(220, 2%, 26%);
338
338
  200: hsl(220, 2%, 26%);
339
- 300: hsl(216, 4%, 69%);
339
+ 300: hsl(220, 4%, 69%);
340
340
  400: hsl(214, 8%, 83%);
341
341
  }
342
342
 
@@ -360,8 +360,8 @@
360
360
  400: hsl(28, 43%, 39%);
361
361
  }
362
362
  .set-bronze-hc-dark() {
363
- 100: hsl(28, 13%, 27%);
364
- 200: hsl(28, 13%, 27%);
363
+ 100: hsl(27, 13%, 27%);
364
+ 200: hsl(27, 13%, 27%);
365
365
  300: hsl(28, 58%, 67%);
366
366
  400: hsl(28, 59%, 83%);
367
367
  }
@@ -3,7 +3,7 @@ import { screen } from "@testing-library/dom";
3
3
  import { visualDiff } from "@web/test-runner-visual-regression";
4
4
  import type { TemplateResult } from "lit-html";
5
5
  import axe from "axe-core";
6
- import registerAxeAPCA from "./axe-apca";
6
+ import registerAxeAPCA from "axe-apca";
7
7
 
8
8
  const customConformanceThresholdFn = (fontSize: string): number | null => {
9
9
  return parseFloat(fontSize) >= 32 ? 45 : 60;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/StackExchange/Stacks.git"
7
7
  },
8
- "version": "2.0.0",
8
+ "version": "2.0.2",
9
9
  "files": [
10
10
  "dist",
11
11
  "lib"
@@ -44,24 +44,24 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@11ty/eleventy": "^2.0.1",
47
- "@highlightjs/cdn-assets": "^11.8.0",
47
+ "@highlightjs/cdn-assets": "^11.9.0",
48
48
  "@open-wc/testing": "^3.2.0",
49
49
  "@rollup/plugin-commonjs": "^25.0.4",
50
- "@rollup/plugin-replace": "^5.0.2",
51
- "@stackoverflow/stacks-editor": "^0.8.9",
52
- "@stackoverflow/stacks-icons": "^5.5.0",
50
+ "@rollup/plugin-replace": "^5.0.4",
51
+ "@stackoverflow/stacks-editor": "^0.9.0",
52
+ "@stackoverflow/stacks-icons": "^6.0.0",
53
53
  "@testing-library/dom": "^9.3.3",
54
54
  "@testing-library/user-event": "^14.5.1",
55
55
  "@types/cssbeautify": "^0.3.2",
56
56
  "@types/less": "^3.0.3",
57
- "@typescript-eslint/eslint-plugin": "^6.7.3",
58
- "@typescript-eslint/parser": "^6.7.2",
57
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
58
+ "@typescript-eslint/parser": "^6.7.5",
59
59
  "@web/dev-server-esbuild": "^0.4.1",
60
60
  "@web/dev-server-rollup": "^0.5.2",
61
61
  "@web/test-runner": "^0.17.1",
62
62
  "@web/test-runner-playwright": "^0.10.1",
63
63
  "@web/test-runner-visual-regression": "^0.8.2",
64
- "apca-w3": "^0.1.9",
64
+ "axe-apca": "^0.0.3",
65
65
  "concurrently": "^8.2.1",
66
66
  "css-loader": "^6.8.1",
67
67
  "cssbeautify": "^0.3.1",
@@ -75,7 +75,7 @@
75
75
  "jquery": "^3.7.1",
76
76
  "less-loader": "^11.1.3",
77
77
  "list.js": "^2.3.1",
78
- "markdown-it": "^13.0.1",
78
+ "markdown-it": "^13.0.2",
79
79
  "mini-css-extract-plugin": "^2.7.6",
80
80
  "postcss-less": "^6.0.0",
81
81
  "postcss-loader": "^7.3.3",
@@ -85,7 +85,7 @@
85
85
  "stylelint-config-recommended": "^13.0.0",
86
86
  "stylelint-config-standard": "^34.0.0",
87
87
  "terser-webpack-plugin": "^5.3.9",
88
- "ts-loader": "^9.4.4",
88
+ "ts-loader": "^9.5.0",
89
89
  "typescript": "^5.2.2",
90
90
  "vitest": "^0.33.0",
91
91
  "webpack": "^5.88.2",
@@ -1,53 +0,0 @@
1
- # axe-apca
2
-
3
- ⚠️ *Once this package become more mature and stable it should be extracted in its own repo (e.g. StackExchange/axe-apca) and published as an npm package. This will allow to use the rule/checks in many contexts including our Core codebase.*
4
-
5
- This package contains custom axe rules and checks for [APCA](https://readtech.org/) Bronze and Silver+ [conformance levels](https://readtech.org/ARC/tests/visual-readability-contrast/?tn=criterion).
6
-
7
- ## Usage
8
-
9
- ### Installation
10
-
11
- ⚠️ *The following command doesn't work because this package is not published on npm yet.*
12
-
13
- ```bash
14
- npm install --save-dev axe-core axe-apca
15
- ```
16
-
17
- ### Setup
18
-
19
- ```js
20
- import axe from "axe-core";
21
- import { registerAxeAPCA } from 'axe-apca';
22
-
23
- registerAxeAPCA('bronze'); // or registerAxeAPCA('silver');
24
-
25
- // consider turning off default WCAG 2.1 AA color contrast rules when using APCA
26
- axe.configure({
27
- rules: [{ id: "color-contrast", enabled: false }]
28
- })
29
-
30
- axe.run(document, (err, results) => {
31
- if (err) throw err;
32
- console.log(results);
33
- });
34
- ```
35
-
36
- ### Using custom APCA thresholds
37
-
38
- To set custom thresholds for APCA checks, follow these steps:
39
-
40
- 1. Use `custom` as the first argument when calling `registerAxeAPCA`.
41
- 1. Provide a function as the second argument, optionally accepting `fontSize` and `fontWeight` arguments.
42
-
43
-
44
- ```js
45
- const customConformanceThresholdFn = (fontSize, fontWeight) => {
46
- const size = parseFloat(fontSize);
47
- const weight = parseFloat(fontWeight);
48
-
49
- return size >= 32 || weight > 700 ? 45 : 60;
50
- };
51
-
52
- registerAxeAPCA('custom', customConformanceThresholdFn);
53
- ```
@@ -1,3 +0,0 @@
1
- import registerAxeAPCA from "./src/axe-apca";
2
-
3
- export default registerAxeAPCA;
@@ -1,30 +0,0 @@
1
- {
2
- "name": "axe-apca",
3
- "description": "Axe rules to check against APCA bronze and silver+ conformance levels.",
4
- "repository": {
5
- "type": "git",
6
- "url": "https://github.com/StackExchange/axe-apca.git"
7
- },
8
- "version": "0.0.0",
9
- "main": "TODO",
10
- "types": "TODO",
11
- "scripts": {
12
- "build": "TODO: transpile ts to js",
13
- "test": "web-test-runner"
14
- },
15
- "license": "MIT",
16
- "dependencies": {
17
- "apca-w3": "^0.1.9"
18
- },
19
- "peerDependencies": {
20
- "axe-core": "^4.0.0"
21
- },
22
- "devDependencies": {
23
- "@open-wc/testing": "^3.2.0",
24
- "@web/dev-server-esbuild": "^0.4.1",
25
- "@web/dev-server-rollup": "^0.5.2",
26
- "@web/test-runner": "^0.16.1",
27
- "@web/test-runner-playwright": "^0.10.1",
28
- "typescript": "^5.1.6"
29
- }
30
- }
@@ -1,3 +0,0 @@
1
- declare module "apca-w3" {
2
- export function calcAPCA(textColor: string, bgColor: string): number;
3
- }
@@ -1,231 +0,0 @@
1
- import { html, fixture, expect } from "@open-wc/testing";
2
- import axe from "axe-core";
3
- import type { AxeResults } from "axe-core";
4
- import registerAxeAPCA from "./axe-apca";
5
-
6
- const runAxe = async (el: HTMLElement): Promise<AxeResults> => {
7
- return new Promise((resolve, reject) => {
8
- axe.run(el, (err, results) => {
9
- if (err) reject(err);
10
- resolve(results);
11
- });
12
- });
13
- };
14
-
15
- describe("axe-apca", () => {
16
- describe("custom conformance level", () => {
17
- beforeEach(() => {
18
- const customConformanceThresholdFn = (
19
- fontSize: string
20
- ): number | null => {
21
- return parseFloat(fontSize) >= 32 ? 45 : 60;
22
- };
23
-
24
- registerAxeAPCA("custom", customConformanceThresholdFn);
25
- });
26
-
27
- it("should check for APCA accessibility contrast violations", async () => {
28
- const el: HTMLElement = await fixture(
29
- html`<p
30
- style="background: white; color: black; font-size: 12px; font-weight: 400;"
31
- >
32
- Some copy
33
- </p>`
34
- );
35
-
36
- const results = await runAxe(el);
37
-
38
- const apcaPasses = results.passes.filter((violation) =>
39
- violation.id.includes("color-contrast-apca-custom")
40
- );
41
-
42
- await expect(apcaPasses.length).to.equal(1);
43
-
44
- const passNode = apcaPasses[0].nodes[0];
45
- expect(passNode.all[0].message).to.include(
46
- "Element has sufficient APCA custom level lightness contrast"
47
- );
48
- });
49
-
50
- it("should detect APCA accessibility contrast violations", async () => {
51
- const el: HTMLElement = await fixture(
52
- html`<p
53
- style="background: white; color: lightgray; font-size: 12px; font-weight: 400;"
54
- >
55
- Some copy
56
- </p>`
57
- );
58
-
59
- const results = await runAxe(el);
60
-
61
- const apcaViolations = results.violations.filter((violation) =>
62
- violation.id.includes("color-contrast-apca-custom")
63
- );
64
-
65
- await expect(apcaViolations.length).to.equal(1);
66
-
67
- const violationNode = apcaViolations[0].nodes[0];
68
- expect(violationNode.failureSummary).to.include(
69
- "Element has insufficient APCA custom level contrast"
70
- );
71
- });
72
-
73
- it("should check nested nodes", async () => {
74
- const el: HTMLElement = await fixture(
75
- html`<div style="background: black;">
76
- <h2>Some title</h2>
77
- <p>Some copy</p>
78
- <button style="background: black;">Some button</button>
79
- </div>`
80
- );
81
-
82
- const results = await runAxe(el);
83
-
84
- const apcaViolations = results.violations.filter((violation) =>
85
- violation.id.includes("color-contrast-apca-custom")
86
- );
87
-
88
- await expect(apcaViolations[0].nodes.length).to.equal(3);
89
- });
90
- });
91
-
92
- describe("bronze conformance level", () => {
93
- beforeEach(() => {
94
- registerAxeAPCA("bronze");
95
- });
96
-
97
- it("should check for APCA accessibility contrast violations", async () => {
98
- const el: HTMLElement = await fixture(
99
- html`<p
100
- style="background: white; color: black; font-size: 12px; font-weight: 400;"
101
- >
102
- Some copy
103
- </p>`
104
- );
105
-
106
- const results = await runAxe(el);
107
-
108
- const apcaPasses = results.passes.filter((violation) =>
109
- violation.id.includes("color-contrast-apca-bronze")
110
- );
111
-
112
- await expect(apcaPasses.length).to.equal(1);
113
-
114
- const passNode = apcaPasses[0].nodes[0];
115
- expect(passNode.all[0].message).to.include(
116
- "Element has sufficient APCA bronze level lightness contrast"
117
- );
118
- });
119
-
120
- it("should detect APCA accessibility contrast violations", async () => {
121
- const el: HTMLElement = await fixture(
122
- html`<p
123
- style="background: white; color: gray; font-size: 12px; font-weight: 400;"
124
- >
125
- Some copy
126
- </p>`
127
- );
128
-
129
- const results = await runAxe(el);
130
-
131
- const apcaViolations = results.violations.filter((violation) =>
132
- violation.id.includes("color-contrast-apca-bronze")
133
- );
134
-
135
- await expect(apcaViolations.length).to.equal(1);
136
-
137
- const violationNode = apcaViolations[0].nodes[0];
138
- expect(violationNode.failureSummary).to.include(
139
- "Element has insufficient APCA bronze level contrast"
140
- );
141
- });
142
-
143
- it("should check nested nodes", async () => {
144
- const el: HTMLElement = await fixture(
145
- html`<div style="background: black;">
146
- <h2>Some title</h2>
147
- <p>Some copy</p>
148
- <button style="background: black;">Some button</button>
149
- </div>`
150
- );
151
-
152
- const results = await runAxe(el);
153
-
154
- const apcaViolations = results.violations.filter((violation) =>
155
- violation.id.includes("color-contrast-apca-bronze")
156
- );
157
-
158
- await expect(apcaViolations[0].nodes.length).to.equal(3);
159
- });
160
- });
161
-
162
- describe("silver conformance level", () => {
163
- beforeEach(() => {
164
- registerAxeAPCA("silver");
165
- });
166
-
167
- it("should check for APCA accessibility contrast violations", async () => {
168
- const el: HTMLElement = await fixture(
169
- html`<p
170
- style="background: white; color: black; font-size: 14px; font-weight: 400;"
171
- >
172
- Some copy
173
- </p>`
174
- );
175
-
176
- const results = await runAxe(el);
177
-
178
- const apcaPasses = results.passes.filter((violation) =>
179
- violation.id.includes("color-contrast-apca-silver")
180
- );
181
-
182
- await expect(apcaPasses.length).to.equal(1);
183
-
184
- const passNode = apcaPasses[0].nodes[0];
185
- expect(passNode.all[0].message).to.include(
186
- "Element has sufficient APCA silver level lightness contrast"
187
- );
188
- });
189
-
190
- it("should detect APCA accessibility contrast violations", async () => {
191
- const el: HTMLElement = await fixture(
192
- html`<p
193
- style="background: white; color: black; font-size: 12px; font-weight: 400;"
194
- >
195
- Some copy
196
- </p>`
197
- );
198
-
199
- const results = await runAxe(el);
200
-
201
- const apcaViolations = results.violations.filter((violation) =>
202
- violation.id.includes("color-contrast-apca-silver")
203
- );
204
-
205
- await expect(apcaViolations.length).to.equal(1);
206
-
207
- const violationNode = apcaViolations[0].nodes[0];
208
- expect(violationNode.failureSummary).to.include(
209
- "Element has insufficient APCA silver level contrast"
210
- );
211
- });
212
-
213
- it("should check nested nodes", async () => {
214
- const el: HTMLElement = await fixture(
215
- html`<div style="background: black;">
216
- <h2>Some title</h2>
217
- <p>Some copy</p>
218
- <button style="background: black;">Some button</button>
219
- </div>`
220
- );
221
-
222
- const results = await runAxe(el);
223
-
224
- const apcaViolations = results.violations.filter((violation) =>
225
- violation.id.includes("color-contrast-apca-silver")
226
- );
227
-
228
- await expect(apcaViolations[0].nodes.length).to.equal(3);
229
- });
230
- });
231
- });