@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.
- package/package.json +42 -0
- package/src/client/createForgeClient.ts +54 -0
- package/src/content/ForgeContentProvider.tsx +118 -0
- package/src/content/ForgeEditBridge.tsx +134 -0
- package/src/content/editFlag.ts +23 -0
- package/src/content/index.ts +28 -0
- package/src/content/resolve.ts +67 -0
- package/src/content/types.ts +97 -0
- package/src/content/useField.ts +64 -0
- package/src/contexts/AppAuthContext.tsx +185 -0
- package/src/contexts/AudioPlayerContext.tsx +389 -0
- package/src/contexts/CartContext.tsx +131 -0
- package/src/contexts/PublicAuthContext.tsx +333 -0
- package/src/contexts/useAppAdminGuard.ts +56 -0
- package/src/css.d.ts +5 -0
- package/src/data/collectionParams.ts +57 -0
- package/src/data/queries/useAccount.ts +71 -0
- package/src/data/queries/useAccountSettings.ts +82 -0
- package/src/data/queries/useAnalytics.ts +86 -0
- package/src/data/queries/useAuthActions.ts +28 -0
- package/src/data/queries/useBlog.ts +103 -0
- package/src/data/queries/useBlogComments.ts +96 -0
- package/src/data/queries/useBroadcasts.ts +31 -0
- package/src/data/queries/useCertificates.ts +58 -0
- package/src/data/queries/useChat.ts +267 -0
- package/src/data/queries/useCoachingAvailability.ts +69 -0
- package/src/data/queries/useCoachingProducts.ts +67 -0
- package/src/data/queries/useCohortPage.ts +17 -0
- package/src/data/queries/useCollections.ts +211 -0
- package/src/data/queries/useCommunity.ts +794 -0
- package/src/data/queries/useCoupons.ts +20 -0
- package/src/data/queries/useCourseAccess.ts +50 -0
- package/src/data/queries/useCourses.ts +91 -0
- package/src/data/queries/useCurrencies.ts +33 -0
- package/src/data/queries/useDocuments.ts +208 -0
- package/src/data/queries/useDonations.ts +29 -0
- package/src/data/queries/useEngagement.ts +115 -0
- package/src/data/queries/useEvents.ts +69 -0
- package/src/data/queries/useFinalize.ts +109 -0
- package/src/data/queries/useForms.ts +31 -0
- package/src/data/queries/useInvoice.ts +65 -0
- package/src/data/queries/useLeadMagnet.ts +96 -0
- package/src/data/queries/useMembership.ts +20 -0
- package/src/data/queries/useNotifications.ts +267 -0
- package/src/data/queries/useOffers.ts +56 -0
- package/src/data/queries/useOrders.ts +71 -0
- package/src/data/queries/usePWA.ts +101 -0
- package/src/data/queries/usePageActions.ts +36 -0
- package/src/data/queries/usePaymentFlow.ts +80 -0
- package/src/data/queries/usePaymentLink.ts +47 -0
- package/src/data/queries/usePodcast.ts +85 -0
- package/src/data/queries/usePostCollections.ts +48 -0
- package/src/data/queries/usePosts.ts +94 -0
- package/src/data/queries/useProducts.ts +108 -0
- package/src/data/queries/useReplay.ts +19 -0
- package/src/data/queries/useReviews.ts +122 -0
- package/src/data/queries/useShipping.ts +109 -0
- package/src/data/queries/useSubscriptions.ts +66 -0
- package/src/data/queries/useWebsite.ts +128 -0
- package/src/data/queries/useWebsiteAgent.ts +100 -0
- package/src/index.ts +98 -0
- package/src/provider/ForgeAppProvider.tsx +149 -0
- package/src/provider/ForgeProvider.tsx +91 -0
- package/src/provider/SiteConfigProvider.tsx +27 -0
- package/src/server/_tests/buildPwaHead.spec.ts +182 -0
- package/src/server/_tests/buildWebManifest.spec.ts +313 -0
- package/src/server/_tests/forgeServiceWorkerScript.spec.ts +251 -0
- package/src/server/index.ts +260 -0
- package/src/server/jobs.ts +104 -0
- package/src/server/pwa.ts +332 -0
- package/src/types/index.ts +74 -0
- package/src/types/models.ts +1313 -0
- package/src/ui/analytics/ForgeAnalytics.tsx +208 -0
- package/src/ui/analytics/PageMetaPixel.tsx +92 -0
- package/src/ui/content/Editable.tsx +90 -0
- package/src/ui/format/PriceDisplay.tsx +142 -0
- package/src/ui/format/useFormatCurrency.ts +92 -0
- package/src/ui/headless/agent/useAiAgent.ts +106 -0
- package/src/ui/headless/auth/useLoginFlow.ts +72 -0
- package/src/ui/headless/auth/useSignupForm.ts +85 -0
- package/src/ui/headless/broadcast/useBroadcastWatch.ts +59 -0
- package/src/ui/headless/chat/attachmentKind.ts +27 -0
- package/src/ui/headless/chat/useChatAttachmentUpload.ts +132 -0
- package/src/ui/headless/chat/useChatRoom.ts +223 -0
- package/src/ui/headless/chat/useMessageThread.ts +60 -0
- package/src/ui/headless/checkout/useCheckout.ts +438 -0
- package/src/ui/headless/coaching/useCoachingBooking.ts +223 -0
- package/src/ui/headless/community/index.ts +20 -0
- package/src/ui/headless/community/lexical.ts +131 -0
- package/src/ui/headless/community/replyTree.ts +51 -0
- package/src/ui/headless/community/richLexical.ts +314 -0
- package/src/ui/headless/community/useCommunityAttachmentUpload.ts +137 -0
- package/src/ui/headless/community/useCommunitySpaceFeed.ts +122 -0
- package/src/ui/headless/community/useCommunityThread.ts +95 -0
- package/src/ui/headless/community/useMentionComposer.ts +105 -0
- package/src/ui/headless/community/useRichMentionComposer.ts +193 -0
- package/src/ui/headless/consent/useCookieConsent.ts +81 -0
- package/src/ui/headless/course/useCourseCheckout.ts +99 -0
- package/src/ui/headless/dialog.tsx +14 -0
- package/src/ui/headless/document/index.ts +7 -0
- package/src/ui/headless/document/useContractSignature.ts +68 -0
- package/src/ui/headless/document/useDocumentSigningFlow.ts +92 -0
- package/src/ui/headless/document/useOtpCodeInput.ts +86 -0
- package/src/ui/headless/document/useSignaturePad.ts +180 -0
- package/src/ui/headless/donation/Donation.tsx +115 -0
- package/src/ui/headless/donation/DonationContext.tsx +223 -0
- package/src/ui/headless/donation/fees.ts +15 -0
- package/src/ui/headless/donation/index.ts +10 -0
- package/src/ui/headless/engagement/usePostEngagement.ts +119 -0
- package/src/ui/headless/event/useEventCheckout.ts +141 -0
- package/src/ui/headless/forms/useContactForm.ts +58 -0
- package/src/ui/headless/forms/useEmailListForm.ts +75 -0
- package/src/ui/headless/forms/useSectionedForm.ts +256 -0
- package/src/ui/headless/index.ts +60 -0
- package/src/ui/headless/invoice/useInvoicePayment.ts +48 -0
- package/src/ui/headless/memberHome/index.ts +7 -0
- package/src/ui/headless/memberHome/useMemberHomeNav.ts +82 -0
- package/src/ui/headless/membership/MembershipGate.tsx +39 -0
- package/src/ui/headless/membership/useMembershipCheckout.ts +121 -0
- package/src/ui/headless/offer/Offer.tsx +88 -0
- package/src/ui/headless/offer/OfferContext.tsx +162 -0
- package/src/ui/headless/offer/index.ts +8 -0
- package/src/ui/headless/paymentLink/usePaymentLinkPayment.ts +46 -0
- package/src/ui/headless/podcast/usePodcastPlayer.ts +96 -0
- package/src/ui/headless/posts/index.ts +13 -0
- package/src/ui/headless/posts/upsell.ts +41 -0
- package/src/ui/headless/posts/useMemberPostsFeed.ts +110 -0
- package/src/ui/headless/posts/usePostCollectionDetail.ts +56 -0
- package/src/ui/headless/posts/usePostCollectionsList.ts +90 -0
- package/src/ui/headless/posts/usePostItem.ts +81 -0
- package/src/ui/headless/reviews/index.ts +6 -0
- package/src/ui/headless/reviews/useHelpfulVote.ts +45 -0
- package/src/ui/headless/reviews/useReviewForm.ts +108 -0
- package/src/ui/headless/reviews/useReviewsList.ts +79 -0
- package/src/ui/headless/work/index.ts +25 -0
- package/src/ui/headless/work/useWorkPortal.ts +349 -0
- package/src/ui/index.ts +144 -0
- package/src/ui/payment/ForgePaymentProvider.tsx +45 -0
- package/src/ui/payment/ForgeStripePayment.tsx +171 -0
- package/src/ui/shell/TribeNestApp.tsx +121 -0
- package/src/ui/shell/shellGating.spec.ts +28 -0
- package/src/ui/shell/shellGating.ts +11 -0
- package/src/ui/styled/AccountDashboard.tsx +575 -0
- package/src/ui/styled/AiAgentWidget.tsx +152 -0
- package/src/ui/styled/AudioPlayer.tsx +123 -0
- package/src/ui/styled/BlogCategory.tsx +79 -0
- package/src/ui/styled/BlogComments.tsx +236 -0
- package/src/ui/styled/BlogList.tsx +101 -0
- package/src/ui/styled/BlogPost.tsx +160 -0
- package/src/ui/styled/BlogPostFooter.tsx +33 -0
- package/src/ui/styled/BotProtection.tsx +101 -0
- package/src/ui/styled/Button.tsx +88 -0
- package/src/ui/styled/Cart.tsx +276 -0
- package/src/ui/styled/ChatRoom.tsx +252 -0
- package/src/ui/styled/Checkout.tsx +988 -0
- package/src/ui/styled/CheckoutConfirmation.tsx +452 -0
- package/src/ui/styled/CoachingBooking.tsx +605 -0
- package/src/ui/styled/CoachingConfirmation.tsx +151 -0
- package/src/ui/styled/CoachingDetail.tsx +99 -0
- package/src/ui/styled/CohortPage.tsx +82 -0
- package/src/ui/styled/ConfirmSubscription.tsx +134 -0
- package/src/ui/styled/Confirmation.tsx +171 -0
- package/src/ui/styled/ContactForm.tsx +81 -0
- package/src/ui/styled/CookieConsent.tsx +239 -0
- package/src/ui/styled/CourseAccess.tsx +169 -0
- package/src/ui/styled/CourseCheckout.tsx +425 -0
- package/src/ui/styled/CourseConfirmation.tsx +191 -0
- package/src/ui/styled/CourseDetail.tsx +140 -0
- package/src/ui/styled/CoursesGrid.tsx +85 -0
- package/src/ui/styled/CurrencySwitcher.tsx +51 -0
- package/src/ui/styled/DonationButton.tsx +247 -0
- package/src/ui/styled/DonationPage.tsx +29 -0
- package/src/ui/styled/EmailListForm.tsx +88 -0
- package/src/ui/styled/EventConfirmation.tsx +228 -0
- package/src/ui/styled/EventCountdown.tsx +98 -0
- package/src/ui/styled/EventDetail.tsx +141 -0
- package/src/ui/styled/EventTickets.tsx +548 -0
- package/src/ui/styled/EventsList.tsx +83 -0
- package/src/ui/styled/ForgotPasswordForm.tsx +105 -0
- package/src/ui/styled/FormRenderer.tsx +249 -0
- package/src/ui/styled/InstallBanner.tsx +114 -0
- package/src/ui/styled/InvoiceConfirmation.tsx +50 -0
- package/src/ui/styled/InvoicePayment.tsx +141 -0
- package/src/ui/styled/LeadMagnet.tsx +93 -0
- package/src/ui/styled/Loading.tsx +56 -0
- package/src/ui/styled/LoginForm.tsx +134 -0
- package/src/ui/styled/Markdown.tsx +103 -0
- package/src/ui/styled/MembershipCheckout.tsx +197 -0
- package/src/ui/styled/MembershipTiers.tsx +115 -0
- package/src/ui/styled/OfferButton.tsx +181 -0
- package/src/ui/styled/PageActions.tsx +124 -0
- package/src/ui/styled/PaymentLinkConfirmation.tsx +50 -0
- package/src/ui/styled/PaymentLinkPayment.tsx +85 -0
- package/src/ui/styled/Paywall.tsx +54 -0
- package/src/ui/styled/PlayButton.tsx +48 -0
- package/src/ui/styled/PodcastEpisode.tsx +137 -0
- package/src/ui/styled/PodcastList.tsx +58 -0
- package/src/ui/styled/PodcastShow.tsx +164 -0
- package/src/ui/styled/PostsFeed.tsx +63 -0
- package/src/ui/styled/ProductDetail.tsx +616 -0
- package/src/ui/styled/ProductGrid.tsx +82 -0
- package/src/ui/styled/PushOptIn.tsx +65 -0
- package/src/ui/styled/PwaRegistration.tsx +58 -0
- package/src/ui/styled/ReactionBar.tsx +93 -0
- package/src/ui/styled/ReplayList.tsx +134 -0
- package/src/ui/styled/ResetPasswordForm.tsx +127 -0
- package/src/ui/styled/ReviewForm.tsx +292 -0
- package/src/ui/styled/ReviewsSection.tsx +260 -0
- package/src/ui/styled/SectionedFormRenderer.tsx +146 -0
- package/src/ui/styled/SignupForm.tsx +109 -0
- package/src/ui/styled/UserMenu.tsx +166 -0
- package/src/ui/styled/chat/ChatAttachments.tsx +172 -0
- package/src/ui/styled/chat/ChatComposer.tsx +153 -0
- package/src/ui/styled/chat/ChatThreadPanel.tsx +94 -0
- package/src/ui/styled/chat/MessageBubble.tsx +66 -0
- package/src/ui/styled/chat/NewDmDialog.tsx +78 -0
- package/src/ui/styled/community/CommunityComposer.tsx +358 -0
- package/src/ui/styled/community/CommunityFeed.tsx +483 -0
- package/src/ui/styled/community/CommunityLeaderboard.tsx +109 -0
- package/src/ui/styled/community/CommunityMediaGallery.tsx +116 -0
- package/src/ui/styled/community/CommunityMemberProfile.tsx +285 -0
- package/src/ui/styled/community/CommunityNotifications.tsx +222 -0
- package/src/ui/styled/community/CommunityPostCard.tsx +165 -0
- package/src/ui/styled/community/CommunityPostDetail.tsx +337 -0
- package/src/ui/styled/community/CommunityReactionBar.tsx +107 -0
- package/src/ui/styled/community/CommunityRichText.tsx +157 -0
- package/src/ui/styled/community/CommunitySpaces.tsx +174 -0
- package/src/ui/styled/community/MemberAvatar.tsx +74 -0
- package/src/ui/styled/community/index.ts +23 -0
- package/src/ui/styled/community/util.ts +15 -0
- package/src/ui/styled/members/MemberHomeLayout.tsx +98 -0
- package/src/ui/styled/members/MemberPostCard.tsx +392 -0
- package/src/ui/styled/members/MemberPostsFeed.tsx +219 -0
- package/src/ui/styled/members/PostCollectionDetail.tsx +227 -0
- package/src/ui/styled/members/PostCollectionsGrid.tsx +287 -0
- package/src/ui/styled/members/index.ts +7 -0
- package/src/ui/styled/rich-text.css +150 -0
- package/src/ui/styled/work/WorkInviteAccept.tsx +222 -0
- package/src/ui/styled/work/WorkPortalProjects.tsx +163 -0
- package/src/ui/styled/work/WorkProjectInvoices.tsx +113 -0
- package/src/ui/styled/work/WorkProjectReport.tsx +66 -0
- package/src/ui/styled/work/WorkReportBody.tsx +327 -0
- package/src/ui/styled/work/WorkTaskAttachments.tsx +67 -0
- package/src/ui/styled/work/WorkTaskComments.tsx +151 -0
- package/src/ui/styled/work/WorkTaskDetail.tsx +92 -0
- package/src/ui/styled/work/WorkTokenReport.tsx +49 -0
- package/src/ui/styled/work/index.ts +10 -0
- package/src/ui/theme/ForgeThemeProvider.tsx +121 -0
- package/src/ui/theme/contrast.ts +22 -0
- package/src/utils/analyticsBus.ts +31 -0
- package/src/utils/attribution.ts +68 -0
- package/src/utils/cookieConsent.ts +83 -0
- package/src/utils/landing.ts +153 -0
- package/src/utils/metaPixel.ts +122 -0
- 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
|
+
}
|