@fabrika/ui 0.9.0-dev.3 → 0.9.0-dev.5
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/package.json +1 -1
- package/src/Challenge.tsx +14 -6
- package/src/components.css +29 -0
- package/types/src/Challenge.d.ts +4 -3
package/package.json
CHANGED
package/src/Challenge.tsx
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
// challenge the application issued, solves its proof of work in workers, and the page sends the payload as the
|
|
3
3
|
// procedure's `challengeToken`. Nothing is loaded from a third party: the widget is bundled with the page.
|
|
4
4
|
//
|
|
5
|
+
// To the visitor it is a part of the page, not a third party's badge: the widget's logo and attribution footer are
|
|
6
|
+
// hidden (the library's MIT license asks for neither), and `.fui-challenge` sets its theme variables from the kit's
|
|
7
|
+
// tokens.
|
|
8
|
+
//
|
|
5
9
|
// The one module of the kit with a runtime dependency, the optional peer `altcha`, which registers `<altcha-widget>`
|
|
6
10
|
// when this module loads; the kit's root never imports it.
|
|
7
11
|
|
|
@@ -13,7 +17,7 @@ import { classNames } from './class-names'
|
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* The texts the widget renders as text, each with the widget's English default. Its footer is not among them: the
|
|
16
|
-
* widget renders that one as HTML,
|
|
20
|
+
* widget renders that one as HTML, and the kit hides it.
|
|
17
21
|
*/
|
|
18
22
|
export interface ChallengeStrings {
|
|
19
23
|
readonly label: string
|
|
@@ -24,7 +28,8 @@ export interface ChallengeStrings {
|
|
|
24
28
|
readonly error: string
|
|
25
29
|
readonly reload: string
|
|
26
30
|
readonly waitAlert: string
|
|
27
|
-
|
|
31
|
+
/** @deprecated The label of the widget's logo link, which the kit hides; it reaches nothing, so it is not sent. */
|
|
32
|
+
readonly ariaLinkLabel?: string
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
export interface ChallengeProps {
|
|
@@ -46,11 +51,14 @@ export interface ChallengeProps {
|
|
|
46
51
|
/** The input a procedure with a challenge reads its token from; `@fabrika/app`'s `CHALLENGE_FIELD`. */
|
|
47
52
|
const CHALLENGE_FIELD = 'challengeToken'
|
|
48
53
|
|
|
54
|
+
/** The widget's configuration: no logo and no footer, both of which name and link the library. */
|
|
55
|
+
const CONFIGURATION = JSON.stringify({ hideLogo: true, hideFooter: true })
|
|
56
|
+
|
|
49
57
|
/** Each set of strings is registered once with the widget, under a language code of its own. */
|
|
50
58
|
const registered = new Map<string, string>()
|
|
51
59
|
|
|
52
|
-
/** The fields of `ChallengeStrings
|
|
53
|
-
const TEXT_FIELDS: readonly
|
|
60
|
+
/** The fields of `ChallengeStrings` that reach the widget, whatever else an object passed as one carries. */
|
|
61
|
+
const TEXT_FIELDS: readonly Exclude<keyof ChallengeStrings, 'ariaLinkLabel'>[] = [
|
|
54
62
|
'label',
|
|
55
63
|
'verifying',
|
|
56
64
|
'verified',
|
|
@@ -59,7 +67,6 @@ const TEXT_FIELDS: readonly (keyof ChallengeStrings)[] = [
|
|
|
59
67
|
'error',
|
|
60
68
|
'reload',
|
|
61
69
|
'waitAlert',
|
|
62
|
-
'ariaLinkLabel',
|
|
63
70
|
]
|
|
64
71
|
|
|
65
72
|
function languageOf(given: Partial<ChallengeStrings> | undefined): string | undefined {
|
|
@@ -97,7 +104,7 @@ function tokenOf(event: Event): string | null | undefined {
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
/**
|
|
100
|
-
* The
|
|
107
|
+
* The proof-of-work widget for one procedure's challenge. A challenge passes once: after a refused submission, give the
|
|
101
108
|
* component a new `key` so the visitor solves a fresh one.
|
|
102
109
|
*/
|
|
103
110
|
export function Challenge({ url, onToken, name = CHALLENGE_FIELD, auto = 'off', strings, className }: ChallengeProps) {
|
|
@@ -121,6 +128,7 @@ export function Challenge({ url, onToken, name = CHALLENGE_FIELD, auto = 'off',
|
|
|
121
128
|
ref={host}
|
|
122
129
|
className={classNames('fui-challenge', className)}
|
|
123
130
|
challenge={url}
|
|
131
|
+
configuration={CONFIGURATION}
|
|
124
132
|
name={name}
|
|
125
133
|
auto={auto}
|
|
126
134
|
language={languageOf(strings)}
|
package/src/components.css
CHANGED
|
@@ -520,6 +520,35 @@
|
|
|
520
520
|
gap: var(--fui-space-4);
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
+
/* Challenge: the widget's own theme variables, set from the kit's tokens on its element, which its parts inherit. */
|
|
524
|
+
|
|
525
|
+
.fui-challenge {
|
|
526
|
+
display: block;
|
|
527
|
+
font-family: var(--fui-font-family);
|
|
528
|
+
font-size: var(--fui-text-md);
|
|
529
|
+
--altcha-color-base: var(--fui-surface);
|
|
530
|
+
--altcha-color-base-content: var(--fui-text);
|
|
531
|
+
--altcha-color-neutral: var(--fui-border-strong);
|
|
532
|
+
--altcha-color-neutral-content: var(--fui-text-muted);
|
|
533
|
+
--altcha-color-primary: var(--fui-accent);
|
|
534
|
+
--altcha-color-primary-content: var(--fui-accent-contrast);
|
|
535
|
+
--altcha-color-success: var(--fui-success);
|
|
536
|
+
--altcha-color-success-content: var(--fui-accent-contrast);
|
|
537
|
+
--altcha-color-error: var(--fui-danger);
|
|
538
|
+
--altcha-color-error-content: var(--fui-accent-contrast);
|
|
539
|
+
--altcha-border-color: var(--fui-border);
|
|
540
|
+
--altcha-border-width: var(--fui-border-width);
|
|
541
|
+
--altcha-border-radius: var(--fui-radius-md);
|
|
542
|
+
--altcha-padding: var(--fui-space-3);
|
|
543
|
+
--altcha-checkbox-size: var(--fui-check-size);
|
|
544
|
+
--altcha-checkbox-border-color: var(--fui-border-strong);
|
|
545
|
+
--altcha-checkbox-border-radius: var(--fui-radius-sm);
|
|
546
|
+
--altcha-checkbox-outline: var(--fui-focus-width) solid var(--fui-focus);
|
|
547
|
+
--altcha-input-background-color: var(--fui-surface);
|
|
548
|
+
--altcha-input-border-radius: var(--fui-radius-sm);
|
|
549
|
+
--altcha-spinner-color: var(--fui-text-muted);
|
|
550
|
+
}
|
|
551
|
+
|
|
523
552
|
/* Button */
|
|
524
553
|
|
|
525
554
|
.fui-button {
|
package/types/src/Challenge.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'altcha';
|
|
2
2
|
/**
|
|
3
3
|
* The texts the widget renders as text, each with the widget's English default. Its footer is not among them: the
|
|
4
|
-
* widget renders that one as HTML,
|
|
4
|
+
* widget renders that one as HTML, and the kit hides it.
|
|
5
5
|
*/
|
|
6
6
|
export interface ChallengeStrings {
|
|
7
7
|
readonly label: string;
|
|
@@ -12,7 +12,8 @@ export interface ChallengeStrings {
|
|
|
12
12
|
readonly error: string;
|
|
13
13
|
readonly reload: string;
|
|
14
14
|
readonly waitAlert: string;
|
|
15
|
-
|
|
15
|
+
/** @deprecated The label of the widget's logo link, which the kit hides; it reaches nothing, so it is not sent. */
|
|
16
|
+
readonly ariaLinkLabel?: string;
|
|
16
17
|
}
|
|
17
18
|
export interface ChallengeProps {
|
|
18
19
|
/** Where the widget fetches its challenge: `challengeUrl(api.<procedure>)` of `@fabrika/app/client`. */
|
|
@@ -30,7 +31,7 @@ export interface ChallengeProps {
|
|
|
30
31
|
readonly className?: string;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
|
-
* The
|
|
34
|
+
* The proof-of-work widget for one procedure's challenge. A challenge passes once: after a refused submission, give the
|
|
34
35
|
* component a new `key` so the visitor solves a fresh one.
|
|
35
36
|
*/
|
|
36
37
|
export declare function Challenge({ url, onToken, name, auto, strings, className }: ChallengeProps): import("react").JSX.Element;
|