This commit is contained in:
Ivan Rezchikov
2026-07-11 21:20:57 +03:00
parent e192717466
commit 18161f4604
57 changed files with 1211 additions and 615 deletions
+33 -26
View File
@@ -15,25 +15,44 @@ import Link from "next/link";
import { useState } from "react";
import { Spinner } from "@/components/ui/spinner";
import { PageType } from "@/lib/pages/types";
import { useAction } from "@/hooks/useAction";
type Draft = { id: string; type: PageType; title: string; slug: string; updatedAt: Date | null };
export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
const [isDeletingId, setIsDeletingId] = useState("");
function DraftItem({ draft, onDeleted }: { draft: Draft; onDeleted: (id: string) => void }) {
const { run, isPending } = useAction(deletePageAction, {
successMessage: "Draft deleted",
onSuccess: () => onDeleted(draft.id),
});
async function deletePage(id: string, type: PageType) {
setIsDeletingId(id);
try {
await deletePageAction(id, type);
} finally {
setIsDeletingId("");
}
return (
<div className="w-full flex flex-row items-center justify-between">
<h3 className="w-64 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={isPending} variant="secondary" size="icon-sm" onClick={() => run(draft.id, draft.type)}>
{isPending ? <Spinner /> : <XIcon />}
</Button>
</div>
</div>
);
}
export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
const [items, setItems] = useState(drafts);
function handleDeleted(id: string) {
setItems((prev) => prev.filter((d) => d.id !== id));
}
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>
<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">{items.length}</div></Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
@@ -41,22 +60,10 @@ export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
<DialogDescription>Here are drafts of your pages</DialogDescription>
</DialogHeader>
{drafts.length > 0 ? (
{items.length > 0 ? (
<div className="flex flex-col items-center gap-2">
{drafts.map((draft) => (
<div className="w-full flex flex-row items-center justify-between" key={draft.id}>
<h3 className="w-64 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, draft.type)}>
{isDeletingId === draft.id ? <Spinner /> : <XIcon />}
</Button>
</div>
</div>
{items.map((draft) => (
<DraftItem key={draft.id} draft={draft} onDeleted={handleDeleted} />
))}
</div>
) : (
@@ -65,4 +72,4 @@ export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
</DialogContent>
</Dialog>
)
}
}
+17 -8
View File
@@ -139,7 +139,7 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
return (
<div className="flex flex-col gap-10">
<FieldSet>
<h2 className=" mb-6">Meta</h2>
<h2 className="md:mb-4">Meta</h2>
<FieldGroup>
<Field data-invalid={!!errors?.title?.length}>
<FieldLabel htmlFor="title">Title</FieldLabel>
@@ -219,12 +219,12 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
</FieldGroup>
</FieldSet>
<div className="flex flex-col gap-1">
<h2 className=" mb-6">Content</h2>
<div className="flex flex-col gap-4">
<h2 className="md:mb-4">Content</h2>
{blocks.length === 0 && (
<p className="text-sm text-muted-foreground">No blocks yet. Add one below.</p>
)}
<div className="flex flex-col gap-6">
<div className="flex flex-col gap-4 md:gap-6">
{blocks.map((block, index) => (
<div
key={block.id}
@@ -234,7 +234,7 @@ export default function Editor({ page, initialBlocks = [], onChange, errors }: E
onDrop={() => handleDrop(index)}
onDragEnd={() => { setDragIndex(null); setDropIndex(null); }}
className={cn(
"group relative flex flex-row gap-4 items-start py-1 transition-opacity",
"group relative flex flex-row gap-2 md:gap-4 items-start py-1 transition-opacity",
dragIndex === index && "opacity-30",
dropIndex === index && dragIndex !== index && "border-t-2 border-primary"
)}
@@ -291,10 +291,19 @@ function BlockInput({ block, onChange }: { block: Block; onChange: (c: Block["co
);
case "HEADING":
const level = (block.content as any).level;
return (
<div className="flex items-center gap-2">
<input
className="flex-1 bg-transparent outline-none tracking-tight placeholder:text-muted-foreground"
className={cn(
"flex-1 min-w-0 bg-transparent outline-none tracking-tight placeholder:text-muted-foreground",
{
"text-2xl sm:text-3xl": level === 1,
"text-xl sm:text-2xl": level === 2,
"text-lg sm:text-xl": level === 3,
}
)}
placeholder="Heading"
value={(block.content as any).text ?? ""}
onChange={(e) => onChange({ type: "HEADING", text: e.target.value, level: (block.content as any).level ?? 2 })}
@@ -362,12 +371,12 @@ function BlockInput({ block, onChange }: { block: Block; onChange: (c: Block["co
onChange={(e) => onChange({ type: "IMAGE", url: e.target.value })}
/>
{(block.content as any).url && (
<div className="w-max relative rounded-md overflow-hidden border bg-muted/30">
<div className="relative max-w-150 rounded-md overflow-hidden border bg-muted/30">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={(block.content as any).url}
alt="preview"
className="max-h-64 w-auto object-contain"
className="block max-w-full h-auto object-contain"
onError={(e) => { (e.target as HTMLImageElement).style.display = "none"; }}
/>
</div>
+4 -7
View File
@@ -4,8 +4,8 @@ import Link from "next/link";
export default function Footer() {
return (
<footer className="flex flex-col w-full px-16 py-8 gap-8 bg-muted">
<div className="flex items-center gap-4">
<footer className="flex flex-col w-full px-4 lg:px-16 py-8 gap-8 bg-muted">
<div className="flex flex-col lg:flex-row lg:items-center gap-4">
<Image
src="/emblem.png"
width={28}
@@ -14,7 +14,7 @@ export default function Footer() {
/>
<h3>This is an official site of the European Federation</h3>
</div>
<div className="flex flex-row gap-32">
<div className="flex flex-row justify-between lg:justify-start lg:gap-32">
<div className="flex flex-col gap-2">
<Link href="/" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Main</Link>
<Link href="/news" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">News</Link>
@@ -25,11 +25,8 @@ export default function Footer() {
<Link href="/page/vice-president" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Vice President</Link>
<Link href="/page/government" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Federal Government</Link>
</div>
<div className="flex flex-col gap-2">
<Link href="/page/regions" className="text-black/60 cursor-pointer hover:underline underline-offset-8 decoration-2">Regions</Link>
</div>
</div>
<p>© 2026 European Federation. All rights reserved.</p>
<p>© {new Date().getFullYear()} European Federation. All rights reserved.</p>
</footer>
)
}
+25 -20
View File
@@ -4,38 +4,43 @@ import { login } from "@/lib/user/actions";
import { getCurrentUser } from "@/lib/user";
import Link from "next/link";
import { getNavLinks } from "@/lib/navlinks/repository";
import { MobileNav } from "./mobile-nav";
export default async function Header() {
const user = await getCurrentUser();
const links = await getNavLinks();
const navLinks = links.map((link) => ({
id: link.id,
href: link.href || (link.page ? `/${link.page.type.toLowerCase()}/${link.page.slug}` : "/"),
label: link.label ?? link.page?.title ?? "",
}));
return (
<header className="relative flex items-center justify-between w-full h-16 px-8 bg-gray-100">
<Link href="/" className="flex items-center gap-4">
<Image
src="/emblem.png"
width={28}
height={28}
alt="Emblem of the European Federation"
/>
<h3>European Federation</h3>
<header className="relative flex items-center justify-between w-full h-16 px-4 sm:px-8 bg-white sm:bg-gray-100">
<Link href="/" className="flex items-center gap-4 shrink-0">
<Image src="/emblem.png" width={28} height={28} alt="Emblem of the European Federation" />
<h3 className="hidden sm:block">European Federation</h3>
</Link>
<div className="absolute left-1/2 -translate-x-1/2 flex items-center gap-6">
{
links.map((link) => (
<Link className="hover:underline underline-offset-8 decoration-2 duration-200" key={link.id} href={link.href || (link.page ? `/${link.page.type.toLowerCase()}/${link.page.slug}` : "/")}><h3>{link.label ?? link.page?.title}</h3></Link>
))
}
<div className="hidden md:flex absolute left-1/2 -translate-x-1/2 items-center gap-6">
{navLinks.map((link) => (
<Link className="hover:underline underline-offset-8 decoration-2 duration-200" key={link.id} href={link.href}>
<h3>{link.label}</h3>
</Link>
))}
</div>
{
user ? (
<div className="hidden md:block">
{user ? (
<Link href="/account"><Button>Account</Button></Link>
) : (
<form action={login}>
<Button size="lg" type="submit">Sign in with Kotosoft ID</Button>
</form>
)
}
)}
</div>
<MobileNav links={navLinks} isAuthenticated={!!user} />
</header>
)
);
}
+13 -18
View File
@@ -70,7 +70,7 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
const expiryClass = expiryDateClass(data.expiryDate);
return (
<div className="relative w-96 bg-blue-50 rounded-lg p-4 overflow-hidden">
<div className="relative md:w-96 bg-blue-50 rounded-lg p-4 overflow-hidden">
<CardPattern />
<div className="relative z-10">
<div className="flex flex-row items-center justify-between">
@@ -88,12 +88,12 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
<DialogContent>
<DialogHeader>
<div className="flex flex-row gap-3">
<div className="relative w-12 h-14 shrink-0 rounded overflow-hidden">
<img src={data.profileUrl} alt="Profile" className="object-cover" />
<div className="relative w-12 aspect-4/5 shrink-0 rounded overflow-hidden">
<img src={data.profileUrl} alt="Profile" className="w-full h-full object-cover" />
</div>
<div className="flex flex-col gap-0 justify-center">
<div className="flex flex-col justify-center">
<DialogTitle asChild>
<h4 className="uppercase">{data.surname} {data.givenNames}</h4>
<h4 className="uppercase">{data.givenNames} {data.surname}</h4>
</DialogTitle>
<h4 className="text-muted-foreground">{data.documentNumber}</h4>
</div>
@@ -103,19 +103,14 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
{DIALOG_FIELDS.map(({ key, label }) => (
<div className="flex flex-col" key={key}>
<h5 className="text-blue-500">{label}</h5>
<h4
className={cn(
"leading-6",
key === "expiryDate" && expiryClass
)}
>
<h4 className={cn(key === "expiryDate" && expiryClass)}>
{formatFieldValue(key, data[key])}
</h4>
</div>
))}
<div className="flex flex-col col-span-2">
<h5 className="text-blue-500">{ADDRESS_FIELD.label}</h5>
<h4 className="leading-6">{formatFieldValue(ADDRESS_FIELD.key, data[ADDRESS_FIELD.key])}</h4>
<h4>{formatFieldValue(ADDRESS_FIELD.key, data[ADDRESS_FIELD.key])}</h4>
</div>
</div>
</DialogContent>
@@ -123,12 +118,12 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
</div>
<div className="flex flex-row gap-8 mt-4">
<div className="flex flex-col gap-8 w-24 shrink-0">
<div className="relative w-24 h-28 shrink-0">
<img src={data.profileUrl} alt="Profile" className="object-cover" />
<div className="flex flex-col gap-4 w-24 shrink-0">
<div className="w-24 aspect-4/5 rounded overflow-hidden">
<img src={data.profileUrl} alt="Profile" className="w-full h-full object-cover" />
</div>
<div className="relative w-24 h-12 shrink-0">
<img src={data.signatureUrl} alt="Signature" className="object-contain" />
<div className="w-24 aspect-5/2 rounded overflow-hidden">
<img src={data.signatureUrl} alt="Signature" className="w-full h-full object-contain" />
</div>
</div>
<div className="flex flex-col gap-2">
@@ -155,7 +150,7 @@ export default function IdentityCard({ data }: { data: IdentityCardData }) {
<div className="flex flex-wrap gap-x-6 gap-y-2">
<div className="flex flex-col min-w-fit">
<h5 className="text-blue-500">Authority</h5>
<h4 className="leading-6">{data.authority}</h4>
<h4>{data.authority}</h4>
</div>
<div className="flex flex-col min-w-fit">
<h5 className="text-blue-500">Nationality</h5>
+210
View File
@@ -0,0 +1,210 @@
"use client";
import { useRef, useState, useEffect } from "react";
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { XIcon, ImageIcon, RefreshCwIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import { Spinner } from "@/components/ui/spinner";
type Props = {
id: string;
name?: string;
label: string;
description?: string;
error?: string;
variant?: "default" | "editor";
previewClassName?: string;
accept?: string;
required?: boolean;
value?: string;
onFileSelect?: (file: File, previewUrl: string) => void;
onRemove?: () => void;
isUploading?: boolean;
children?: React.ReactNode;
caption?: string;
onCaptionChange?: (caption: string) => void;
};
const MAX_SIZE = 5 * 1024 * 1024;
const DEFAULT_ACCEPT = "image/jpeg,image/png,image/webp";
const EDITOR_WRAPPER_CLASS = "flex flex-col gap-2 items-stretch md:items-start";
const EDITOR_IMG_CLASS = "block max-w-full md:max-w-200 h-auto rounded-md border object-contain";
function formatFileSize(bytes: number): string {
return bytes < 1024 * 1024
? `${Math.round(bytes / 1024)} KB`
: `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}
function validateFile(file: File, accept: string): string | null {
const allowed = accept.split(",").map((t) => t.trim());
if (!allowed.includes(file.type)) {
return "Only JPEG, PNG, or WEBP images are allowed.";
}
if (file.size > MAX_SIZE) {
return "Image must be smaller than 5MB.";
}
return null;
}
export function ImageUploader({ id, name, label, description, error, variant = "default", previewClassName, accept = DEFAULT_ACCEPT, required, value, onFileSelect, onRemove, isUploading, children, caption, onCaptionChange }: Props) {
const inputRef = useRef<HTMLInputElement>(null);
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
const [fileInfo, setFileInfo] = useState<{ name: string; size: number } | null>(null);
const [clientError, setClientError] = useState<string | null>(null);
const [isDragOver, setIsDragOver] = useState(false);
useEffect(() => {
return () => {
if (previewUrl) URL.revokeObjectURL(previewUrl);
};
}, [previewUrl]);
function clearFileState() {
if (previewUrl) URL.revokeObjectURL(previewUrl);
setPreviewUrl(null);
setFileInfo(null);
if (inputRef.current) inputRef.current.value = "";
}
function reset() {
clearFileState();
setClientError(null);
onRemove?.();
}
function applyFile(file: File) {
const validationError = validateFile(file, accept);
if (validationError) {
setClientError(validationError);
clearFileState();
return;
}
setClientError(null);
const url = URL.createObjectURL(file);
setPreviewUrl(url);
setFileInfo({ name: file.name, size: file.size });
onFileSelect?.(file, url);
}
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0];
if (!file) return;
applyFile(file);
}
function handleDrop(e: React.DragEvent<HTMLDivElement>) {
e.preventDefault();
setIsDragOver(false);
const file = e.dataTransfer.files?.[0];
if (file) applyFile(file);
}
const displayedError = clientError ?? error;
const displayUrl = previewUrl ?? value;
if (variant === "editor") {
return (
<Field data-invalid={!!displayedError}>
<Input ref={inputRef} id={id} name={name} type="file" accept={accept} className="hidden" onChange={handleChange} disabled={isUploading} />
{displayUrl ? (
<div className={EDITOR_WRAPPER_CLASS}>
<div className="group relative rounded-md">
<img src={displayUrl} alt="" className={previewClassName ?? EDITOR_IMG_CLASS} />
<div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity">
<Button type="button" variant="secondary" size="sm" onClick={() => inputRef.current?.click()} disabled={isUploading}>
<RefreshCwIcon />
Replace
</Button>
</div>
{isUploading && (
<div className="absolute inset-0 flex items-center justify-center bg-background/90 rounded-md">
<Spinner />
</div>
)}
</div>
{onCaptionChange && (
<input
className="w-full bg-transparent outline-none text-xs md:text-sm text-muted-foreground placeholder:text-muted-foreground/50"
placeholder="Add a caption..."
value={caption ?? ""}
onChange={(e) => onCaptionChange(e.target.value)}
/>
)}
</div>
) : (
<div
role="button"
tabIndex={0}
onClick={() => inputRef.current?.click()}
onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") inputRef.current?.click(); }}
onDragOver={(e) => { e.preventDefault(); setIsDragOver(true); }}
onDragLeave={() => setIsDragOver(false)}
onDrop={handleDrop}
className={cn(
"flex flex-row rounded-md bg-card px-2.5 py-1 text-sm text-muted-foreground ring-1 ring-foreground/10 transition-colors items-center gap-2",
"hover:bg-muted/60",
isDragOver && "bg-muted"
)}
>
<ImageIcon size={16} />
<span>Add image</span>
</div>
)}
{displayedError && <FieldError>{displayedError}</FieldError>}
</Field>
);
}
return (
<Field data-invalid={!!displayedError}>
<FieldLabel htmlFor={id}>{label}</FieldLabel>
<div className="flex flex-col md:flex-row items-start gap-4">
<div
className={cn(
"w-28 rounded-md border border-dashed border-foreground/15 bg-muted flex items-center justify-center overflow-hidden shrink-0",
previewClassName ?? "aspect-square"
)}
>
{isUploading ? (
<Spinner className="text-muted-foreground" />
) : displayUrl ? (
<img src={displayUrl} alt="" className="w-full h-full object-cover" />
) : (
<ImageIcon className="text-muted-foreground" size={24} />
)}
</div>
<div className="flex flex-col gap-1 flex-1 min-w-0">
<Input ref={inputRef} id={id} name={name} type="file" accept={accept} aria-invalid={!!displayedError} onChange={handleChange} disabled={isUploading} required={required && !fileInfo && !value} />
{fileInfo && (
<div className="flex items-center gap-2 text-sm text-muted-foreground min-w-0">
<span className="flex-1 truncate">
{fileInfo.name} ({formatFileSize(fileInfo.size)})
</span>
<Button type="button" variant="ghost" size="icon" className="h-6 w-6" onClick={reset} disabled={isUploading}>
<XIcon size={14} />
</Button>
</div>
)}
{description && <FieldDescription className="mt-1">{description}</FieldDescription>}
{children}
</div>
</div>
{displayedError && <FieldError>{displayedError}</FieldError>}
</Field>
);
}
+53
View File
@@ -0,0 +1,53 @@
"use client";
import { useState } from "react";
import Link from "next/link";
import { MenuIcon, XIcon } from "lucide-react";
import { Button } from "./ui/button";
import { login } from "@/lib/user/actions";
import Image from "next/image";
type NavLink = { id: string; href: string; label: string };
export function MobileNav({ links, isAuthenticated }: { links: NavLink[]; isAuthenticated: boolean }) {
const [open, setOpen] = useState(false);
return (
<div className="md:hidden">
<Button variant="ghost" size="icon" onClick={() => setOpen(true)} aria-label="Open menu">
<MenuIcon />
</Button>
{open && (
<div className="fixed inset-0 z-50 bg-white flex flex-col">
<div className="flex items-center justify-between h-16 px-4">
<Link href="/" onClick={() => setOpen(false)} className="flex items-center gap-4 shrink-0">
<Image src="/emblem.png" width={28} height={28} alt="Emblem of the European Federation" />
<h3 className="hidden sm:block">European Federation</h3>
</Link>
<Button variant="ghost" size="icon" onClick={() => setOpen(false)} aria-label="Close menu">
<XIcon />
</Button>
</div>
<nav className="flex flex-col gap-2.5 p-4">
{links.map((link) => (
<Link key={link.id} href={link.href} onClick={() => setOpen(false)} className="hover:underline underline-offset-8 decoration-2 duration-200">
<h2>{link.label}</h2>
</Link>
))}
<div className="mt-4">
{isAuthenticated ? (
<Link href="/account" onClick={() => setOpen(false)}>
<Button>Account</Button>
</Link>
) : (
<form action={login}>
<Button size="lg" type="submit">Sign in with Kotosoft ID</Button>
</form>
)}
</div>
</nav>
</div>
)}
</div>
);
}
+6 -4
View File
@@ -10,10 +10,12 @@ export function NewsCard({ news }: { news: PagePublic }) {
<Link href={`/news/${news.slug}`} className="w-max">
<h2 className="hover:underline underline-offset-8 decoration-2 hover:duration-200 cursor-pointer">{news.title}</h2>
</Link>
<div className="flex flex-row gap-8 items-center">
<p className="flex gap-2 items-center"><CalendarIcon size={16} />{formatDate(news.publishedAt)}</p>
{(news?.meta as PageMeta)?.location && <p className="flex gap-2 items-center"><Globe2Icon size={16} />{(news.meta as PageMeta)?.location}</p>}
<div className="flex flex-row gap-4">
<div className="flex flex-col md:flex-row gap-2 md:gap-8 md:items-center">
<div className="flex flex-row gap-4 md:gap-8">
<p className="flex gap-2 items-center"><CalendarIcon size={16} />{formatDate(news.publishedAt)}</p>
{(news?.meta as PageMeta)?.location && <p className="flex gap-2 items-center"><Globe2Icon size={16} />{(news.meta as PageMeta)?.location}</p>}
</div>
<div className="hidden md:flex flex-row gap-4">
{((news.meta as PageMeta)?.tags)?.map((tag) => (
<Badge key={tag}>{tag}</Badge>
))}
+2 -2
View File
@@ -23,7 +23,7 @@ const buttonVariants = cva(
size: {
default:
"h-8 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",
xs: "h-6 gap-1 px-2.5 text-xs has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",
xs: "h-6 gap-1 px-2.5 text-xs md:text-xs has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",
sm: "h-7 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
lg: "h-9 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
icon: "size-8",
@@ -62,4 +62,4 @@ function Button({
)
}
export { Button, buttonVariants }
export { Button, buttonVariants }
+6 -6
View File
@@ -30,7 +30,7 @@ function FieldLegend({
data-slot="field-legend"
data-variant={variant}
className={cn(
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
"mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base md:data-[variant=legend]:text-lg",
className
)}
{...props}
@@ -43,7 +43,7 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
<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",
"group/field-group @container/field-group flex w-full flex-col gap-6 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
className
)}
{...props}
@@ -130,11 +130,11 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<p
<h5
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",
"text-left font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-2",
"nth-last-2:-mt-0.5",
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
className
)}
@@ -235,4 +235,4 @@ export {
FieldSet,
FieldContent,
FieldTitle,
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"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",
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 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 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}
+1 -1
View File
@@ -187,4 +187,4 @@ export {
SelectSeparator,
SelectTrigger,
SelectValue,
}
}
+57
View File
@@ -0,0 +1,57 @@
"use client"
import * as React from "react"
import { Tooltip as TooltipPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function TooltipProvider({
delayDuration = 0,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
return (
<TooltipPrimitive.Provider
data-slot="tooltip-provider"
delayDuration={delayDuration}
{...props}
/>
)
}
function Tooltip({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
}
function TooltipTrigger({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
}
function TooltipContent({
className,
sideOffset = 0,
children,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
return (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
"z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-xl bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 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}
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=left]:translate-x-[-1.5px] data-[side=right]:translate-x-[1.5px]" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
)
}
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }