@tribe-nest/forge 1.13.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 (255) hide show
  1. package/package.json +42 -0
  2. package/src/client/createForgeClient.ts +54 -0
  3. package/src/content/ForgeContentProvider.tsx +118 -0
  4. package/src/content/ForgeEditBridge.tsx +134 -0
  5. package/src/content/editFlag.ts +23 -0
  6. package/src/content/index.ts +28 -0
  7. package/src/content/resolve.ts +67 -0
  8. package/src/content/types.ts +97 -0
  9. package/src/content/useField.ts +64 -0
  10. package/src/contexts/AppAuthContext.tsx +185 -0
  11. package/src/contexts/AudioPlayerContext.tsx +389 -0
  12. package/src/contexts/CartContext.tsx +131 -0
  13. package/src/contexts/PublicAuthContext.tsx +333 -0
  14. package/src/contexts/useAppAdminGuard.ts +56 -0
  15. package/src/css.d.ts +5 -0
  16. package/src/data/collectionParams.ts +57 -0
  17. package/src/data/queries/useAccount.ts +71 -0
  18. package/src/data/queries/useAccountSettings.ts +82 -0
  19. package/src/data/queries/useAnalytics.ts +86 -0
  20. package/src/data/queries/useAuthActions.ts +28 -0
  21. package/src/data/queries/useBlog.ts +103 -0
  22. package/src/data/queries/useBlogComments.ts +96 -0
  23. package/src/data/queries/useBroadcasts.ts +31 -0
  24. package/src/data/queries/useCertificates.ts +58 -0
  25. package/src/data/queries/useChat.ts +267 -0
  26. package/src/data/queries/useCoachingAvailability.ts +69 -0
  27. package/src/data/queries/useCoachingProducts.ts +67 -0
  28. package/src/data/queries/useCohortPage.ts +17 -0
  29. package/src/data/queries/useCollections.ts +211 -0
  30. package/src/data/queries/useCommunity.ts +794 -0
  31. package/src/data/queries/useCoupons.ts +20 -0
  32. package/src/data/queries/useCourseAccess.ts +50 -0
  33. package/src/data/queries/useCourses.ts +91 -0
  34. package/src/data/queries/useCurrencies.ts +33 -0
  35. package/src/data/queries/useDocuments.ts +208 -0
  36. package/src/data/queries/useDonations.ts +29 -0
  37. package/src/data/queries/useEngagement.ts +115 -0
  38. package/src/data/queries/useEvents.ts +69 -0
  39. package/src/data/queries/useFinalize.ts +109 -0
  40. package/src/data/queries/useForms.ts +31 -0
  41. package/src/data/queries/useInvoice.ts +65 -0
  42. package/src/data/queries/useLeadMagnet.ts +96 -0
  43. package/src/data/queries/useMembership.ts +20 -0
  44. package/src/data/queries/useNotifications.ts +267 -0
  45. package/src/data/queries/useOffers.ts +56 -0
  46. package/src/data/queries/useOrders.ts +71 -0
  47. package/src/data/queries/usePWA.ts +101 -0
  48. package/src/data/queries/usePageActions.ts +36 -0
  49. package/src/data/queries/usePaymentFlow.ts +80 -0
  50. package/src/data/queries/usePaymentLink.ts +47 -0
  51. package/src/data/queries/usePodcast.ts +85 -0
  52. package/src/data/queries/usePostCollections.ts +48 -0
  53. package/src/data/queries/usePosts.ts +94 -0
  54. package/src/data/queries/useProducts.ts +108 -0
  55. package/src/data/queries/useReplay.ts +19 -0
  56. package/src/data/queries/useReviews.ts +122 -0
  57. package/src/data/queries/useShipping.ts +109 -0
  58. package/src/data/queries/useSubscriptions.ts +66 -0
  59. package/src/data/queries/useWebsite.ts +128 -0
  60. package/src/data/queries/useWebsiteAgent.ts +100 -0
  61. package/src/index.ts +98 -0
  62. package/src/provider/ForgeAppProvider.tsx +149 -0
  63. package/src/provider/ForgeProvider.tsx +91 -0
  64. package/src/provider/SiteConfigProvider.tsx +27 -0
  65. package/src/server/_tests/buildPwaHead.spec.ts +182 -0
  66. package/src/server/_tests/buildWebManifest.spec.ts +313 -0
  67. package/src/server/_tests/forgeServiceWorkerScript.spec.ts +251 -0
  68. package/src/server/index.ts +260 -0
  69. package/src/server/jobs.ts +104 -0
  70. package/src/server/pwa.ts +332 -0
  71. package/src/types/index.ts +74 -0
  72. package/src/types/models.ts +1313 -0
  73. package/src/ui/analytics/ForgeAnalytics.tsx +208 -0
  74. package/src/ui/analytics/PageMetaPixel.tsx +92 -0
  75. package/src/ui/content/Editable.tsx +90 -0
  76. package/src/ui/format/PriceDisplay.tsx +142 -0
  77. package/src/ui/format/useFormatCurrency.ts +92 -0
  78. package/src/ui/headless/agent/useAiAgent.ts +106 -0
  79. package/src/ui/headless/auth/useLoginFlow.ts +72 -0
  80. package/src/ui/headless/auth/useSignupForm.ts +85 -0
  81. package/src/ui/headless/broadcast/useBroadcastWatch.ts +59 -0
  82. package/src/ui/headless/chat/attachmentKind.ts +27 -0
  83. package/src/ui/headless/chat/useChatAttachmentUpload.ts +132 -0
  84. package/src/ui/headless/chat/useChatRoom.ts +223 -0
  85. package/src/ui/headless/chat/useMessageThread.ts +60 -0
  86. package/src/ui/headless/checkout/useCheckout.ts +438 -0
  87. package/src/ui/headless/coaching/useCoachingBooking.ts +223 -0
  88. package/src/ui/headless/community/index.ts +20 -0
  89. package/src/ui/headless/community/lexical.ts +131 -0
  90. package/src/ui/headless/community/replyTree.ts +51 -0
  91. package/src/ui/headless/community/richLexical.ts +314 -0
  92. package/src/ui/headless/community/useCommunityAttachmentUpload.ts +137 -0
  93. package/src/ui/headless/community/useCommunitySpaceFeed.ts +122 -0
  94. package/src/ui/headless/community/useCommunityThread.ts +95 -0
  95. package/src/ui/headless/community/useMentionComposer.ts +105 -0
  96. package/src/ui/headless/community/useRichMentionComposer.ts +193 -0
  97. package/src/ui/headless/consent/useCookieConsent.ts +81 -0
  98. package/src/ui/headless/course/useCourseCheckout.ts +99 -0
  99. package/src/ui/headless/dialog.tsx +14 -0
  100. package/src/ui/headless/document/index.ts +7 -0
  101. package/src/ui/headless/document/useContractSignature.ts +68 -0
  102. package/src/ui/headless/document/useDocumentSigningFlow.ts +92 -0
  103. package/src/ui/headless/document/useOtpCodeInput.ts +86 -0
  104. package/src/ui/headless/document/useSignaturePad.ts +180 -0
  105. package/src/ui/headless/donation/Donation.tsx +115 -0
  106. package/src/ui/headless/donation/DonationContext.tsx +223 -0
  107. package/src/ui/headless/donation/fees.ts +15 -0
  108. package/src/ui/headless/donation/index.ts +10 -0
  109. package/src/ui/headless/engagement/usePostEngagement.ts +119 -0
  110. package/src/ui/headless/event/useEventCheckout.ts +141 -0
  111. package/src/ui/headless/forms/useContactForm.ts +58 -0
  112. package/src/ui/headless/forms/useEmailListForm.ts +75 -0
  113. package/src/ui/headless/forms/useSectionedForm.ts +256 -0
  114. package/src/ui/headless/index.ts +60 -0
  115. package/src/ui/headless/invoice/useInvoicePayment.ts +48 -0
  116. package/src/ui/headless/memberHome/index.ts +7 -0
  117. package/src/ui/headless/memberHome/useMemberHomeNav.ts +82 -0
  118. package/src/ui/headless/membership/MembershipGate.tsx +39 -0
  119. package/src/ui/headless/membership/useMembershipCheckout.ts +121 -0
  120. package/src/ui/headless/offer/Offer.tsx +88 -0
  121. package/src/ui/headless/offer/OfferContext.tsx +162 -0
  122. package/src/ui/headless/offer/index.ts +8 -0
  123. package/src/ui/headless/paymentLink/usePaymentLinkPayment.ts +46 -0
  124. package/src/ui/headless/podcast/usePodcastPlayer.ts +96 -0
  125. package/src/ui/headless/posts/index.ts +13 -0
  126. package/src/ui/headless/posts/upsell.ts +41 -0
  127. package/src/ui/headless/posts/useMemberPostsFeed.ts +110 -0
  128. package/src/ui/headless/posts/usePostCollectionDetail.ts +56 -0
  129. package/src/ui/headless/posts/usePostCollectionsList.ts +90 -0
  130. package/src/ui/headless/posts/usePostItem.ts +81 -0
  131. package/src/ui/headless/reviews/index.ts +6 -0
  132. package/src/ui/headless/reviews/useHelpfulVote.ts +45 -0
  133. package/src/ui/headless/reviews/useReviewForm.ts +108 -0
  134. package/src/ui/headless/reviews/useReviewsList.ts +79 -0
  135. package/src/ui/headless/work/index.ts +25 -0
  136. package/src/ui/headless/work/useWorkPortal.ts +349 -0
  137. package/src/ui/index.ts +144 -0
  138. package/src/ui/payment/ForgePaymentProvider.tsx +45 -0
  139. package/src/ui/payment/ForgeStripePayment.tsx +171 -0
  140. package/src/ui/shell/TribeNestApp.tsx +121 -0
  141. package/src/ui/shell/shellGating.spec.ts +28 -0
  142. package/src/ui/shell/shellGating.ts +11 -0
  143. package/src/ui/styled/AccountDashboard.tsx +575 -0
  144. package/src/ui/styled/AiAgentWidget.tsx +152 -0
  145. package/src/ui/styled/AudioPlayer.tsx +123 -0
  146. package/src/ui/styled/BlogCategory.tsx +79 -0
  147. package/src/ui/styled/BlogComments.tsx +236 -0
  148. package/src/ui/styled/BlogList.tsx +101 -0
  149. package/src/ui/styled/BlogPost.tsx +160 -0
  150. package/src/ui/styled/BlogPostFooter.tsx +33 -0
  151. package/src/ui/styled/BotProtection.tsx +101 -0
  152. package/src/ui/styled/Button.tsx +88 -0
  153. package/src/ui/styled/Cart.tsx +276 -0
  154. package/src/ui/styled/ChatRoom.tsx +252 -0
  155. package/src/ui/styled/Checkout.tsx +988 -0
  156. package/src/ui/styled/CheckoutConfirmation.tsx +452 -0
  157. package/src/ui/styled/CoachingBooking.tsx +605 -0
  158. package/src/ui/styled/CoachingConfirmation.tsx +151 -0
  159. package/src/ui/styled/CoachingDetail.tsx +99 -0
  160. package/src/ui/styled/CohortPage.tsx +82 -0
  161. package/src/ui/styled/ConfirmSubscription.tsx +134 -0
  162. package/src/ui/styled/Confirmation.tsx +171 -0
  163. package/src/ui/styled/ContactForm.tsx +81 -0
  164. package/src/ui/styled/CookieConsent.tsx +239 -0
  165. package/src/ui/styled/CourseAccess.tsx +169 -0
  166. package/src/ui/styled/CourseCheckout.tsx +425 -0
  167. package/src/ui/styled/CourseConfirmation.tsx +191 -0
  168. package/src/ui/styled/CourseDetail.tsx +140 -0
  169. package/src/ui/styled/CoursesGrid.tsx +85 -0
  170. package/src/ui/styled/CurrencySwitcher.tsx +51 -0
  171. package/src/ui/styled/DonationButton.tsx +247 -0
  172. package/src/ui/styled/DonationPage.tsx +29 -0
  173. package/src/ui/styled/EmailListForm.tsx +88 -0
  174. package/src/ui/styled/EventConfirmation.tsx +228 -0
  175. package/src/ui/styled/EventCountdown.tsx +98 -0
  176. package/src/ui/styled/EventDetail.tsx +141 -0
  177. package/src/ui/styled/EventTickets.tsx +548 -0
  178. package/src/ui/styled/EventsList.tsx +83 -0
  179. package/src/ui/styled/ForgotPasswordForm.tsx +105 -0
  180. package/src/ui/styled/FormRenderer.tsx +249 -0
  181. package/src/ui/styled/InstallBanner.tsx +114 -0
  182. package/src/ui/styled/InvoiceConfirmation.tsx +50 -0
  183. package/src/ui/styled/InvoicePayment.tsx +141 -0
  184. package/src/ui/styled/LeadMagnet.tsx +93 -0
  185. package/src/ui/styled/Loading.tsx +56 -0
  186. package/src/ui/styled/LoginForm.tsx +134 -0
  187. package/src/ui/styled/Markdown.tsx +103 -0
  188. package/src/ui/styled/MembershipCheckout.tsx +197 -0
  189. package/src/ui/styled/MembershipTiers.tsx +115 -0
  190. package/src/ui/styled/OfferButton.tsx +181 -0
  191. package/src/ui/styled/PageActions.tsx +124 -0
  192. package/src/ui/styled/PaymentLinkConfirmation.tsx +50 -0
  193. package/src/ui/styled/PaymentLinkPayment.tsx +85 -0
  194. package/src/ui/styled/Paywall.tsx +54 -0
  195. package/src/ui/styled/PlayButton.tsx +48 -0
  196. package/src/ui/styled/PodcastEpisode.tsx +137 -0
  197. package/src/ui/styled/PodcastList.tsx +58 -0
  198. package/src/ui/styled/PodcastShow.tsx +164 -0
  199. package/src/ui/styled/PostsFeed.tsx +63 -0
  200. package/src/ui/styled/ProductDetail.tsx +616 -0
  201. package/src/ui/styled/ProductGrid.tsx +82 -0
  202. package/src/ui/styled/PushOptIn.tsx +65 -0
  203. package/src/ui/styled/PwaRegistration.tsx +58 -0
  204. package/src/ui/styled/ReactionBar.tsx +93 -0
  205. package/src/ui/styled/ReplayList.tsx +134 -0
  206. package/src/ui/styled/ResetPasswordForm.tsx +127 -0
  207. package/src/ui/styled/ReviewForm.tsx +292 -0
  208. package/src/ui/styled/ReviewsSection.tsx +260 -0
  209. package/src/ui/styled/SectionedFormRenderer.tsx +146 -0
  210. package/src/ui/styled/SignupForm.tsx +109 -0
  211. package/src/ui/styled/UserMenu.tsx +166 -0
  212. package/src/ui/styled/chat/ChatAttachments.tsx +172 -0
  213. package/src/ui/styled/chat/ChatComposer.tsx +153 -0
  214. package/src/ui/styled/chat/ChatThreadPanel.tsx +94 -0
  215. package/src/ui/styled/chat/MessageBubble.tsx +66 -0
  216. package/src/ui/styled/chat/NewDmDialog.tsx +78 -0
  217. package/src/ui/styled/community/CommunityComposer.tsx +358 -0
  218. package/src/ui/styled/community/CommunityFeed.tsx +483 -0
  219. package/src/ui/styled/community/CommunityLeaderboard.tsx +109 -0
  220. package/src/ui/styled/community/CommunityMediaGallery.tsx +116 -0
  221. package/src/ui/styled/community/CommunityMemberProfile.tsx +285 -0
  222. package/src/ui/styled/community/CommunityNotifications.tsx +222 -0
  223. package/src/ui/styled/community/CommunityPostCard.tsx +165 -0
  224. package/src/ui/styled/community/CommunityPostDetail.tsx +337 -0
  225. package/src/ui/styled/community/CommunityReactionBar.tsx +107 -0
  226. package/src/ui/styled/community/CommunityRichText.tsx +157 -0
  227. package/src/ui/styled/community/CommunitySpaces.tsx +174 -0
  228. package/src/ui/styled/community/MemberAvatar.tsx +74 -0
  229. package/src/ui/styled/community/index.ts +23 -0
  230. package/src/ui/styled/community/util.ts +15 -0
  231. package/src/ui/styled/members/MemberHomeLayout.tsx +98 -0
  232. package/src/ui/styled/members/MemberPostCard.tsx +392 -0
  233. package/src/ui/styled/members/MemberPostsFeed.tsx +219 -0
  234. package/src/ui/styled/members/PostCollectionDetail.tsx +227 -0
  235. package/src/ui/styled/members/PostCollectionsGrid.tsx +287 -0
  236. package/src/ui/styled/members/index.ts +7 -0
  237. package/src/ui/styled/rich-text.css +150 -0
  238. package/src/ui/styled/work/WorkInviteAccept.tsx +222 -0
  239. package/src/ui/styled/work/WorkPortalProjects.tsx +163 -0
  240. package/src/ui/styled/work/WorkProjectInvoices.tsx +113 -0
  241. package/src/ui/styled/work/WorkProjectReport.tsx +66 -0
  242. package/src/ui/styled/work/WorkReportBody.tsx +327 -0
  243. package/src/ui/styled/work/WorkTaskAttachments.tsx +67 -0
  244. package/src/ui/styled/work/WorkTaskComments.tsx +151 -0
  245. package/src/ui/styled/work/WorkTaskDetail.tsx +92 -0
  246. package/src/ui/styled/work/WorkTokenReport.tsx +49 -0
  247. package/src/ui/styled/work/index.ts +10 -0
  248. package/src/ui/theme/ForgeThemeProvider.tsx +121 -0
  249. package/src/ui/theme/contrast.ts +22 -0
  250. package/src/utils/analyticsBus.ts +31 -0
  251. package/src/utils/attribution.ts +68 -0
  252. package/src/utils/cookieConsent.ts +83 -0
  253. package/src/utils/landing.ts +153 -0
  254. package/src/utils/metaPixel.ts +122 -0
  255. package/src/utils/structuredData.ts +126 -0
