@thewhatmatters/wmds 0.2.0 → 0.3.0

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 (134) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/CONSUMING.md +4 -4
  3. package/README.md +3 -3
  4. package/dist/styles.css +1 -1
  5. package/docs/component-contracts.md +1 -1
  6. package/docs/components.md +6 -6
  7. package/docs/exports.json +1 -13
  8. package/docs/patterns/components-avatar--dropdown-row.tsx +1 -1
  9. package/docs/patterns/components-badge--with-avatar.tsx +1 -1
  10. package/docs/patterns/components-button-button--destructive-action.tsx +1 -1
  11. package/docs/patterns/components-button-button--ghost-action.tsx +1 -1
  12. package/docs/patterns/components-button-button--inverse-action.tsx +1 -1
  13. package/docs/patterns/components-button-button--link-render.tsx +1 -1
  14. package/docs/patterns/components-button-button--multi-state-badge.tsx +1 -1
  15. package/docs/patterns/components-button-button--outline-mono.tsx +1 -1
  16. package/docs/patterns/components-button-button--primary-action.tsx +1 -1
  17. package/docs/patterns/components-button-button--row-hug.tsx +1 -1
  18. package/docs/patterns/components-button-button--row-layout.tsx +1 -1
  19. package/docs/patterns/components-button-button--secondary-action.tsx +1 -1
  20. package/docs/patterns/components-button-button--suggestion-pills.tsx +1 -1
  21. package/docs/patterns/components-button-button--with-count.tsx +1 -1
  22. package/docs/patterns/components-button-button--with-icon.tsx +1 -1
  23. package/docs/patterns/components-button-floatingactionbutton--vertical-actions.tsx +1 -1
  24. package/docs/patterns/components-calembed--pattern-skip-in-footer.tsx +1 -1
  25. package/docs/patterns/components-card-card--body-slot-occupancy-history.tsx +1 -1
  26. package/docs/patterns/components-card-card--headerless-media.tsx +1 -1
  27. package/docs/patterns/components-card-card--outlined-layout.tsx +1 -1
  28. package/docs/patterns/components-card-card--pinned-height.tsx +1 -1
  29. package/docs/patterns/components-card-selectablecard--selectable-cards-pattern.tsx +1 -1
  30. package/docs/patterns/components-chart--audience-activity-heatmap.tsx +1 -1
  31. package/docs/patterns/components-chart--cartesian-no-data-gaps.tsx +1 -1
  32. package/docs/patterns/components-chart--occupancy-history-in-card.tsx +1 -1
  33. package/docs/patterns/components-chart--occupancy-in-card.tsx +1 -1
  34. package/docs/patterns/components-chart--post-reach-distribution.tsx +1 -1
  35. package/docs/patterns/components-chart--ranked-audience-breakdown.tsx +1 -1
  36. package/docs/patterns/components-chart--unit-grid-composition.tsx +1 -1
  37. package/docs/patterns/components-chatqa--pattern-qa-with-reply.tsx +1 -1
  38. package/docs/patterns/components-checkbox-checkbox--default.tsx +1 -1
  39. package/docs/patterns/components-checkbox-checkbox--with-description.tsx +1 -1
  40. package/docs/patterns/components-checkbox-checkboxgroup--default.tsx +1 -1
  41. package/docs/patterns/components-dialog--alert-dialog-destructive.tsx +1 -1
  42. package/docs/patterns/components-dialog--default-dialog.tsx +1 -1
  43. package/docs/patterns/components-dialog--form-dialog.tsx +1 -1
  44. package/docs/patterns/components-displaycontrols--page-utilities.tsx +1 -1
  45. package/docs/patterns/components-field--horizontal-input.tsx +1 -1
  46. package/docs/patterns/components-field--horizontal-text-area.tsx +1 -1
  47. package/docs/patterns/components-field--multi-control.tsx +1 -1
  48. package/docs/patterns/components-footerreveal--marketing-hero-pattern.tsx +1 -1
  49. package/docs/patterns/components-footerreveal--marketing-hero-ruled-pattern.tsx +1 -1
  50. package/docs/patterns/components-footerreveal--marketing-hero-with-gallery-intro.tsx +1 -1
  51. package/docs/patterns/components-footerreveal--marketing-page-pattern.tsx +1 -1
  52. package/docs/patterns/components-footerreveal--ruled-grid-footer-pattern.tsx +1 -1
  53. package/docs/patterns/components-footerreveal--sequenced-marketing-hero.tsx +1 -1
  54. package/docs/patterns/components-herointro--two-line-intro.tsx +1 -1
  55. package/docs/patterns/components-herotilestack--marketing-hero-pattern.tsx +1 -1
  56. package/docs/patterns/components-herotilestack--marketing-hero-text-sequence.tsx +1 -1
  57. package/docs/patterns/components-herotilestack--marketing-hero-with-gallery-intro.tsx +1 -1
  58. package/docs/patterns/components-intakeconfirmation--booked-pattern.tsx +1 -1
  59. package/docs/patterns/components-intakeconfirmation--emailed-pattern.tsx +1 -1
  60. package/docs/patterns/components-intakeform--about-you-pattern.tsx +1 -1
  61. package/docs/patterns/components-intakemodal--intake-modal-pattern.tsx +1 -1
  62. package/docs/patterns/components-kbd--command-row.tsx +1 -1
  63. package/docs/patterns/components-kbd--numbered-choices.tsx +1 -1
  64. package/docs/patterns/components-kbd--shortcut.tsx +1 -1
  65. package/docs/patterns/components-moremenu--action-menu.tsx +1 -1
  66. package/docs/patterns/components-moremenu--in-card-header.tsx +1 -1
  67. package/docs/patterns/components-navlist--side-nav-settings.tsx +1 -1
  68. package/docs/patterns/components-pageheader--app-header-pattern.tsx +1 -1
  69. package/docs/patterns/components-pageheader--page-section-header.tsx +1 -1
  70. package/docs/patterns/components-pageheader--toolbar-header.tsx +1 -1
  71. package/docs/patterns/components-panel--end-detail-rail.tsx +1 -1
  72. package/docs/patterns/components-pillgroup--pill-group-pattern.tsx +1 -1
  73. package/docs/patterns/components-promptbar--pattern-marketing-composer.tsx +3 -3
  74. package/docs/patterns/components-promptbar--pattern-prompt-bar.tsx +1 -1
  75. package/docs/patterns/components-radio-radiogroup--default.tsx +1 -1
  76. package/docs/patterns/components-scrollhorizontal--project-gallery-pattern.tsx +1 -1
  77. package/docs/patterns/components-scrollhorizontal--with-intro.tsx +1 -1
  78. package/docs/patterns/components-sheet--bottom-sheet.tsx +1 -1
  79. package/docs/patterns/components-sheet--end-sheet.tsx +1 -1
  80. package/docs/patterns/components-sitenav--brand-and-cta.tsx +1 -1
  81. package/docs/patterns/components-sitenav--centered-links.tsx +1 -1
  82. package/docs/patterns/components-sitenav--compact.tsx +1 -1
  83. package/docs/patterns/components-sitenav--marketing-header.tsx +1 -1
  84. package/docs/patterns/components-sitenav--mega-menu.tsx +1 -1
  85. package/docs/patterns/components-stat--insights-row.tsx +1 -1
  86. package/docs/patterns/components-stepprogress--step-progress-pattern.tsx +1 -1
  87. package/docs/patterns/components-switch--default.tsx +1 -1
  88. package/docs/patterns/components-switch--settings-row.tsx +1 -1
  89. package/docs/patterns/components-tab--settings-pages.tsx +1 -1
  90. package/docs/patterns/components-taskrows--action-details.tsx +1 -1
  91. package/docs/patterns/components-taskrows--capsules.tsx +1 -1
  92. package/docs/patterns/components-taskrows--card-with-status-rows.tsx +1 -1
  93. package/docs/patterns/components-taskrows--controlled-expand.tsx +1 -1
  94. package/docs/patterns/components-taskrows--custom-slots.tsx +1 -1
  95. package/docs/patterns/components-taskrows--status-list.tsx +1 -1
  96. package/docs/patterns/components-taskrows--tag-chips.tsx +1 -1
  97. package/docs/patterns/components-textlink--external-destination.tsx +1 -1
  98. package/docs/patterns/components-textlink--inline-prose.tsx +1 -1
  99. package/docs/patterns/components-textlink--supporting-copy.tsx +1 -1
  100. package/docs/patterns/components-textsequence--default.tsx +1 -1
  101. package/docs/patterns/components-textsequence--reduced-motion.tsx +1 -1
  102. package/docs/patterns/components-textsequence--shapes.tsx +1 -1
  103. package/docs/patterns/components-toast--stacked-notifications.tsx +1 -1
  104. package/docs/patterns/components-tooltip--controlled.tsx +1 -1
  105. package/docs/patterns/components-tooltip--disabled-control.tsx +1 -1
  106. package/docs/patterns/components-tooltip--icon-action.tsx +1 -1
  107. package/docs/patterns/components-tooltip--keyboard-shortcut.tsx +1 -1
  108. package/docs/patterns/components-tooltip--placement.tsx +1 -1
  109. package/docs/patterns/foundations-scroll-fade--horizontal-rail.tsx +1 -1
  110. package/docs/patterns/foundations-scroll-fade--overflowing-list.tsx +1 -1
  111. package/docs/patterns/guides-chart-explorations--comparison-gallery.tsx +1 -1
  112. package/docs/patterns/guides-overlay-flows--notification-preferences.tsx +1 -1
  113. package/docs/patterns/guides-profile-typography--editorial-profile.tsx +1 -1
  114. package/docs/patterns/index.json +1 -153
  115. package/package.json +1 -1
  116. package/docs/patterns/sites-pitchkit-account-settings--account-settings-owner.tsx +0 -265
  117. package/docs/patterns/sites-pitchkit-creator-identity--creator-identity-owner-settings.tsx +0 -154
  118. package/docs/patterns/sites-pitchkit-creator-identity--creator-identity-public.tsx +0 -96
  119. package/docs/patterns/sites-pitchkit-insights-and-kit--creator-insights-loading.tsx +0 -1006
  120. package/docs/patterns/sites-pitchkit-insights-and-kit--creator-insights.tsx +0 -1031
  121. package/docs/patterns/sites-pitchkit-insights-and-kit--insufficient-audience-data.tsx +0 -1015
  122. package/docs/patterns/sites-pitchkit-insights-and-kit--insufficient-reach-and-audience-data.tsx +0 -1017
  123. package/docs/patterns/sites-pitchkit-insights-and-kit--insufficient-reach-data.tsx +0 -1033
  124. package/docs/patterns/sites-pitchkit-insights-and-kit--owner-pitch-kit.tsx +0 -838
  125. package/docs/patterns/sites-pitchkit-insights-and-kit--shareable-pitch-kit.tsx +0 -608
  126. package/docs/patterns/sites-pitchkit-intro--intro-owner.tsx +0 -161
  127. package/docs/patterns/sites-pitchkit-intro--intro-public.tsx +0 -111
  128. package/docs/patterns/sites-pitchkit-past-brands--past-brands-owner.tsx +0 -611
  129. package/docs/patterns/sites-pitchkit-past-brands--past-brands-public.tsx +0 -299
  130. package/docs/patterns/sites-pitchkit-theme-picker--theme-picker-owner.tsx +0 -832
  131. package/docs/patterns/sites-whatmatters-intake--start-a-project-pattern.tsx +0 -234
  132. package/docs/patterns/sites-whatmatters-marketing-landing--marketing-landing.tsx +0 -87
  133. package/docs/patterns/sites-whatmatters-prompt-chat--landing-to-chat.tsx +0 -899
  134. package/docs/patterns/sites-whatmatters-rfp-submitted--rfp-submitted.tsx +0 -302
