Gerador de vídeos narrativos (Godot + FFmpeg), painel Next.js, serviço de voz, Clipador de lives e Publicador para YouTube, TikTok e Instagram. Inclui a leitura das visualizações dos posts para o Dashboard e o botão "Publicar no <rede>" nos cartões das publicações. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
110 lines
6.8 KiB
TypeScript
110 lines
6.8 KiB
TypeScript
import Link from "next/link";
|
|
import { connection } from "next/server";
|
|
import { DeleteStoryButton } from "@/components/delete-story-button";
|
|
import { CreateStoryForm } from "@/components/forms";
|
|
import { ArrowRightIcon, ChevronDownIcon, FilmIcon, PenIcon } from "@/components/icons";
|
|
import { StoryComposer } from "@/components/story-composer";
|
|
import { storyFormatLabel, unitTerms } from "@/components/story-formats";
|
|
import {
|
|
Badge, EmptyState, PageHeader, SectionHeader, StagePipeline, Stat, episodeCode, formatRelative, hueOf,
|
|
} from "@/components/ui";
|
|
import { defaultProviderFor, models, providers } from "@/lib/agents";
|
|
import { listEpisodes, listStories } from "@/lib/stories";
|
|
import type { EpisodeView, Story } from "@/lib/types";
|
|
|
|
export default async function HomePage() {
|
|
await connection();
|
|
const stories = listStories().map((s) => ({ story: s, episodes: listEpisodes(s.id) }));
|
|
const totalEpisodes = stories.reduce((sum, s) => sum + s.episodes.length, 0);
|
|
const rendered = stories.reduce((sum, s) => sum + s.episodes.filter((e) => e.stage === "renderizado" || e.stage === "decidido").length, 0);
|
|
const openVotes = stories.reduce((sum, s) => sum + (s.story.kind === "interactive" ? s.episodes.filter((e) => e.stage === "renderizado").length : 0), 0);
|
|
const available = Object.fromEntries(providers().map((p) => [p.id, p.available])) as Record<"claude" | "codex", boolean>;
|
|
|
|
return (
|
|
<>
|
|
<PageHeader eyebrow="Estúdio CenaForge" title={<>Suas histórias, <span className="text-fg-subtle">episódio a episódio.</span></>}
|
|
description="Escreva com IA, monte a cena, renderize o vertical e deixe o público decidir o próximo capítulo."
|
|
actions={stories.length > 0 && (
|
|
<dl className="flex gap-10 rounded-card border border-line bg-surface/60 px-7 py-5">
|
|
<Stat label="Histórias" value={stories.length} />
|
|
<Stat label="Episódios" value={totalEpisodes} />
|
|
<Stat label="Renderizados" value={rendered} />
|
|
{openVotes > 0 && <Stat label="Em votação" value={openVotes} />}
|
|
</dl>
|
|
)} />
|
|
|
|
<StoryComposer autoProvider={defaultProviderFor("story")} available={available} models={models()} />
|
|
|
|
<section aria-labelledby="lista-historias" className="grid gap-6">
|
|
<SectionHeader id="lista-historias" eyebrow="Biblioteca" title="Em produção"
|
|
description={stories.length > 0 ? "Abra uma história para continuar de onde parou." : undefined} />
|
|
{stories.length === 0 ? (
|
|
<EmptyState icon={<FilmIcon />} title="Nenhuma história ainda">
|
|
Cole uma ideia no painel acima e a IA monta a primeira história com você.
|
|
</EmptyState>
|
|
) : (
|
|
<ul className="grid gap-5 lg:grid-cols-2 2xl:grid-cols-3">
|
|
{stories.map(({ story, episodes }) => <StoryCard key={story.id} story={story} episodes={episodes} />)}
|
|
</ul>
|
|
)}
|
|
</section>
|
|
|
|
<details className="group rounded-card border border-line bg-surface/50 open:bg-surface">
|
|
<summary className="flex cursor-pointer list-none items-center gap-4 rounded-card px-6 py-5 transition-colors hover:bg-raised/40 [&::-webkit-details-marker]:hidden">
|
|
<span className="grid size-10 shrink-0 place-items-center rounded-xl border border-line-strong bg-raised text-fg-muted"><PenIcon size={18} /></span>
|
|
<span className="grid min-w-0 flex-1 gap-0.5">
|
|
<span className="font-display text-[0.9375rem] font-semibold text-fg">Prefere começar sem IA?</span>
|
|
<span className="text-[0.8125rem] text-fg-subtle">Crie uma história vazia com título e premissa, e escreva você mesmo.</span>
|
|
</span>
|
|
<ChevronDownIcon size={18} className="shrink-0 text-fg-subtle transition-transform group-open:rotate-180" />
|
|
</summary>
|
|
<div className="border-t border-line px-6 pt-5 pb-6">
|
|
<CreateStoryForm />
|
|
</div>
|
|
</details>
|
|
</>
|
|
);
|
|
}
|
|
|
|
/** Cartão de história: um "pôster" vertical com a cor própria da história e o estado do último episódio. */
|
|
function StoryCard({ story, episodes }: { story: Story; episodes: EpisodeView[] }) {
|
|
const last = episodes.at(-1);
|
|
const hue = hueOf(story.id);
|
|
const interactive = story.kind === "interactive";
|
|
const terms = unitTerms(story.kind);
|
|
return (
|
|
<li className="relative">
|
|
{/* Fora do link: um botão dentro de <a> não é válido. Fica no canto inferior direito do cartão. */}
|
|
<DeleteStoryButton storyId={story.id} title={story.title} compact className="absolute right-4 bottom-4 z-10" />
|
|
<Link href={`/stories/${story.id}`}
|
|
className="group flex h-full gap-5 rounded-card border border-line bg-surface p-4 shadow-card transition-[border-color,background-color,transform] duration-200 hover:-translate-y-0.5 hover:border-line-strong hover:bg-raised/60">
|
|
<div aria-hidden="true"
|
|
className="relative flex aspect-[9/16] w-24 shrink-0 flex-col justify-between overflow-hidden rounded-xl border border-white/10 p-2.5"
|
|
style={{ background: `linear-gradient(160deg, oklch(0.55 0.16 ${hue}) 0%, oklch(0.32 0.12 ${(hue + 40) % 360}) 55%, oklch(0.16 0.04 ${(hue + 60) % 360}) 100%)` }}>
|
|
<span className="font-mono text-[0.625rem] font-semibold text-white/80">{last ? terms.code(last.number) : terms.code(0)}</span>
|
|
<span className="font-display text-[1.75rem] leading-none font-bold text-white/90">{story.title.charAt(0).toUpperCase()}</span>
|
|
<span className="absolute inset-x-0 bottom-0 h-1/2 bg-linear-to-t from-black/50 to-transparent" />
|
|
</div>
|
|
|
|
<div className="flex min-w-0 flex-1 flex-col py-1">
|
|
<div className="flex items-start justify-between gap-3">
|
|
<h3 className="font-display text-[1.1875rem] leading-snug font-semibold tracking-[-0.015em] text-fg transition-colors group-hover:text-accent">{story.title}</h3>
|
|
<ArrowRightIcon size={18} className="mt-1 shrink-0 text-fg-subtle opacity-0 transition-[opacity,transform] group-hover:translate-x-0.5 group-hover:opacity-100" />
|
|
</div>
|
|
<p className="mt-1.5 line-clamp-2 text-sm leading-relaxed text-fg-muted">{story.logline || "Sem premissa ainda."}</p>
|
|
|
|
<div className="mt-auto grid gap-3 pt-4">
|
|
{last ? <StagePipeline stage={last.stage} /> : <span className="text-xs text-fg-subtle">Sem {terms.many}</span>}
|
|
<div className="flex flex-wrap items-center gap-x-3 gap-y-2 pr-10 text-xs text-fg-subtle">
|
|
<Badge tone={interactive ? "accent" : "neutral"}>{storyFormatLabel(story.kind)}</Badge>
|
|
<span>{episodes.length} {episodes.length === 1 ? terms.one : terms.many}</span>
|
|
<span aria-hidden="true">·</span>
|
|
<span>atualizada {formatRelative(story.updated_at)}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Link>
|
|
</li>
|
|
);
|
|
}
|