Skip to content

Commit 8ed7903

Browse files
committed
feat(widget@0.1.49): finish WCAG 2.2 Level AA compliance
1 parent c0ea0fc commit 8ed7903

6 files changed

Lines changed: 216 additions & 98 deletions

File tree

widget/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const minifyCSS = (input) => {
1111
targets: {
1212
chrome: 90 << 16,
1313
firefox: 90 << 16,
14-
safari: 14 << 16,
14+
safari: (14 << 16) | (1 << 8),
1515
},
1616
});
1717
return code.toString();

widget/src/cap.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ declare global {
33
CAP_CUSTOM_FETCH?: typeof fetch;
44
CAP_CUSTOM_WASM_URL?: string;
55
CAP_CSS_NONCE?: string;
6+
CAP_SCRIPT_NONCE?: string;
67
CAP_DONT_SKIP_REDEFINE?: boolean;
78
Cap: typeof Cap;
89
}

widget/src/cap.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

widget/src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cap.js/widget",
3-
"version": "0.1.48",
3+
"version": "0.1.49",
44
"description": "The self-hosted CAPTCHA for the modern web.",
55
"keywords": [
66
"algorithm",

widget/src/src/cap.css

Lines changed: 115 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
:host {
2+
display: inline-block;
3+
}
4+
15
@media (prefers-reduced-motion: reduce) {
26
.captcha,
37
.captcha * {
@@ -27,35 +31,22 @@
2731
}
2832

2933
.captcha {
34+
position: relative;
35+
display: inline-block;
36+
width: var(--cap-widget-width, 260px);
37+
height: var(--cap-widget-height, 58px);
3038
background-color: var(--cap-background, #fdfdfd);
3139
border: 1px solid var(--cap-border-color, #dddddd8f);
3240
border-radius: var(--cap-border-radius, 14px);
3341
user-select: none;
34-
height: var(--cap-widget-height, 58px);
35-
width: var(--cap-widget-width, 260px);
36-
display: flex;
37-
align-items: center;
38-
padding: var(--cap-widget-padding, 14px);
39-
gap: var(--cap-gap, 15px);
4042
cursor: pointer;
4143
transition:
4244
filter 0.2s,
43-
transform 0.2s;
44-
position: relative;
45+
transform 0.2s,
46+
height 0.2s;
4547
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
4648
overflow: hidden;
4749
color: var(--cap-color, #212121);
48-
}
49-
50-
.captcha:not([data-state]):active {
51-
transform: scale(0.97);
52-
}
53-
54-
.captcha:hover {
55-
filter: brightness(98%);
56-
}
57-
58-
.captcha * {
5950
font-family: var(
6051
--cap-font,
6152
system,
@@ -73,6 +64,38 @@
7364
);
7465
}
7566

67+
.captcha.has-troubleshoot {
68+
height: calc(var(--cap-widget-height, 58px) + 26px);
69+
}
70+
71+
.captcha.has-troubleshoot .captcha-trigger {
72+
inset-block-end: 26px;
73+
}
74+
75+
.captcha:not([data-state]):active {
76+
transform: scale(0.97);
77+
}
78+
79+
.captcha:hover {
80+
filter: brightness(98%);
81+
}
82+
83+
.captcha-trigger {
84+
position: absolute;
85+
inset: 0;
86+
display: flex;
87+
align-items: center;
88+
padding: var(--cap-widget-padding, 14px);
89+
gap: var(--cap-gap, 15px);
90+
border-radius: inherit;
91+
transition: inset 0.2s;
92+
}
93+
94+
.captcha-trigger:focus-visible {
95+
outline: 2px solid var(--cap-focus-ring, #0066cc);
96+
outline-offset: -3px;
97+
}
98+
7699
.checkbox {
77100
width: var(--cap-checkbox-size, 25px);
78101
height: var(--cap-checkbox-size, 25px);
@@ -82,6 +105,7 @@
82105
transition: opacity 0.2s;
83106
margin-top: var(--cap-checkbox-margin, 2px);
84107
margin-bottom: var(--cap-checkbox-margin, 2px);
108+
flex-shrink: 0;
85109
}
86110

87111
.captcha p {
@@ -106,7 +130,7 @@
106130
content: "";
107131
pointer-events: none;
108132
position: absolute;
109-
left: 0;
133+
inset-inline-start: 0;
110134
width: 100%;
111135
height: 0.6em;
112136
z-index: 1;
@@ -229,40 +253,100 @@
229253
}
230254
}
231255

232-
.captcha[disabled] {
256+
.captcha-trigger[disabled] {
233257
cursor: not-allowed;
234258
}
235259

236-
.captcha[disabled][data-state="verifying"] {
260+
.captcha[data-state="verifying"] .captcha-trigger {
237261
cursor: progress;
238262
}
239263

240-
.captcha[disabled][data-state="done"] {
264+
.captcha[data-state="done"] .captcha-trigger {
241265
cursor: default;
242266
}
243267

244-
.captcha .credits {
268+
.credits {
245269
position: absolute;
246-
bottom: 10px;
247-
right: 10px;
270+
inset-block-end: 4px;
271+
inset-inline-end: 4px;
248272
font-size: 12px !important;
249273
color: var(--cap-color, #212121);
250274
opacity: 0.8 !important;
251275
text-underline-offset: 0.18em;
252276
text-decoration-thickness: 0.08em;
253-
z-index: 6;
254-
display: block !important;
277+
z-index: 2;
278+
min-width: 24px;
279+
min-height: 24px;
280+
padding: 4px 6px;
281+
display: inline-flex !important;
282+
align-items: center;
283+
justify-content: flex-end;
284+
border-radius: 4px;
285+
text-decoration: underline;
286+
}
287+
288+
.credits:focus-visible {
289+
outline: 2px solid var(--cap-focus-ring, #0066cc);
290+
outline-offset: 2px;
291+
opacity: 1 !important;
255292
}
256293

257294
.cap-troubleshoot-link {
258-
color: #0066cc;
295+
position: absolute;
296+
inset-block-end: 4px;
297+
inset-inline-start: 14px;
298+
display: inline-flex;
299+
align-items: center;
300+
padding: 4px 6px;
301+
min-width: 24px;
302+
min-height: 24px;
303+
color: var(--cap-troubleshoot-color, #0050a0);
259304
text-decoration: underline;
260305
text-underline-offset: 0.15em;
261306
text-decoration-thickness: 0.08em;
262307
cursor: pointer;
263308
font-weight: 500;
264-
font-size: inherit;
309+
font-size: 13px;
310+
border-radius: 4px;
311+
z-index: 2;
265312
}
313+
314+
.cap-troubleshoot-link[hidden] {
315+
display: none;
316+
}
317+
266318
.cap-troubleshoot-link:hover {
267-
opacity: 0.8;
319+
opacity: 0.85;
320+
}
321+
322+
.cap-troubleshoot-link:focus-visible {
323+
outline: 2px solid var(--cap-focus-ring, #0066cc);
324+
outline-offset: 2px;
325+
}
326+
327+
@media (forced-colors: active) {
328+
.captcha {
329+
border-color: CanvasText;
330+
}
331+
.checkbox {
332+
border-color: CanvasText;
333+
}
334+
.captcha-trigger:focus-visible,
335+
.credits:focus-visible,
336+
.cap-troubleshoot-link:focus-visible {
337+
outline-color: Highlight;
338+
}
339+
.progress-ring-bg {
340+
stroke: GrayText;
341+
}
342+
.progress-ring-circle {
343+
stroke: CanvasText;
344+
}
345+
.captcha.invalid {
346+
border-color: Mark;
347+
box-shadow: none;
348+
}
349+
.credits {
350+
opacity: 1 !important;
351+
}
268352
}

0 commit comments

Comments
 (0)