@@ -0,0 +1,137 @@
1
+ import { Play, Pause } from "lucide-react";
2
+ import { usePodcast, findEpisode, episodeAudio } from "../../data/queries/usePodcast";
3
+ import { usePodcastPlayer } from "../headless/podcast/usePodcastPlayer";
4
+ import type { BlogPost, BlogCategory } from "../../types/models";
5
+ import { useForgeTheme } from "../theme/ForgeThemeProvider";
6
+ import { Loading } from "./Loading";
7
+ // Baseline `.rich-text` content styles ship with Forge (WYSIWYG with the admin
8
+ // editor) — no host-loaded stylesheet needed.
9
+ import "./rich-text.css";
10
+
11
+ export interface PodcastEpisodeProps {
12
+ /** Show (podcast category) slug. */
13
+ showSlug: string;
14
+ /** Episode (blog post) slug. */
15
+ episodeSlug: string;
16
+ /** Build hrefs for sibling episodes + back to the show. */
17
+ episodeHref?: (episodeSlug: string) => string;
18
+ showHref?: (showSlug: string) => string;
19
+ initialShow?: BlogCategory | null;
20
+ initialEpisodes?: BlogPost[] | null;
21
+ }
22
+
23
+ function fmt(sec?: number | null) {
24
+ if (!sec || sec <= 0) return "";
25
+ const m = Math.floor(sec / 60);
26
+ const s = Math.floor(sec % 60);
27
+ return `${m}:${s.toString().padStart(2, "0")}`;
28
+ }
29
+
30
+ /**
31
+ * Single-episode page — plays this episode and offers Previous / Next episode
32
+ * buttons. Shares the queue + player with the show page (persistent playback).
33
+ * Built on `usePodcast` + `usePodcastPlayer`.
34
+ */
35
+ export function PodcastEpisode({
36
+ showSlug,
37
+ episodeSlug,
38
+ episodeHref = (s) => `/i/podcasts/${showSlug}/${s}`,
39
+ showHref = (s) => `/i/podcasts/${s}`,
40
+ initialShow,
41
+ initialEpisodes,
42
+ }: PodcastEpisodeProps) {
43
+ const theme = useForgeTheme();
44
+ const { show, episodes, isLoading } = usePodcast(showSlug, {
45
+ initialShow: initialShow ?? undefined,
46
+ initialEpisodes: initialEpisodes ?? undefined,
47
+ });
48
+ const player = usePodcastPlayer({ episodes, show });
49
+ const { episode, previous, next } = findEpisode(episodes, episodeSlug);
50
+
51
+ if (isLoading) return <Loading fullPage />;
52
+ if (!episode) return <p style={{ color: theme.colors.text }}>Episode not found.</p>;
53
+
54
+ const border = `${theme.colors.text}1a`;
55
+ const dur = episodeAudio(episode)?.durationSec;
56
+ const playing = player.isEpisodePlaying(episode);
57
+
58
+ return (
59
+ <article style={{ maxWidth: 720, margin: "0 auto", padding: "40px 20px", color: theme.colors.text }}>
60
+ <a href={showHref(showSlug)} style={{ color: theme.colors.primary, textDecoration: "none", fontSize: 14 }}>
61
+ ← {show?.title ?? "Podcast"}
62
+ </a>
63
+
64
+ <h1 style={{ fontSize: 26, fontWeight: 800, marginTop: 12 }}>{episode.title}</h1>
65
+ <div style={{ fontSize: 13, opacity: 0.55, marginTop: 4 }}>
66
+ {episode.publishedAt ? new Date(episode.publishedAt).toLocaleDateString() : ""}
67
+ {dur ? ` · ${fmt(dur)}` : ""}
68
+ </div>
69
+
70
+ {/* Play control for this episode (loads the show as the queue) */}
71
+ <div style={{ display: "flex", alignItems: "center", gap: 12, margin: "18px 0" }}>
72
+ <button
73
+ onClick={() => player.toggleEpisode(episode)}
74
+ style={{
75
+ display: "inline-flex",
76
+ alignItems: "center",
77
+ gap: 8,
78
+ padding: "10px 18px",
79
+ borderRadius: 999,
80
+ border: "none",
81
+ background: theme.colors.primary,
82
+ color: theme.colors.background,
83
+ cursor: "pointer",
84
+ fontWeight: 600,
85
+ }}
86
+ >
87
+ {playing ? <Pause size={18} /> : <Play size={18} />}
88
+ {playing ? "Pause" : "Play episode"}
89
+ </button>
90
+ {player.isCurrent(episode) && (
91
+ <span style={{ fontSize: 13, opacity: 0.6 }}>
92
+ {fmt(player.currentTime)} / {fmt(player.duration)}
93
+ </span>
94
+ )}
95
+ </div>
96
+
97
+ {/* Show notes — `rich-text` = shared baseline content styles (WYSIWYG
98
+ with the editor), bundled with Forge via the ./rich-text.css import. */}
99
+ <div
100
+ className="rich-text"
101
+ style={{ lineHeight: 1.7, marginTop: 8, borderTop: `1px solid ${border}`, paddingTop: 18 }}
102
+ dangerouslySetInnerHTML={{ __html: episode.content }}
103
+ />
104
+
105
+ {/* Prev / Next episode navigation */}
106
+ <nav style={{ display: "flex", justifyContent: "space-between", gap: 12, marginTop: 32, borderTop: `1px solid ${border}`, paddingTop: 18 }}>
107
+ {previous ? (
108
+ <a href={episodeHref(previous.slug)} style={navLink(theme)}>
109
+ <span style={{ opacity: 0.55, fontSize: 12 }}>← Previous</span>
110
+ <span style={{ fontWeight: 600 }}>{previous.title}</span>
111
+ </a>
112
+ ) : (
113
+ <span />
114
+ )}
115
+ {next ? (
116
+ <a href={episodeHref(next.slug)} style={{ ...navLink(theme), textAlign: "right", alignItems: "flex-end" }}>
117
+ <span style={{ opacity: 0.55, fontSize: 12 }}>Next →</span>
118
+ <span style={{ fontWeight: 600 }}>{next.title}</span>
119
+ </a>
120
+ ) : (
121
+ <span />
122
+ )}
123
+ </nav>
124
+ </article>
125
+ );
126
+ }
127
+
128
+ function navLink(theme: ReturnType<typeof useForgeTheme>): React.CSSProperties {
129
+ return {
130
+ display: "flex",
131
+ flexDirection: "column",
132
+ gap: 2,
133
+ maxWidth: "48%",
134
+ color: theme.colors.text,
135
+ textDecoration: "none",
136
+ };
137
+ }
@@ -0,0 +1,58 @@
1
+ import { usePodcasts } from "../../data/queries/usePodcast";
2
+ import type { PodcastShow } from "../../types/models";
3
+ import { useForgeTheme } from "../theme/ForgeThemeProvider";
4
+ import { Loading } from "./Loading";
5
+
6
+ export interface PodcastListProps {
7
+ /** Build the href for a show page from its slug. */
8
+ showHref?: (slug: string) => string;
9
+ /** Server-fetched shows to seed the query for SSR (no loading flash). */
10
+ initialShows?: PodcastShow[] | null;
11
+ }
12
+
13
+ /** Podcast index — grid of the creator's shows. Built on `usePodcasts`. */
14
+ export function PodcastList({ showHref = (s) => `/i/podcasts/${s}`, initialShows }: PodcastListProps) {
15
+ const theme = useForgeTheme();
16
+ const { data: shows, isLoading } = usePodcasts({ initialData: initialShows ?? undefined });
17
+
18
+ if (isLoading) return <Loading fullPage />;
19
+ const list = shows ?? [];
20
+ if (!list.length) return <p style={{ opacity: 0.7, color: theme.colors.text }}>No podcasts yet.</p>;
21
+
22
+ return (
23
+ <div style={{ maxWidth: 960, margin: "0 auto", padding: "40px 20px", color: theme.colors.text }}>
24
+ <header style={{ marginBottom: 28 }}>
25
+ <h1 style={{ fontSize: 30, fontWeight: 800 }}>Podcasts</h1>
26
+ </header>
27
+ <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(220px, 1fr))", gap: 24 }}>
28
+ {list.map((show) => (
29
+ <a
30
+ key={show.id}
31
+ href={showHref(show.slug)}
32
+ style={{
33
+ color: theme.colors.text,
34
+ textDecoration: "none",
35
+ border: `1px solid ${theme.colors.text}1a`,
36
+ borderRadius: theme.cornerRadius,
37
+ overflow: "hidden",
38
+ display: "block",
39
+ }}
40
+ >
41
+ {show.coverImage?.url ? (
42
+ <img src={show.coverImage.url} alt={show.title} style={{ width: "100%", aspectRatio: "1/1", objectFit: "cover" }} />
43
+ ) : (
44
+ <div style={{ width: "100%", aspectRatio: "1/1", background: `${theme.colors.text}0d` }} />
45
+ )}
46
+ <div style={{ padding: 14 }}>
47
+ <h3 style={{ fontWeight: 700 }}>{show.title}</h3>
48
+ {show.author && <p style={{ fontSize: 13, opacity: 0.6, marginTop: 2 }}>{show.author}</p>}
49
+ <p style={{ fontSize: 12, opacity: 0.5, marginTop: 6 }}>
50
+ {show.episodeCount} episode{show.episodeCount === 1 ? "" : "s"}
51
+ </p>
52
+ </div>
53
+ </a>
54
+ ))}
55
+ </div>
56
+ </div>
57
+ );
58
+ }
@@ -0,0 +1,164 @@
1
+ import { Play, Pause, SkipBack, SkipForward } from "lucide-react";
2
+ import { usePodcast } from "../../data/queries/usePodcast";
3
+ import { usePodcastPlayer } from "../headless/podcast/usePodcastPlayer";
4
+ import type { BlogPost, BlogCategory } from "../../types/models";
5
+ import { useForgeTheme } from "../theme/ForgeThemeProvider";
6
+ import { Loading } from "./Loading";
7
+
8
+ export interface PodcastShowProps {
9
+ /** Show (podcast category) slug. */
10
+ slug: string;
11
+ /** Build the href for a single-episode page from its slug. */
12
+ episodeHref?: (episodeSlug: string) => string;
13
+ /** Server-fetched show + episodes to seed the queries for SSR (no loading flash). */
14
+ initialShow?: BlogCategory | null;
15
+ initialEpisodes?: BlogPost[] | null;
16
+ }
17
+
18
+ function fmt(sec?: number | null) {
19
+ if (!sec || sec <= 0) return "";
20
+ const m = Math.floor(sec / 60);
21
+ const s = Math.floor(sec % 60);
22
+ return `${m}:${s.toString().padStart(2, "0")}`;
23
+ }
24
+
25
+ /**
26
+ * Podcast show page — header + a single in-page player that plays the current
27
+ * episode and walks next/previous without leaving the page, plus the episode list.
28
+ * Built on `usePodcast` + `usePodcastPlayer` (the shared AudioPlayer + queue).
29
+ */
30
+ export function PodcastShow({ slug, episodeHref = (s) => `/i/podcasts/${slug}/${s}`, initialShow, initialEpisodes }: PodcastShowProps) {
31
+ const theme = useForgeTheme();
32
+ const { show, episodes, isLoading } = usePodcast(slug, {
33
+ initialShow: initialShow ?? undefined,
34
+ initialEpisodes: initialEpisodes ?? undefined,
35
+ });
36
+ const player = usePodcastPlayer({ episodes, show });
37
+
38
+ if (isLoading) return <Loading fullPage />;
39
+ if (!show) return <p>Podcast not found.</p>;
40
+
41
+ const cover = show.coverImage?.url;
42
+ const nowPlaying = player.currentEpisode ?? episodes[0] ?? null;
43
+ const pct = player.duration > 0 ? (player.currentTime / player.duration) * 100 : 0;
44
+ const border = `${theme.colors.text}1a`;
45
+
46
+ return (
47
+ <div style={{ maxWidth: 820, margin: "0 auto", padding: "40px 20px", color: theme.colors.text }}>
48
+ <header style={{ display: "flex", gap: 20, alignItems: "flex-start", marginBottom: 24 }}>
49
+ {cover ? (
50
+ <img src={cover} alt={show.title} style={{ width: 140, height: 140, borderRadius: theme.cornerRadius, objectFit: "cover" }} />
51
+ ) : (
52
+ <div style={{ width: 140, height: 140, borderRadius: theme.cornerRadius, background: `${theme.colors.text}0d` }} />
53
+ )}
54
+ <div>
55
+ <h1 style={{ fontSize: 28, fontWeight: 800 }}>{show.title}</h1>
56
+ {show.author && <p style={{ opacity: 0.6, marginTop: 4 }}>{show.author}</p>}
57
+ {show.description && <p style={{ opacity: 0.75, marginTop: 10, lineHeight: 1.5 }}>{show.description}</p>}
58
+ </div>
59
+ </header>
60
+
61
+ {/* In-page player — current episode + prev/next + seek, no navigation */}
62
+ {nowPlaying && (
63
+ <div
64
+ style={{
65
+ position: "sticky",
66
+ top: 8,
67
+ zIndex: 5,
68
+ background: theme.colors.background,
69
+ border: `1px solid ${border}`,
70
+ borderRadius: theme.cornerRadius,
71
+ padding: 14,
72
+ marginBottom: 20,
73
+ boxShadow: "0 4px 16px rgba(0,0,0,0.06)",
74
+ }}
75
+ >
76
+ <div style={{ fontSize: 13, opacity: 0.6 }}>Now playing</div>
77
+ <div style={{ fontWeight: 600, margin: "2px 0 10px" }}>{nowPlaying.title}</div>
78
+ <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
79
+ <button onClick={player.playPrevious} disabled={!player.hasPrevious} aria-label="Previous episode" style={iconBtn(theme, !player.hasPrevious)}>
80
+ <SkipBack size={18} />
81
+ </button>
82
+ <button onClick={() => player.toggleEpisode(nowPlaying)} aria-label="Play/pause" style={{ ...iconBtn(theme, false), background: theme.colors.primary, color: theme.colors.background, width: 44, height: 44 }}>
83
+ {player.isEpisodePlaying(nowPlaying) ? <Pause size={20} /> : <Play size={20} />}
84
+ </button>
85
+ <button onClick={player.playNext} disabled={!player.hasNext} aria-label="Next episode" style={iconBtn(theme, !player.hasNext)}>
86
+ <SkipForward size={18} />
87
+ </button>
88
+ <div style={{ flex: 1 }}>
89
+ <input
90
+ type="range"
91
+ min={0}
92
+ max={player.duration || 0}
93
+ value={player.currentTime}
94
+ onChange={(e) => player.seek(Number(e.target.value))}
95
+ style={{ width: "100%", accentColor: theme.colors.primary }}
96
+ />
97
+ <div style={{ display: "flex", justifyContent: "space-between", fontSize: 12, opacity: 0.6 }}>
98
+ <span>{fmt(player.currentTime)}</span>
99
+ <span>{fmt(player.duration)}</span>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ {/* thin progress affordance under the row */}
104
+ <div style={{ height: 2, background: `${theme.colors.text}14`, borderRadius: 2, marginTop: 6 }}>
105
+ <div style={{ height: 2, width: `${pct}%`, background: theme.colors.primary, borderRadius: 2 }} />
106
+ </div>
107
+ </div>
108
+ )}
109
+
110
+ {/* Episode list — click to play in place; title links to the episode page */}
111
+ <div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
112
+ {episodes.map((ep) => {
113
+ const active = player.isCurrent(ep);
114
+ const dur = ep.media?.find((m) => (m.type || "").startsWith("audio"))?.durationSec;
115
+ return (
116
+ <div
117
+ key={ep.id}
118
+ style={{
119
+ display: "flex",
120
+ alignItems: "center",
121
+ gap: 12,
122
+ padding: "12px 10px",
123
+ borderRadius: theme.cornerRadius,
124
+ background: active ? `${theme.colors.primary}12` : "transparent",
125
+ borderBottom: `1px solid ${border}`,
126
+ }}
127
+ >
128
+ <button onClick={() => player.toggleEpisode(ep)} aria-label={player.isEpisodePlaying(ep) ? "Pause episode" : "Play episode"} style={{ ...iconBtn(theme, false), flexShrink: 0 }}>
129
+ {player.isEpisodePlaying(ep) ? <Pause size={16} /> : <Play size={16} />}
130
+ </button>
131
+ <div style={{ flex: 1, minWidth: 0 }}>
132
+ <a href={episodeHref(ep.slug)} style={{ color: theme.colors.text, textDecoration: "none", fontWeight: 600 }}>
133
+ {ep.title}
134
+ </a>
135
+ <div style={{ fontSize: 12, opacity: 0.55, marginTop: 2 }}>
136
+ {ep.publishedAt ? new Date(ep.publishedAt).toLocaleDateString() : ""}
137
+ {dur ? ` · ${fmt(dur)}` : ""}
138
+ </div>
139
+ </div>
140
+ </div>
141
+ );
142
+ })}
143
+ {!episodes.length && <p style={{ opacity: 0.7 }}>No episodes yet.</p>}
144
+ </div>
145
+ </div>
146
+ );
147
+ }
148
+
149
+ function iconBtn(theme: ReturnType<typeof useForgeTheme>, disabled: boolean): React.CSSProperties {
150
+ return {
151
+ width: 36,
152
+ height: 36,
153
+ borderRadius: 999,
154
+ border: `1px solid ${theme.colors.text}22`,
155
+ background: theme.colors.background,
156
+ color: theme.colors.text,
157
+ cursor: disabled ? "default" : "pointer",
158
+ opacity: disabled ? 0.4 : 1,
159
+ fontSize: 14,
160
+ display: "inline-flex",
161
+ alignItems: "center",
162
+ justifyContent: "center",
163
+ };
164
+ }
@@ -0,0 +1,63 @@
1
+ import { useGetPosts } from "../../data/queries/usePosts";
2
+ import type { IPublicPost } from "../../types/models";
3
+ import { useThemeTokens } from "../theme/ForgeThemeProvider";
4
+ import { Loading } from "./Loading";
5
+
6
+ export interface PostsFeedProps {
7
+ columns?: number;
8
+ limit?: number;
9
+ onSelect?: (post: IPublicPost) => void;
10
+ className?: string;
11
+ style?: React.CSSProperties;
12
+ }
13
+
14
+ /** Themed posts grid, built on `useGetPosts`. */
15
+ export function PostsFeed({ columns = 3, limit, onSelect, className, style }: PostsFeedProps) {
16
+ const t = useThemeTokens();
17
+ const { data, isLoading } = useGetPosts({ page: 1 });
18
+ const posts = (data?.data ?? []).slice(0, limit ?? 100);
19
+
20
+ if (isLoading) return <Loading />;
21
+ if (!posts.length) return <p style={{ color: t.text, opacity: 0.7 }}>No posts yet.</p>;
22
+
23
+ const gap = 16;
24
+ const track = `minmax(max(150px, calc((100% - ${(columns - 1) * gap}px) / ${columns})), 1fr)`;
25
+
26
+ return (
27
+ <div
28
+ className={className}
29
+ style={{
30
+ display: "grid",
31
+ gridTemplateColumns: `repeat(auto-fill, ${track})`,
32
+ gap,
33
+ fontFamily: t.fontFamily,
34
+ ...style,
35
+ }}
36
+ >
37
+ {posts.map((post) => {
38
+ const cover = post.media?.find((m) => m.type === "image")?.url ?? post.media?.[0]?.url;
39
+ return (
40
+ <button
41
+ key={post.id}
42
+ onClick={() => onSelect?.(post)}
43
+ style={{
44
+ textAlign: "left",
45
+ cursor: onSelect ? "pointer" : "default",
46
+ background: t.surface,
47
+ border: `1px solid ${t.primary}20`,
48
+ borderRadius: t.cornerRadius,
49
+ overflow: "hidden",
50
+ padding: 0,
51
+ color: t.text,
52
+ }}
53
+ >
54
+ <div style={{ aspectRatio: "1 / 1", background: `${t.primary}10` }}>
55
+ {cover && <img src={cover} alt="" style={{ width: "100%", height: "100%", objectFit: "cover" }} />}
56
+ </div>
57
+ <div style={{ padding: 10, fontSize: 14 }}>{post.caption?.slice(0, 100)}</div>
58
+ </button>
59
+ );
60
+ })}
61
+ </div>
62
+ );
63
+ }