Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions src/app/story/[storylineId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { AgentBadge } from "../../../components/AgentBadge";
import { WriterIdentity } from "../../../components/WriterIdentity";
import { ViewCount, ViewTracker } from "../../../components/ViewCount";
import { CommentSection } from "../../../components/CommentSection";
import { MobileActionBar } from "../../../components/MobileActionBar";

type Params = Promise<{ storylineId: string }>;

Expand Down Expand Up @@ -130,7 +131,7 @@ export default async function StoryPage({ params }: { params: Params }) {
: null;

return (
<div className="mx-auto max-w-5xl px-6 py-10">
<div className="mx-auto max-w-5xl px-6 py-10 pb-24 lg:pb-10">
<ViewTracker storylineId={id} />
<StoryHeader storyline={storyline} priceInfo={priceInfo} />

Expand All @@ -152,10 +153,15 @@ export default async function StoryPage({ params }: { params: Params }) {
chapters={chapters}
/>
)}

{/* Share — visible on mobile (sidebar hidden) */}
<div className="mt-6 lg:hidden">
<ShareToFarcaster storylineId={id} title={sl.title} />
</div>
</main>

{/* Sidebar — engagement widgets */}
<aside className="order-first space-y-4 lg:order-none">
{/* Sidebar — desktop only */}
<aside className="hidden space-y-4 lg:block">
{sl.token_address && priceInfo && (
<PriceChart
tokenAddress={sl.token_address as Address}
Expand All @@ -173,6 +179,32 @@ export default async function StoryPage({ params }: { params: Params }) {
<ShareToFarcaster storylineId={id} title={sl.title} />
</aside>
</div>

{/* Mobile floating bottom bar */}
<MobileActionBar
tradeContent={
sl.token_address ? (
<>
{priceInfo && (
<PriceChart
tokenAddress={sl.token_address as Address}
totalSupplyRaw={priceInfo.totalSupplyRaw}
currentPriceRaw={priceInfo.priceRaw}
/>
)}
<TradingWidget tokenAddress={sl.token_address as Address} />
</>
) : undefined
}
donateContent={
<DonateWidget storylineId={id} writerAddress={sl.writer_address} />
}
rateContent={
sl.token_address ? (
<RatingWidget storylineId={id} tokenAddress={sl.token_address} />
) : undefined
}
/>
</div>
);
}
Expand Down
72 changes: 72 additions & 0 deletions src/components/MobileActionBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use client";

import { useState, type ReactNode } from "react";

type Panel = "trade" | "donate" | "rate" | null;

export function MobileActionBar({
tradeContent,
donateContent,
rateContent,
}: {
tradeContent?: ReactNode;
donateContent: ReactNode;
rateContent?: ReactNode;
}) {
const [open, setOpen] = useState<Panel>(null);

const buttons: { key: Panel; label: string; content?: ReactNode }[] = [
{ key: "trade", label: "Trade", content: tradeContent },
{ key: "donate", label: "Donate", content: donateContent },
{ key: "rate", label: "Rate", content: rateContent },
].filter((b) => b.content != null) as { key: Panel; label: string; content: ReactNode }[];

return (
<div className="lg:hidden">
{/* Backdrop */}
{open && (
<div
className="fixed inset-0 z-40 bg-black/60"
onClick={() => setOpen(null)}
/>
)}

{/* Bottom sheet */}
{open && (
<div className="fixed inset-x-0 bottom-0 z-50 max-h-[80vh] overflow-y-auto rounded-t-lg border-t border-[var(--border)] bg-[var(--bg)] p-4">
<div className="mb-3 flex items-center justify-between">
<span className="text-foreground text-sm font-medium capitalize">
{open}
</span>
<button
onClick={() => setOpen(null)}
className="text-muted hover:text-foreground text-xs transition-colors"
>
[close]
</button>
</div>
<div className="space-y-4">
{buttons.find((b) => b.key === open)?.content}
</div>
</div>
)}

{/* Fixed bottom bar */}
<div className="fixed inset-x-0 bottom-0 z-30 grid grid-cols-3 gap-2 border-t border-[var(--border)] bg-[var(--bg)]/95 p-3 backdrop-blur-sm">
{buttons.map(({ key, label }) => (
<button
key={key}
onClick={() => setOpen(open === key ? null : key)}
className={`rounded border px-3 py-2 text-xs transition-colors ${
open === key
? "border-accent text-accent"
: "border-[var(--border)] text-muted hover:text-foreground"
}`}
>
{label}
</button>
))}
</div>
</div>
);
}
Loading