feat: basic pages system
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
import Header from "@/components/header";
|
||||||
|
import Footer from "@/components/footer";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { getPageBySlug } from "@/lib/pages/repository";
|
||||||
|
import { getCurrentUser } from "@/lib/user";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
import Editor from "@/components/editor";
|
||||||
|
|
||||||
|
export default async function EditPage({ params }: { params: Promise<{ slug: string }> }) {
|
||||||
|
const user = await getCurrentUser();
|
||||||
|
if (!user?.isAdmin) redirect("/");
|
||||||
|
|
||||||
|
const { slug } = await params;
|
||||||
|
const page = slug === "create" ? null : await getPageBySlug(slug);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Header />
|
||||||
|
<div className="flex flex-col p-16 gap-16">
|
||||||
|
<div className="flex flex-row items-center justify-between">
|
||||||
|
<h1 className="underline underline-offset-8 decoration-2">
|
||||||
|
{page ? "Edit page" : "Create page"}
|
||||||
|
</h1>
|
||||||
|
<div className="flex flex-row gap-4">
|
||||||
|
<Button variant="outline">Save as draft</Button>
|
||||||
|
<Button>Publish</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Editor page={page} />
|
||||||
|
</div>
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import DraftsDialog from "@/components/drafts";
|
||||||
|
import Footer from "@/components/footer";
|
||||||
|
import Header from "@/components/header";
|
||||||
|
import { Badge } from "@/components/ui/badge"
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { getPages } from "@/lib/pages/repository";
|
||||||
|
import { PageMeta } from "@/lib/pages/types";
|
||||||
|
import { getCurrentUser } from "@/lib/user";
|
||||||
|
import { ArrowRight, Calendar, Globe2 } from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
export default async function News() {
|
||||||
|
const user = await getCurrentUser();
|
||||||
|
const news = await getPages("NEWS", "PUBLISHED");
|
||||||
|
const drafts = await getPages("NEWS", "DRAFT");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Header />
|
||||||
|
<div className="flex flex-col p-16 gap-16">
|
||||||
|
<div className="flex flex-row items-center justify-between">
|
||||||
|
<h1 className="underline underline-offset-8 decoration-2">News</h1>
|
||||||
|
<div className="flex flex-row items-center gap-4">
|
||||||
|
<DraftsDialog drafts={drafts} />
|
||||||
|
{user?.isAdmin && (<Link href="/news/create/edit"><Button variant="secondary">Create a news page</Button></Link>)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{
|
||||||
|
news.length > 0 ? news.map((n) => (
|
||||||
|
<div className="flex flex-col gap-2" key={n.id}>
|
||||||
|
<h2 className="w-max hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">{n.title}</h2>
|
||||||
|
<div className="flex flex-row gap-8 items-center">
|
||||||
|
<h3 className="flex gap-2 items-baseline"><Calendar size={18} />{(n.publishedAt)?.toString()}</h3>
|
||||||
|
<h3 className="flex gap-2 items-baseline"><Globe2 size={18} />{(n.meta as PageMeta)?.location}</h3>
|
||||||
|
<div className="flex flex-row gap-4">
|
||||||
|
{((n.meta as PageMeta)?.tags)?.map((i, tag) => (
|
||||||
|
<Badge key={i}>{tag}</Badge>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
), (
|
||||||
|
<h2 className="w-max flex flex-row items-center gap-2 hover:gap-4 hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">See all news<ArrowRight size={32} /></h2>
|
||||||
|
)) : <h2>There are no news yet...</h2>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
+22
-23
@@ -1,9 +1,13 @@
|
|||||||
import Footer from "@/components/footer";
|
import Footer from "@/components/footer";
|
||||||
import Header from "@/components/header";
|
import Header from "@/components/header";
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
|
import { getPages } from "@/lib/pages/repository";
|
||||||
|
import { PageMeta } from "@/lib/pages/types";
|
||||||
import { ArrowRight, Calendar, Globe2 } from "lucide-react";
|
import { ArrowRight, Calendar, Globe2 } from "lucide-react";
|
||||||
|
|
||||||
export default function Home() {
|
export default async function Home() {
|
||||||
|
const news = await getPages("NEWS", "PUBLISHED", 5);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
@@ -32,29 +36,24 @@ export default function Home() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-8 mt-8">
|
<div className="flex flex-col gap-8 mt-8">
|
||||||
<h1 className="underline underline-offset-8 decoration-2">Recent news</h1>
|
<h1 className="underline underline-offset-8 decoration-2">Recent news</h1>
|
||||||
<div className="flex flex-col gap-2">
|
{
|
||||||
<h2 className="w-max hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">Construction of the White House has started</h2>
|
news.length > 0 ? news.map((n) => (
|
||||||
<div className="flex flex-row gap-8 items-center">
|
<div className="flex flex-col gap-2" key={n.id}>
|
||||||
<h3 className="flex gap-2 items-baseline"><Calendar size={18} />16 June, 2026</h3>
|
<h2 className="w-max hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">{n.title}</h2>
|
||||||
<h3 className="flex gap-2 items-baseline"><Globe2 size={18} />Liberty City</h3>
|
<div className="flex flex-row gap-8 items-center">
|
||||||
<div className="flex flex-row gap-4">
|
<h3 className="flex gap-2 items-baseline"><Calendar size={18} />{(n.publishedAt)?.toString()}</h3>
|
||||||
<Badge>Liberty City</Badge>
|
<h3 className="flex gap-2 items-baseline"><Globe2 size={18} />{(n.meta as PageMeta)?.location}</h3>
|
||||||
|
<div className="flex flex-row gap-4">
|
||||||
|
{((n.meta as PageMeta)?.tags)?.map((i, tag) => (
|
||||||
|
<Badge key={i}>{tag}</Badge>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
), (
|
||||||
</div>
|
<h2 className="w-max flex flex-row items-center gap-2 hover:gap-4 hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">See all news<ArrowRight size={32} /></h2>
|
||||||
<div className="flex flex-col gap-2">
|
)) : <h2>There are no news yet...</h2>
|
||||||
<h2 className="w-max hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">President Volokhov has visited the Liberty City Trainbuilding Plant</h2>
|
}
|
||||||
<div className="flex flex-row gap-8 items-center">
|
|
||||||
<h3 className="flex gap-2 items-baseline"><Calendar size={18} />16 June, 2026</h3>
|
|
||||||
<h3 className="flex gap-2 items-baseline"><Globe2 size={18} />Liberty City</h3>
|
|
||||||
<div className="flex flex-row gap-4">
|
|
||||||
<Badge>President</Badge>
|
|
||||||
<Badge>Liberty City</Badge>
|
|
||||||
<Badge>Industry</Badge>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h2 className="w-max flex flex-row items-center gap-2 hover:gap-4 hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">See all news<ArrowRight size={32} /></h2>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from "@/components/ui/dialog"
|
||||||
|
import { deletePageAction } from "@/lib/pages/actions";
|
||||||
|
import { PencilIcon, XIcon } from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
|
|
||||||
|
type Draft = { id: string; title: string; slug: string; updatedAt: Date };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
|
||||||
|
const [isDeletingId, setIsDeletingId] = useState("");
|
||||||
|
|
||||||
|
async function deletePage(id: string) {
|
||||||
|
setIsDeletingId(id);
|
||||||
|
try {
|
||||||
|
await deletePageAction(id)
|
||||||
|
} finally {
|
||||||
|
setIsDeletingId("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button variant="secondary" className="flex flex-row items-center gap-2">Drafts<div className="flex items-center justify-center bg-black/50 text-white w-3.5 h-3.5 text-xs rounded-full">{drafts.length}</div></Button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent className="sm:max-w-md">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Drafts</DialogTitle>
|
||||||
|
<DialogDescription>Here are drafts of your pages</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<div className="flex flex-col items-center gap-2">
|
||||||
|
{drafts.length > 0 ? (
|
||||||
|
drafts.map((draft) => (
|
||||||
|
<div className="w-full flex flex-row items-center justify-between" key={draft.id}>
|
||||||
|
<h3 className="w-64 hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer truncate">
|
||||||
|
{draft.title}
|
||||||
|
</h3>
|
||||||
|
<div className="flex flex-row items-center gap-2">
|
||||||
|
<Link href={`/news/${draft.slug}/edit`}>
|
||||||
|
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
|
||||||
|
</Link>
|
||||||
|
<Button disabled={isDeletingId === draft.id} variant="secondary" size="icon-sm" onClick={() => deletePage(draft.id)}>
|
||||||
|
{isDeletingId === draft.id ? <Spinner /> : <XIcon />}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<h3>There are no drafts yet...</h3>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState, useTransition } from "react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Field,
|
||||||
|
FieldGroup,
|
||||||
|
FieldLabel,
|
||||||
|
FieldSet,
|
||||||
|
} from "@/components/ui/field";
|
||||||
|
import {
|
||||||
|
InputGroup,
|
||||||
|
InputGroupAddon,
|
||||||
|
InputGroupButton,
|
||||||
|
InputGroupInput,
|
||||||
|
} from "@/components/ui/input-group";
|
||||||
|
import { Block, BlockType, Page, PageMeta, PageType } from "@/lib/pages/types";
|
||||||
|
import { savePageAction } from "@/lib/pages/actions";
|
||||||
|
import { Globe2, Loader2, Plus, Trash2, X } from "lucide-react";
|
||||||
|
|
||||||
|
export default function Editor({ page, type, initialBlocks = [] }: { page: Page | null; type: PageType; initialBlocks?: Block[] }) {
|
||||||
|
const meta = (page?.meta as PageMeta) ?? {};
|
||||||
|
const router = useRouter();
|
||||||
|
const [isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
|
const [title, setTitle] = useState(page?.title ?? "");
|
||||||
|
const [slug, setSlug] = useState(page?.slug ?? "");
|
||||||
|
const [location, setLocation] = useState(meta.location ?? "");
|
||||||
|
const [tags, setTags] = useState<string[]>(meta.tags ?? []);
|
||||||
|
const [tagInput, setTagInput] = useState("");
|
||||||
|
const [blocks, setBlocks] = useState<Block[]>(initialBlocks);
|
||||||
|
|
||||||
|
function handleSave(status: "DRAFT" | "PUBLISHED") {
|
||||||
|
startTransition(async () => {
|
||||||
|
await savePageAction({
|
||||||
|
id: page?.id ?? null,
|
||||||
|
slug: slug || title.toLowerCase().replace(/\s+/g, "-"),
|
||||||
|
title,
|
||||||
|
type: "NEWS",
|
||||||
|
status,
|
||||||
|
blocks,
|
||||||
|
meta: { location, tags },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTag() {
|
||||||
|
const trimmed = tagInput.trim();
|
||||||
|
if (!trimmed || tags.includes(trimmed)) return;
|
||||||
|
setTags([...tags, trimmed]);
|
||||||
|
setTagInput("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeTag(tag: string) {
|
||||||
|
setTags(tags.filter((t) => t !== tag));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBlock(type: BlockType) {
|
||||||
|
setBlocks([...blocks, {
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
pageId: page?.id ?? "",
|
||||||
|
parentId: null,
|
||||||
|
type,
|
||||||
|
position: blocks.length,
|
||||||
|
content: getDefaultContent(type),
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeBlock(id: string) {
|
||||||
|
setBlocks(blocks.filter((b) => b.id !== id));
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateBlock(id: string, content: Block["content"]) {
|
||||||
|
setBlocks(blocks.map((b) => (b.id === id ? { ...b, content } : b)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-8">
|
||||||
|
<FieldSet>
|
||||||
|
<h2 className="underline underline-offset-8 decoration-2 mb-4">Meta</h2>
|
||||||
|
<FieldGroup>
|
||||||
|
<Field>
|
||||||
|
<FieldLabel htmlFor="title">Title</FieldLabel>
|
||||||
|
<InputGroup>
|
||||||
|
<InputGroupInput
|
||||||
|
id="title"
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => {
|
||||||
|
setTitle(e.target.value);
|
||||||
|
if (!page) {
|
||||||
|
setSlug(e.target.value.toLowerCase().replace(/\s+/g, "-"));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
placeholder="Enter the page title"
|
||||||
|
/>
|
||||||
|
</InputGroup>
|
||||||
|
</Field>
|
||||||
|
<Field>
|
||||||
|
<FieldLabel htmlFor="slug">Slug</FieldLabel>
|
||||||
|
<InputGroup>
|
||||||
|
<InputGroupInput
|
||||||
|
id="slug"
|
||||||
|
value={slug}
|
||||||
|
onChange={(e) => setSlug(e.target.value)}
|
||||||
|
placeholder="page-slug"
|
||||||
|
/>
|
||||||
|
</InputGroup>
|
||||||
|
</Field>
|
||||||
|
<Field>
|
||||||
|
<FieldLabel htmlFor="location">Location</FieldLabel>
|
||||||
|
<InputGroup>
|
||||||
|
<InputGroupInput
|
||||||
|
id="location"
|
||||||
|
value={location}
|
||||||
|
onChange={(e) => setLocation(e.target.value)}
|
||||||
|
placeholder="Liberty City, European Federation"
|
||||||
|
/>
|
||||||
|
<InputGroupAddon align="inline-start">
|
||||||
|
<Globe2 size={16} className="text-muted-foreground" />
|
||||||
|
</InputGroupAddon>
|
||||||
|
</InputGroup>
|
||||||
|
</Field>
|
||||||
|
<Field>
|
||||||
|
<FieldLabel htmlFor="tags">Tags</FieldLabel>
|
||||||
|
<InputGroup>
|
||||||
|
<InputGroupInput
|
||||||
|
id="tags"
|
||||||
|
value={tagInput}
|
||||||
|
onChange={(e) => setTagInput(e.target.value)}
|
||||||
|
onKeyDown={(e) => e.key === "Enter" && addTag()}
|
||||||
|
placeholder="Add a tag"
|
||||||
|
/>
|
||||||
|
<InputGroupAddon align="inline-end">
|
||||||
|
<InputGroupButton onClick={addTag}>Add</InputGroupButton>
|
||||||
|
</InputGroupAddon>
|
||||||
|
</InputGroup>
|
||||||
|
{tags.length > 0 && (
|
||||||
|
<div className="flex flex-row gap-2 flex-wrap mt-2">
|
||||||
|
{tags.map((tag) => (
|
||||||
|
<Badge
|
||||||
|
key={tag}
|
||||||
|
className="flex gap-1 items-center cursor-pointer"
|
||||||
|
onClick={() => removeTag(tag)}
|
||||||
|
>
|
||||||
|
{tag}
|
||||||
|
<X size={12} />
|
||||||
|
</Badge>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</FieldGroup>
|
||||||
|
</FieldSet>
|
||||||
|
<FieldSet>
|
||||||
|
<h2 className="underline underline-offset-8 decoration-2 mb-4">Content</h2>
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
{blocks.length === 0 && (
|
||||||
|
<p className="text-muted-foreground">No blocks yet</p>
|
||||||
|
)}
|
||||||
|
{blocks.map((block) => (
|
||||||
|
<BlockEditor
|
||||||
|
key={block.id}
|
||||||
|
block={block}
|
||||||
|
onChange={(content) => updateBlock(block.id, content)}
|
||||||
|
onRemove={() => removeBlock(block.id)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-row gap-4 flex-wrap mt-8">
|
||||||
|
{(["PARAGRAPH", "HEADING", "IMAGE", "QUOTE", "CALLOUT", "DIVIDER", "LIST", "TABLE"] as BlockType[]).map((t) => (
|
||||||
|
<Button key={t} variant="outline" onClick={() => addBlock(t)}>
|
||||||
|
<Plus size={14} />{t.toLowerCase()}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</FieldSet>
|
||||||
|
<div className="flex flex-row gap-4">
|
||||||
|
<Button variant="outline" disabled={isPending} onClick={() => handleSave("DRAFT")}>
|
||||||
|
{isPending ? <Loader2 size={14} className="animate-spin" /> : null}
|
||||||
|
Save as draft
|
||||||
|
</Button>
|
||||||
|
<Button disabled={isPending} onClick={() => handleSave("PUBLISHED")}>
|
||||||
|
{isPending ? <Loader2 size={14} className="animate-spin" /> : null}
|
||||||
|
Publish
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BlockEditor({ block, onChange, onRemove }: { block: Block; onChange: (content: Block["content"]) => void; onRemove: () => void }) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-row gap-4 items-start group">
|
||||||
|
<div className="flex-1 rounded-lg border p-4">
|
||||||
|
<BlockInput block={block} onChange={onChange} />
|
||||||
|
</div>
|
||||||
|
<Button variant="ghost" size="icon" onClick={onRemove} className="opacity-0 group-hover:opacity-100 duration-200">
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BlockInput({ block, onChange }: {
|
||||||
|
block: Block;
|
||||||
|
onChange: (c: Block["content"]) => void;
|
||||||
|
}) {
|
||||||
|
switch (block.type) {
|
||||||
|
case "PARAGRAPH":
|
||||||
|
return (
|
||||||
|
<textarea
|
||||||
|
className="w-full bg-transparent resize-none outline-none text-sm"
|
||||||
|
rows={3}
|
||||||
|
placeholder="Paragraph text..."
|
||||||
|
value={(block.content as any).text ?? ""}
|
||||||
|
onChange={(e) => onChange({ type: "PARAGRAPH", text: e.target.value })}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case "HEADING":
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
className="w-full bg-transparent outline-none text-xl font-semibold tracking-tight"
|
||||||
|
placeholder="Heading..."
|
||||||
|
value={(block.content as any).text ?? ""}
|
||||||
|
onChange={(e) => onChange({ type: "HEADING", text: e.target.value, level: 2 })}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case "QUOTE":
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-2 border-l-2 pl-4">
|
||||||
|
<textarea
|
||||||
|
className="w-full bg-transparent resize-none outline-none text-sm"
|
||||||
|
rows={2}
|
||||||
|
placeholder="Quote text..."
|
||||||
|
value={(block.content as any).text ?? ""}
|
||||||
|
onChange={(e) => onChange({ type: "QUOTE", text: e.target.value, author: (block.content as any).author })}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
className="w-full bg-transparent outline-none text-sm text-muted-foreground"
|
||||||
|
placeholder="Author..."
|
||||||
|
value={(block.content as any).author ?? ""}
|
||||||
|
onChange={(e) => onChange({ type: "QUOTE", text: (block.content as any).text, author: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "DIVIDER":
|
||||||
|
return <hr />;
|
||||||
|
case "CALLOUT":
|
||||||
|
return (
|
||||||
|
<div className="flex flex-row gap-2 items-start bg-muted rounded-lg p-4">
|
||||||
|
<span>⚠️</span>
|
||||||
|
<textarea
|
||||||
|
className="w-full bg-transparent resize-none outline-none text-sm"
|
||||||
|
rows={2}
|
||||||
|
placeholder="Callout text..."
|
||||||
|
value={(block.content as any).text ?? ""}
|
||||||
|
onChange={(e) => onChange({ type: "CALLOUT", text: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return <p className="text-muted-foreground text-sm">{block.type} — editor coming soon</p>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDefaultContent(type: BlockType): Block["content"] {
|
||||||
|
switch (type) {
|
||||||
|
case "PARAGRAPH": return { type: "PARAGRAPH", text: "" };
|
||||||
|
case "HEADING": return { type: "HEADING", text: "", level: 2 };
|
||||||
|
case "QUOTE": return { type: "QUOTE", text: "" };
|
||||||
|
case "CALLOUT": return { type: "CALLOUT", text: "" };
|
||||||
|
case "DIVIDER": return { type: "DIVIDER" };
|
||||||
|
case "LIST": return { type: "LIST", style: "BULLET", items: [] };
|
||||||
|
case "TABLE": return { type: "TABLE", headers: [], rows: [] };
|
||||||
|
case "IMAGE": return { type: "IMAGE", url: "" };
|
||||||
|
default: return { type: "PARAGRAPH", text: "" };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import { XIcon } from "lucide-react"
|
||||||
|
import { Dialog as DialogPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
|
||||||
|
function Dialog({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
||||||
|
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogTrigger({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
||||||
|
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogPortal({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
||||||
|
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogClose({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
||||||
|
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogOverlay({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Overlay
|
||||||
|
data-slot="dialog-overlay"
|
||||||
|
className={cn(
|
||||||
|
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogContent({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
showCloseButton = true,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
||||||
|
showCloseButton?: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<DialogPortal>
|
||||||
|
<DialogOverlay />
|
||||||
|
<DialogPrimitive.Content
|
||||||
|
data-slot="dialog-content"
|
||||||
|
className={cn(
|
||||||
|
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
{showCloseButton && (
|
||||||
|
<DialogPrimitive.Close data-slot="dialog-close" asChild>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
className="absolute top-2 right-2"
|
||||||
|
size="icon-sm"
|
||||||
|
>
|
||||||
|
<XIcon />
|
||||||
|
<span className="sr-only">Close</span>
|
||||||
|
</Button>
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
)}
|
||||||
|
</DialogPrimitive.Content>
|
||||||
|
</DialogPortal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="dialog-header"
|
||||||
|
className={cn("flex flex-col gap-2", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogFooter({
|
||||||
|
className,
|
||||||
|
showCloseButton = false,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"div"> & {
|
||||||
|
showCloseButton?: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="dialog-footer"
|
||||||
|
className={cn(
|
||||||
|
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
{showCloseButton && (
|
||||||
|
<DialogPrimitive.Close asChild>
|
||||||
|
<Button variant="outline">Close</Button>
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogTitle({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Title
|
||||||
|
data-slot="dialog-title"
|
||||||
|
className={cn(
|
||||||
|
"cn-font-heading text-base leading-none font-medium",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogDescription({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
data-slot="dialog-description"
|
||||||
|
className={cn(
|
||||||
|
"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogPortal,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
}
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useMemo } from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { Label } from "@/components/ui/label"
|
||||||
|
import { Separator } from "@/components/ui/separator"
|
||||||
|
|
||||||
|
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
||||||
|
return (
|
||||||
|
<fieldset
|
||||||
|
data-slot="field-set"
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldLegend({
|
||||||
|
className,
|
||||||
|
variant = "legend",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
|
||||||
|
return (
|
||||||
|
<legend
|
||||||
|
data-slot="field-legend"
|
||||||
|
data-variant={variant}
|
||||||
|
className={cn(
|
||||||
|
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="field-group"
|
||||||
|
className={cn(
|
||||||
|
"group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const fieldVariants = cva(
|
||||||
|
"group/field flex w-full gap-2 data-[invalid=true]:text-destructive",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
orientation: {
|
||||||
|
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
|
||||||
|
horizontal:
|
||||||
|
"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
||||||
|
responsive:
|
||||||
|
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
orientation: "vertical",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function Field({
|
||||||
|
className,
|
||||||
|
orientation = "vertical",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="group"
|
||||||
|
data-slot="field"
|
||||||
|
data-orientation={orientation}
|
||||||
|
className={cn(fieldVariants({ orientation }), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="field-content"
|
||||||
|
className={cn(
|
||||||
|
"group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldLabel({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof Label>) {
|
||||||
|
return (
|
||||||
|
<Label
|
||||||
|
data-slot="field-label"
|
||||||
|
className={cn(
|
||||||
|
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10",
|
||||||
|
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="field-label"
|
||||||
|
className={cn(
|
||||||
|
"flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
||||||
|
return (
|
||||||
|
<p
|
||||||
|
data-slot="field-description"
|
||||||
|
className={cn(
|
||||||
|
"text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
|
||||||
|
"last:mt-0 nth-last-2:-mt-1",
|
||||||
|
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldSeparator({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"div"> & {
|
||||||
|
children?: React.ReactNode
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="field-separator"
|
||||||
|
data-content={!!children}
|
||||||
|
className={cn(
|
||||||
|
"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<Separator className="absolute inset-0 top-1/2" />
|
||||||
|
{children && (
|
||||||
|
<span
|
||||||
|
className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
|
||||||
|
data-slot="field-separator-content"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldError({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
errors,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"div"> & {
|
||||||
|
errors?: Array<{ message?: string } | undefined>
|
||||||
|
}) {
|
||||||
|
const content = useMemo(() => {
|
||||||
|
if (children) {
|
||||||
|
return children
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!errors?.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const uniqueErrors = [
|
||||||
|
...new Map(errors.map((error) => [error?.message, error])).values(),
|
||||||
|
]
|
||||||
|
|
||||||
|
if (uniqueErrors?.length == 1) {
|
||||||
|
return uniqueErrors[0]?.message
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ul className="ml-4 flex list-disc flex-col gap-1">
|
||||||
|
{uniqueErrors.map(
|
||||||
|
(error, index) =>
|
||||||
|
error?.message && <li key={index}>{error.message}</li>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
)
|
||||||
|
}, [children, errors])
|
||||||
|
|
||||||
|
if (!content) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="alert"
|
||||||
|
data-slot="field-error"
|
||||||
|
className={cn("text-sm font-normal text-destructive", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Field,
|
||||||
|
FieldLabel,
|
||||||
|
FieldDescription,
|
||||||
|
FieldError,
|
||||||
|
FieldGroup,
|
||||||
|
FieldLegend,
|
||||||
|
FieldSeparator,
|
||||||
|
FieldSet,
|
||||||
|
FieldContent,
|
||||||
|
FieldTitle,
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
import { Input } from "@/components/ui/input"
|
||||||
|
import { Textarea } from "@/components/ui/textarea"
|
||||||
|
|
||||||
|
function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="input-group"
|
||||||
|
role="group"
|
||||||
|
className={cn(
|
||||||
|
"group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputGroupAddonVariants = cva(
|
||||||
|
"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
align: {
|
||||||
|
"inline-start":
|
||||||
|
"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]",
|
||||||
|
"inline-end":
|
||||||
|
"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]",
|
||||||
|
"block-start":
|
||||||
|
"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
||||||
|
"block-end":
|
||||||
|
"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
align: "inline-start",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function InputGroupAddon({
|
||||||
|
className,
|
||||||
|
align = "inline-start",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="group"
|
||||||
|
data-slot="input-group-addon"
|
||||||
|
data-align={align}
|
||||||
|
className={cn(inputGroupAddonVariants({ align }), className)}
|
||||||
|
onClick={(e) => {
|
||||||
|
if ((e.target as HTMLElement).closest("button")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
e.currentTarget.parentElement?.querySelector("input")?.focus()
|
||||||
|
}}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputGroupButtonVariants = cva(
|
||||||
|
"flex items-center gap-2 text-sm shadow-none",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
size: {
|
||||||
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
||||||
|
sm: "",
|
||||||
|
"icon-xs":
|
||||||
|
"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
|
||||||
|
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
size: "xs",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function InputGroupButton({
|
||||||
|
className,
|
||||||
|
type = "button",
|
||||||
|
variant = "ghost",
|
||||||
|
size = "xs",
|
||||||
|
...props
|
||||||
|
}: Omit<React.ComponentProps<typeof Button>, "size"> &
|
||||||
|
VariantProps<typeof inputGroupButtonVariants>) {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
type={type}
|
||||||
|
data-size={size}
|
||||||
|
variant={variant}
|
||||||
|
className={cn(inputGroupButtonVariants({ size }), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function InputGroupInput({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"input">) {
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
data-slot="input-group-control"
|
||||||
|
className={cn(
|
||||||
|
"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function InputGroupTextarea({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"textarea">) {
|
||||||
|
return (
|
||||||
|
<Textarea
|
||||||
|
data-slot="input-group-control"
|
||||||
|
className={cn(
|
||||||
|
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
InputGroup,
|
||||||
|
InputGroupAddon,
|
||||||
|
InputGroupButton,
|
||||||
|
InputGroupText,
|
||||||
|
InputGroupInput,
|
||||||
|
InputGroupTextarea,
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
type={type}
|
||||||
|
data-slot="input"
|
||||||
|
className={cn(
|
||||||
|
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Input }
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import { Label as LabelPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Label({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<LabelPrimitive.Root
|
||||||
|
data-slot="label"
|
||||||
|
className={cn(
|
||||||
|
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Label }
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import { Separator as SeparatorPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Separator({
|
||||||
|
className,
|
||||||
|
orientation = "horizontal",
|
||||||
|
decorative = true,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<SeparatorPrimitive.Root
|
||||||
|
data-slot="separator"
|
||||||
|
decorative={decorative}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Separator }
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Loader2Icon } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
|
||||||
|
return (
|
||||||
|
<Loader2Icon
|
||||||
|
data-slot="spinner"
|
||||||
|
role="status"
|
||||||
|
aria-label="Loading"
|
||||||
|
className={cn("size-4 animate-spin", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Spinner }
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||||
|
return (
|
||||||
|
<textarea
|
||||||
|
data-slot="textarea"
|
||||||
|
className={cn(
|
||||||
|
"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Textarea }
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
import { Block, PageMeta, PageStatus, PageType } from "./types";
|
||||||
|
import { createPage, deletePage, updatePage } from "./repository";
|
||||||
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
|
export async function savePageAction(params: {
|
||||||
|
id: string | null,
|
||||||
|
slug: string,
|
||||||
|
title: string,
|
||||||
|
type: PageType,
|
||||||
|
status: PageStatus,
|
||||||
|
blocks: Block[],
|
||||||
|
meta?: PageMeta
|
||||||
|
}) {
|
||||||
|
if (params.id) {
|
||||||
|
await updatePage(params.id, params.title, params.status, params.blocks, params.meta);
|
||||||
|
revalidatePath(`/${params.slug}`);
|
||||||
|
revalidatePath("/news");
|
||||||
|
} else {
|
||||||
|
const page = await createPage(params.slug, params.title, params.type, params.status, params.blocks, params.meta);
|
||||||
|
revalidatePath("/news");
|
||||||
|
redirect(`/news/${page.slug}/edit`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deletePageAction(id: string) {
|
||||||
|
await deletePage(id);
|
||||||
|
revalidatePath("/news");
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
import { getCurrentUser } from "../user";
|
||||||
|
import { Block, PageMeta, PageStatus, PageType } from "./types";
|
||||||
|
import { prisma } from "../prisma";
|
||||||
|
|
||||||
|
export async function getPages(type: PageType, status: PageStatus, limit?: number) {
|
||||||
|
return await prisma.page.findMany({ where: { type, status }, take: limit, orderBy: { publishedAt: "desc" }, });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPageById(id: string) {
|
||||||
|
return await prisma.page.findUnique({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPageBySlug(slug: string) {
|
||||||
|
return await prisma.page.findUnique({ where: { slug } });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createPage(slug: string, title: string, type: PageType, status: PageStatus, blocks: Block[], meta?: PageMeta) {
|
||||||
|
const user = await getCurrentUser();
|
||||||
|
if (!user) {
|
||||||
|
throw new Error("Failed to fetch user");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.isAdmin) {
|
||||||
|
throw new Error("Access denied")
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingPage = await prisma.page.findUnique({ where: { slug } });
|
||||||
|
if (existingPage) {
|
||||||
|
throw new Error("Page already exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
const page = await prisma.page.create({
|
||||||
|
data: {
|
||||||
|
slug,
|
||||||
|
title,
|
||||||
|
type,
|
||||||
|
status,
|
||||||
|
meta: meta ?? {},
|
||||||
|
publishedAt: status === "PUBLISHED" ? new Date() : null,
|
||||||
|
createdBy: user.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (blocks.length > 0) {
|
||||||
|
await prisma.block.createMany({
|
||||||
|
data: blocks.map((block) => ({
|
||||||
|
pageId: page.id,
|
||||||
|
parentId: block.parentId,
|
||||||
|
type: block.type,
|
||||||
|
position: block.position,
|
||||||
|
content: block.content,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === "PUBLISHED") {
|
||||||
|
await prisma.pageVersion.create({
|
||||||
|
data: {
|
||||||
|
pageId: page.id,
|
||||||
|
title: page.title,
|
||||||
|
blocks: blocks,
|
||||||
|
createdBy: user.id,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function restoreVersion(pageId: string, versionId: string) {
|
||||||
|
const version = await prisma.pageVersion.findUnique({
|
||||||
|
where: { id: versionId }
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.$transaction([
|
||||||
|
prisma.block.deleteMany({ where: { pageId } }),
|
||||||
|
prisma.block.createMany({
|
||||||
|
data: (version?.blocks as Block[]).map(block => ({
|
||||||
|
...block,
|
||||||
|
pageId,
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
}))
|
||||||
|
}),
|
||||||
|
prisma.page.update({
|
||||||
|
where: { id: pageId },
|
||||||
|
data: { updatedAt: new Date() }
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updatePage(
|
||||||
|
id: string,
|
||||||
|
title: string,
|
||||||
|
status: PageStatus,
|
||||||
|
blocks: Block[],
|
||||||
|
meta?: PageMeta
|
||||||
|
) {
|
||||||
|
const user = await getCurrentUser();
|
||||||
|
if (!user?.isAdmin) throw new Error("Access denied");
|
||||||
|
|
||||||
|
const page = await prisma.page.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
title,
|
||||||
|
status,
|
||||||
|
meta: meta ?? {},
|
||||||
|
publishedAt: status === "PUBLISHED" ? new Date() : undefined,
|
||||||
|
updatedAt: new Date(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.$transaction([
|
||||||
|
prisma.block.deleteMany({ where: { pageId: id } }),
|
||||||
|
...(blocks.length > 0
|
||||||
|
? [prisma.block.createMany({
|
||||||
|
data: blocks.map((b) => ({
|
||||||
|
pageId: id,
|
||||||
|
parentId: b.parentId,
|
||||||
|
type: b.type,
|
||||||
|
position: b.position,
|
||||||
|
content: b.content as any,
|
||||||
|
})),
|
||||||
|
})]
|
||||||
|
: []),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (status === "PUBLISHED") {
|
||||||
|
await prisma.pageVersion.create({
|
||||||
|
data: {
|
||||||
|
pageId: id,
|
||||||
|
title: page.title,
|
||||||
|
blocks: blocks as any,
|
||||||
|
createdBy: user.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deletePage(id: string) {
|
||||||
|
const user = await getCurrentUser();
|
||||||
|
if (!user?.isAdmin) throw new Error("Access denied");
|
||||||
|
await prisma.page.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBlocksByPageId(pageId: string) {
|
||||||
|
return prisma.block.findMany({
|
||||||
|
where: { pageId },
|
||||||
|
orderBy: { position: "asc" },
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
export const PAGE_TYPES = ["NEWS"] as const;
|
||||||
|
export type PageType = typeof PAGE_TYPES[number];
|
||||||
|
|
||||||
|
export const PAGE_STATUSES = ["DRAFT", "PUBLISHED", "ARCHIVED"] as const;
|
||||||
|
export type PageStatus = typeof PAGE_STATUSES[number];
|
||||||
|
|
||||||
|
export type PageMeta = {
|
||||||
|
tags?: string[];
|
||||||
|
location?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Page = {
|
||||||
|
id: string;
|
||||||
|
slug: string;
|
||||||
|
title: string;
|
||||||
|
type: PageType;
|
||||||
|
status: PageStatus;
|
||||||
|
meta: PageMeta;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
publishedAt: Date | null;
|
||||||
|
createdBy: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BLOCK_TYPES = ["PARAGRAPH", "HEADING", "IMAGE", "FILE", "QUOTE", "DIVIDER", "TABLE", "CALLOUT", "LIST", "LINK"] as const;
|
||||||
|
export type BlockType = typeof BLOCK_TYPES[number];
|
||||||
|
|
||||||
|
export type BlockContent =
|
||||||
|
| { type: "PARAGRAPH"; text: string }
|
||||||
|
| { type: "HEADING"; text: string; level: 1 | 2 | 3 }
|
||||||
|
| { type: "IMAGE"; url: string; caption?: string }
|
||||||
|
| { type: "FILE"; url: string; name: string }
|
||||||
|
| { type: "QUOTE"; text: string; author?: string }
|
||||||
|
| { type: "DIVIDER" }
|
||||||
|
| { type: "TABLE"; headers: string[]; rows: string[][] }
|
||||||
|
| { type: "CALLOUT"; text: string; icon?: string; color?: string }
|
||||||
|
| { type: "LIST"; style: "BULLET" | "NUMBERED"; items: string[] }
|
||||||
|
| { type: "LINK"; text?: string; url: string };
|
||||||
|
|
||||||
|
export type Block = {
|
||||||
|
id: string;
|
||||||
|
pageId: string;
|
||||||
|
parentId: string | null;
|
||||||
|
type: BlockType;
|
||||||
|
position: number;
|
||||||
|
content: BlockContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PageVersion = {
|
||||||
|
id: string;
|
||||||
|
pageId: string;
|
||||||
|
title: string;
|
||||||
|
blocks: Block[];
|
||||||
|
createdAt: Date;
|
||||||
|
createdBy: string;
|
||||||
|
};
|
||||||
@@ -5,4 +5,5 @@ export type UserData = {
|
|||||||
secondName: string;
|
secondName: string;
|
||||||
sex: string;
|
sex: string;
|
||||||
birthDate: string;
|
birthDate: string;
|
||||||
|
isAdmin: boolean;
|
||||||
}
|
}
|
||||||
+68
-8
@@ -13,13 +13,73 @@ datasource db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
kotosoftId String @unique
|
kotosoftId String @unique
|
||||||
email String @unique
|
email String @unique
|
||||||
firstName String
|
firstName String
|
||||||
secondName String
|
secondName String
|
||||||
sex String
|
sex String
|
||||||
birthDate DateTime
|
birthDate DateTime
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
isAdmin Boolean @default(false)
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
pages Page[]
|
||||||
|
versions PageVersion[]
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PageStatus {
|
||||||
|
DRAFT
|
||||||
|
PUBLISHED
|
||||||
|
ARCHIVED
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PageType {
|
||||||
|
NEWS
|
||||||
|
}
|
||||||
|
|
||||||
|
model Page {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
slug String @unique
|
||||||
|
title String
|
||||||
|
type PageType
|
||||||
|
status PageStatus @default(DRAFT)
|
||||||
|
meta Json @default("{}")
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
publishedAt DateTime?
|
||||||
|
|
||||||
|
createdBy String
|
||||||
|
author User @relation(fields: [createdBy], references: [id])
|
||||||
|
|
||||||
|
blocks Block[]
|
||||||
|
versions PageVersion[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Block {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
pageId String
|
||||||
|
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
parentId String?
|
||||||
|
parent Block? @relation("BlockChildren", fields: [parentId], references: [id])
|
||||||
|
children Block[] @relation("BlockChildren")
|
||||||
|
|
||||||
|
type String
|
||||||
|
position Float
|
||||||
|
content Json
|
||||||
|
|
||||||
|
@@index([pageId, position])
|
||||||
|
}
|
||||||
|
|
||||||
|
model PageVersion {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
pageId String
|
||||||
|
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
title String
|
||||||
|
blocks Json
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
createdBy String
|
||||||
|
author User @relation(fields: [createdBy], references: [id])
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
Я разрабатываю сайт государства "European Federation" на Next.js (App Router) + Prisma + Postgres + Tailwind + Shadcn UI.
|
||||||
|
|
||||||
|
Это CMS с универсальными "страницами" (тип: NEWS, LAW, DEPARTMENT, FAQ, STATIC).
|
||||||
|
Каждая страница состоит из блоков (PARAGRAPH, HEADING, IMAGE, QUOTE, CALLOUT, DIVIDER, LIST, TABLE).
|
||||||
|
|
||||||
|
Схема БД (Prisma):
|
||||||
|
- User { id, kotosoftId, email, firstName, secondName, sex, birthDate, isAdmin }
|
||||||
|
- Page { id, slug, title, type, status (DRAFT/PUBLISHED/ARCHIVED), meta (Json), publishedAt, createdAt, updatedAt, createdBy }
|
||||||
|
- Block { id, pageId, parentId, type, position (Float), content (Json) }
|
||||||
|
- PageVersion { id, pageId, title, blocks (Json snapshot), createdAt, createdBy }
|
||||||
|
|
||||||
|
TypeScript типы:
|
||||||
|
- PageType = "NEWS" | "LAW" | "DEPARTMENT" | "FAQ" | "STATIC"
|
||||||
|
- PageStatus = "DRAFT" | "PUBLISHED" | "ARCHIVED"
|
||||||
|
- BlockContent = discriminated union по type
|
||||||
|
- PageMeta = { description?, ogImage?, location?, tags?, coverUrl?, lawNumber?, signedAt? }
|
||||||
|
|
||||||
|
Архитектура:
|
||||||
|
- /[slug] — публичная страница (SSR), время редактирования видно всем
|
||||||
|
- /[slug]/edit — редактор (только isAdmin), Server Actions для save/publish
|
||||||
|
- /pages — список черновиков в Dialog (только isAdmin)
|
||||||
|
- /news, /laws и т.д. — списки по типу
|
||||||
|
|
||||||
|
Стилистика (важно соблюдать):
|
||||||
|
- p-16 gap-16 на страницах
|
||||||
|
- Заголовки: h1/h2 с underline underline-offset-8 decoration-2
|
||||||
|
- Hover-анимации: hover:underline или hover:gap-4 duration-200
|
||||||
|
- Shadcn компоненты: Field/FieldGroup/FieldSet для форм, InputGroup для инпутов с иконками
|
||||||
|
- Без лишних Card/Panel — минималистично
|
||||||
|
|
||||||
|
Текущие баги:
|
||||||
|
1. Блоки не сохраняются в DRAFT — нужно убрать условие if (status === "PUBLISHED") вокруг createMany
|
||||||
|
2. Теги показывают индексы — .map((i, tag) => tag) перепутано, надо .map((tag) => tag)
|
||||||
|
3. Даты — .toString() надо заменить на toLocaleDateString("en-GB", {...})
|
||||||
|
|
||||||
|
Текущие задачи:
|
||||||
|
1. UI везде говорит "news" — нужно сделать type-aware (заголовки, маршруты, тексты)
|
||||||
|
2. Дореализовать блоки LIST, TABLE, IMAGE в Editor (сейчас "coming soon")
|
||||||
|
3. UI истории версий в редакторе — список версий, кнопка "restore"
|
||||||
|
4. On-demand ISR через revalidatePath при публикации (уже частично есть)
|
||||||
|
|
||||||
|
Цель: чистый, человеческий, безопасный код без бойлерплейта.
|
||||||
Reference in New Issue
Block a user