@@ -1,832 +0,0 @@
1
- // @thewhatmatters/wmds@0.2.0 · Pattern — theme picker (owner)
2
- // Storybook: Sites/PitchKit/Theme picker → Pattern — theme picker (owner) (?path=/story/sites-pitchkit-theme-picker--theme-picker-owner)
3
- // Show code — copy verbatim and keep this header; upgrades find pasted patterns by it.
4
-
5
- import { useLayoutEffect, useRef, useState, type CSSProperties } from "react";
6
- import {
7
- AlertDialog,
8
- Avatar,
9
- Badge,
10
- Button,
11
- Card,
12
- Chart,
13
- Chip,
14
- Dialog,
15
- Dropdown,
16
- PageHeader,
17
- SegmentedControl,
18
- Stat,
19
- TextLink,
20
- Toaster,
21
- cardSubtitleClasses,
22
- cardTitleClasses,
23
- chartSeriesConfigFromKeys,
24
- toast,
25
- type ChartCartesianPoint,
26
- type ChartRankedBarItem,
27
- } from "@thewhatmatters/wmds";
28
-
29
- const reachConfig = chartSeriesConfigFromKeys([
30
- { key: "typical", label: "Typical reach" },
31
- { key: "reach", label: "Daily reach" },
32
- ]);
33
-
34
- const compactNumber = new Intl.NumberFormat("en", {
35
- notation: "compact",
36
- maximumFractionDigits: 1,
37
- });
38
-
39
- const pitchKitThemes = ["light", "dark", "soft"];
40
-
41
-
42
- function copyShareKitUrl(handle: string) {
43
- const path = `/k/${handle}`;
44
- void navigator.clipboard.writeText(path);
45
- toast.add({
46
- title: "Kit URL copied",
47
- description: path,
48
- tone: "success",
49
- });
50
- }
51
-
52
- function AccountSettingsDialog({
53
- identity,
54
- open,
55
- onOpenChange,
56
- }: {
57
- identity: PitchKitCreatorIdentity;
58
- open: boolean;
59
- onOpenChange: (open: boolean) => void;
60
- }) {
61
- return (
62
- <Dialog open={open} onOpenChange={onOpenChange}>
63
- <Dialog.Content size="md" title="Account settings">
64
- <div className="flex w-full min-w-0 flex-col gap-4">
65
- <Card variant="outlined" shape="rounded" bodyTerminal className="col-span-full">
66
- <Card.Header
67
- start={<h2 className={cardTitleClasses}>Connected Instagram</h2>}
68
- end={
69
- identity.connected ? (
70
- <Badge variant="success" emphasis="muted" size="sm">
71
- Connected
72
- </Badge>
73
- ) : null
74
- }
75
- />
76
- <Card.Body>
77
- <div className="flex min-w-0 flex-col gap-4 px-3.5 py-[16px]">
78
- <CreatorIdentityStrip
79
- identity={identity}
80
- nameAs="p"
81
- showProfessionalChip
82
- />
83
- {identity.lastSyncedLabel != null ? (
84
- <p className="type-supporting text-muted text-muted">
85
- Last synced {identity.lastSyncedLabel}
86
- </p>
87
- ) : null}
88
- </div>
89
- </Card.Body>
90
- </Card>
91
- </div>
92
- </Dialog.Content>
93
- </Dialog>
94
- );
95
- }
96
-
97
- function OwnerAccountMenu({ identity }: { identity: PitchKitCreatorIdentity }) {
98
- const [menuOpen, setMenuOpen] = useState(false);
99
- const [settingsOpen, setSettingsOpen] = useState(false);
100
- const [deleteOpen, setDeleteOpen] = useState(false);
101
-
102
- function handleAction(actionId: string) {
103
- setMenuOpen(false);
104
- if (actionId === "settings") {
105
- setSettingsOpen(true);
106
- return;
107
- }
108
- if (actionId === "share") {
109
- copyShareKitUrl(identity.handle);
110
- return;
111
- }
112
- if (actionId === "delete") {
113
- setDeleteOpen(true);
114
- }
115
- }
116
-
117
- return (
118
- <>
119
- <div className="relative">
120
- <Button
121
- type="button"
122
- role="ghost"
123
- size="sm"
124
- aria-label="My account"
125
- aria-haspopup="menu"
126
- aria-expanded={menuOpen}
127
- className="size-9 min-h-9 gap-0 px-0 py-0 focus-visible:ring-offset-0"
128
- onClick={() => setMenuOpen((open) => !open)}
129
- >
130
- <Avatar
131
- name={identity.displayName ?? identity.handle}
132
- src={identity.profilePictureUrl}
133
- size="md"
134
- />
135
- </Button>
136
- {menuOpen ? (
137
- <Dropdown.Menu
138
- role="menu"
139
- aria-label="My account"
140
- className="absolute end-0 top-full mt-1 min-w-56"
141
- >
142
- <li role="presentation">
143
- <p className="type-supporting font-medium uppercase tracking-wider text-muted px-3.5 py-2">My account</p>
144
- </li>
145
- <li role="presentation">
146
- <Dropdown.Item role="menuitem" truncate={false} onClick={() => handleAction("settings")}>
147
- Account settings
148
- </Dropdown.Item>
149
- </li>
150
- <li role="presentation">
151
- <Dropdown.Item role="menuitem" truncate={false} onClick={() => handleAction("share")}>
152
- Share kit
153
- </Dropdown.Item>
154
- </li>
155
- <li role="separator" className="mx-1.5 my-0.5 border-0 border-t border-border" />
156
- <li role="presentation">
157
- <Dropdown.Item role="menuitem" truncate={false} onClick={() => handleAction("signout")}>
158
- Sign out
159
- </Dropdown.Item>
160
- </li>
161
- <li role="presentation">
162
- <Dropdown.Item role="menuitem" truncate={false} onClick={() => handleAction("disconnect")}>
163
- Disconnect
164
- </Dropdown.Item>
165
- </li>
166
- <li role="presentation">
167
- <Dropdown.Item role="menuitem" truncate={false} onClick={() => handleAction("delete")}>Delete</Dropdown.Item>
168
- </li>
169
- </Dropdown.Menu>
170
- ) : null}
171
- </div>
172
- <AccountSettingsDialog
173
- identity={identity}
174
- open={settingsOpen}
175
- onOpenChange={setSettingsOpen}
176
- />
177
- <AlertDialog
178
- open={deleteOpen}
179
- onOpenChange={setDeleteOpen}
180
- title="Delete your Pitchkit account?"
181
- description="This permanently deletes your kit, stored media copies, and connection. Your Instagram account is not deleted. This cannot be undone."
182
- cancelLabel="Cancel"
183
- confirmLabel="Delete account"
184
- confirmRole="destructive"
185
- onConfirm={() => setDeleteOpen(false)}
186
- />
187
- </>
188
- );
189
- }
190
-
191
- function PitchKitPageFooter() {
192
- return (
193
- <div className="band pb-6 pt-10">
194
- <footer className="col-span-full flex items-center justify-center gap-4">
195
- <TextLink href="/privacy">Privacy</TextLink>
196
- <TextLink href="mailto:hello@whatmatters.com">Support</TextLink>
197
- </footer>
198
- </div>
199
- );
200
- }
201
-
202
-
203
-
204
- export interface PitchKitCreatorIdentity {
205
- displayName?: string;
206
- /** Without the @ — shown as @handle, shared as /k/[handle]. */
207
- handle: string;
208
- profilePictureUrl?: string;
209
- followersCount?: number;
210
- professionalAccount?: "Business" | "Creator";
211
- connected?: boolean;
212
- lastSyncedLabel?: string;
213
- }
214
-
215
- function CreatorIdentityStrip({
216
- identity,
217
- nameAs = "h1",
218
- showProfessionalChip = false,
219
- }: {
220
- identity: PitchKitCreatorIdentity;
221
- nameAs?: "h1" | "p";
222
- showProfessionalChip?: boolean;
223
- }) {
224
- const NameTag = nameAs;
225
- const avatarName = identity.displayName ?? identity.handle;
226
- const handleLabel = `@${identity.handle}`;
227
- const followerLabel =
228
- identity.followersCount == null
229
- ? null
230
- : `${compactNumber.format(identity.followersCount)} followers`;
231
- const meta = [handleLabel, followerLabel].filter(Boolean).join(" · ");
232
- const showTitleRow =
233
- identity.displayName != null ||
234
- (showProfessionalChip && identity.professionalAccount != null);
235
-
236
- return (
237
- <div className="flex flex-wrap items-center gap-4">
238
- <Avatar
239
- name={avatarName}
240
- src={identity.profilePictureUrl}
241
- size="lg"
242
- />
243
- <div className="flex min-w-0 flex-col gap-1">
244
- {showTitleRow ? (
245
- <div className="flex flex-wrap items-center gap-2">
246
- {identity.displayName != null ? (
247
- <NameTag className="type-heading-2 text-fg">
248
- {identity.displayName}
249
- </NameTag>
250
- ) : null}
251
- {showProfessionalChip && identity.professionalAccount != null ? (
252
- <Chip readOnly size="sm">
253
- {identity.professionalAccount}
254
- </Chip>
255
- ) : null}
256
- </div>
257
- ) : null}
258
- <p className="type-body text-fg text-muted">{meta}</p>
259
- </div>
260
- </div>
261
- );
262
- }
263
-
264
-
265
- export interface PitchKitPost {
266
- id: string;
267
- publishedAt: string;
268
- imageUrl: string;
269
- imageAlt: string;
270
- saves: number;
271
- reach: number;
272
- likes: number;
273
- comments: number;
274
- }
275
-
276
- export interface PitchKitContact {
277
- email: string;
278
- websiteHref: string;
279
- websiteLabel: string;
280
- location: string;
281
- }
282
-
283
- /** "insufficient" when the 30-day reach series cannot be plotted. */
284
- export type PitchKitReachState = "resolved" | "insufficient";
285
-
286
- export interface PitchKitPageData {
287
- identity: PitchKitCreatorIdentity;
288
- intro: string;
289
- posts: PitchKitPost[];
290
- contact: PitchKitContact;
291
- brands: PitchKitPastBrand[];
292
- countries: ChartRankedBarItem[];
293
- reachData: ChartCartesianPoint[];
294
- }
295
-
296
- interface ShareablePitchKitProps extends PitchKitPageData {
297
- reachState?: PitchKitReachState;
298
- /** Unsigned visitors who are not the kit owner only. */
299
- showCreateBand?: boolean;
300
- }
301
-
302
- function pitchKitIntroIsEmpty(intro: string) {
303
- return intro.trim().length === 0;
304
- }
305
-
306
- function PublicIntro({ intro }: { intro: string }) {
307
- if (pitchKitIntroIsEmpty(intro)) return null;
308
- return <p className="type-body text-fg text-fg">{intro}</p>;
309
- }
310
-
311
- export interface PitchKitPastBrand {
312
- id: string;
313
- name: string;
314
- /** Curated mark key — missing or unknown keys use a letter Avatar. */
315
- logo_key?: string;
316
- result_label?: string;
317
- }
318
-
319
- const PITCHKIT_BRAND_RESULT_MAX = 24;
320
- const PITCHKIT_BRAND_LOGO_LETTER = "letter";
321
-
322
- const pitchKitBrandLogoKeys = [
323
- "nike", "adidas", "apple", "google", "meta", "amazon", "spotify", "netflix",
324
- "sephora", "glossier", "nordstrom", "target", "walmart", "starbucks",
325
- "coca-cola", "pepsi", "samsung", "microsoft", "adobe", "shopify",
326
- "uber", "airbnb", "disney", "lululemon", "reebok", "puma",
327
- "dior", "chanel", "bmw", "ford", "chase", "visa",
328
- ];
329
-
330
- const pastBrandLogoKeySet = new Set(pitchKitBrandLogoKeys);
331
-
332
- function resolvePastBrandLogoKey(logoKey: string | null | undefined) {
333
- if (logoKey == null || logoKey === "" || logoKey === PITCHKIT_BRAND_LOGO_LETTER) {
334
- return undefined;
335
- }
336
- return pastBrandLogoKeySet.has(logoKey) ? logoKey : undefined;
337
- }
338
-
339
- function pastBrandLogoMonogram(logoKey: string) {
340
- const parts = logoKey.split("-");
341
- if (parts.length > 1) {
342
- return parts.map((part) => part.charAt(0).toUpperCase()).join("").slice(0, 2);
343
- }
344
- return logoKey.slice(0, 1).toUpperCase();
345
- }
346
-
347
- function normalizePastBrandResult(value: string | null | undefined) {
348
- const trimmed = value?.trim() ?? "";
349
- if (trimmed.length === 0) return undefined;
350
- return trimmed.slice(0, PITCHKIT_BRAND_RESULT_MAX);
351
- }
352
-
353
- function BrandMark({ name, logoKey }: { name: string; logoKey?: string }) {
354
- const resolved = resolvePastBrandLogoKey(logoKey);
355
- if (resolved == null) {
356
- return <Avatar name={name} size="sm" />;
357
- }
358
-
359
- return (
360
- <span className="flex size-6 shrink-0 items-center justify-center rounded-full bg-fg type-supporting text-muted font-medium uppercase leading-none text-bg" role="img" aria-label={name}>
361
- <span aria-hidden>{pastBrandLogoMonogram(resolved)}</span>
362
- </span>
363
- );
364
- }
365
-
366
- function BrandResultChip({ label }: { label?: string }) {
367
- const result = normalizePastBrandResult(label);
368
- if (result == null) return null;
369
- return <Chip readOnly size="sm">{result}</Chip>;
370
- }
371
-
372
- function BrandLockup({ brand }: { brand: PitchKitPastBrand }) {
373
- return (
374
- <div className="flex min-w-0 items-center gap-3">
375
- <BrandMark name={brand.name} logoKey={brand.logo_key} />
376
- <h3 className="type-label text-fg">{brand.name}</h3>
377
- <BrandResultChip label={brand.result_label} />
378
- </div>
379
- );
380
- }
381
-
382
- function PastBrandCard({ brand, className }: { brand: PitchKitPastBrand; className: string }) {
383
- return (
384
- <Card variant="outlined" shape="rounded" className={className}>
385
- <Card.Header start={<BrandLockup brand={brand} />} />
386
- </Card>
387
- );
388
- }
389
-
390
- function PastBrandsRail({ brands }: { brands: readonly PitchKitPastBrand[] }) {
391
- const hostRef = useRef<HTMLDivElement>(null);
392
- const measureRef = useRef<HTMLUListElement>(null);
393
- const [overflows, setOverflows] = useState(false);
394
- const [reduceMotion, setReduceMotion] = useState(false);
395
-
396
- useLayoutEffect(() => {
397
- const media = window.matchMedia("(prefers-reduced-motion: reduce)");
398
- const updateMotion = () => setReduceMotion(media.matches);
399
- updateMotion();
400
- media.addEventListener("change", updateMotion);
401
- return () => media.removeEventListener("change", updateMotion);
402
- }, []);
403
-
404
- useLayoutEffect(() => {
405
- const host = hostRef.current;
406
- const measure = measureRef.current;
407
- if (host == null || measure == null) return;
408
-
409
- const update = () => {
410
- setOverflows(measure.scrollWidth > host.clientWidth + 1);
411
- };
412
- update();
413
- const observer = new ResizeObserver(update);
414
- observer.observe(host);
415
- observer.observe(measure);
416
- return () => observer.disconnect();
417
- }, [brands]);
418
-
419
- const duration = Math.max(16, brands.length * 4);
420
- const showMarquee = overflows && !reduceMotion;
421
-
422
- return (
423
- <div
424
- ref={hostRef}
425
- className="relative col-span-full min-w-0"
426
- data-overflow={showMarquee ? "true" : "false"}
427
- >
428
- <ul ref={measureRef} className="pointer-events-none invisible absolute flex w-max items-center gap-3" aria-hidden>
429
- {brands.map((brand) => (
430
- <li key={`${brand.id}-measure`}>
431
- <PastBrandCard brand={brand} className="w-max max-w-full shrink-0" />
432
- </li>
433
- ))}
434
- </ul>
435
- {reduceMotion ? (
436
- <ul className="flex min-w-0 flex-wrap items-center gap-3" aria-label="Past brands">
437
- {brands.map((brand) => (
438
- <li key={brand.id}>
439
- <PastBrandCard brand={brand} className="w-max max-w-full shrink-0" />
440
- </li>
441
- ))}
442
- </ul>
443
- ) : showMarquee ? (
444
- <>
445
- <ul className="sr-only" aria-label="Past brands">
446
- {brands.map((brand) => {
447
- const result = normalizePastBrandResult(brand.result_label);
448
- return (
449
- <li key={brand.id}>
450
- {result == null ? brand.name : `${brand.name}, ${result}`}
451
- </li>
452
- );
453
- })}
454
- </ul>
455
- <div className="group overflow-hidden" aria-hidden>
456
- <div
457
- className="marquee-track flex w-max items-center"
458
- style={{ "--marquee-duration": `${duration}s` } as CSSProperties}
459
- >
460
- <ul className="flex min-w-0 items-center gap-3">
461
- {brands.map((brand) => (
462
- <li key={`${brand.id}-loop-a`}>
463
- <PastBrandCard brand={brand} className="w-max max-w-full shrink-0" />
464
- </li>
465
- ))}
466
- </ul>
467
- <ul className="flex min-w-0 items-center gap-3">
468
- {brands.map((brand) => (
469
- <li key={`${brand.id}-loop-b`}>
470
- <PastBrandCard brand={brand} className="w-max max-w-full shrink-0" />
471
- </li>
472
- ))}
473
- </ul>
474
- </div>
475
- </div>
476
- </>
477
- ) : (
478
- <ul className="flex min-w-0 items-center gap-3" aria-label="Past brands">
479
- {brands.map((brand) => (
480
- <li key={brand.id}>
481
- <PastBrandCard brand={brand} className="w-max max-w-full shrink-0" />
482
- </li>
483
- ))}
484
- </ul>
485
- )}
486
- </div>
487
- );
488
- }
489
-
490
- export function PublicPastBrands({ brands }: { brands: readonly PitchKitPastBrand[] }) {
491
- if (brands.length === 0) return null;
492
-
493
- return (
494
- <section className="band min-w-0 gap-y-4">
495
- <div className="col-span-full flex flex-wrap items-end justify-between gap-3">
496
- <h2 className={cardTitleClasses}>Past brands</h2>
497
- </div>
498
- <PastBrandsRail brands={brands} />
499
- </section>
500
- );
501
- }
502
-
503
-
504
- function PublicCreatePitchkitBand() {
505
- return (
506
- <Card
507
- variant="outlined"
508
- shape="rounded"
509
- bodyTerminal
510
- className="col-span-full"
511
- >
512
- <Card.Header
513
- start={<h2 className={cardTitleClasses}>Create your Pitchkit</h2>}
514
- />
515
- <Card.Body>
516
- <div className="flex min-w-0 flex-col gap-4 px-3.5 py-[16px]">
517
- <p className="type-body text-fg text-muted">
518
- Turn your Instagram into a shareable media kit.
519
- </p>
520
- <div className="flex flex-wrap items-center gap-3">
521
- <Button role="primary">Continue with Instagram</Button>
522
- </div>
523
- </div>
524
- </Card.Body>
525
- </Card>
526
- );
527
- }
528
-
529
- function PublicReachCard({
530
- reachState,
531
- reachData,
532
- }: {
533
- reachState: PitchKitReachState;
534
- reachData: ChartCartesianPoint[];
535
- }) {
536
- return (
537
- <Card
538
- variant="outlined"
539
- shape="rounded"
540
- bodyTerminal
541
- className="col-span-full min-w-0 lg:col-span-6"
542
- >
543
- <Card.Header
544
- start={
545
- <>
546
- <h2 className={cardTitleClasses}>Reach over 30 days</h2>
547
- <p className={cardSubtitleClasses}>
548
- Typical performance with unusual spikes left visible.
549
- </p>
550
- </>
551
- }
552
- end={
553
- <Badge variant="neutral" emphasis="muted" size="sm">
554
- Graph data
555
- </Badge>
556
- }
557
- />
558
- <Card.Body>
559
- {reachState === "insufficient" ? (
560
- <div
561
- className="flex min-w-0 flex-col gap-4 bg-body px-3.5 py-4 rounded-[var(--radius-card-body)] items-center justify-center text-center"
562
- style={{ minHeight: 220 }}
563
- >
564
- <div className="flex max-w-lg flex-col gap-2 items-center text-center">
565
- <Badge variant="neutral" emphasis="muted">No data</Badge>
566
- <h3 className="type-heading-2 text-fg">No reach data yet</h3>
567
- <p className="type-body text-fg text-muted">
568
- Connect more Instagram activity to plot the last 30 days.
569
- </p>
570
- </div>
571
- </div>
572
- ) : (
573
- <div className="flex min-w-0 flex-col gap-4 bg-body px-3.5 py-4 rounded-[var(--radius-card-body)]">
574
- <Chart.Cartesian
575
- data={reachData}
576
- config={reachConfig}
577
- periodKind="month"
578
- minHeight={220}
579
- aria-label="Daily and typical Instagram reach over the last 30 days"
580
- />
581
- <Chart.Legend config={reachConfig} />
582
- </div>
583
- )}
584
- </Card.Body>
585
- </Card>
586
- );
587
- }
588
-
589
- function PublicCountries({ countries }: { countries: ChartRankedBarItem[] }) {
590
- const topCountries = countries.slice(0, 3);
591
- if (topCountries.length === 0) return null;
592
-
593
- return (
594
- <Card
595
- variant="outlined"
596
- shape="rounded"
597
- bodyTerminal
598
- className="col-span-full min-w-0 lg:col-span-6"
599
- >
600
- <Card.Header
601
- start={
602
- <>
603
- <h2 className={cardTitleClasses}>Top countries</h2>
604
- <p className={cardSubtitleClasses}>
605
- Top 3 from Instagram Insights.
606
- </p>
607
- </>
608
- }
609
- />
610
- <Card.Body>
611
- <div className="flex min-w-0 flex-col gap-4 bg-body px-3.5 py-4 rounded-[var(--radius-card-body)]">
612
- <Chart.RankedBars
613
- aria-label="Audience by country"
614
- items={topCountries}
615
- animate="initial"
616
- />
617
- </div>
618
- </Card.Body>
619
- </Card>
620
- );
621
- }
622
-
623
- function ShareablePitchKit({
624
- identity,
625
- intro,
626
- posts,
627
- contact,
628
- brands,
629
- countries,
630
- reachData,
631
- reachState = "resolved",
632
- showCreateBand = true,
633
- }: ShareablePitchKitProps) {
634
- const engagementRate = reachState === "resolved" ? "5.8%" : null;
635
- const typicalReach = reachState === "resolved" ? "9.3K" : "—";
636
-
637
- return (
638
- <>
639
- <section className="col-span-full border-b border-border pb-6">
640
- <div className="flex min-w-0 flex-col gap-3">
641
- <CreatorIdentityStrip
642
- identity={identity}
643
- nameAs="h1"
644
- showProfessionalChip
645
- />
646
- <PublicIntro intro={intro} />
647
- </div>
648
- </section>
649
-
650
- <div
651
- role="group"
652
- aria-label="Instagram performance summary"
653
- className="band gap-y-4"
654
- >
655
- <Stat className="col-span-2 md:col-span-4 lg:col-span-3" label="Followers" value="84.2K" />
656
- {engagementRate != null ? (
657
- <Stat className="col-span-2 md:col-span-4 lg:col-span-3" label="Engagement rate" value={engagementRate} />
658
- ) : null}
659
- <Stat className="col-span-2 md:col-span-4 lg:col-span-3" label="Typical reach" value={typicalReach} />
660
- <Stat className="col-span-2 md:col-span-4 lg:col-span-3" label="Typical saves" value="6.1K" />
661
- </div>
662
-
663
- <div className="band min-w-0 gap-y-6 [align-items:stretch]">
664
- <PublicReachCard reachState={reachState} reachData={reachData} />
665
- <PublicCountries countries={countries} />
666
- </div>
667
-
668
- <section className="band min-w-0 gap-y-4">
669
- <div className="col-span-full flex flex-wrap items-end justify-between gap-3">
670
- <div>
671
- <h2 className={cardTitleClasses}>Selected posts</h2>
672
- <p className="type-body text-fg text-muted">
673
- Proof from the current Instagram set.
674
- </p>
675
- </div>
676
- </div>
677
- <div className="band col-span-full min-w-0 gap-y-4">
678
- {posts.map((post) => (
679
- <Card key={post.id} variant="outlined" shape="rounded" className="col-span-full min-w-0 md:col-span-4 lg:col-span-4">
680
- <Card.Body>
681
- <img
682
- className="aspect-[4/3] w-full bg-body object-cover rounded-[var(--radius-card-body)]"
683
- src={post.imageUrl}
684
- alt={post.imageAlt}
685
- />
686
- </Card.Body>
687
- <Card.Footer>
688
- <div className="grid w-full grid-cols-2 gap-3">
689
- {[
690
- ["Likes", post.likes],
691
- ["Comments", post.comments],
692
- ].map(([label, value]) => (
693
- <span key={label} className="flex min-w-0 flex-col gap-1">
694
- <span className="type-supporting font-medium uppercase tracking-wider text-muted text-muted">{label}</span>
695
- <span className="font-mono text-sm tabular-nums text-fg">
696
- {compactNumber.format(value as number)}
697
- </span>
698
- </span>
699
- ))}
700
- </div>
701
- </Card.Footer>
702
- </Card>
703
- ))}
704
- </div>
705
- </section>
706
-
707
- <section className="band min-w-0 gap-y-4">
708
- <div className="col-span-full flex flex-wrap items-end justify-between gap-3">
709
- <div>
710
- <h2 className={cardTitleClasses}>Contact</h2>
711
- <p className="type-body text-fg text-muted">
712
- Creator-entered details for brand outreach.
713
- </p>
714
- </div>
715
- </div>
716
- <Card variant="outlined" padding="md" shape="rounded" className="col-span-full">
717
- <div className="flex flex-col gap-3">
718
- <div className="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-3">
719
- <span className="type-supporting font-medium uppercase tracking-wider text-muted text-muted">Email</span>
720
- <TextLink href={`mailto:${contact.email}`}>{contact.email}</TextLink>
721
- </div>
722
- <div className="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-3">
723
- <span className="type-supporting font-medium uppercase tracking-wider text-muted text-muted">Website</span>
724
- <TextLink href={contact.websiteHref} external>{contact.websiteLabel}</TextLink>
725
- </div>
726
- <div className="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-3">
727
- <span className="type-supporting font-medium uppercase tracking-wider text-muted text-muted">Location</span>
728
- <span className="type-body text-fg text-muted">{contact.location}</span>
729
- </div>
730
- </div>
731
- </Card>
732
- </section>
733
-
734
- <PublicPastBrands brands={brands} />
735
-
736
- {showCreateBand ? <PublicCreatePitchkitBand /> : null}
737
- </>
738
- );
739
- }
740
-
741
-
742
- export function ThemePickerOwnerPage({
743
- identity,
744
- intro,
745
- posts,
746
- contact,
747
- brands,
748
- countries,
749
- reachData,
750
- }: PitchKitPageData) {
751
- const [draftTheme, setDraftTheme] = useState("light");
752
- const [savedTheme, setSavedTheme] = useState("light");
753
- const dirty = draftTheme !== savedTheme;
754
-
755
- function saveTheme() {
756
- if (!dirty) return;
757
- setSavedTheme(draftTheme);
758
- toast.add({
759
- title: "Theme saved",
760
- description: `Public kit appearance is ${draftTheme}.`,
761
- tone: "success",
762
- });
763
- }
764
-
765
- return (
766
- <main data-theme={draftTheme} className="grid-page min-h-screen bg-body [--grid-column-gap:8px] [--grid-max:1140px] [padding-bottom:44px]">
767
- <div className="band pb-4">
768
- <header className="col-span-full grid grid-cols-[1fr_auto_1fr] items-center gap-3">
769
- <span className="type-heading-4 text-fg text-fg">PitchKit</span>
770
- <span />
771
- <span className="justify-self-end">
772
- <OwnerAccountMenu identity={identity} />
773
- </span>
774
- </header>
775
- </div>
776
-
777
- <div className="band pt-6 sm:pt-8">
778
- <div className="band min-w-0 gap-y-6 sm:gap-y-8">
779
- <section className="col-span-full">
780
- <PageHeader
781
- variant="page"
782
- title="Theme"
783
- end={
784
- <Button
785
- role="primary"
786
- size="sm"
787
- disabled={!dirty}
788
- onClick={saveTheme}
789
- >
790
- Save theme
791
- </Button>
792
- }
793
- />
794
- <div className="flex max-w-2xl flex-col gap-1">
795
- <p className="type-body text-fg text-muted">
796
- Choose a look for your public Pitchkit. Changes apply when you save.
797
- </p>
798
- </div>
799
- </section>
800
-
801
- <div className="col-span-full flex flex-wrap items-end justify-between gap-3">
802
- <SegmentedControl
803
- aria-label="Kit theme"
804
- size="sm"
805
- value={draftTheme}
806
- onValueChange={setDraftTheme}
807
- >
808
- {pitchKitThemes.map((theme) => (
809
- <SegmentedControl.Item key={theme} value={theme}>
810
- {theme === "light" ? "Light" : theme === "dark" ? "Dark" : "Soft"}
811
- </SegmentedControl.Item>
812
- ))}
813
- </SegmentedControl>
814
- </div>
815
-
816
- <ShareablePitchKit
817
- identity={identity}
818
- intro={intro}
819
- posts={posts}
820
- contact={contact}
821
- brands={brands}
822
- countries={countries}
823
- reachData={reachData}
824
- showCreateBand={false}
825
- />
826
- </div>
827
- </div>
828
- <PitchKitPageFooter />
829
- <Toaster position="bottom-right" />
830
- </main>
831
- );
832
- }