@connextar/house 0.23.0 → 0.23.3
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/README.md +27 -3
- package/dist/analytics/browser.d.ts +1 -0
- package/dist/analytics/browser.d.ts.map +1 -1
- package/dist/analytics/browser.js +20 -3
- package/dist/analytics/browser.js.map +1 -1
- package/dist/analytics/config.d.ts +5 -0
- package/dist/analytics/config.d.ts.map +1 -1
- package/dist/analytics/config.js +4 -1
- package/dist/analytics/config.js.map +1 -1
- package/dist/analytics/react.d.ts.map +1 -1
- package/dist/analytics/react.js +4 -2
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics/redact.d.ts.map +1 -1
- package/dist/analytics/redact.js +6 -1
- package/dist/analytics/redact.js.map +1 -1
- package/dist/rate-limit/prisma-index.d.ts +1 -1
- package/dist/rate-limit/prisma-index.d.ts.map +1 -1
- package/dist/rate-limit/prisma-index.js.map +1 -1
- package/dist/rate-limit/prisma.d.ts +10 -1
- package/dist/rate-limit/prisma.d.ts.map +1 -1
- package/dist/rate-limit/prisma.js +2 -1
- package/dist/rate-limit/prisma.js.map +1 -1
- package/package.json +5 -2
- package/src/account/data-contract.ts +112 -0
- package/src/account/index.ts +11 -0
- package/src/admin/access.ts +267 -0
- package/src/admin/audit.ts +238 -0
- package/src/admin/bootstrap.ts +220 -0
- package/src/admin/client-index.ts +19 -0
- package/src/admin/client.tsx +187 -0
- package/src/admin/index.ts +91 -0
- package/src/admin/proof.ts +155 -0
- package/src/admin/second-factor-index.ts +16 -0
- package/src/admin/second-factor.ts +403 -0
- package/src/admin/testing-index.ts +13 -0
- package/src/admin/testing.ts +299 -0
- package/src/admin/view-as.ts +511 -0
- package/src/ai/config-index.ts +40 -0
- package/src/ai/config.ts +176 -0
- package/src/ai/images.ts +18 -0
- package/src/ai/index.ts +21 -0
- package/src/ai/pricing.ts +107 -0
- package/src/ai/provider.ts +403 -0
- package/src/analytics/browser.ts +400 -0
- package/src/analytics/client-index.ts +12 -0
- package/src/analytics/config.ts +89 -0
- package/src/analytics/index.ts +17 -0
- package/src/analytics/ingest.ts +81 -0
- package/src/analytics/react-index.ts +16 -0
- package/src/analytics/react.tsx +241 -0
- package/src/analytics/redact.ts +146 -0
- package/src/analytics/server-index.ts +17 -0
- package/src/analytics/server.ts +277 -0
- package/src/auth/index.ts +30 -0
- package/src/auth/second-factor-index.ts +16 -0
- package/src/auth/second-factor-next.ts +136 -0
- package/src/auth/second-factor-routes.ts +40 -0
- package/src/auth/second-factor.ts +226 -0
- package/src/auth/step-up-client-index.ts +13 -0
- package/src/auth/step-up-client.ts +23 -0
- package/src/auth/step-up-index.ts +19 -0
- package/src/auth/step-up-routes.ts +99 -0
- package/src/auth/step-up.ts +432 -0
- package/src/auth/two-factor-policy.ts +112 -0
- package/src/changelog/changelog.tsx +367 -0
- package/src/changelog/index.ts +12 -0
- package/src/editor/block-handle.tsx +312 -0
- package/src/editor/blocks.ts +169 -0
- package/src/editor/bubble-toolbar.tsx +208 -0
- package/src/editor/collapsible.ts +159 -0
- package/src/editor/content-index.ts +1 -0
- package/src/editor/content.tsx +343 -0
- package/src/editor/editor.tsx +333 -0
- package/src/editor/emoji-index.ts +1 -0
- package/src/editor/emoji-picker.tsx +114 -0
- package/src/editor/emoji.ts +436 -0
- package/src/editor/index.ts +6 -0
- package/src/editor/sections.ts +83 -0
- package/src/editor/suggestion-popup.tsx +136 -0
- package/src/editor/suggestions.ts +309 -0
- package/src/editor/ui.tsx +171 -0
- package/src/errors/error-shell.tsx +72 -0
- package/src/errors/global-error-shell.tsx +116 -0
- package/src/errors/index.ts +2 -0
- package/src/grid/columns.ts +48 -0
- package/src/grid/compare.ts +35 -0
- package/src/grid/hidden-columns.ts +95 -0
- package/src/grid/index.ts +27 -0
- package/src/grid/use-grid.ts +282 -0
- package/src/grid/views.ts +70 -0
- package/src/guides/guide-article.tsx +92 -0
- package/src/guides/guide-figure-zoom.tsx +533 -0
- package/src/guides/guide-figure.tsx +68 -0
- package/src/guides/guide-toc.tsx +133 -0
- package/src/guides/guides-landing.tsx +57 -0
- package/src/guides/guides-search.tsx +160 -0
- package/src/guides/guides-shell.tsx +60 -0
- package/src/guides/guides-sidebar.tsx +93 -0
- package/src/guides/index.ts +28 -0
- package/src/guides/library.ts +165 -0
- package/src/health/health.ts +115 -0
- package/src/health/index.ts +11 -0
- package/src/internal/cx.ts +4 -0
- package/src/internal/next-link.ts +23 -0
- package/src/jobs/counts.ts +151 -0
- package/src/jobs/cron-auth.ts +60 -0
- package/src/jobs/health.ts +315 -0
- package/src/jobs/idle.ts +86 -0
- package/src/jobs/index.ts +120 -0
- package/src/jobs/job-health-list.tsx +316 -0
- package/src/jobs/next-index.ts +4 -0
- package/src/jobs/next.ts +65 -0
- package/src/jobs/prisma-index.ts +12 -0
- package/src/jobs/prisma.ts +170 -0
- package/src/jobs/prune.ts +79 -0
- package/src/jobs/react-index.ts +35 -0
- package/src/jobs/registry.ts +189 -0
- package/src/jobs/scheduler.ts +437 -0
- package/src/jobs/store.ts +212 -0
- package/src/jobs/windows.ts +157 -0
- package/src/maintenance/core.ts +270 -0
- package/src/maintenance/gate.ts +171 -0
- package/src/maintenance/index.ts +40 -0
- package/src/maintenance/page.ts +76 -0
- package/src/maintenance/proxy.ts +88 -0
- package/src/maintenance/react-index.ts +7 -0
- package/src/maintenance/react.tsx +190 -0
- package/src/maintenance/route.ts +82 -0
- package/src/maintenance/unavailable.ts +61 -0
- package/src/markdown/figure.tsx +132 -0
- package/src/markdown/figures.ts +237 -0
- package/src/markdown/guide.tsx +536 -0
- package/src/markdown/index.ts +53 -0
- package/src/markdown/table-view.tsx +74 -0
- package/src/markdown/table.ts +90 -0
- package/src/password/common.ts +58 -0
- package/src/password/estimate-index.ts +18 -0
- package/src/password/estimate.ts +715 -0
- package/src/password/index.ts +40 -0
- package/src/password/password-input.tsx +116 -0
- package/src/password/password-strength.tsx +157 -0
- package/src/password/reveal.ts +151 -0
- package/src/rate-limit/better-auth.ts +94 -0
- package/src/rate-limit/index.ts +32 -0
- package/src/rate-limit/keys.ts +110 -0
- package/src/rate-limit/limiter.ts +276 -0
- package/src/rate-limit/prisma-index.ts +12 -0
- package/src/rate-limit/prisma.ts +157 -0
- package/src/rate-limit/store.ts +47 -0
- package/src/release/changelog.ts +364 -0
- package/src/release/index.ts +32 -0
- package/src/release/version.ts +64 -0
- package/src/setup-guide/bits.tsx +420 -0
- package/src/setup-guide/card.tsx +358 -0
- package/src/setup-guide/class-names.ts +144 -0
- package/src/setup-guide/context.tsx +239 -0
- package/src/setup-guide/guide.ts +271 -0
- package/src/setup-guide/index.ts +76 -0
- package/src/setup-guide/launcher.tsx +207 -0
- package/src/setup-guide/strip.tsx +127 -0
- package/src/styles/house.css +384 -0
- package/src/trail/index.ts +12 -0
- package/src/trail/rules.ts +84 -0
- package/src/trail/trail.tsx +367 -0
- package/src/ux/errors.ts +32 -0
- package/src/ux/feedback.tsx +41 -0
- package/src/ux/index.ts +44 -0
- package/src/ux/navigation-index.ts +16 -0
- package/src/ux/navigation-progress.tsx +270 -0
- package/src/ux/optimistic.ts +415 -0
- package/src/ux/use-action.ts +155 -0
- package/src/ux/use-optimistic-list.ts +227 -0
- package/src/ux/use-optimistic-value.ts +136 -0
- package/src/web-search/index.ts +13 -0
- package/src/web-search/providers.ts +177 -0
- package/src/web-search/types.ts +98 -0
- package/src/whats-new/body.tsx +190 -0
- package/src/whats-new/index.ts +43 -0
- package/src/whats-new/seen.ts +40 -0
- package/src/whats-new/select.ts +230 -0
- package/src/whats-new/use-whats-new.ts +109 -0
- package/src/wizard/index.ts +61 -0
- package/src/wizard/invalid.ts +152 -0
- package/src/wizard/react-hook-form-index.ts +11 -0
- package/src/wizard/rhf-adapter.ts +67 -0
- package/src/wizard/rules.ts +137 -0
- package/src/wizard/wizard.tsx +442 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { BookOpen, Check, Info, Sparkles } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import { cx } from "../internal/cx.js";
|
|
7
|
+
import { SETUP_GUIDE_CLASS_NAMES, type SetupGuideClassNames } from "./class-names.js";
|
|
8
|
+
import { rewardWord, useSetupGuide, type RewardWords, type SetupLinkComponent } from "./context.js";
|
|
9
|
+
import type { GuideItem, SetupGuideLink, SetupHowTo, StepState } from "./guide.js";
|
|
10
|
+
|
|
11
|
+
/** The small parts every drawing of the guide shares. */
|
|
12
|
+
|
|
13
|
+
export type ClassNameOverrides = Partial<SetupGuideClassNames>;
|
|
14
|
+
|
|
15
|
+
export function useClassNames(overrides?: ClassNameOverrides): SetupGuideClassNames {
|
|
16
|
+
return React.useMemo(() => ({ ...SETUP_GUIDE_CLASS_NAMES, ...overrides }), [overrides]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The words and the link component, with sane answers outside a provider so a part can be rendered alone. */
|
|
20
|
+
export function useGuideChrome(): { words: RewardWords; Link: SetupLinkComponent } {
|
|
21
|
+
const setup = useSetupGuide();
|
|
22
|
+
const fallback = React.useCallback<SetupLinkComponent>(({ children, ...rest }) => <a {...rest}>{children}</a>, []);
|
|
23
|
+
return { words: setup?.words ?? { one: "credit", many: "credits" }, Link: setup?.Link ?? fallback };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type RewardState = "todo" | "earned" | "on-complete";
|
|
27
|
+
|
|
28
|
+
/** What a step pays. */
|
|
29
|
+
export function RewardChip({
|
|
30
|
+
reward,
|
|
31
|
+
state = "todo",
|
|
32
|
+
tone = "light",
|
|
33
|
+
words,
|
|
34
|
+
className,
|
|
35
|
+
classNames,
|
|
36
|
+
}: {
|
|
37
|
+
reward: number;
|
|
38
|
+
state?: RewardState;
|
|
39
|
+
tone?: "light" | "dark";
|
|
40
|
+
words?: RewardWords;
|
|
41
|
+
className?: string;
|
|
42
|
+
classNames?: ClassNameOverrides;
|
|
43
|
+
}) {
|
|
44
|
+
const c = useClassNames(classNames);
|
|
45
|
+
const chrome = useGuideChrome();
|
|
46
|
+
const said = words ?? chrome.words;
|
|
47
|
+
const unit = rewardWord(reward, said);
|
|
48
|
+
|
|
49
|
+
if (state === "earned") {
|
|
50
|
+
return (
|
|
51
|
+
<span className={cx(c.chipEarned, tone === "dark" && "text-white", className)}>
|
|
52
|
+
<Check className="size-3.5" aria-hidden />
|
|
53
|
+
{reward} earned
|
|
54
|
+
<span className={c.srOnly}> {unit}</span>
|
|
55
|
+
</span>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return (
|
|
59
|
+
<span
|
|
60
|
+
className={cx(
|
|
61
|
+
c.chip,
|
|
62
|
+
tone === "dark" && c.chipDark,
|
|
63
|
+
state === "on-complete" && tone !== "dark" && c.chipOnComplete,
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
<Sparkles className="size-3" aria-hidden />+{reward}
|
|
68
|
+
{state === "on-complete" ? " on build" : null}
|
|
69
|
+
<span className={c.srOnly}> {unit}</span>
|
|
70
|
+
</span>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function StepCircle({
|
|
75
|
+
state,
|
|
76
|
+
n,
|
|
77
|
+
size = "md",
|
|
78
|
+
className,
|
|
79
|
+
classNames,
|
|
80
|
+
}: {
|
|
81
|
+
state: StepState;
|
|
82
|
+
n?: number;
|
|
83
|
+
size?: "sm" | "md";
|
|
84
|
+
className?: string;
|
|
85
|
+
classNames?: ClassNameOverrides;
|
|
86
|
+
}) {
|
|
87
|
+
const c = useClassNames(classNames);
|
|
88
|
+
return (
|
|
89
|
+
<span
|
|
90
|
+
aria-hidden
|
|
91
|
+
className={cx(
|
|
92
|
+
c.circle,
|
|
93
|
+
size === "sm" ? "size-6" : "size-7",
|
|
94
|
+
state === "done" && c.circleDone,
|
|
95
|
+
state === "next" && c.circleNext,
|
|
96
|
+
state === "ready" && c.circleReady,
|
|
97
|
+
state === "todo" && c.circleTodo,
|
|
98
|
+
className,
|
|
99
|
+
)}
|
|
100
|
+
>
|
|
101
|
+
{state === "done" || state === "ready" ? <Check className={size === "sm" ? "size-3.5" : "size-4"} /> : n}
|
|
102
|
+
</span>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The share earned, as a ring with the number inside. */
|
|
107
|
+
export function RewardRing({
|
|
108
|
+
earned,
|
|
109
|
+
total,
|
|
110
|
+
size = 84,
|
|
111
|
+
tone = "dark",
|
|
112
|
+
words,
|
|
113
|
+
classNames,
|
|
114
|
+
}: {
|
|
115
|
+
earned: number;
|
|
116
|
+
total: number;
|
|
117
|
+
size?: number;
|
|
118
|
+
tone?: "dark" | "light";
|
|
119
|
+
words?: RewardWords;
|
|
120
|
+
classNames?: ClassNameOverrides;
|
|
121
|
+
}) {
|
|
122
|
+
const c = useClassNames(classNames);
|
|
123
|
+
const chrome = useGuideChrome();
|
|
124
|
+
const said = words ?? chrome.words;
|
|
125
|
+
const share = total === 0 ? 0 : Math.round((earned / total) * 100);
|
|
126
|
+
// The ring is a gradient, so it cannot be a class. An app that marks these
|
|
127
|
+
// rewards with a colour of its own — AltEd's credits are violet everywhere
|
|
128
|
+
// else — sets these two variables and the ring follows, in both tones.
|
|
129
|
+
const fill = tone === "dark" ? "var(--setup-ring-fill, #ffffff)" : "var(--setup-ring-fill, var(--primary))";
|
|
130
|
+
const track =
|
|
131
|
+
tone === "dark"
|
|
132
|
+
? "var(--setup-ring-track, rgb(255 255 255 / 0.12))"
|
|
133
|
+
: "var(--setup-ring-track, color-mix(in oklab, var(--primary) 14%, transparent))";
|
|
134
|
+
return (
|
|
135
|
+
<span
|
|
136
|
+
role="img"
|
|
137
|
+
aria-label={`${earned} of ${total} ${rewardWord(total, said)} earned`}
|
|
138
|
+
className="flex shrink-0 items-center justify-center rounded-full"
|
|
139
|
+
style={{
|
|
140
|
+
width: size,
|
|
141
|
+
height: size,
|
|
142
|
+
background: `conic-gradient(${fill} 0 ${share}%, ${track} 0)`,
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
<span
|
|
146
|
+
className={cx(
|
|
147
|
+
"flex flex-col items-center justify-center rounded-full leading-none",
|
|
148
|
+
tone === "dark" ? c.ringFace : c.ringFaceLight,
|
|
149
|
+
)}
|
|
150
|
+
style={{ width: size - 14, height: size - 14 }}
|
|
151
|
+
>
|
|
152
|
+
<span className="font-bold" style={{ fontSize: Math.round(size * 0.34) }}>
|
|
153
|
+
{earned}
|
|
154
|
+
</span>
|
|
155
|
+
<span className={cx("mt-1 text-[11px]", tone === "dark" ? "text-slate-400" : "text-muted-foreground")}>
|
|
156
|
+
of {total}
|
|
157
|
+
</span>
|
|
158
|
+
</span>
|
|
159
|
+
</span>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** A small progress ring, for a header. */
|
|
164
|
+
export function ProgressRing({ value, size = 24 }: { value: number; size?: number }) {
|
|
165
|
+
return (
|
|
166
|
+
<span
|
|
167
|
+
aria-hidden
|
|
168
|
+
className="flex shrink-0 items-center justify-center rounded-full"
|
|
169
|
+
style={{
|
|
170
|
+
width: size,
|
|
171
|
+
height: size,
|
|
172
|
+
background: `conic-gradient(var(--primary) 0 ${value}%, var(--secondary) 0)`,
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
<span className="block rounded-full bg-background" style={{ width: size - 8, height: size - 8 }} />
|
|
176
|
+
</span>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** One bar per item, lit when it is done. */
|
|
181
|
+
export function Segments({
|
|
182
|
+
done,
|
|
183
|
+
total,
|
|
184
|
+
tone = "dark",
|
|
185
|
+
classNames,
|
|
186
|
+
}: {
|
|
187
|
+
done: number;
|
|
188
|
+
total: number;
|
|
189
|
+
tone?: "dark" | "light";
|
|
190
|
+
classNames?: ClassNameOverrides;
|
|
191
|
+
}) {
|
|
192
|
+
const c = useClassNames(classNames);
|
|
193
|
+
return (
|
|
194
|
+
<div className="flex gap-1.5" aria-hidden>
|
|
195
|
+
{Array.from({ length: total }, (_, index) => (
|
|
196
|
+
<span
|
|
197
|
+
key={index}
|
|
198
|
+
className={cx(
|
|
199
|
+
c.segment,
|
|
200
|
+
index < done
|
|
201
|
+
? tone === "dark"
|
|
202
|
+
? c.segmentDoneDark
|
|
203
|
+
: c.segmentDone
|
|
204
|
+
: tone === "dark"
|
|
205
|
+
? c.segmentTodoDark
|
|
206
|
+
: c.segmentTodo,
|
|
207
|
+
)}
|
|
208
|
+
/>
|
|
209
|
+
))}
|
|
210
|
+
</div>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function MiniProgress({ done, total, className }: { done: number; total: number; className?: string }) {
|
|
215
|
+
return (
|
|
216
|
+
<span className={cx("inline-flex items-center gap-2", className)}>
|
|
217
|
+
<span className="h-1.5 w-20 overflow-hidden rounded-full bg-secondary" aria-hidden>
|
|
218
|
+
<span
|
|
219
|
+
className="block h-full rounded-full bg-primary"
|
|
220
|
+
style={{ width: `${total === 0 ? 0 : Math.round((done / total) * 100)}%` }}
|
|
221
|
+
/>
|
|
222
|
+
</span>
|
|
223
|
+
<span className="text-xs text-muted-foreground tabular-nums">
|
|
224
|
+
{done} of {total} done
|
|
225
|
+
</span>
|
|
226
|
+
</span>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** `**label**` in bold and `_example_` in italics — the only markup the instructions use. */
|
|
231
|
+
export function HowText({ text }: { text: string }) {
|
|
232
|
+
const parts = text.split(/(\*\*[^*]+\*\*|_[^_]+_)/g).filter(Boolean);
|
|
233
|
+
return (
|
|
234
|
+
<>
|
|
235
|
+
{parts.map((part, index) =>
|
|
236
|
+
part.startsWith("**") && part.endsWith("**") && part.length > 4 ? (
|
|
237
|
+
<strong key={index} className="font-semibold">
|
|
238
|
+
{part.slice(2, -2)}
|
|
239
|
+
</strong>
|
|
240
|
+
) : part.startsWith("_") && part.endsWith("_") && part.length > 2 ? (
|
|
241
|
+
<em key={index}>{part.slice(1, -1)}</em>
|
|
242
|
+
) : (
|
|
243
|
+
<span key={index}>{part}</span>
|
|
244
|
+
),
|
|
245
|
+
)}
|
|
246
|
+
</>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The ⓘ: how to do this step, beside the step itself.
|
|
252
|
+
*
|
|
253
|
+
* Built here rather than on a popover library, because this package cannot pick
|
|
254
|
+
* one for six apps. It is a disclosure, not a dialog: Escape closes it, a click
|
|
255
|
+
* outside closes it, and focus is left where the person put it — nothing here
|
|
256
|
+
* is worth trapping focus for.
|
|
257
|
+
*/
|
|
258
|
+
export function HowToButton({
|
|
259
|
+
how,
|
|
260
|
+
guide,
|
|
261
|
+
footer,
|
|
262
|
+
className,
|
|
263
|
+
classNames,
|
|
264
|
+
}: {
|
|
265
|
+
how: SetupHowTo;
|
|
266
|
+
guide?: SetupGuideLink;
|
|
267
|
+
footer?: React.ReactNode;
|
|
268
|
+
className?: string;
|
|
269
|
+
classNames?: ClassNameOverrides;
|
|
270
|
+
}) {
|
|
271
|
+
const c = useClassNames(classNames);
|
|
272
|
+
const { Link } = useGuideChrome();
|
|
273
|
+
const [open, setOpen] = React.useState(false);
|
|
274
|
+
const wrapper = React.useRef<HTMLSpanElement>(null);
|
|
275
|
+
const panelId = React.useId();
|
|
276
|
+
|
|
277
|
+
React.useEffect(() => {
|
|
278
|
+
if (!open) return;
|
|
279
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
280
|
+
if (event.key === "Escape") setOpen(false);
|
|
281
|
+
};
|
|
282
|
+
const onPointerDown = (event: MouseEvent | TouchEvent) => {
|
|
283
|
+
const node = event.target;
|
|
284
|
+
if (node instanceof Node && wrapper.current?.contains(node)) return;
|
|
285
|
+
setOpen(false);
|
|
286
|
+
};
|
|
287
|
+
document.addEventListener("keydown", onKeyDown);
|
|
288
|
+
document.addEventListener("mousedown", onPointerDown);
|
|
289
|
+
return () => {
|
|
290
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
291
|
+
document.removeEventListener("mousedown", onPointerDown);
|
|
292
|
+
};
|
|
293
|
+
}, [open]);
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<span ref={wrapper} className="relative inline-flex">
|
|
297
|
+
<button
|
|
298
|
+
type="button"
|
|
299
|
+
onClick={() => setOpen((current) => !current)}
|
|
300
|
+
aria-expanded={open}
|
|
301
|
+
aria-controls={open ? panelId : undefined}
|
|
302
|
+
aria-label={how.title}
|
|
303
|
+
title={how.title}
|
|
304
|
+
className={cx(c.iconButton, className)}
|
|
305
|
+
>
|
|
306
|
+
<Info className="size-4" aria-hidden />
|
|
307
|
+
</button>
|
|
308
|
+
{open ? (
|
|
309
|
+
<span id={panelId} role="group" aria-label={how.title} className={c.popover}>
|
|
310
|
+
<span className={cx(c.popoverTitle, "block")}>{how.title}</span>
|
|
311
|
+
<ol className="mt-3 flex flex-col gap-2">
|
|
312
|
+
{how.steps.map((step, index) => (
|
|
313
|
+
<li key={index} className={c.popoverStep}>
|
|
314
|
+
<span aria-hidden className={c.popoverNumber}>
|
|
315
|
+
{index + 1}
|
|
316
|
+
</span>
|
|
317
|
+
<span>
|
|
318
|
+
<HowText text={step} />
|
|
319
|
+
</span>
|
|
320
|
+
</li>
|
|
321
|
+
))}
|
|
322
|
+
</ol>
|
|
323
|
+
{footer}
|
|
324
|
+
{guide ? (
|
|
325
|
+
<span className={cx(c.popoverFooter, "flex")}>
|
|
326
|
+
<Link
|
|
327
|
+
href={guide.href}
|
|
328
|
+
target="_blank"
|
|
329
|
+
rel="noopener"
|
|
330
|
+
className="inline-flex items-center gap-1.5 text-[13px] font-medium text-primary underline-offset-4 hover:underline"
|
|
331
|
+
>
|
|
332
|
+
<BookOpen className="size-3.5" aria-hidden />
|
|
333
|
+
{guide.title} guide
|
|
334
|
+
</Link>
|
|
335
|
+
<span className="text-xs text-muted-foreground">Opens in a new tab</span>
|
|
336
|
+
</span>
|
|
337
|
+
) : null}
|
|
338
|
+
</span>
|
|
339
|
+
) : null}
|
|
340
|
+
</span>
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** The book: the guide for the feature, in a new tab. */
|
|
345
|
+
export function GuideIconLink({
|
|
346
|
+
guide,
|
|
347
|
+
className,
|
|
348
|
+
classNames,
|
|
349
|
+
}: {
|
|
350
|
+
guide?: SetupGuideLink;
|
|
351
|
+
className?: string;
|
|
352
|
+
classNames?: ClassNameOverrides;
|
|
353
|
+
}) {
|
|
354
|
+
const c = useClassNames(classNames);
|
|
355
|
+
const { Link } = useGuideChrome();
|
|
356
|
+
if (!guide) return null;
|
|
357
|
+
const label = `Guide: ${guide.title}`;
|
|
358
|
+
return (
|
|
359
|
+
<Link
|
|
360
|
+
href={guide.href}
|
|
361
|
+
target="_blank"
|
|
362
|
+
rel="noopener"
|
|
363
|
+
aria-label={label}
|
|
364
|
+
title={label}
|
|
365
|
+
className={cx(c.iconButton, className)}
|
|
366
|
+
>
|
|
367
|
+
<BookOpen className="size-4" aria-hidden />
|
|
368
|
+
</Link>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Both icons for one step — or, for an item with several, its steps listed in
|
|
374
|
+
* the ⓘ and the first step's guide on the book.
|
|
375
|
+
*/
|
|
376
|
+
export function ItemHelp({
|
|
377
|
+
item,
|
|
378
|
+
className,
|
|
379
|
+
classNames,
|
|
380
|
+
}: {
|
|
381
|
+
item: GuideItem;
|
|
382
|
+
className?: string;
|
|
383
|
+
classNames?: ClassNameOverrides;
|
|
384
|
+
}) {
|
|
385
|
+
const { words } = useGuideChrome();
|
|
386
|
+
const [first] = item.steps;
|
|
387
|
+
if (!first) return null;
|
|
388
|
+
|
|
389
|
+
if (item.steps.length === 1) {
|
|
390
|
+
return (
|
|
391
|
+
<span className={cx("inline-flex items-center", className)}>
|
|
392
|
+
{first.how ? <HowToButton how={first.how} guide={first.guide} classNames={classNames} /> : null}
|
|
393
|
+
<GuideIconLink guide={first.guide} classNames={classNames} />
|
|
394
|
+
</span>
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return (
|
|
399
|
+
<span className={cx("inline-flex items-center", className)}>
|
|
400
|
+
<HowToButton
|
|
401
|
+
classNames={classNames}
|
|
402
|
+
how={{
|
|
403
|
+
title: `What “${item.title}” asks for`,
|
|
404
|
+
steps: item.steps.map(
|
|
405
|
+
(step) =>
|
|
406
|
+
`${step.done ? "Done — " : ""}**${step.title}**${step.reward > 0 ? ` · ${step.reward} ${rewardWord(step.reward, words)}` : ""}`,
|
|
407
|
+
),
|
|
408
|
+
}}
|
|
409
|
+
guide={first.guide}
|
|
410
|
+
footer={
|
|
411
|
+
<p className="mt-3 text-xs text-muted-foreground">
|
|
412
|
+
Each step, with how to do it, is on the screen it's done on.
|
|
413
|
+
{item.paysOnComplete && item.earnedReward === 0 ? " Nothing is paid until the whole thing is built." : ""}
|
|
414
|
+
</p>
|
|
415
|
+
}
|
|
416
|
+
/>
|
|
417
|
+
<GuideIconLink guide={first.guide} classNames={classNames} />
|
|
418
|
+
</span>
|
|
419
|
+
);
|
|
420
|
+
}
|