Enhance Next.js configuration and dependencies for improved functionality and localization support. Added support for internationalization with next-intl, updated global styles, and integrated new fonts. Removed default home page and updated README with project details and setup instructions.
This commit is contained in:
1 parent
2911dea00b
commit
44f4fa98e2
320 files changed
+31666
-220
No files matched your search
@@ -0,0 +1,39 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
const PERSIAN_DIGITS = "۰۱۲۳۴۵۶۷۸۹";
|
||||
const toLatin = (value: string) => value.replace(/[۰-۹]/g, (digit) => String(PERSIAN_DIGITS.indexOf(digit)));
|
||||
|
||||
export function AnimatedMetric({ value, className }: { value: string; className?: string }) {
|
||||
const ref = useRef<HTMLSpanElement>(null);
|
||||
const [display, setDisplay] = useState(value);
|
||||
|
||||
useEffect(() => {
|
||||
const element = ref.current;
|
||||
if (!element || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
||||
const latin = toLatin(value).replaceAll("٬", "");
|
||||
const match = latin.match(/^(\D*)(\d+)(\D*)$/);
|
||||
if (!match) return;
|
||||
const [, prefix, rawNumber, suffix] = match;
|
||||
const target = Number(rawNumber);
|
||||
const observer = new IntersectionObserver(([entry]) => {
|
||||
if (!entry.isIntersecting) return;
|
||||
observer.disconnect();
|
||||
const startedAt = performance.now();
|
||||
const duration = 1000;
|
||||
const tick = (now: number) => {
|
||||
const progress = Math.min((now - startedAt) / duration, 1);
|
||||
const eased = 1 - Math.pow(1 - progress, 3);
|
||||
const current = Math.round(target * eased).toLocaleString("fa-IR");
|
||||
setDisplay(`${prefix}${current}${suffix}`);
|
||||
if (progress < 1) requestAnimationFrame(tick);
|
||||
};
|
||||
requestAnimationFrame(tick);
|
||||
}, { threshold: 0.55 });
|
||||
observer.observe(element);
|
||||
return () => observer.disconnect();
|
||||
}, [value]);
|
||||
|
||||
return <span ref={ref} className={className}>{display}</span>;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type BadgeVariant = "accent" | "muted" | "inverse";
|
||||
|
||||
export function BadgeLabel({
|
||||
className,
|
||||
variant = "accent",
|
||||
...props
|
||||
}: React.ComponentProps<"span"> & { variant?: BadgeVariant }) {
|
||||
const map = {
|
||||
accent: "default" as const,
|
||||
muted: "secondary" as const,
|
||||
inverse: "outline" as const,
|
||||
};
|
||||
return (
|
||||
<Badge
|
||||
variant={map[variant]}
|
||||
className={cn(
|
||||
variant === "inverse" &&
|
||||
"border-background/30 bg-background/15 text-background",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const LOGO_SRC = "/brand/amirkabir.png";
|
||||
|
||||
type BrandLogoProps = {
|
||||
href?: string;
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
onDark?: boolean;
|
||||
className?: string;
|
||||
compact?: boolean;
|
||||
};
|
||||
|
||||
/** AUT seal on a dark disc — works on light and dark headers (asset is white-on-black). */
|
||||
export function BrandLogo({
|
||||
href = "/",
|
||||
title,
|
||||
subtitle,
|
||||
onDark = false,
|
||||
className,
|
||||
compact = false,
|
||||
}: BrandLogoProps) {
|
||||
return (
|
||||
<Link
|
||||
href={href}
|
||||
className={cn(
|
||||
"group flex min-w-0 items-center gap-2.5 sm:gap-3",
|
||||
className,
|
||||
)}
|
||||
aria-label={[title, subtitle].filter(Boolean).join(" — ")}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"relative shrink-0 overflow-hidden rounded-full bg-chart-3 shadow-sm ring-1",
|
||||
onDark ? "ring-background/20" : "ring-border",
|
||||
compact ? "size-9" : "size-11 sm:size-12",
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
src={LOGO_SRC}
|
||||
alt=""
|
||||
fill
|
||||
priority
|
||||
sizes="48px"
|
||||
className="object-cover"
|
||||
/>
|
||||
</span>
|
||||
<span className="min-w-0 text-start leading-tight">
|
||||
<span
|
||||
className={cn(
|
||||
"block truncate font-black tracking-tight transition-colors",
|
||||
compact ? "text-base" : "text-base sm:text-lg",
|
||||
onDark ? "group-hover:text-background/70" : "group-hover:text-primary",
|
||||
)}
|
||||
>
|
||||
{title}
|
||||
</span>
|
||||
{subtitle ? (
|
||||
<span
|
||||
className={cn(
|
||||
"mt-0.5 block truncate text-[0.7rem] font-medium sm:text-xs",
|
||||
onDark ? "text-background/70" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{subtitle}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type ContainerProps = React.ComponentProps<"div"> & {
|
||||
narrow?: boolean;
|
||||
};
|
||||
|
||||
export function Container({
|
||||
className,
|
||||
narrow = false,
|
||||
...props
|
||||
}: ContainerProps) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"mx-auto w-full px-5 sm:px-8 lg:px-12",
|
||||
narrow ? "max-w-3xl" : "max-w-7xl",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import Link from "next/link";
|
||||
import { MorphMark } from "@/components/atoms/MorphMark";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type DotCtaProps = {
|
||||
href: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
onDark?: boolean;
|
||||
external?: boolean;
|
||||
};
|
||||
|
||||
/** CTA with metamorphism mark (dots → lines on hover) */
|
||||
export function DotCta({
|
||||
href,
|
||||
children,
|
||||
className,
|
||||
onDark = false,
|
||||
external = false,
|
||||
}: DotCtaProps) {
|
||||
const classes = cn(
|
||||
buttonVariants({ variant: "outline" }),
|
||||
"group h-auto gap-2.5 px-5 py-3 text-sm font-bold",
|
||||
onDark &&
|
||||
"border-background/40 bg-background text-foreground hover:bg-background/90",
|
||||
className,
|
||||
);
|
||||
|
||||
const content = (
|
||||
<>
|
||||
<MorphMark />
|
||||
<span>{children}</span>
|
||||
</>
|
||||
);
|
||||
|
||||
if (external) {
|
||||
return (
|
||||
<a href={href} target="_blank" rel="noreferrer" className={classes}>
|
||||
{content}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Link href={href} className={classes}>
|
||||
{content}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const levels = {
|
||||
1: "text-3xl font-bold tracking-tight sm:text-4xl lg:text-5xl",
|
||||
2: "text-2xl font-bold tracking-tight sm:text-3xl",
|
||||
3: "text-lg font-semibold sm:text-xl",
|
||||
4: "text-base font-semibold sm:text-lg",
|
||||
} as const;
|
||||
|
||||
type HeadingProps = React.ComponentProps<"h1"> & {
|
||||
as?: "h1" | "h2" | "h3" | "h4";
|
||||
level?: keyof typeof levels;
|
||||
};
|
||||
|
||||
export function Heading({ as, level = 2, className, ...props }: HeadingProps) {
|
||||
const Tag = as ?? (`h${level}` as "h1" | "h2" | "h3" | "h4");
|
||||
return <Tag className={cn(levels[level], className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type MetamorphFieldProps = {
|
||||
className?: string;
|
||||
/** `dark` = light strokes on navy/hero; `light` = ink strokes on sand/muted */
|
||||
tone?: "dark" | "light";
|
||||
/** Visual density of the constellation */
|
||||
density?: "sparse" | "normal";
|
||||
};
|
||||
|
||||
type Node = { x: number; y: number; r?: number };
|
||||
type Edge = [number, number];
|
||||
|
||||
/** Landscape constellation — matches typical flex section bands (≈ 2.5∶1) */
|
||||
const NODES_NORMAL: Node[] = [
|
||||
{ x: 40, y: 60, r: 2.1 },
|
||||
{ x: 130, y: 36, r: 1.7 },
|
||||
{ x: 220, y: 88, r: 2.4 },
|
||||
{ x: 100, y: 140, r: 1.5 },
|
||||
{ x: 190, y: 168, r: 2.0 },
|
||||
{ x: 310, y: 110, r: 1.6 },
|
||||
{ x: 400, y: 48, r: 2.2 },
|
||||
{ x: 480, y: 130, r: 1.8 },
|
||||
{ x: 560, y: 70, r: 2.5 },
|
||||
{ x: 650, y: 150, r: 1.6 },
|
||||
{ x: 740, y: 40, r: 1.9 },
|
||||
{ x: 830, y: 120, r: 2.1 },
|
||||
{ x: 920, y: 64, r: 1.7 },
|
||||
{ x: 1010, y: 140, r: 2.0 },
|
||||
{ x: 1100, y: 90, r: 1.5 },
|
||||
{ x: 70, y: 240, r: 2.3 },
|
||||
{ x: 170, y: 280, r: 1.6 },
|
||||
{ x: 280, y: 230, r: 2.0 },
|
||||
{ x: 370, y: 300, r: 1.8 },
|
||||
{ x: 470, y: 250, r: 2.2 },
|
||||
{ x: 570, y: 310, r: 1.7 },
|
||||
{ x: 680, y: 260, r: 2.4 },
|
||||
{ x: 780, y: 320, r: 1.6 },
|
||||
{ x: 880, y: 270, r: 2.0 },
|
||||
{ x: 980, y: 330, r: 1.8 },
|
||||
{ x: 1080, y: 280, r: 2.1 },
|
||||
{ x: 120, y: 380, r: 1.5 },
|
||||
{ x: 250, y: 410, r: 2.2 },
|
||||
{ x: 390, y: 390, r: 1.7 },
|
||||
{ x: 530, y: 430, r: 2.0 },
|
||||
{ x: 670, y: 400, r: 1.9 },
|
||||
{ x: 810, y: 440, r: 1.6 },
|
||||
{ x: 950, y: 410, r: 2.3 },
|
||||
{ x: 1090, y: 450, r: 1.8 },
|
||||
];
|
||||
|
||||
const EDGES_NORMAL: Edge[] = [
|
||||
[0, 1], [1, 2], [0, 3], [1, 3], [2, 4], [3, 4], [2, 5], [4, 5],
|
||||
[5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [8, 9], [7, 9],
|
||||
[8, 10], [9, 11], [10, 11], [10, 12], [11, 12], [12, 13], [11, 13], [13, 14],
|
||||
[3, 15], [4, 16], [5, 17], [7, 18], [8, 19], [9, 20], [11, 21], [12, 22], [13, 23], [14, 24],
|
||||
[15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25],
|
||||
[15, 26], [16, 27], [18, 28], [19, 29], [21, 30], [22, 31], [24, 32], [25, 33],
|
||||
[26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33],
|
||||
];
|
||||
|
||||
const NODES_SPARSE = NODES_NORMAL.filter((_, i) => i % 2 === 0);
|
||||
const EDGES_SPARSE: Edge[] = [
|
||||
[0, 1], [1, 2], [0, 3], [2, 4], [3, 4], [3, 5], [4, 6], [5, 6],
|
||||
[5, 7], [6, 8], [7, 8], [7, 9], [8, 10], [9, 10], [9, 11], [10, 12],
|
||||
[11, 12], [11, 13], [12, 14], [13, 14], [13, 15], [14, 16], [15, 16],
|
||||
];
|
||||
|
||||
const VIEW_W = 1200;
|
||||
const VIEW_H = 480;
|
||||
|
||||
/**
|
||||
* Decorative metamorphism field — dots joined by thin lines.
|
||||
* Place inside a `relative overflow-hidden` flex/grid surface.
|
||||
* The outer wrapper fills the parent; the SVG covers with landscape slice
|
||||
* so density stays proportional across wide hero/footer bands.
|
||||
*/
|
||||
export function MetamorphField({
|
||||
className,
|
||||
tone = "dark",
|
||||
density = "normal",
|
||||
}: MetamorphFieldProps) {
|
||||
const nodes = density === "sparse" ? NODES_SPARSE : NODES_NORMAL;
|
||||
const edges = density === "sparse" ? EDGES_SPARSE : EDGES_NORMAL;
|
||||
const stroke =
|
||||
tone === "dark" ? "color-mix(in oklab, white 55%, transparent)" : "var(--foreground)";
|
||||
const fill =
|
||||
tone === "dark" ? "color-mix(in oklab, white 70%, transparent)" : "var(--primary)";
|
||||
const accent = tone === "dark" ? "var(--accent)" : "var(--primary)";
|
||||
|
||||
const targets = nodes.map((node, index) => ({
|
||||
x: Math.max(24, Math.min(VIEW_W - 24, node.x + Math.sin(index * 1.7) * 28)),
|
||||
y: Math.max(24, Math.min(VIEW_H - 24, node.y + Math.cos(index * 1.3) * 22)),
|
||||
}));
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"pointer-events-none absolute inset-0 z-[1] overflow-hidden metamorph-field",
|
||||
tone === "light" ? "opacity-[0.14]" : "opacity-[0.42]",
|
||||
className,
|
||||
)}
|
||||
aria-hidden
|
||||
>
|
||||
<svg
|
||||
className="block size-full max-h-none max-w-none"
|
||||
viewBox={`0 0 ${VIEW_W} ${VIEW_H}`}
|
||||
fill="none"
|
||||
preserveAspectRatio="xMidYMid slice"
|
||||
focusable="false"
|
||||
>
|
||||
<g className="metamorph-field__mesh" stroke={stroke} strokeWidth="0.9">
|
||||
{edges.map(([a, b], i) => {
|
||||
const n1 = nodes[a];
|
||||
const n2 = nodes[b];
|
||||
if (!n1 || !n2) return null;
|
||||
return (
|
||||
<line
|
||||
key={`e-${i}`}
|
||||
x1={n1.x}
|
||||
y1={n1.y}
|
||||
x2={n2.x}
|
||||
y2={n2.y}
|
||||
className="metamorph-field__line"
|
||||
style={{ animationDelay: `${(i % 8) * 0.35}s` }}
|
||||
>
|
||||
<animate
|
||||
attributeName="x1"
|
||||
values={`${n1.x};${targets[a].x};${n1.x}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="y1"
|
||||
values={`${n1.y};${targets[a].y};${n1.y}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="x2"
|
||||
values={`${n2.x};${targets[b].x};${n2.x}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="y2"
|
||||
values={`${n2.y};${targets[b].y};${n2.y}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</line>
|
||||
);
|
||||
})}
|
||||
</g>
|
||||
<g>
|
||||
{nodes.map((n, i) => (
|
||||
<g key={`n-${i}`}>
|
||||
{i % 5 === 0 ? (
|
||||
<circle
|
||||
cx={n.x}
|
||||
cy={n.y}
|
||||
r="8"
|
||||
fill="none"
|
||||
stroke={accent}
|
||||
strokeWidth="0.7"
|
||||
opacity="0.45"
|
||||
>
|
||||
<animate
|
||||
attributeName="cx"
|
||||
values={`${n.x};${targets[i].x};${n.x}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="cy"
|
||||
values={`${n.y};${targets[i].y};${n.y}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="r"
|
||||
values="5;11;5"
|
||||
dur={`${8 + (i % 3)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="opacity"
|
||||
values="0.45;0;0.45"
|
||||
dur={`${8 + (i % 3)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</circle>
|
||||
) : null}
|
||||
<circle
|
||||
cx={n.x}
|
||||
cy={n.y}
|
||||
r={n.r ?? 2}
|
||||
fill={i % 5 === 0 ? accent : fill}
|
||||
className="metamorph-field__dot"
|
||||
style={{ animationDelay: `${(i % 6) * 0.4}s` }}
|
||||
>
|
||||
<animate
|
||||
attributeName="cx"
|
||||
values={`${n.x};${targets[i].x};${n.x}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="cy"
|
||||
values={`${n.y};${targets[i].y};${n.y}`}
|
||||
dur={`${14 + (i % 4)}s`}
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</circle>
|
||||
</g>
|
||||
))}
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type MorphMarkProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Metamorphism mark: four dots that morph into crossing lines on group hover.
|
||||
* Parent must use `group` (e.g. Button).
|
||||
*/
|
||||
export function MorphMark({ className }: MorphMarkProps) {
|
||||
return (
|
||||
<svg
|
||||
viewBox="0 0 16 16"
|
||||
className={cn("size-4 shrink-0", className)}
|
||||
aria-hidden
|
||||
>
|
||||
{/* Idle: four dots */}
|
||||
<g className="origin-center transition-opacity duration-300 group-hover:opacity-0 group-focus-visible:opacity-0">
|
||||
<circle cx="4" cy="4" r="1.65" fill="currentColor" />
|
||||
<circle cx="12" cy="4" r="1.65" fill="currentColor" />
|
||||
<circle cx="4" cy="12" r="1.65" fill="currentColor" />
|
||||
<circle cx="12" cy="12" r="1.65" fill="currentColor" />
|
||||
</g>
|
||||
{/* Hover: crossing lines */}
|
||||
<g
|
||||
className="origin-center opacity-0 transition-opacity duration-300 group-hover:opacity-100 group-focus-visible:opacity-100"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.75"
|
||||
strokeLinecap="round"
|
||||
>
|
||||
<line x1="3.5" y1="3.5" x2="12.5" y2="12.5" />
|
||||
<line x1="12.5" y1="3.5" x2="3.5" y2="12.5" />
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SectionProps = React.ComponentProps<"section"> & {
|
||||
tone?: "default" | "muted" | "dark" | "accent";
|
||||
tight?: boolean;
|
||||
};
|
||||
|
||||
const tones = {
|
||||
default: "bg-background text-foreground",
|
||||
muted: "bg-muted text-foreground",
|
||||
dark: "bg-chart-3 text-background",
|
||||
accent: "bg-primary text-primary-foreground",
|
||||
};
|
||||
|
||||
export function Section({
|
||||
className,
|
||||
tone = "default",
|
||||
tight = false,
|
||||
...props
|
||||
}: SectionProps) {
|
||||
return (
|
||||
<section
|
||||
data-tone={tone}
|
||||
className={cn(
|
||||
"motion-section relative",
|
||||
tight ? "py-8 sm:py-10" : "py-16 sm:py-24",
|
||||
tones[tone],
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import Link from "next/link";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type TextLinkProps = React.ComponentProps<typeof Link> & {
|
||||
tone?: "default" | "inverse" | "accent";
|
||||
};
|
||||
|
||||
export function TextLink({
|
||||
className,
|
||||
tone = "default",
|
||||
...props
|
||||
}: TextLinkProps) {
|
||||
return (
|
||||
<Link
|
||||
className={cn(
|
||||
"font-medium underline-offset-4 transition-colors hover:underline",
|
||||
tone === "default" && "text-chart-2 hover:text-primary",
|
||||
tone === "inverse" && "text-background/90 hover:text-background",
|
||||
tone === "accent" && "text-primary hover:text-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { ArrowUpLeft, MapPin, Wifi } from "lucide-react";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { blurDataURL } from "@/lib/images";
|
||||
import type { Program } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function ProgramCard({
|
||||
program,
|
||||
className,
|
||||
}: {
|
||||
program: Program;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<Card className={cn("group h-full gap-2 border-border/70 py-6 shadow-sm transition-[box-shadow,border-color] hover:border-primary/25 hover:shadow-lg", className)}>
|
||||
<CardHeader className="gap-1">
|
||||
{program.tagline ? (
|
||||
<p className="text-xs font-bold text-primary">{program.tagline}</p>
|
||||
) : null}
|
||||
<CardTitle className="text-lg">
|
||||
<Link href={program.href} className="hover:text-primary">
|
||||
{program.title}
|
||||
</Link>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<CardDescription className="leading-relaxed">
|
||||
{program.blurb}
|
||||
</CardDescription>
|
||||
<span className="mt-5 inline-flex items-center gap-1 text-xs font-bold text-primary">
|
||||
جزئیات برنامه
|
||||
<ArrowUpLeft className="size-3.5 transition-transform group-hover:-translate-x-0.5 group-hover:-translate-y-0.5" />
|
||||
</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function ArticleCard({
|
||||
title,
|
||||
category,
|
||||
excerpt,
|
||||
imageUrl,
|
||||
href,
|
||||
featured = false,
|
||||
variant = "grid",
|
||||
}: {
|
||||
title: string;
|
||||
category: string;
|
||||
excerpt: string;
|
||||
imageUrl: string;
|
||||
href: string;
|
||||
featured?: boolean;
|
||||
variant?: "grid" | "list";
|
||||
}) {
|
||||
if (variant === "list") {
|
||||
return (
|
||||
<article className="group grid overflow-hidden border-b border-border py-7 first:pt-0 last:border-b-0 sm:grid-cols-[14rem_1fr] sm:gap-8 lg:grid-cols-[19rem_1fr] lg:py-9">
|
||||
<Link href={href} className="relative aspect-[16/10] overflow-hidden rounded-xl bg-muted sm:aspect-auto sm:min-h-44">
|
||||
<Image src={imageUrl} alt={title} fill placeholder="blur" blurDataURL={blurDataURL} className="object-cover transition-transform duration-500 group-hover:scale-[1.025]" sizes="(max-width:640px) 100vw, 304px" />
|
||||
</Link>
|
||||
<div className="flex min-w-0 flex-col justify-center pt-5 sm:pt-0">
|
||||
<p className="text-xs font-bold text-primary">{category}</p>
|
||||
<h2 className="mt-2 text-xl font-bold leading-relaxed tracking-tight sm:text-2xl">
|
||||
<Link href={href} className="transition-colors hover:text-primary">{title}</Link>
|
||||
</h2>
|
||||
<p className="mt-3 max-w-2xl text-sm leading-7 text-muted-foreground sm:text-base">{excerpt}</p>
|
||||
<Link href={href} className="mt-4 inline-flex w-fit items-center gap-2 text-sm font-semibold text-foreground/70 transition-colors hover:text-primary">
|
||||
مطالعه مقاله <ArrowUpLeft className="size-4 transition-transform group-hover:-translate-x-0.5 group-hover:-translate-y-0.5" />
|
||||
</Link>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<article
|
||||
className={cn(
|
||||
"group flex h-full flex-col",
|
||||
featured && "lg:flex-row lg:gap-8",
|
||||
)}
|
||||
>
|
||||
<Link
|
||||
href={href}
|
||||
className={cn(
|
||||
"relative block shrink-0 overflow-hidden rounded-2xl",
|
||||
featured && "lg:w-[58%]",
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"relative w-full",
|
||||
featured ? "aspect-[16/10]" : "aspect-[4/3]",
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
src={imageUrl}
|
||||
alt={title}
|
||||
fill
|
||||
placeholder="blur"
|
||||
blurDataURL={blurDataURL}
|
||||
className="object-cover transition-transform duration-500 group-hover:scale-[1.035]"
|
||||
sizes={
|
||||
featured
|
||||
? "(max-width:1024px) 100vw, 58vw"
|
||||
: "(max-width:768px) 100vw, 33vw"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Link>
|
||||
<div
|
||||
className={cn(
|
||||
"mt-4 flex flex-1 flex-col",
|
||||
featured && "lg:mt-0 lg:justify-center",
|
||||
)}
|
||||
>
|
||||
<p className="text-xs font-semibold text-muted-foreground">{category}</p>
|
||||
<h3
|
||||
className={cn(
|
||||
featured
|
||||
? "mt-2 text-2xl font-bold tracking-tight sm:text-3xl"
|
||||
: "mt-1.5 text-lg font-semibold",
|
||||
)}
|
||||
>
|
||||
<Link href={href} className="hover:text-primary">
|
||||
{title}
|
||||
</Link>
|
||||
</h3>
|
||||
{featured ? (
|
||||
<p className="mt-3 max-w-md text-base leading-relaxed text-muted-foreground">
|
||||
{excerpt}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
export function EventCard({
|
||||
title,
|
||||
startDate,
|
||||
endDate,
|
||||
location,
|
||||
href,
|
||||
variant = "home",
|
||||
}: {
|
||||
title: string;
|
||||
startDate: string;
|
||||
endDate: string | null;
|
||||
location: string;
|
||||
href: string;
|
||||
variant?: "home" | "list";
|
||||
}) {
|
||||
const start = new Date(startDate);
|
||||
const end = endDate ? new Date(endDate) : null;
|
||||
const day = start.toLocaleDateString("fa-IR", { day: "numeric" });
|
||||
const month = start.toLocaleDateString("fa-IR", { month: "short" });
|
||||
const endDay = end?.toLocaleDateString("fa-IR", { day: "numeric" });
|
||||
const endMonth = end?.toLocaleDateString("fa-IR", { month: "short" });
|
||||
const isOnline = /آنلاین|online/i.test(location);
|
||||
|
||||
const body = (
|
||||
<>
|
||||
<div className="flex items-start gap-3">
|
||||
<div>
|
||||
<p className="text-xs font-semibold text-muted-foreground">{month}</p>
|
||||
<p className="mt-0.5 text-2xl font-bold leading-none">{day}</p>
|
||||
</div>
|
||||
{end ? (
|
||||
<>
|
||||
<span className="mt-7 text-xs font-medium text-primary">تا</span>
|
||||
<div>
|
||||
<p className="text-xs font-semibold text-muted-foreground">
|
||||
{endMonth}
|
||||
</p>
|
||||
<p className="mt-0.5 text-2xl font-bold leading-none">{endDay}</p>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">
|
||||
<Link href={href} className="hover:text-primary">
|
||||
{title}
|
||||
</Link>
|
||||
</h3>
|
||||
<p className="mt-2 flex items-center gap-1.5 text-sm text-muted-foreground">
|
||||
{isOnline ? (
|
||||
<Wifi className="size-3.5 shrink-0" aria-hidden />
|
||||
) : (
|
||||
<MapPin className="size-3.5 shrink-0" aria-hidden />
|
||||
)}
|
||||
{location}
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
if (variant === "list") {
|
||||
return (
|
||||
<Card className="gap-4 py-5">
|
||||
<CardContent className="flex flex-col gap-4">{body}</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<article className="flex flex-col gap-4 py-4 sm:border-e sm:border-border sm:px-5 sm:py-2 sm:last:border-e-0">
|
||||
{body}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
export function StatItem({ value, label }: { value: string; label: string }) {
|
||||
return (
|
||||
<div className="text-center">
|
||||
<p className="text-4xl font-extrabold text-accent">{value}</p>
|
||||
<p className="mt-2 text-sm text-background/70">{label}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function QuoteBlock({
|
||||
quote,
|
||||
name,
|
||||
role,
|
||||
courseTitle,
|
||||
}: {
|
||||
quote: string;
|
||||
name: string;
|
||||
role: string;
|
||||
courseTitle: string;
|
||||
}) {
|
||||
return (
|
||||
<blockquote className="flex h-full flex-col rounded-xl bg-background/5 p-7 ring-1 ring-background/10">
|
||||
<p className="flex-1 text-sm leading-8 text-background/90">«{quote}»</p>
|
||||
<footer className="mt-7">
|
||||
<p className="font-bold text-background">{name}</p>
|
||||
<p className="mt-0.5 text-sm text-background/55">{role}</p>
|
||||
<p className="mt-2 text-xs font-semibold text-accent">{courseTitle}</p>
|
||||
</footer>
|
||||
</blockquote>
|
||||
);
|
||||
}
|
||||
|
||||
export function IntersectionCard({
|
||||
title,
|
||||
description,
|
||||
href,
|
||||
imageUrl,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
href: string;
|
||||
imageUrl: string;
|
||||
}) {
|
||||
return (
|
||||
<Link
|
||||
href={href}
|
||||
className="group relative block min-h-[16rem] overflow-hidden rounded-2xl bg-chart-3 shadow-sm sm:min-h-[18rem]"
|
||||
>
|
||||
<div className="absolute inset-0 overflow-hidden">
|
||||
<Image
|
||||
src={imageUrl}
|
||||
alt={title}
|
||||
fill
|
||||
placeholder="blur"
|
||||
blurDataURL={blurDataURL}
|
||||
className="object-cover transition-transform duration-500 group-hover:scale-[1.04]"
|
||||
sizes="(max-width:768px) 100vw, 25vw"
|
||||
/>
|
||||
</div>
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-chart-3 via-chart-3/50 to-transparent" />
|
||||
<div className="absolute inset-x-0 bottom-0 p-6 text-background">
|
||||
<div className="flex items-center justify-between gap-3"><p className="text-sm font-bold text-accent">{title}</p><ArrowUpLeft className="size-4 transition-transform group-hover:-translate-x-1 group-hover:-translate-y-1" /></div>
|
||||
<p className="mt-2 text-sm font-semibold leading-relaxed text-background/80">{description}</p>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import Link from "next/link";
|
||||
import { ArrowLeft, GraduationCap } from "lucide-react";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { MetamorphField } from "@/components/atoms/MetamorphField";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function HeroFeatured({ title, href, eyebrow }: { title: string; href: string; imageUrl: string; eyebrow: string }) {
|
||||
return (
|
||||
<header className="home-hero relative isolate overflow-hidden bg-chart-3 text-background">
|
||||
<MetamorphField tone="dark" density="sparse" className="end-0 start-auto w-[min(55vw,36rem)] opacity-20" />
|
||||
<Container className="relative z-[2] flex min-h-[38rem] items-center py-20 sm:py-24">
|
||||
<div className="home-hero__copy max-w-4xl">
|
||||
<div className="inline-flex items-center gap-2 text-sm font-medium text-background/60">
|
||||
<GraduationCap className="size-4" />
|
||||
مرکز آموزشهای آزاد دانشگاه صنعتی امیرکبیر
|
||||
</div>
|
||||
<h1 className="mt-8 text-4xl font-black leading-[1.25] tracking-tight sm:text-6xl lg:text-7xl">
|
||||
آموزش حرفهای برای
|
||||
<span className="mt-2 block text-background">مدیریت در دنیای متغیر</span>
|
||||
</h1>
|
||||
<p className="mt-7 max-w-2xl text-base leading-8 text-background/65 sm:text-lg sm:leading-9">
|
||||
دانش دانشگاهی و تجربهی صنعت را کنار هم میآوریم تا مدیران و متخصصان برای تصمیمهای پیچیده آمادهتر شوند.
|
||||
</p>
|
||||
<div className="mt-10 flex flex-wrap gap-3">
|
||||
<Link
|
||||
href="/programs"
|
||||
className={cn(
|
||||
buttonVariants({ size: "lg" }),
|
||||
"bg-primary font-bold text-primary-foreground hover:bg-primary/85",
|
||||
)}
|
||||
>
|
||||
مشاهده دورهها <ArrowLeft className="size-4" />
|
||||
</Link>
|
||||
<Link
|
||||
href="/about"
|
||||
className={cn(
|
||||
buttonVariants({ variant: "outline", size: "lg" }),
|
||||
"border-background/25 bg-transparent font-bold text-background hover:bg-background hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
درباره مرکز
|
||||
</Link>
|
||||
</div>
|
||||
<div className="mt-12 border-t border-background/10 pt-6">
|
||||
<Link href={href} className="group inline-flex max-w-2xl items-center gap-3 text-sm text-background/55 transition-colors hover:text-background">
|
||||
<span className="shrink-0 font-semibold text-background/80">{eyebrow}</span>
|
||||
<span className="truncate">{title}</span>
|
||||
<ArrowLeft className="size-4 shrink-0 transition-transform group-hover:-translate-x-1" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import Image from "next/image";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Heading } from "@/components/atoms/Heading";
|
||||
import { MetamorphField } from "@/components/atoms/MetamorphField";
|
||||
|
||||
export function PageHero({ title, intro, eyebrow, imageUrl }: { title: string; intro?: string; eyebrow?: string; imageUrl?: string }) {
|
||||
return (
|
||||
<header className="page-hero relative isolate overflow-hidden bg-chart-3 py-20 text-background sm:py-28">
|
||||
{imageUrl ? (
|
||||
<><Image src={imageUrl} alt="" fill priority className="object-cover opacity-25" sizes="100vw" /><div className="absolute inset-0 bg-gradient-to-l from-chart-3 via-chart-3/90 to-chart-3/60" /></>
|
||||
) : <><Image src="/brand/campus-collaboration-v1.png" alt="" fill priority className="object-cover opacity-15 grayscale" sizes="100vw" /><div className="absolute inset-0 bg-gradient-to-l from-chart-3 via-chart-3/95 to-chart-3/75" /></>}
|
||||
<MetamorphField tone="dark" density="normal" className="end-0 start-auto w-[min(75vw,42rem)] opacity-45" />
|
||||
<div className="absolute end-0 top-0 h-px w-1/3 bg-gradient-to-l from-accent to-transparent" />
|
||||
<Container className="relative z-[2]">
|
||||
<div className="page-hero__content max-w-3xl text-start">
|
||||
{eyebrow ? <p className="mb-4 inline-flex rounded-full border border-background/15 bg-background/5 px-3 py-1.5 text-xs font-semibold text-accent backdrop-blur-sm">{eyebrow}</p> : null}
|
||||
<Heading as="h1" level={1} className="text-4xl leading-tight text-background sm:text-6xl">{title}</Heading>
|
||||
{intro ? <p className="mt-5 max-w-2xl border-s border-accent/70 ps-5 text-base leading-8 text-background/70 sm:text-lg">{intro}</p> : null}
|
||||
</div>
|
||||
</Container>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SurfaceCardProps = {
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
id?: string;
|
||||
padded?: boolean | "sm" | "md" | "lg";
|
||||
as?: "article" | "div";
|
||||
};
|
||||
|
||||
const padClass = {
|
||||
true: "p-6",
|
||||
sm: "p-4",
|
||||
md: "p-5",
|
||||
lg: "p-8",
|
||||
} as const;
|
||||
|
||||
/** Light surface built on shadcn Card */
|
||||
export function SurfaceCard({
|
||||
padded = "md",
|
||||
className,
|
||||
children,
|
||||
id,
|
||||
as = "article",
|
||||
}: SurfaceCardProps) {
|
||||
return (
|
||||
<Card
|
||||
id={id}
|
||||
data-slot={as === "div" ? "surface-div" : "surface-article"}
|
||||
className={cn(
|
||||
"gap-0 border-border/70 bg-card py-0 shadow-sm transition-[box-shadow,border-color] hover:border-primary/20 hover:shadow-md",
|
||||
padded !== false &&
|
||||
padClass[padded === true ? "true" : (padded as "sm" | "md" | "lg")],
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { X } from "lucide-react";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { DotCta } from "@/components/atoms/DotCta";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { Program } from "@/lib/types";
|
||||
|
||||
export function AcademicsOverlay({
|
||||
open,
|
||||
onClose,
|
||||
title,
|
||||
executiveLabel,
|
||||
exploreLabel,
|
||||
standardPrograms,
|
||||
executivePrograms,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
title: string;
|
||||
executiveLabel: string;
|
||||
exploreLabel: string;
|
||||
standardPrograms: Program[];
|
||||
executivePrograms: Program[];
|
||||
}) {
|
||||
if (!open) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-[70] overflow-y-auto bg-card text-foreground"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={title}
|
||||
>
|
||||
<Container className="py-8">
|
||||
<div className="mb-8 flex items-center justify-between gap-4">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
onClick={onClose}
|
||||
className="px-0 font-semibold hover:bg-transparent hover:text-primary"
|
||||
>
|
||||
بازگشت به منو
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={onClose}
|
||||
aria-label="بستن"
|
||||
>
|
||||
<X className="size-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<h2 className="mb-10 max-w-3xl text-start text-3xl font-bold tracking-tight sm:text-4xl">
|
||||
{title}
|
||||
</h2>
|
||||
|
||||
<ul className="grid gap-x-10 gap-y-8 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{standardPrograms.map((program) => (
|
||||
<li key={program.id}>
|
||||
<Link
|
||||
href={program.href}
|
||||
onClick={onClose}
|
||||
className="group block"
|
||||
>
|
||||
<span className="text-base font-extrabold leading-snug group-hover:text-primary">
|
||||
{program.title}
|
||||
</span>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{program.blurb}
|
||||
</p>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<h3 className="mt-14 mb-6 text-lg font-extrabold text-primary">
|
||||
{executiveLabel}
|
||||
</h3>
|
||||
<ul className="grid gap-x-10 gap-y-8 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{executivePrograms.map((program) => (
|
||||
<li key={program.id}>
|
||||
<Link
|
||||
href={program.href}
|
||||
onClick={onClose}
|
||||
className="group block"
|
||||
>
|
||||
<span className="text-base font-extrabold leading-snug group-hover:text-primary">
|
||||
{program.title}
|
||||
</span>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{program.blurb}
|
||||
</p>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<div className="mt-12">
|
||||
<DotCta href="/programs">{exploreLabel}</DotCta>
|
||||
</div>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { X } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { CampaignBanner } from "@/lib/types";
|
||||
|
||||
const STORAGE_PREFIX = "aut-banner:v1:";
|
||||
|
||||
export function CampaignBanners({ banners }: { banners: CampaignBanner[] }) {
|
||||
const [hidden, setHidden] = useState<Record<string, boolean>>({});
|
||||
const [ready, setReady] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const frame = requestAnimationFrame(() => {
|
||||
const next: Record<string, boolean> = {};
|
||||
for (const banner of banners) {
|
||||
try {
|
||||
next[banner.id] =
|
||||
localStorage.getItem(`${STORAGE_PREFIX}${banner.version}`) === "1";
|
||||
} catch {
|
||||
next[banner.id] = false;
|
||||
}
|
||||
}
|
||||
setHidden(next);
|
||||
setReady(true);
|
||||
});
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}, [banners]);
|
||||
|
||||
function dismiss(banner: CampaignBanner) {
|
||||
try {
|
||||
localStorage.setItem(`${STORAGE_PREFIX}${banner.version}`, "1");
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
setHidden((prev) => ({ ...prev, [banner.id]: true }));
|
||||
}
|
||||
|
||||
if (!ready) return null;
|
||||
|
||||
const visible = banners.filter((b) => !hidden[b.id]);
|
||||
if (visible.length === 0) return null;
|
||||
|
||||
const banner = visible[0];
|
||||
|
||||
return (
|
||||
<div className="bg-chart-3 text-background">
|
||||
<Container className="flex items-center justify-between gap-4 py-3">
|
||||
<p className="min-w-0 flex-1 text-sm leading-relaxed">
|
||||
<span className="text-background/90">{banner.text}</span>{" "}
|
||||
<Link
|
||||
href={banner.href}
|
||||
className="font-bold text-background underline-offset-4 hover:underline"
|
||||
>
|
||||
{banner.cta}
|
||||
</Link>
|
||||
</p>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="بستن بنر"
|
||||
className="shrink-0 text-background/70 hover:bg-background/10 hover:text-background"
|
||||
onClick={() => dismiss(banner)}
|
||||
>
|
||||
<X className="size-4" />
|
||||
</Button>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
"use client";
|
||||
|
||||
import { useDeferredValue, useMemo, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import type { Course } from "@/lib/types";
|
||||
import { courseCategories } from "@/lib/site-config";
|
||||
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function CategoryCourseExplorer({
|
||||
courses,
|
||||
findLabel,
|
||||
}: {
|
||||
courses: Course[];
|
||||
findLabel: string;
|
||||
}) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [category, setCategory] = useState("all");
|
||||
const deferredQuery = useDeferredValue(query);
|
||||
const isStale = query !== deferredQuery;
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
return courses.filter((course) => {
|
||||
const matchesCategory =
|
||||
category === "all" ||
|
||||
category === "best" ||
|
||||
course.category === category;
|
||||
const matchesQuery =
|
||||
!deferredQuery ||
|
||||
course.title.includes(deferredQuery) ||
|
||||
course.summary.includes(deferredQuery);
|
||||
return matchesCategory && matchesQuery;
|
||||
});
|
||||
}, [courses, category, deferredQuery]);
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<form
|
||||
className="flex flex-col gap-3 sm:flex-row"
|
||||
onSubmit={(e) => e.preventDefault()}
|
||||
role="search"
|
||||
>
|
||||
<Label className="sr-only" htmlFor="course-search">
|
||||
{findLabel}
|
||||
</Label>
|
||||
<Input
|
||||
id="course-search"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={findLabel}
|
||||
className="h-11 flex-1 border-border bg-background text-foreground placeholder:text-muted-foreground"
|
||||
/>
|
||||
<Button type="submit" className="h-11">
|
||||
جستجو
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div
|
||||
className="flex flex-wrap gap-2"
|
||||
role="tablist"
|
||||
aria-label="دستهبندی دورهها"
|
||||
>
|
||||
{courseCategories.map((item) => (
|
||||
<Button
|
||||
key={item.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
size="sm"
|
||||
variant={category === item.id ? "default" : "ghost"}
|
||||
aria-selected={category === item.id}
|
||||
onClick={() => setCategory(item.id)}
|
||||
className={cn(
|
||||
category !== item.id &&
|
||||
"bg-background/10 text-background/85 hover:bg-background/20 hover:text-background",
|
||||
)}
|
||||
>
|
||||
{item.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"grid gap-5 transition-opacity sm:grid-cols-2 lg:grid-cols-3",
|
||||
isStale && "opacity-70",
|
||||
)}
|
||||
>
|
||||
{filtered.map((course) => {
|
||||
const priceLabel = formatCoursePrice(course.price);
|
||||
return (
|
||||
<Card
|
||||
key={course.id}
|
||||
className="gap-0 overflow-hidden bg-background/5 py-0 text-background ring-background/10"
|
||||
>
|
||||
<div className="relative aspect-[16/10] overflow-hidden">
|
||||
<Image
|
||||
src={course.imageUrl}
|
||||
alt={course.title}
|
||||
fill
|
||||
className="object-cover"
|
||||
sizes="(max-width:768px) 100vw, 33vw"
|
||||
/>
|
||||
</div>
|
||||
<CardHeader className="gap-1 px-4 pt-4">
|
||||
<CardTitle className="text-base text-background">
|
||||
<Link
|
||||
href={course.registrationUrl}
|
||||
className="transition-opacity hover:opacity-90"
|
||||
>
|
||||
{course.title}
|
||||
</Link>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 px-4 pb-4">
|
||||
<CardDescription className="line-clamp-3 text-background/70">
|
||||
{course.summary}
|
||||
</CardDescription>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-background/55">
|
||||
<span>
|
||||
{course.durationHours} ساعت · {formatLabel(course.format)}
|
||||
</span>
|
||||
{priceLabel ? (
|
||||
<span className="font-semibold text-background/90">
|
||||
{priceLabel}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<Link
|
||||
href={course.registrationUrl}
|
||||
className="inline-flex text-sm font-semibold text-background underline-offset-4 hover:underline"
|
||||
>
|
||||
جزئیات و ثبتنام
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
|
||||
export function ContactInterestForm({
|
||||
submitLabel,
|
||||
successLabel,
|
||||
courseSlug,
|
||||
}: {
|
||||
submitLabel: string;
|
||||
successLabel: string;
|
||||
courseSlug?: string;
|
||||
}) {
|
||||
const [form, setForm] = useState({ fullName: "", email: "", phone: "", message: "" });
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const [sent, setSent] = useState(false);
|
||||
|
||||
function set<K extends keyof typeof form>(key: K, value: string) {
|
||||
setForm((f) => ({ ...f, [key]: value }));
|
||||
}
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch("/api/registrations", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ ...form, courseSlug }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در ثبت درخواست");
|
||||
return;
|
||||
}
|
||||
setSent(true);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (sent) {
|
||||
return (
|
||||
<p className="rounded-lg border border-primary/25 bg-primary/5 p-4 text-sm text-chart-2">
|
||||
{successLabel}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<form className="space-y-4" onSubmit={handleSubmit}>
|
||||
{error && (
|
||||
<p className="rounded-lg bg-destructive/10 p-3 text-sm text-red-600" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="name">نام و نام خانوادگی</Label>
|
||||
<Input
|
||||
id="name"
|
||||
value={form.fullName}
|
||||
onChange={(e) => set("fullName", e.target.value)}
|
||||
required
|
||||
className="h-11"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="email">ایمیل</Label>
|
||||
<Input
|
||||
id="email"
|
||||
name="email"
|
||||
type="email"
|
||||
value={form.email}
|
||||
onChange={(e) => set("email", e.target.value)}
|
||||
required
|
||||
className="h-11"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="phone">تلفن</Label>
|
||||
<Input
|
||||
id="phone"
|
||||
value={form.phone}
|
||||
onChange={(e) => set("phone", e.target.value)}
|
||||
className="h-11"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="message">پیام</Label>
|
||||
<Textarea
|
||||
id="message"
|
||||
value={form.message}
|
||||
onChange={(e) => set("message", e.target.value)}
|
||||
rows={4}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" disabled={loading}>
|
||||
{loading ? "در حال ارسال..." : submitLabel}
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { ContactInterestForm } from "@/components/organisms/ContactInterestForm";
|
||||
|
||||
type CourseRegisterGateProps = {
|
||||
courseSlug: string;
|
||||
submitLabel: string;
|
||||
successLabel: string;
|
||||
ctaLabel: string;
|
||||
formTitle: string;
|
||||
formDescription: string;
|
||||
hint: string;
|
||||
cancelLabel: string;
|
||||
};
|
||||
|
||||
export function CourseRegisterGate({
|
||||
courseSlug,
|
||||
submitLabel,
|
||||
successLabel,
|
||||
ctaLabel,
|
||||
formTitle,
|
||||
formDescription,
|
||||
hint,
|
||||
cancelLabel,
|
||||
}: CourseRegisterGateProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
if (!open) {
|
||||
return (
|
||||
<div className="space-y-4 rounded-2xl bg-card p-6 shadow-sm ring-1 ring-border">
|
||||
<div className="space-y-2">
|
||||
<h2 className="text-lg font-bold tracking-tight">{formTitle}</h2>
|
||||
<p className="text-sm leading-7 text-muted-foreground">{hint}</p>
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
size="lg"
|
||||
className="w-full font-bold"
|
||||
onClick={() => setOpen(true)}
|
||||
>
|
||||
{ctaLabel}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="rounded-2xl border-border/70 shadow-lg" id="register-form">
|
||||
<CardHeader className="space-y-1">
|
||||
<CardTitle>{formTitle}</CardTitle>
|
||||
<CardDescription>{formDescription}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<ContactInterestForm
|
||||
courseSlug={courseSlug}
|
||||
submitLabel={submitLabel}
|
||||
successLabel={successLabel}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
className="w-full"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
{cancelLabel}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
"use client";
|
||||
|
||||
import useEmblaCarousel from "embla-carousel-react";
|
||||
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import { useCallback } from "react";
|
||||
import { DotCta } from "@/components/atoms/DotCta";
|
||||
import { ProgramCard } from "@/components/molecules/Cards";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { Program } from "@/lib/types";
|
||||
|
||||
export function ProgramCarousel({
|
||||
title,
|
||||
programs,
|
||||
keepExploringLabel,
|
||||
hideTitle = false,
|
||||
}: {
|
||||
title: string;
|
||||
programs: Program[];
|
||||
keepExploringLabel: string;
|
||||
hideTitle?: boolean;
|
||||
}) {
|
||||
const [emblaRef, emblaApi] = useEmblaCarousel({
|
||||
align: "start",
|
||||
direction: "rtl",
|
||||
loop: false,
|
||||
});
|
||||
|
||||
const scrollPrev = useCallback(() => emblaApi?.scrollPrev(), [emblaApi]);
|
||||
const scrollNext = useCallback(() => emblaApi?.scrollNext(), [emblaApi]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-5 flex items-end justify-between gap-4">
|
||||
{!hideTitle && title ? (
|
||||
<h2 className="text-2xl font-bold tracking-tight sm:text-3xl">
|
||||
{title}
|
||||
</h2>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
<div className="flex gap-1">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="icon"
|
||||
aria-label="قبلی"
|
||||
onClick={scrollPrev}
|
||||
>
|
||||
<ChevronRight className="size-4" />
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="icon"
|
||||
aria-label="بعدی"
|
||||
onClick={scrollNext}
|
||||
>
|
||||
<ChevronLeft className="size-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-hidden" ref={emblaRef}>
|
||||
<div className="flex gap-5">
|
||||
{programs.map((program) => (
|
||||
<div
|
||||
key={program.id}
|
||||
className="min-w-0 shrink-0 basis-[88%] sm:basis-[42%] lg:basis-[30%]"
|
||||
>
|
||||
<ProgramCard program={program} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-7">
|
||||
<DotCta href="/programs">{keepExploringLabel}</DotCta>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { Search, X } from "lucide-react";
|
||||
import { useDeferredValue, useEffect, useMemo, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import type { Course, Program } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function SearchOverlay({
|
||||
courses,
|
||||
programs,
|
||||
label,
|
||||
}: {
|
||||
courses: Course[];
|
||||
programs: Program[];
|
||||
label: string;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [query, setQuery] = useState("");
|
||||
const deferredQuery = useDeferredValue(query);
|
||||
const isStale = query !== deferredQuery;
|
||||
|
||||
useEffect(() => {
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === "Escape") setOpen(false);
|
||||
}
|
||||
if (open) window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const previousOverflow = document.body.style.overflow;
|
||||
const previousPadding = document.body.style.paddingInlineEnd;
|
||||
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
||||
document.body.style.overflow = "hidden";
|
||||
if (scrollbarWidth > 0) document.body.style.paddingInlineEnd = `${scrollbarWidth}px`;
|
||||
return () => {
|
||||
document.body.style.overflow = previousOverflow;
|
||||
document.body.style.paddingInlineEnd = previousPadding;
|
||||
};
|
||||
}, [open]);
|
||||
|
||||
const results = useMemo(() => {
|
||||
const q = deferredQuery.trim();
|
||||
if (!q) {
|
||||
return { programs: programs.slice(0, 4), courses: courses.slice(0, 4) };
|
||||
}
|
||||
return {
|
||||
programs: programs.filter(
|
||||
(p) => p.title.includes(q) || p.blurb.includes(q),
|
||||
),
|
||||
courses: courses.filter(
|
||||
(c) => c.title.includes(q) || c.summary.includes(q),
|
||||
),
|
||||
};
|
||||
}, [deferredQuery, programs, courses]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={label}
|
||||
onClick={() => setOpen(true)}
|
||||
className="size-11 text-inherit hover:bg-foreground/5"
|
||||
>
|
||||
<Search />
|
||||
</Button>
|
||||
|
||||
{open ? createPortal(
|
||||
<div
|
||||
className="fixed inset-0 z-[100] overflow-y-auto bg-background text-foreground"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={label}
|
||||
>
|
||||
<div className="border-b border-border bg-card">
|
||||
<div className="mx-auto flex max-w-4xl items-center justify-between px-4 py-5 sm:px-6">
|
||||
<p className="text-sm font-semibold text-muted-foreground">{label}</p>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="text-foreground hover:bg-muted"
|
||||
aria-label="بستن جستجو"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<X />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mx-auto flex max-w-4xl flex-col gap-8 px-4 py-8 sm:px-6 sm:py-12">
|
||||
<Input
|
||||
autoFocus
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder="جستجوی برنامه یا دوره…"
|
||||
className="h-14 rounded-xl border-border bg-card px-4 text-lg text-foreground shadow-sm placeholder:text-muted-foreground focus-visible:border-primary focus-visible:ring-primary/20 sm:text-xl"
|
||||
/>
|
||||
<div
|
||||
className={cn(
|
||||
"grid gap-8 transition-opacity sm:grid-cols-2",
|
||||
isStale && "opacity-70",
|
||||
)}
|
||||
>
|
||||
<ResultGroup
|
||||
title="برنامهها"
|
||||
items={results.programs.map((p) => ({
|
||||
href: p.href,
|
||||
title: p.title,
|
||||
subtitle: p.tagline,
|
||||
}))}
|
||||
onNavigate={() => setOpen(false)}
|
||||
/>
|
||||
<ResultGroup
|
||||
title="دورهها"
|
||||
items={results.courses.map((c) => ({
|
||||
href: c.registrationUrl,
|
||||
title: c.title,
|
||||
subtitle: c.summary,
|
||||
}))}
|
||||
onNavigate={() => setOpen(false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
, document.body) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ResultGroup({
|
||||
title,
|
||||
items,
|
||||
onNavigate,
|
||||
}: {
|
||||
title: string;
|
||||
items: { href: string; title: string; subtitle?: string }[];
|
||||
onNavigate: () => void;
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<p className="mb-3 text-xs font-bold text-muted-foreground">{title}</p>
|
||||
<ul className="space-y-3">
|
||||
{items.length === 0 ? (
|
||||
<li className="text-sm text-muted-foreground">موردی یافت نشد</li>
|
||||
) : (
|
||||
items.map((item) => (
|
||||
<li key={item.href + item.title}>
|
||||
<Link
|
||||
href={item.href}
|
||||
onClick={onNavigate}
|
||||
className="block rounded-xl bg-card p-4 shadow-sm ring-1 ring-border transition-[background-color,box-shadow] hover:bg-muted hover:shadow-md"
|
||||
>
|
||||
<span className="font-semibold">{item.title}</span>
|
||||
{item.subtitle ? (
|
||||
<span className="mt-1 line-clamp-2 block text-xs leading-6 text-muted-foreground">
|
||||
{item.subtitle}
|
||||
</span>
|
||||
) : null}
|
||||
</Link>
|
||||
</li>
|
||||
))
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import Link from "next/link";
|
||||
import { BrandLogo } from "@/components/atoms/BrandLogo";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
siteAddress,
|
||||
siteShortName,
|
||||
siteUniversity,
|
||||
} from "@/lib/site-config";
|
||||
|
||||
export function SiteFooter({
|
||||
copyright,
|
||||
links,
|
||||
linksTitle = "دسترسی سریع",
|
||||
}: {
|
||||
copyright: string;
|
||||
links: { label: string; href: string }[];
|
||||
linksTitle?: string;
|
||||
variant?: "home" | "professional";
|
||||
}) {
|
||||
return (
|
||||
<footer className="border-t border-border bg-chart-3 pb-[env(safe-area-inset-bottom)] text-background">
|
||||
<Container className="py-12 sm:py-14">
|
||||
<div className="grid gap-10 sm:grid-cols-2 lg:grid-cols-3 lg:gap-12">
|
||||
<div className="max-w-sm space-y-4">
|
||||
<BrandLogo
|
||||
title={siteShortName}
|
||||
subtitle={siteUniversity}
|
||||
onDark
|
||||
/>
|
||||
<p className="text-sm leading-7 text-background/65">
|
||||
{siteAddress.line}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<nav aria-label="لینکهای پاورقی" className="space-y-4">
|
||||
<p className="text-xs font-semibold tracking-wide text-background/55">
|
||||
{linksTitle}
|
||||
</p>
|
||||
<ul className="flex flex-col gap-2.5 text-sm font-medium">
|
||||
{links.map((link) => (
|
||||
<li key={link.href}>
|
||||
<Link
|
||||
href={link.href}
|
||||
className="text-background/80 transition-colors hover:text-background"
|
||||
>
|
||||
{link.label}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div className="space-y-4 sm:max-w-xs lg:justify-self-end lg:text-end">
|
||||
<p className="text-xs font-semibold tracking-wide text-background/55">
|
||||
تماس
|
||||
</p>
|
||||
<div className="space-y-1.5 text-sm text-background/75">
|
||||
<p dir="ltr">
|
||||
<a
|
||||
href={`tel:${siteAddress.phone}`}
|
||||
className="transition-colors hover:text-background"
|
||||
>
|
||||
{siteAddress.phone}
|
||||
</a>
|
||||
</p>
|
||||
<p dir="ltr">
|
||||
<a
|
||||
href={`mailto:${siteAddress.email}`}
|
||||
className="transition-colors hover:text-background"
|
||||
>
|
||||
{siteAddress.email}
|
||||
</a>
|
||||
</p>
|
||||
<p className="pt-1">
|
||||
<a
|
||||
href={siteAddress.mapUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="font-medium text-background/90 transition-colors hover:text-background"
|
||||
>
|
||||
موقعیت روی نقشه
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator className="my-8 bg-background/10" />
|
||||
|
||||
<p className="text-xs text-background/45">{copyright}</p>
|
||||
</Container>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
"use client";
|
||||
|
||||
import dynamic from "next/dynamic";
|
||||
import Link from "next/link";
|
||||
import { Menu, X } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { BrandLogo } from "@/components/atoms/BrandLogo";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { SearchOverlay } from "@/components/organisms/SearchOverlay";
|
||||
import type { Course, NavItem, Program } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const AcademicsOverlay = dynamic(
|
||||
() =>
|
||||
import("@/components/organisms/AcademicsOverlay").then(
|
||||
(m) => m.AcademicsOverlay,
|
||||
),
|
||||
{ ssr: false },
|
||||
);
|
||||
|
||||
export function SiteHeader({
|
||||
items,
|
||||
searchLabel,
|
||||
brandHref = "/",
|
||||
brandTitle,
|
||||
brandSubtitle,
|
||||
academicsLabel,
|
||||
programSelectorTitle,
|
||||
executiveLabel,
|
||||
exploreLabel,
|
||||
variant = "home",
|
||||
courses = [],
|
||||
programs = [],
|
||||
}: {
|
||||
items: NavItem[];
|
||||
searchLabel: string;
|
||||
brandHref?: string;
|
||||
brandTitle: string;
|
||||
brandSubtitle?: string;
|
||||
academicsLabel: string;
|
||||
programSelectorTitle: string;
|
||||
executiveLabel: string;
|
||||
exploreLabel: string;
|
||||
variant?: "home" | "professional";
|
||||
courses?: Course[];
|
||||
programs?: Program[];
|
||||
}) {
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
const [academicsOpen, setAcademicsOpen] = useState(false);
|
||||
const isDark = variant === "professional";
|
||||
const standardPrograms = programs.filter((p) => p.group === "standard");
|
||||
const executivePrograms = programs.filter((p) => p.group === "executive");
|
||||
|
||||
useEffect(() => {
|
||||
if (!mobileOpen) return;
|
||||
const prev = document.body.style.overflow;
|
||||
document.body.style.overflow = "hidden";
|
||||
return () => {
|
||||
document.body.style.overflow = prev;
|
||||
};
|
||||
}, [mobileOpen]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<header
|
||||
className={cn(
|
||||
"site-header sticky top-0 z-50 pt-[env(safe-area-inset-top)] shadow-sm backdrop-blur-xl",
|
||||
isDark
|
||||
? "border-b border-background/10 bg-chart-3/95 text-background"
|
||||
: "border-b border-border bg-card/95 text-foreground",
|
||||
)}
|
||||
>
|
||||
<Container className="flex h-[4.5rem] items-center justify-start gap-3 sm:h-20 sm:gap-5" dir="rtl">
|
||||
<BrandLogo
|
||||
href={brandHref}
|
||||
title={brandTitle}
|
||||
subtitle={brandSubtitle}
|
||||
onDark={isDark}
|
||||
/>
|
||||
|
||||
<nav
|
||||
className="hidden min-w-0 flex-1 items-center justify-start gap-0.5 xl:flex"
|
||||
aria-label="منوی اصلی"
|
||||
>
|
||||
{items.map((item) => (
|
||||
<Link
|
||||
key={item.href + item.label}
|
||||
href={item.href}
|
||||
className={cn(
|
||||
"rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors",
|
||||
isDark
|
||||
? "text-background/80 hover:text-background"
|
||||
: "text-foreground/75 hover:bg-muted hover:text-primary",
|
||||
)}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
))}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className={cn(
|
||||
"ms-2 h-9 border-primary/20 font-bold text-primary hover:bg-primary hover:text-primary-foreground",
|
||||
isDark &&
|
||||
"border-background/50 bg-transparent text-background hover:bg-background hover:text-foreground",
|
||||
)}
|
||||
onClick={() => setAcademicsOpen(true)}
|
||||
>
|
||||
{academicsLabel}
|
||||
</Button>
|
||||
</nav>
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"ms-auto flex shrink-0 items-center gap-0.5 xl:ms-0",
|
||||
isDark && "text-background",
|
||||
)}
|
||||
>
|
||||
<SearchOverlay
|
||||
courses={courses}
|
||||
programs={programs}
|
||||
label={searchLabel}
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="xl:hidden"
|
||||
aria-label={mobileOpen ? "بستن منو" : "باز کردن منو"}
|
||||
aria-expanded={mobileOpen}
|
||||
onClick={() => setMobileOpen((v) => !v)}
|
||||
>
|
||||
{mobileOpen ? (
|
||||
<X className="size-5" />
|
||||
) : (
|
||||
<Menu className="size-5" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</Container>
|
||||
</header>
|
||||
|
||||
{mobileOpen ? (
|
||||
<div
|
||||
className="fixed inset-0 z-[60] flex flex-col bg-chart-3 text-background pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] xl:hidden"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="منوی اصلی"
|
||||
>
|
||||
<Container className="flex h-16 items-center justify-between gap-3">
|
||||
<BrandLogo
|
||||
href={brandHref}
|
||||
title={brandTitle}
|
||||
subtitle={brandSubtitle}
|
||||
onDark
|
||||
compact
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="text-background hover:bg-background/10"
|
||||
aria-label="بستن منو"
|
||||
onClick={() => setMobileOpen(false)}
|
||||
>
|
||||
<X className="size-5" />
|
||||
</Button>
|
||||
</Container>
|
||||
<Separator className="bg-background/10" />
|
||||
<Container className="flex-1 overflow-y-auto py-6">
|
||||
<ul className="space-y-1 text-start">
|
||||
{items.map((item) => (
|
||||
<li key={item.href + item.label}>
|
||||
<Link
|
||||
href={item.href}
|
||||
className="block py-3.5 text-lg font-bold transition-colors hover:text-background/70"
|
||||
onClick={() => setMobileOpen(false)}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mt-8 w-full border-background/80 bg-transparent py-3.5 text-background hover:bg-background hover:text-foreground"
|
||||
onClick={() => {
|
||||
setMobileOpen(false);
|
||||
setAcademicsOpen(true);
|
||||
}}
|
||||
>
|
||||
{academicsLabel}
|
||||
</Button>
|
||||
</Container>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{academicsOpen ? (
|
||||
<AcademicsOverlay
|
||||
open={academicsOpen}
|
||||
onClose={() => setAcademicsOpen(false)}
|
||||
title={programSelectorTitle}
|
||||
executiveLabel={executiveLabel}
|
||||
exploreLabel={exploreLabel}
|
||||
standardPrograms={standardPrograms}
|
||||
executivePrograms={executivePrograms}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import type { ReactNode } from "react";
|
||||
import Link from "next/link";
|
||||
import { ArrowRight } from "lucide-react";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function AdminPageHeader({
|
||||
title,
|
||||
description,
|
||||
actions,
|
||||
backHref,
|
||||
backLabel = "بازگشت",
|
||||
}: {
|
||||
title: string;
|
||||
description?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
backHref?: string;
|
||||
backLabel?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col gap-4 border-b border-border pb-6 sm:flex-row sm:items-end sm:justify-between">
|
||||
<div className="min-w-0 space-y-2">
|
||||
{backHref ? (
|
||||
<Link
|
||||
href={backHref}
|
||||
className={cn(
|
||||
buttonVariants({ variant: "ghost", size: "sm" }),
|
||||
"-ms-2 h-8 gap-1.5 px-2 text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
<ArrowRight className="size-3.5" />
|
||||
{backLabel}
|
||||
</Link>
|
||||
) : null}
|
||||
<div className="space-y-1">
|
||||
<h1 className="text-2xl font-bold tracking-tight text-foreground">
|
||||
{title}
|
||||
</h1>
|
||||
{description ? (
|
||||
<div className="text-sm text-muted-foreground">{description}</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{actions ? (
|
||||
<div className="flex shrink-0 flex-wrap items-center gap-2">{actions}</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminToolbarCard({
|
||||
title = "فیلترها",
|
||||
description,
|
||||
children,
|
||||
}: {
|
||||
title?: string;
|
||||
description?: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Card size="sm" className="shadow-none">
|
||||
<CardHeader className="border-b [.border-b]:pb-3">
|
||||
<CardTitle className="text-sm font-semibold">{title}</CardTitle>
|
||||
{description ? <CardDescription>{description}</CardDescription> : null}
|
||||
</CardHeader>
|
||||
<CardContent className="pt-4">{children}</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminTableCard({
|
||||
title = "فهرست",
|
||||
description,
|
||||
children,
|
||||
}: {
|
||||
title?: string;
|
||||
description?: ReactNode;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Card className="gap-0 overflow-hidden py-0 shadow-none">
|
||||
<CardHeader className="border-b py-4 [.border-b]:pb-4">
|
||||
<CardTitle className="text-base">{title}</CardTitle>
|
||||
{description ? <CardDescription>{description}</CardDescription> : null}
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">{children}</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminFormCard({
|
||||
title = "جزئیات",
|
||||
description,
|
||||
children,
|
||||
footer,
|
||||
}: {
|
||||
title?: string;
|
||||
description?: string;
|
||||
children: ReactNode;
|
||||
footer?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Card className="max-w-3xl shadow-none">
|
||||
<CardHeader className="border-b [.border-b]:pb-4">
|
||||
<CardTitle>{title}</CardTitle>
|
||||
{description ? <CardDescription>{description}</CardDescription> : null}
|
||||
</CardHeader>
|
||||
<CardContent className="pt-6">{children}</CardContent>
|
||||
{footer ? (
|
||||
<CardFooter className="justify-start gap-2 border-t bg-muted/30">
|
||||
{footer}
|
||||
</CardFooter>
|
||||
) : null}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminPage({
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return <div className={cn("space-y-6", className)}>{children}</div>;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import {
|
||||
SidebarInset,
|
||||
SidebarProvider,
|
||||
SidebarTrigger,
|
||||
} from "@/components/ui/sidebar";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { AdminSidebar } from "@/components/organisms/admin/AdminSidebar";
|
||||
|
||||
export function AdminShell({
|
||||
userName,
|
||||
children,
|
||||
}: {
|
||||
userName: string;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<SidebarProvider
|
||||
dir="rtl"
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": "16.5rem",
|
||||
"--header-height": "3.5rem",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<AdminSidebar userName={userName} />
|
||||
<SidebarInset className="bg-muted/30 md:peer-data-[variant=inset]:ms-2 md:peer-data-[variant=inset]:me-0 md:peer-data-[variant=inset]:peer-data-[state=collapsed]:me-2">
|
||||
<header className="sticky top-0 z-20 flex h-(--header-height) shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur supports-backdrop-filter:bg-background/80">
|
||||
<SidebarTrigger className="-ms-1" />
|
||||
<Separator orientation="vertical" className="me-1 data-[orientation=vertical]:h-4" />
|
||||
<div className="flex min-w-0 flex-1 items-center justify-between gap-3">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="relative size-6 shrink-0 overflow-hidden rounded-full bg-chart-3 ring-1 ring-border md:hidden">
|
||||
<Image
|
||||
src="/brand/amirkabir.png"
|
||||
alt=""
|
||||
fill
|
||||
sizes="24px"
|
||||
className="object-cover"
|
||||
/>
|
||||
</span>
|
||||
<p className="truncate text-sm font-medium text-muted-foreground">
|
||||
مدیریت محتوا
|
||||
</p>
|
||||
</div>
|
||||
<span className="hidden truncate text-sm text-muted-foreground sm:inline">
|
||||
{userName}
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
<div className="mx-auto w-full max-w-7xl flex-1 px-4 py-6 md:px-8 md:py-8">
|
||||
{children}
|
||||
</div>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import {
|
||||
BookOpen,
|
||||
Calendar,
|
||||
FileText,
|
||||
GraduationCap,
|
||||
LayoutDashboard,
|
||||
Megaphone,
|
||||
MessageSquareQuote,
|
||||
Newspaper,
|
||||
Scale,
|
||||
Tags,
|
||||
Users,
|
||||
ClipboardList,
|
||||
BarChart3,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarGroupContent,
|
||||
SidebarGroupLabel,
|
||||
SidebarHeader,
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
SidebarRail,
|
||||
SidebarSeparator,
|
||||
} from "@/components/ui/sidebar";
|
||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||
import { LogoutButton } from "@/components/organisms/admin/LogoutButton";
|
||||
|
||||
const NAV_GROUPS = [
|
||||
{
|
||||
label: "نمای کلی",
|
||||
items: [{ href: "/admin", label: "داشبورد", icon: LayoutDashboard, exact: true }],
|
||||
},
|
||||
{
|
||||
label: "محتوا",
|
||||
items: [
|
||||
{ href: "/admin/courses", label: "دورهها", icon: BookOpen },
|
||||
{ href: "/admin/programs", label: "برنامهها", icon: GraduationCap },
|
||||
{ href: "/admin/events", label: "رویدادها", icon: Calendar },
|
||||
{ href: "/admin/articles", label: "مقالات", icon: Newspaper },
|
||||
{ href: "/admin/topics", label: "موضوعات", icon: Tags },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "جامعه",
|
||||
items: [
|
||||
{ href: "/admin/faculty", label: "اساتید", icon: Users },
|
||||
{ href: "/admin/alumni", label: "دانشآموختگان", icon: MessageSquareQuote },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "سایت",
|
||||
items: [
|
||||
{ href: "/admin/banners", label: "بنرهای کمپین", icon: Megaphone },
|
||||
{ href: "/admin/stats", label: "آمار", icon: BarChart3 },
|
||||
{ href: "/admin/testimonials", label: "نظرات", icon: FileText },
|
||||
{ href: "/admin/legal", label: "صفحات قانونی", icon: Scale },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "درخواستها",
|
||||
items: [{ href: "/admin/registrations", label: "برگ ثبتنام", icon: ClipboardList }],
|
||||
},
|
||||
] as const;
|
||||
|
||||
function isActive(pathname: string, href: string, exact?: boolean) {
|
||||
if (exact) return pathname === href;
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
}
|
||||
|
||||
export function AdminSidebar({ userName }: { userName: string }) {
|
||||
const pathname = usePathname();
|
||||
const initials = userName
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.slice(0, 2)
|
||||
.map((part) => part[0])
|
||||
.join("");
|
||||
|
||||
return (
|
||||
<Sidebar side="right" collapsible="icon" variant="inset">
|
||||
<SidebarHeader className="gap-3 p-3">
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
size="lg"
|
||||
render={<Link href="/admin" />}
|
||||
className="data-active:bg-sidebar-accent"
|
||||
>
|
||||
<span className="relative size-8 shrink-0 overflow-hidden rounded-lg bg-chart-3 ring-1 ring-sidebar-border">
|
||||
<Image
|
||||
src="/brand/amirkabir.png"
|
||||
alt=""
|
||||
fill
|
||||
sizes="32px"
|
||||
className="object-cover"
|
||||
priority
|
||||
/>
|
||||
</span>
|
||||
<div className="grid flex-1 text-start text-sm leading-tight">
|
||||
<span className="truncate font-semibold">پنل مدیریت</span>
|
||||
<span className="truncate text-xs text-muted-foreground">
|
||||
آموزش آزاد امیرکبیر
|
||||
</span>
|
||||
</div>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarHeader>
|
||||
|
||||
<SidebarSeparator />
|
||||
|
||||
<SidebarContent>
|
||||
{NAV_GROUPS.map((group) => (
|
||||
<SidebarGroup key={group.label}>
|
||||
<SidebarGroupLabel>{group.label}</SidebarGroupLabel>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{group.items.map((item) => {
|
||||
const Icon = item.icon;
|
||||
const active = isActive(
|
||||
pathname,
|
||||
item.href,
|
||||
"exact" in item ? item.exact : false,
|
||||
);
|
||||
return (
|
||||
<SidebarMenuItem key={item.href}>
|
||||
<SidebarMenuButton
|
||||
isActive={active}
|
||||
tooltip={item.label}
|
||||
render={<Link href={item.href} />}
|
||||
>
|
||||
<Icon />
|
||||
<span>{item.label}</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
);
|
||||
})}
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
))}
|
||||
</SidebarContent>
|
||||
|
||||
<SidebarFooter className="p-3">
|
||||
<div className="flex items-center gap-2 rounded-lg border border-sidebar-border bg-sidebar px-2 py-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:border-0 group-data-[collapsible=icon]:p-0">
|
||||
<Avatar className="size-8">
|
||||
<AvatarFallback className="bg-sidebar-accent text-xs font-semibold">
|
||||
{initials || "اد"}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="min-w-0 flex-1 group-data-[collapsible=icon]:hidden">
|
||||
<p className="truncate text-sm font-medium">{userName}</p>
|
||||
<p className="truncate text-xs text-muted-foreground">مدیر محتوا</p>
|
||||
</div>
|
||||
<div className="group-data-[collapsible=icon]:hidden">
|
||||
<LogoutButton />
|
||||
</div>
|
||||
</div>
|
||||
</SidebarFooter>
|
||||
<SidebarRail />
|
||||
</Sidebar>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
export const LEAD_STATUS_LABELS: Record<string, string> = {
|
||||
new: "جدید",
|
||||
contacted: "تماس گرفته شد",
|
||||
enrolled: "ثبتنام شد",
|
||||
rejected: "رد شد",
|
||||
};
|
||||
|
||||
const STATUS_VARIANTS: Record<string, "default" | "secondary" | "outline" | "destructive"> = {
|
||||
new: "default",
|
||||
contacted: "secondary",
|
||||
enrolled: "outline",
|
||||
rejected: "destructive",
|
||||
};
|
||||
|
||||
export interface LeadForDashboard {
|
||||
id: string;
|
||||
full_name: string;
|
||||
email: string;
|
||||
course_slug: string | null;
|
||||
status: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export function LeadsList({ leads }: { leads: LeadForDashboard[] }) {
|
||||
const router = useRouter();
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function changeStatus(id: string, status: string) {
|
||||
setError("");
|
||||
const res = await fetch(`/api/admin/registrations/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ status }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در تغییر وضعیت");
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
if (leads.length === 0) {
|
||||
return <p className="text-sm text-muted-foreground">درخواستی ثبت نشده است.</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
{error && (
|
||||
<p className="text-sm text-red-600" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-right text-sm">
|
||||
<thead>
|
||||
<tr className="border-b text-muted-foreground">
|
||||
<th className="py-2 pe-4 font-medium">نام</th>
|
||||
<th className="py-2 pe-4 font-medium">ایمیل</th>
|
||||
<th className="py-2 pe-4 font-medium">دوره</th>
|
||||
<th className="py-2 pe-4 font-medium">وضعیت</th>
|
||||
<th className="py-2 font-medium">تغییر وضعیت</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{leads.map((lead) => (
|
||||
<tr key={lead.id} className="border-b">
|
||||
<td className="py-3 pe-4">{lead.full_name}</td>
|
||||
<td className="py-3 pe-4 text-muted-foreground">{lead.email}</td>
|
||||
<td className="py-3 pe-4 text-muted-foreground">
|
||||
{lead.course_slug ?? "—"}
|
||||
</td>
|
||||
<td className="py-3 pe-4">
|
||||
<Badge variant={STATUS_VARIANTS[lead.status] ?? "secondary"}>
|
||||
{LEAD_STATUS_LABELS[lead.status] ?? lead.status}
|
||||
</Badge>
|
||||
</td>
|
||||
<td className="py-3">
|
||||
<Select
|
||||
value={lead.status}
|
||||
onValueChange={(v) => v && changeStatus(lead.id, v)}
|
||||
>
|
||||
<SelectTrigger className="w-40">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="new">جدید</SelectItem>
|
||||
<SelectItem value="contacted">تماس گرفته شد</SelectItem>
|
||||
<SelectItem value="enrolled">ثبتنام شد</SelectItem>
|
||||
<SelectItem value="rejected">رد شد</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export function LogoutButton() {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function handleLogout() {
|
||||
setLoading(true);
|
||||
try {
|
||||
await fetch("/api/admin/logout", { method: "POST" });
|
||||
} catch {
|
||||
// ignore network errors — still navigate to login
|
||||
} finally {
|
||||
router.push("/admin/login");
|
||||
router.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Button variant="ghost" size="sm" onClick={handleLogout} disabled={loading}>
|
||||
{loading ? "…" : "خروج"}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
function buildUrl(search: string, published: string) {
|
||||
const params = new URLSearchParams();
|
||||
if (search.trim()) params.set("search", search.trim());
|
||||
if (published && published !== "all") params.set("published", published);
|
||||
const qs = params.toString();
|
||||
return qs ? `/admin/courses?${qs}` : "/admin/courses";
|
||||
}
|
||||
|
||||
export function CourseFilters({
|
||||
initialSearch,
|
||||
initialPublished,
|
||||
}: {
|
||||
initialSearch: string;
|
||||
initialPublished: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [search, setSearch] = useState(initialSearch);
|
||||
const [published, setPublished] = useState(initialPublished);
|
||||
const hasFilters = Boolean(initialSearch.trim()) || initialPublished !== "all";
|
||||
|
||||
function apply(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
router.push(buildUrl(search, published));
|
||||
}
|
||||
|
||||
function clear() {
|
||||
setSearch("");
|
||||
setPublished("all");
|
||||
router.push("/admin/courses");
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={apply}
|
||||
className="flex flex-wrap items-end gap-3"
|
||||
>
|
||||
<div className="w-full max-w-xs space-y-1.5">
|
||||
<label htmlFor="course-search" className="text-sm font-medium">
|
||||
جستجو
|
||||
</label>
|
||||
<Input
|
||||
id="course-search"
|
||||
placeholder="عنوان یا اسلاگ دوره..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full max-w-[12rem] space-y-1.5">
|
||||
<label htmlFor="course-published" className="text-sm font-medium">
|
||||
وضعیت انتشار
|
||||
</label>
|
||||
<Select value={published} onValueChange={(v) => setPublished(v ?? "all")}>
|
||||
<SelectTrigger id="course-published" className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">همه</SelectItem>
|
||||
<SelectItem value="true">منتشرشده</SelectItem>
|
||||
<SelectItem value="false">پیشنویس</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button type="submit">اعمال فیلتر</Button>
|
||||
{hasFilters && (
|
||||
<Button type="button" variant="ghost" onClick={clear}>
|
||||
پاککردن فیلترها
|
||||
</Button>
|
||||
)}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import type { AdminCourse } from "@/lib/data/admin/courses";
|
||||
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
|
||||
|
||||
type Payload = {
|
||||
slug: string;
|
||||
title: string;
|
||||
summary: string;
|
||||
category: string;
|
||||
durationHours: number;
|
||||
format: string;
|
||||
price: number | null;
|
||||
registrationUrl: string;
|
||||
imageUrl: string;
|
||||
seoDescription: string;
|
||||
published: boolean;
|
||||
};
|
||||
|
||||
interface CourseFormProps {
|
||||
initial?: AdminCourse;
|
||||
}
|
||||
|
||||
export function CourseForm({ initial }: CourseFormProps) {
|
||||
const router = useRouter();
|
||||
const isEdit = Boolean(initial);
|
||||
const [form, setForm] = useState<Payload>({
|
||||
slug: initial?.slug ?? "",
|
||||
title: initial?.title ?? "",
|
||||
summary: initial?.summary ?? "",
|
||||
category: initial?.category ?? "leadership",
|
||||
durationHours: initial?.durationHours ?? 16,
|
||||
format: initial?.format ?? "online",
|
||||
price: initial?.price ?? null,
|
||||
registrationUrl: initial?.registrationUrl ?? "/register/",
|
||||
imageUrl: initial?.imageUrl ?? "",
|
||||
seoDescription: initial?.seoDescription ?? "",
|
||||
published: initial?.published ?? true,
|
||||
});
|
||||
const [priceInput, setPriceInput] = useState(
|
||||
initial?.price != null ? String(initial.price) : "",
|
||||
);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
function set<K extends keyof Payload>(key: K, value: Payload[K]) {
|
||||
setForm((f) => ({ ...f, [key]: value }));
|
||||
}
|
||||
|
||||
function onPriceChange(raw: string) {
|
||||
setPriceInput(raw);
|
||||
const trimmed = raw.trim();
|
||||
if (trimmed === "") {
|
||||
set("price", null);
|
||||
return;
|
||||
}
|
||||
const n = Number(trimmed.replace(/,/g, ""));
|
||||
set("price", Number.isFinite(n) ? Math.round(n) : null);
|
||||
}
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(
|
||||
isEdit ? `/api/admin/courses/${initial!.id}` : "/api/admin/courses",
|
||||
{
|
||||
method: isEdit ? "PATCH" : "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(form),
|
||||
},
|
||||
);
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در ذخیره دوره");
|
||||
return;
|
||||
}
|
||||
router.push("/admin/courses");
|
||||
router.refresh();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<AdminFormCard
|
||||
title={isEdit ? "ویرایش دوره" : "ثبت دوره جدید"}
|
||||
description="فیلدهای ستارهدار الزامیاند. قیمت اختیاری است."
|
||||
footer={
|
||||
<>
|
||||
<Button type="submit" disabled={loading}>
|
||||
{loading ? "در حال ذخیره..." : isEdit ? "ذخیره تغییرات" : "ایجاد دوره"}
|
||||
</Button>
|
||||
<Link
|
||||
href="/admin/courses"
|
||||
className={cn(buttonVariants({ variant: "outline" }))}
|
||||
>
|
||||
انصراف
|
||||
</Link>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{error ? (
|
||||
<p
|
||||
className="mb-6 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive"
|
||||
role="alert"
|
||||
>
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<div className="space-y-8">
|
||||
<section className="space-y-4">
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold text-foreground">اطلاعات اصلی</h2>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
||||
شناسه، عنوان و خلاصهٔ نمایشی دوره
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="slug">اسلاگ</Label>
|
||||
<Input
|
||||
id="slug"
|
||||
value={form.slug}
|
||||
onChange={(e) => set("slug", e.target.value)}
|
||||
placeholder="ai-for-managers"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="title">عنوان</Label>
|
||||
<Input
|
||||
id="title"
|
||||
value={form.title}
|
||||
onChange={(e) => set("title", e.target.value)}
|
||||
placeholder="هوش مصنوعی برای مدیران"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5 sm:col-span-2">
|
||||
<Label htmlFor="summary">خلاصه</Label>
|
||||
<Textarea
|
||||
id="summary"
|
||||
value={form.summary}
|
||||
onChange={(e) => set("summary", e.target.value)}
|
||||
rows={3}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="space-y-4">
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold text-foreground">برگزاری و قیمت</h2>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
||||
دسته، قالب، مدت و هزینهٔ اختیاری
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="category">دستهبندی</Label>
|
||||
<Select value={form.category} onValueChange={(v) => v && set("category", v)}>
|
||||
<SelectTrigger id="category" className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="leadership">رهبری</SelectItem>
|
||||
<SelectItem value="technology">فناوری</SelectItem>
|
||||
<SelectItem value="innovation">نوآوری</SelectItem>
|
||||
<SelectItem value="energy">انرژی</SelectItem>
|
||||
<SelectItem value="design">طراحی</SelectItem>
|
||||
<SelectItem value="digital">دیجیتال</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="format">قالب برگزاری</Label>
|
||||
<Select value={form.format} onValueChange={(v) => v && set("format", v)}>
|
||||
<SelectTrigger id="format" className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="online">آنلاین</SelectItem>
|
||||
<SelectItem value="blended">ترکیبی</SelectItem>
|
||||
<SelectItem value="in-person">حضوری</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="durationHours">مدت (ساعت)</Label>
|
||||
<Input
|
||||
id="durationHours"
|
||||
type="number"
|
||||
min={1}
|
||||
value={form.durationHours}
|
||||
onChange={(e) => set("durationHours", Number(e.target.value))}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5 sm:col-span-3">
|
||||
<Label htmlFor="price">قیمت (تومان)</Label>
|
||||
<Input
|
||||
id="price"
|
||||
type="number"
|
||||
min={0}
|
||||
inputMode="numeric"
|
||||
value={priceInput}
|
||||
onChange={(e) => onPriceChange(e.target.value)}
|
||||
placeholder="خالی = بدون نمایش قیمت"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
اگر خالی بماند، قیمت در سایت نمایش داده نمیشود.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="space-y-4">
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold text-foreground">رسانه و انتشار</h2>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
||||
لینک ثبتنام، تصویر، SEO و وضعیت انتشار
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-1.5 sm:col-span-2">
|
||||
<Label htmlFor="registrationUrl">لینک ثبتنام</Label>
|
||||
<Input
|
||||
id="registrationUrl"
|
||||
value={form.registrationUrl}
|
||||
onChange={(e) => set("registrationUrl", e.target.value)}
|
||||
placeholder="/register/ai-for-managers"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5 sm:col-span-2">
|
||||
<Label htmlFor="imageUrl">آدرس تصویر</Label>
|
||||
<Input
|
||||
id="imageUrl"
|
||||
value={form.imageUrl}
|
||||
onChange={(e) => set("imageUrl", e.target.value)}
|
||||
placeholder="/images/courses/..."
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5 sm:col-span-2">
|
||||
<Label htmlFor="seoDescription">توضیح SEO</Label>
|
||||
<Textarea
|
||||
id="seoDescription"
|
||||
value={form.seoDescription}
|
||||
onChange={(e) => set("seoDescription", e.target.value)}
|
||||
rows={2}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="published">وضعیت انتشار</Label>
|
||||
<Select
|
||||
value={form.published ? "true" : "false"}
|
||||
onValueChange={(v) => set("published", (v ?? "true") === "true")}
|
||||
>
|
||||
<SelectTrigger id="published" className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="true">منتشرشده</SelectItem>
|
||||
<SelectItem value="false">پیشنویس</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</AdminFormCard>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import Link from "next/link";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import type { AdminCourse } from "@/lib/data/admin/courses";
|
||||
import { categoryLabel, formatCoursePrice, formatLabel } from "@/lib/labels";
|
||||
import { PublishToggle } from "@/components/organisms/admin/courses/PublishToggle";
|
||||
import { DeleteCourseDialog } from "@/components/organisms/admin/courses/DeleteCourseDialog";
|
||||
|
||||
export function CourseTable({ courses }: { courses: AdminCourse[] }) {
|
||||
if (courses.length === 0) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center px-6 py-14 text-center">
|
||||
<p className="text-sm font-medium text-foreground">دورهای یافت نشد</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
فیلتر را تغییر دهید یا دوره جدیدی بسازید.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-x-auto">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>عنوان</TableHead>
|
||||
<TableHead>دسته</TableHead>
|
||||
<TableHead>قالب</TableHead>
|
||||
<TableHead>مدت (ساعت)</TableHead>
|
||||
<TableHead>قیمت</TableHead>
|
||||
<TableHead>انتشار</TableHead>
|
||||
<TableHead>عملیات</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{courses.map((course) => (
|
||||
<TableRow key={course.id}>
|
||||
<TableCell className="font-medium">{course.title}</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant="secondary">{categoryLabel(course.category)}</Badge>
|
||||
</TableCell>
|
||||
<TableCell className="text-muted-foreground">
|
||||
{formatLabel(course.format)}
|
||||
</TableCell>
|
||||
<TableCell className="text-muted-foreground">
|
||||
{course.durationHours ?? "—"}
|
||||
</TableCell>
|
||||
<TableCell className="text-muted-foreground">
|
||||
{formatCoursePrice(course.price) ?? "—"}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<PublishToggle id={course.id} published={course.published} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-2">
|
||||
<Link
|
||||
href={`/admin/courses/${course.id}/edit`}
|
||||
className="text-sm text-primary hover:underline"
|
||||
>
|
||||
ویرایش
|
||||
</Link>
|
||||
{course.published && (
|
||||
<Link
|
||||
href={`/register/${course.slug}`}
|
||||
className="text-sm text-muted-foreground hover:underline"
|
||||
>
|
||||
پیشنمایش
|
||||
</Link>
|
||||
)}
|
||||
<DeleteCourseDialog id={course.id} title={course.title} />
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
|
||||
export function DeleteCourseDialog({ id, title }: { id: string; title: string }) {
|
||||
const router = useRouter();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function handleDelete() {
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(`/api/admin/courses/${id}`, { method: "DELETE" });
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در حذف دوره");
|
||||
return;
|
||||
}
|
||||
setOpen(false);
|
||||
router.refresh();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger render={<Button variant="ghost" size="sm" />}>
|
||||
حذف
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>حذف دوره</DialogTitle>
|
||||
<DialogDescription>
|
||||
دوره «{title}» برای همیشه حذف میشود. این عمل قابل بازگشت نیست.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={() => setOpen(false)}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button type="button" variant="destructive" onClick={handleDelete} disabled={loading}>
|
||||
{loading ? "در حال حذف..." : "حذف دوره"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export function PublishToggle({ id, published }: { id: string; published: boolean }) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function toggle() {
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(`/api/admin/courses/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ published: !published }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در ذخیره وضعیت");
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={published ? "outline" : "ghost"}
|
||||
onClick={toggle}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? "..." : published ? "منتشرشده" : "پیشنویس"}
|
||||
</Button>
|
||||
{error && <p className="mt-1 max-w-40 text-xs text-red-600">{error}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
|
||||
export function GenericDeleteDialog({
|
||||
apiPath,
|
||||
id,
|
||||
noun,
|
||||
subject,
|
||||
}: {
|
||||
apiPath: string;
|
||||
id: string;
|
||||
noun: string;
|
||||
subject: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function handleDelete() {
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(`${apiPath}/${id}`, { method: "DELETE" });
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در حذف");
|
||||
return;
|
||||
}
|
||||
setOpen(false);
|
||||
router.refresh();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger render={<Button variant="ghost" size="sm" />}>
|
||||
حذف
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>حذف {noun}</DialogTitle>
|
||||
<DialogDescription>
|
||||
«{subject}» برای همیشه حذف میشود. این عمل قابل بازگشت نیست.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={() => setOpen(false)}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button type="button" variant="destructive" onClick={handleDelete} disabled={loading}>
|
||||
{loading ? "در حال حذف..." : `حذف ${noun}`}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
function buildUrl(entity: string, search: string, published: string) {
|
||||
const params = new URLSearchParams();
|
||||
if (search.trim()) params.set("search", search.trim());
|
||||
if (published && published !== "all") params.set("published", published);
|
||||
const qs = params.toString();
|
||||
return qs ? `/admin/${entity}?${qs}` : `/admin/${entity}`;
|
||||
}
|
||||
|
||||
export function GenericFilters({
|
||||
entity,
|
||||
searchHint,
|
||||
hasPublished,
|
||||
initialSearch,
|
||||
initialPublished,
|
||||
}: {
|
||||
entity: string;
|
||||
searchHint: string;
|
||||
hasPublished: boolean;
|
||||
initialSearch: string;
|
||||
initialPublished: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [search, setSearch] = useState(initialSearch);
|
||||
const [published, setPublished] = useState(initialPublished);
|
||||
const hasFilters = Boolean(initialSearch.trim()) || initialPublished !== "all";
|
||||
|
||||
function apply(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
router.push(buildUrl(entity, search, published));
|
||||
}
|
||||
|
||||
function clear() {
|
||||
setSearch("");
|
||||
setPublished("all");
|
||||
router.push(`/admin/${entity}`);
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={apply} className="flex flex-wrap items-end gap-3">
|
||||
<div className="w-full max-w-xs space-y-1.5">
|
||||
<label htmlFor={`${entity}-search`} className="text-sm font-medium">
|
||||
جستجو
|
||||
</label>
|
||||
<Input
|
||||
id={`${entity}-search`}
|
||||
placeholder={searchHint}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{hasPublished && (
|
||||
<div className="w-full max-w-[12rem] space-y-1.5">
|
||||
<label htmlFor={`${entity}-published`} className="text-sm font-medium">
|
||||
وضعیت انتشار
|
||||
</label>
|
||||
<Select value={published} onValueChange={(v) => setPublished(v ?? "all")}>
|
||||
<SelectTrigger id={`${entity}-published`} className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">همه</SelectItem>
|
||||
<SelectItem value="true">منتشرشده</SelectItem>
|
||||
<SelectItem value="false">پیشنویس</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
)}
|
||||
<Button type="submit">اعمال فیلتر</Button>
|
||||
{hasFilters && (
|
||||
<Button type="button" variant="ghost" onClick={clear}>
|
||||
پاککردن فیلترها
|
||||
</Button>
|
||||
)}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
type AdminFieldSpec,
|
||||
type GenericFormSpec,
|
||||
} from "@/lib/admin/entities";
|
||||
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
|
||||
|
||||
function defaultValue(field: AdminFieldSpec): unknown {
|
||||
if (field.type === "stringList") return [];
|
||||
if (field.type === "boolean") return Boolean(field.defaultValue ?? false);
|
||||
return field.defaultValue ?? "";
|
||||
}
|
||||
|
||||
function finalValue(field: AdminFieldSpec, value: unknown): unknown {
|
||||
if (field.type === "stringList") {
|
||||
return (value as string[]).map((s) => s.trim()).filter(Boolean);
|
||||
}
|
||||
if (field.type === "number") return Number(value);
|
||||
if (field.type === "boolean") return value;
|
||||
// optional empty text/date becomes null (e.g. event endDate, program tagline)
|
||||
if (!field.required && value === "") return null;
|
||||
return value;
|
||||
}
|
||||
|
||||
export function GenericForm({
|
||||
spec,
|
||||
initial,
|
||||
}: {
|
||||
spec: GenericFormSpec;
|
||||
initial?: unknown;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const data = (initial ?? {}) as Record<string, unknown>;
|
||||
const isEdit = Boolean(initial);
|
||||
const editId = data[spec.idColumn];
|
||||
|
||||
const [form, setForm] = useState<Record<string, unknown>>(() => {
|
||||
const state: Record<string, unknown> = {};
|
||||
for (const field of spec.fields) {
|
||||
state[field.name] = data[field.name] !== undefined ? data[field.name] : defaultValue(field);
|
||||
}
|
||||
return state;
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
function set(name: string, value: unknown) {
|
||||
setForm((f) => ({ ...f, [name]: value }));
|
||||
}
|
||||
|
||||
function setListItem(name: string, index: number, value: string) {
|
||||
setForm((f) => {
|
||||
const list = [...((f[name] as string[]) ?? [])];
|
||||
list[index] = value;
|
||||
return { ...f, [name]: list };
|
||||
});
|
||||
}
|
||||
|
||||
function addListItem(name: string) {
|
||||
setForm((f) => ({ ...f, [name]: [...((f[name] as string[]) ?? []), ""] }));
|
||||
}
|
||||
|
||||
function removeListItem(name: string, index: number) {
|
||||
setForm((f) => ({
|
||||
...f,
|
||||
[name]: ((f[name] as string[]) ?? []).filter((_, i) => i !== index),
|
||||
}));
|
||||
}
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError("");
|
||||
|
||||
const payload: Record<string, unknown> = {};
|
||||
for (const field of spec.fields) {
|
||||
payload[field.name] = finalValue(field, form[field.name]);
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(isEdit ? `${spec.apiPath}/${editId}` : spec.apiPath, {
|
||||
method: isEdit ? "PATCH" : "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در ذخیره");
|
||||
return;
|
||||
}
|
||||
router.push(`/admin/${spec.key}`);
|
||||
router.refresh();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
function renderControl(field: AdminFieldSpec) {
|
||||
const value = form[field.name];
|
||||
|
||||
switch (field.type) {
|
||||
case "textarea":
|
||||
return (
|
||||
<Textarea
|
||||
value={String(value ?? "")}
|
||||
onChange={(e) => set(field.name, e.target.value)}
|
||||
rows={4}
|
||||
required={field.required}
|
||||
placeholder={field.placeholder}
|
||||
/>
|
||||
);
|
||||
case "number":
|
||||
return (
|
||||
<Input
|
||||
type="number"
|
||||
value={Number(value ?? 0)}
|
||||
onChange={(e) => set(field.name, Number(e.target.value))}
|
||||
required={field.required}
|
||||
placeholder={field.placeholder}
|
||||
/>
|
||||
);
|
||||
case "date":
|
||||
return (
|
||||
<Input
|
||||
type="date"
|
||||
value={String(value ?? "")}
|
||||
onChange={(e) => set(field.name, e.target.value)}
|
||||
required={field.required}
|
||||
/>
|
||||
);
|
||||
case "select":
|
||||
return (
|
||||
<Select value={String(value ?? "")} onValueChange={(v) => v && set(field.name, v)}>
|
||||
<SelectTrigger id={field.name} className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{(field.options ?? []).map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
case "boolean": {
|
||||
const options = field.options ?? [
|
||||
{ value: "true", label: "بله" },
|
||||
{ value: "false", label: "خیر" },
|
||||
];
|
||||
return (
|
||||
<Select
|
||||
value={Boolean(value) ? "true" : "false"}
|
||||
onValueChange={(v) => set(field.name, v === "true")}
|
||||
>
|
||||
<SelectTrigger id={field.name} className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options.map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
case "stringList":
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{((value as string[]) ?? []).map((item, index) => (
|
||||
<div key={index} className="flex gap-2">
|
||||
<Input
|
||||
value={item}
|
||||
onChange={(e) => setListItem(field.name, index, e.target.value)}
|
||||
placeholder={field.placeholder ?? "مورد…"}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => removeListItem(field.name, index)}
|
||||
>
|
||||
حذف
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
<Button type="button" variant="outline" size="sm" onClick={() => addListItem(field.name)}>
|
||||
+ افزودن مورد
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<Input
|
||||
value={String(value ?? "")}
|
||||
onChange={(e) => set(field.name, e.target.value)}
|
||||
required={field.required}
|
||||
placeholder={field.placeholder}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<AdminFormCard
|
||||
title={isEdit ? `ویرایش ${spec.noun}` : `ثبت ${spec.noun} جدید`}
|
||||
description="پس از ذخیره، فهرست بهروز میشود."
|
||||
footer={
|
||||
<>
|
||||
<Button type="submit" disabled={loading}>
|
||||
{loading
|
||||
? "در حال ذخیره..."
|
||||
: isEdit
|
||||
? "ذخیره تغییرات"
|
||||
: `ایجاد ${spec.noun}`}
|
||||
</Button>
|
||||
<Link
|
||||
href={`/admin/${spec.key}`}
|
||||
className={cn(buttonVariants({ variant: "outline" }))}
|
||||
>
|
||||
انصراف
|
||||
</Link>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{error ? (
|
||||
<p
|
||||
className="mb-6 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive"
|
||||
role="alert"
|
||||
>
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<div className="grid gap-5 sm:grid-cols-2">
|
||||
{spec.fields.map((field) => (
|
||||
<div
|
||||
key={field.name}
|
||||
className={field.full ? "space-y-1.5 sm:col-span-2" : "space-y-1.5"}
|
||||
>
|
||||
<Label htmlFor={field.name}>{field.label}</Label>
|
||||
{renderControl(field)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</AdminFormCard>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import Link from "next/link";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import type { AdminEntitySpec } from "@/lib/admin/entities";
|
||||
import { PublishToggle } from "@/components/organisms/admin/generic/PublishToggle";
|
||||
import { GenericDeleteDialog } from "@/components/organisms/admin/generic/GenericDeleteDialog";
|
||||
|
||||
function truncate(value: unknown, max = 60): string {
|
||||
const text = String(value ?? "—");
|
||||
return text.length > max ? `${text.slice(0, max)}…` : text;
|
||||
}
|
||||
|
||||
export function GenericTable({ spec, rows }: { spec: AdminEntitySpec; rows: unknown[] }) {
|
||||
if (rows.length === 0) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center px-6 py-14 text-center">
|
||||
<p className="text-sm font-medium text-foreground">موردی یافت نشد</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
هنوز محتوایی برای این بخش ثبت نشده است.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-x-auto">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{spec.columns.map((col) => (
|
||||
<TableHead key={col.name}>{col.label}</TableHead>
|
||||
))}
|
||||
<TableHead>عملیات</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{rows.map((row) => {
|
||||
const r = row as Record<string, unknown>;
|
||||
const id = String(r[spec.idColumn] ?? "");
|
||||
const preview = spec.preview && r.published ? spec.preview(r) : null;
|
||||
return (
|
||||
<TableRow key={String(id)}>
|
||||
{spec.columns.map((col, i) => {
|
||||
const value = r[col.name];
|
||||
if (col.variant === "badge") {
|
||||
const label = col.map ? (col.map[String(value)] ?? String(value)) : String(value);
|
||||
const isPublish = col.name === "published";
|
||||
return (
|
||||
<TableCell key={col.name}>
|
||||
<Badge variant={isPublish || label === "پیشنویس" ? "outline" : "secondary"}>
|
||||
{value === null || value === undefined || value === "" ? "—" : label}
|
||||
</Badge>
|
||||
</TableCell>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<TableCell
|
||||
key={col.name}
|
||||
className={i === 0 ? "font-medium" : "text-muted-foreground"}
|
||||
>
|
||||
<span title={String(value ?? "")}>{truncate(value)}</span>
|
||||
</TableCell>
|
||||
);
|
||||
})}
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-3">
|
||||
{spec.hasPublished && (
|
||||
<PublishToggle apiPath={spec.apiPath} id={id} published={Boolean(r.published)} />
|
||||
)}
|
||||
<Link
|
||||
href={`/admin/${spec.key}/${id}/edit`}
|
||||
className="text-sm text-primary hover:underline"
|
||||
>
|
||||
ویرایش
|
||||
</Link>
|
||||
{preview && (
|
||||
<Link
|
||||
href={preview}
|
||||
className="text-sm text-muted-foreground hover:underline"
|
||||
>
|
||||
پیشنمایش
|
||||
</Link>
|
||||
)}
|
||||
<GenericDeleteDialog apiPath={spec.apiPath} id={id} noun={spec.noun} subject={String(r[spec.columns[0].name] ?? "")} />
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export function PublishToggle({
|
||||
apiPath,
|
||||
id,
|
||||
published,
|
||||
}: {
|
||||
apiPath: string;
|
||||
id: string;
|
||||
published: boolean;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function toggle() {
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(`${apiPath}/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ published: !published }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در ذخیره وضعیت");
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={published ? "outline" : "ghost"}
|
||||
onClick={toggle}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? "..." : published ? "منتشرشده" : "پیشنویس"}
|
||||
</Button>
|
||||
{error && <p className="mt-1 max-w-40 text-xs text-red-600">{error}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
function buildUrl(search: string, status: string) {
|
||||
const params = new URLSearchParams();
|
||||
if (search.trim()) params.set("search", search.trim());
|
||||
if (status && status !== "all") params.set("status", status);
|
||||
const qs = params.toString();
|
||||
return qs ? `/admin/registrations?${qs}` : "/admin/registrations";
|
||||
}
|
||||
|
||||
export function RegistrationFilters({
|
||||
initialSearch,
|
||||
initialStatus,
|
||||
}: {
|
||||
initialSearch: string;
|
||||
initialStatus: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [search, setSearch] = useState(initialSearch);
|
||||
const [status, setStatus] = useState(initialStatus);
|
||||
const hasFilters = Boolean(initialSearch.trim()) || initialStatus !== "all";
|
||||
|
||||
function apply(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
router.push(buildUrl(search, status));
|
||||
}
|
||||
|
||||
function clear() {
|
||||
setSearch("");
|
||||
setStatus("all");
|
||||
router.push("/admin/registrations");
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={apply} className="flex flex-wrap items-end gap-3">
|
||||
<div className="w-full max-w-xs space-y-1.5">
|
||||
<label htmlFor="reg-search" className="text-sm font-medium">
|
||||
جستجو
|
||||
</label>
|
||||
<Input
|
||||
id="reg-search"
|
||||
placeholder="نام، ایمیل یا اسلاگ دوره..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full max-w-[12rem] space-y-1.5">
|
||||
<label htmlFor="reg-status" className="text-sm font-medium">
|
||||
وضعیت
|
||||
</label>
|
||||
<Select value={status} onValueChange={(v) => setStatus(v ?? "all")}>
|
||||
<SelectTrigger id="reg-status" className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">همه</SelectItem>
|
||||
<SelectItem value="new">جدید</SelectItem>
|
||||
<SelectItem value="contacted">تماس گرفته شد</SelectItem>
|
||||
<SelectItem value="enrolled">ثبتنام شد</SelectItem>
|
||||
<SelectItem value="rejected">رد شد</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button type="submit">اعمال فیلتر</Button>
|
||||
{hasFilters && (
|
||||
<Button type="button" variant="ghost" onClick={clear}>
|
||||
پاککردن فیلترها
|
||||
</Button>
|
||||
)}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import type { AdminRegistration } from "@/lib/data/admin/registrations";
|
||||
import { LEAD_STATUS_LABELS } from "@/components/organisms/admin/LeadsList";
|
||||
|
||||
function statusVariant(status: string): "default" | "secondary" | "outline" | "destructive" {
|
||||
switch (status) {
|
||||
case "new":
|
||||
return "default";
|
||||
case "contacted":
|
||||
return "secondary";
|
||||
case "enrolled":
|
||||
return "outline";
|
||||
case "rejected":
|
||||
return "destructive";
|
||||
default:
|
||||
return "secondary";
|
||||
}
|
||||
}
|
||||
|
||||
function faDate(value: string): string {
|
||||
return new Date(value).toLocaleDateString("fa-IR");
|
||||
}
|
||||
|
||||
export function RegistrationsTable({ rows }: { rows: AdminRegistration[] }) {
|
||||
const router = useRouter();
|
||||
const [busyId, setBusyId] = useState<string | null>(null);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function changeStatus(id: string, status: string) {
|
||||
setBusyId(id);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(`/api/admin/registrations/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ status }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در تغییر وضعیت");
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
} finally {
|
||||
setBusyId(null);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteLead(id: string) {
|
||||
setBusyId(id);
|
||||
setError("");
|
||||
try {
|
||||
const res = await fetch(`/api/admin/registrations/${id}`, { method: "DELETE" });
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setError(data.error || "خطا در حذف لید");
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
} finally {
|
||||
setBusyId(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (rows.length === 0) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center px-6 py-14 text-center">
|
||||
<p className="text-sm font-medium text-foreground">درخواستی یافت نشد</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
فیلتر را تغییر دهید یا منتظر درخواست جدید بمانید.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-0">
|
||||
{error ? (
|
||||
<p className="border-b border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="overflow-x-auto">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>نام</TableHead>
|
||||
<TableHead>ایمیل</TableHead>
|
||||
<TableHead>تلفن</TableHead>
|
||||
<TableHead>دوره</TableHead>
|
||||
<TableHead>وضعیت</TableHead>
|
||||
<TableHead>تغییر وضعیت</TableHead>
|
||||
<TableHead>تاریخ</TableHead>
|
||||
<TableHead>عملیات</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{rows.map((lead) => (
|
||||
<TableRow key={lead.id}>
|
||||
<TableCell className="font-medium">{lead.full_name}</TableCell>
|
||||
<TableCell className="text-muted-foreground">{lead.email}</TableCell>
|
||||
<TableCell className="text-muted-foreground">{lead.phone ?? "—"}</TableCell>
|
||||
<TableCell className="text-muted-foreground">
|
||||
{lead.course_slug ?? "—"}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant={statusVariant(lead.status)}>
|
||||
{LEAD_STATUS_LABELS[lead.status] ?? lead.status}
|
||||
</Badge>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Select value={lead.status} onValueChange={(v) => v && changeStatus(lead.id, v)}>
|
||||
<SelectTrigger className="w-40" disabled={busyId === lead.id}>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="new">جدید</SelectItem>
|
||||
<SelectItem value="contacted">تماس گرفته شد</SelectItem>
|
||||
<SelectItem value="enrolled">ثبتنام شد</SelectItem>
|
||||
<SelectItem value="rejected">رد شد</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell className="text-muted-foreground">{faDate(lead.created_at)}</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={busyId === lead.id}
|
||||
onClick={() => deleteLead(lead.id)}
|
||||
>
|
||||
حذف
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
import Image from "next/image";
|
||||
import { Clock, Layers, Tag, Wallet } from "lucide-react";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { TextLink } from "@/components/atoms/TextLink";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { CourseRegisterGate } from "@/components/organisms/CourseRegisterGate";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import type { Course } from "@/lib/types";
|
||||
import {
|
||||
categoryLabel,
|
||||
formatCoursePrice,
|
||||
formatLabel,
|
||||
} from "@/lib/labels";
|
||||
import { JsonLd, courseJsonLd } from "@/lib/seo/json-ld";
|
||||
|
||||
export type CourseDetailLabels = {
|
||||
submit: string;
|
||||
success: string;
|
||||
cta: string;
|
||||
formTitle: string;
|
||||
formDescription: string;
|
||||
hint: string;
|
||||
cancel: string;
|
||||
backToCatalog: string;
|
||||
detailsTitle: string;
|
||||
aboutTitle: string;
|
||||
duration: string;
|
||||
format: string;
|
||||
category: string;
|
||||
price: string;
|
||||
priceUnset: string;
|
||||
};
|
||||
|
||||
export function CourseDetailTemplate({
|
||||
course,
|
||||
labels,
|
||||
}: {
|
||||
course: Course;
|
||||
labels: CourseDetailLabels;
|
||||
}) {
|
||||
const priceLabel = formatCoursePrice(course.price);
|
||||
const specs = [
|
||||
{
|
||||
icon: Tag,
|
||||
label: labels.category,
|
||||
value: categoryLabel(course.category),
|
||||
},
|
||||
{
|
||||
icon: Layers,
|
||||
label: labels.format,
|
||||
value: formatLabel(course.format),
|
||||
},
|
||||
{
|
||||
icon: Clock,
|
||||
label: labels.duration,
|
||||
value: `${course.durationHours} ساعت`,
|
||||
},
|
||||
{
|
||||
icon: Wallet,
|
||||
label: labels.price,
|
||||
value: priceLabel ?? labels.priceUnset,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<JsonLd data={courseJsonLd(course)} />
|
||||
<PageHero
|
||||
title={course.title}
|
||||
intro={course.summary}
|
||||
eyebrow={categoryLabel(course.category)}
|
||||
imageUrl={course.imageUrl}
|
||||
/>
|
||||
|
||||
<Section className="bg-gradient-to-b from-background to-muted/40">
|
||||
<Container className="grid gap-10 lg:grid-cols-[minmax(0,1.4fr)_minmax(18rem,0.85fr)] lg:items-start lg:gap-12">
|
||||
<div className="space-y-8">
|
||||
<div className="overflow-hidden rounded-2xl ring-1 ring-border">
|
||||
<div className="relative aspect-[16/9] bg-muted">
|
||||
<Image
|
||||
src={course.imageUrl}
|
||||
alt={course.title}
|
||||
fill
|
||||
className="object-cover"
|
||||
sizes="(max-width:1024px) 100vw, 60vw"
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="space-y-4">
|
||||
<h2 className="text-xl font-bold tracking-tight">
|
||||
{labels.aboutTitle}
|
||||
</h2>
|
||||
<p className="text-base leading-8 text-foreground/90">
|
||||
{course.summary}
|
||||
</p>
|
||||
{course.seoDescription &&
|
||||
course.seoDescription !== course.summary ? (
|
||||
<p className="text-base leading-8 text-muted-foreground">
|
||||
{course.seoDescription}
|
||||
</p>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
<section className="space-y-4">
|
||||
<h2 className="text-xl font-bold tracking-tight">
|
||||
{labels.detailsTitle}
|
||||
</h2>
|
||||
<dl className="grid overflow-hidden rounded-2xl bg-card ring-1 ring-border sm:grid-cols-2 sm:divide-x sm:divide-x-reverse sm:divide-border">
|
||||
{specs.map((item) => (
|
||||
<div
|
||||
key={item.label}
|
||||
className="flex gap-3 border-b border-border p-5 last:border-b-0 sm:[&:nth-last-child(-n+2)]:border-b-0"
|
||||
>
|
||||
<div className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
||||
<item.icon className="size-4" />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<dt className="text-xs font-medium text-muted-foreground">
|
||||
{item.label}
|
||||
</dt>
|
||||
<dd className="mt-1 text-sm font-semibold text-foreground">
|
||||
{item.value}
|
||||
</dd>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<aside className="space-y-6 lg:sticky lg:top-28">
|
||||
<div className="rounded-2xl bg-card p-6 shadow-sm ring-1 ring-border">
|
||||
<p className="text-sm font-semibold text-foreground">{course.title}</p>
|
||||
<Separator className="my-4" />
|
||||
<ul className="space-y-3 text-sm text-muted-foreground">
|
||||
<li className="flex justify-between gap-3">
|
||||
<span>{labels.duration}</span>
|
||||
<span className="font-medium text-foreground">
|
||||
{course.durationHours} ساعت
|
||||
</span>
|
||||
</li>
|
||||
<li className="flex justify-between gap-3">
|
||||
<span>{labels.format}</span>
|
||||
<span className="font-medium text-foreground text-end">
|
||||
{formatLabel(course.format)}
|
||||
</span>
|
||||
</li>
|
||||
{priceLabel ? (
|
||||
<li className="flex justify-between gap-3">
|
||||
<span>{labels.price}</span>
|
||||
<span className="font-bold text-primary">{priceLabel}</span>
|
||||
</li>
|
||||
) : null}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<CourseRegisterGate
|
||||
courseSlug={course.slug}
|
||||
submitLabel={labels.submit}
|
||||
successLabel={labels.success}
|
||||
ctaLabel={labels.cta}
|
||||
formTitle={labels.formTitle}
|
||||
formDescription={labels.formDescription}
|
||||
hint={labels.hint}
|
||||
cancelLabel={labels.cancel}
|
||||
/>
|
||||
|
||||
<TextLink href="/professional" className="block text-sm">
|
||||
{labels.backToCatalog}
|
||||
</TextLink>
|
||||
</aside>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { ArrowLeft, Building2, Compass, Network } from "lucide-react";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { DotCta } from "@/components/atoms/DotCta";
|
||||
import { Heading } from "@/components/atoms/Heading";
|
||||
import { MetamorphField } from "@/components/atoms/MetamorphField";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { HeroFeatured } from "@/components/molecules/HeroFeatured";
|
||||
import {
|
||||
ArticleCard,
|
||||
EventCard,
|
||||
IntersectionCard,
|
||||
} from "@/components/molecules/Cards";
|
||||
import { ProgramCarousel } from "@/components/organisms/ProgramCarousel";
|
||||
import type { Article, EventItem, IntersectionTopic, Program, SiteStat } from "@/lib/types";
|
||||
import { siteMission } from "@/lib/site-config";
|
||||
import { AnimatedMetric } from "@/components/atoms/AnimatedMetric";
|
||||
|
||||
export type HomeLabels = {
|
||||
executiveLabel: string;
|
||||
exploreOurPrograms: string;
|
||||
ideasTitle: string;
|
||||
eventsTitle: string;
|
||||
seeAllEvents: string;
|
||||
intersectionsTitle: string;
|
||||
intersectionsSubtitle: string;
|
||||
moreThanDegree: string;
|
||||
moreThanDegreeBody: string;
|
||||
keepExploring: string;
|
||||
hireTitle: string;
|
||||
hireBody: string;
|
||||
registerCta: string;
|
||||
missionTitle: string;
|
||||
findUsTitle: string;
|
||||
ideasEyebrow: string;
|
||||
linksTitle: string;
|
||||
};
|
||||
|
||||
export function HomeHero({
|
||||
featured,
|
||||
eyebrow,
|
||||
}: {
|
||||
featured: Article;
|
||||
eyebrow: string;
|
||||
}) {
|
||||
return (
|
||||
<HeroFeatured
|
||||
title={featured.title}
|
||||
href={featured.href}
|
||||
imageUrl={featured.imageUrl}
|
||||
eyebrow={eyebrow}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function HomeIdeas({
|
||||
articles,
|
||||
title,
|
||||
}: {
|
||||
articles: Article[];
|
||||
title: string;
|
||||
}) {
|
||||
const ideaCards = articles.filter((a) => !a.featured).slice(0, 3);
|
||||
return (
|
||||
<>
|
||||
<Section className="relative py-20 sm:py-28">
|
||||
<Container>
|
||||
<div className="grid gap-10 lg:grid-cols-[.8fr_1.2fr] lg:items-start lg:gap-20">
|
||||
<div className="lg:sticky lg:top-28">
|
||||
<Badge variant="outline" className="border-primary/20 bg-primary/5 text-primary">چرا امیرکبیر؟</Badge>
|
||||
<Heading level={2} className="mt-5 text-3xl leading-tight sm:text-4xl">
|
||||
آموزش برای جهانِ در حال تغییر
|
||||
</Heading>
|
||||
<p className="mt-5 text-base leading-8 text-muted-foreground sm:text-lg">
|
||||
اینجا آموزش، انتقال محتوا نیست؛ فضایی است برای دیدن مسئله از زاویهای تازه، ساختن راهحل و اجرای آن در دنیای واقعی.
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-3 lg:grid-cols-1">
|
||||
{[
|
||||
{ icon: Compass, title: "تفکر راهبردی", text: "دیدن مسئله از زاویههای تازه و تبدیل پیچیدگی به تصمیمهای بهتر." },
|
||||
{ icon: Building2, title: "اثر سازمانی", text: "یادگیری مبتنی بر مسئلههای واقعی کسبوکار و صنعت ایران." },
|
||||
{ icon: Network, title: "شبکهی حرفهای", text: "پیوند با مدیران، متخصصان و پژوهشگران برای رشد ماندگار." },
|
||||
].map((item, index) => (
|
||||
<Card key={item.title} className="border-border/70 py-0 shadow-none transition-colors hover:border-primary/25">
|
||||
<CardContent className="flex h-full flex-col gap-5 p-6 lg:flex-row lg:items-center lg:gap-6 lg:p-7">
|
||||
<div className="flex size-12 shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary"><item.icon className="size-6" /></div>
|
||||
<div><p className="text-xs font-bold text-primary">۰{index + 1}</p><h3 className="mt-1 text-lg font-bold">{item.title}</h3><p className="mt-2 text-sm leading-7 text-muted-foreground">{item.text}</p></div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
<Section className="overflow-hidden py-0">
|
||||
<Container className="grid max-w-none px-0 lg:grid-cols-2">
|
||||
<div className="relative min-h-80 lg:min-h-[32rem]">
|
||||
<Image src="/brand/campus-collaboration-v1.png" alt="همکاری مدرسان و متخصصان در محیط دانشگاه" fill className="object-cover" sizes="(max-width:1024px) 100vw, 50vw" />
|
||||
</div>
|
||||
<div className="relative flex items-center overflow-hidden bg-chart-3 px-6 py-14 text-background sm:px-12 lg:px-16">
|
||||
<MetamorphField tone="dark" density="sparse" className="opacity-20" />
|
||||
<div className="relative z-[2] max-w-xl">
|
||||
<p className="text-xs font-bold text-background/55">یادگیری در بستر مسئلههای واقعی</p>
|
||||
<Heading level={2} className="mt-3 text-3xl leading-tight text-background sm:text-4xl">جایی برای پیوند دانش دانشگاهی و تجربهی صنعت</Heading>
|
||||
<p className="mt-5 text-base leading-8 text-background/65">دورهها با مشارکت مدرسان دانشگاه، مدیران و متخصصان طراحی میشوند تا آموختهها از کلاس به تصمیم و اجرا برسند.</p>
|
||||
<Link
|
||||
href="/about"
|
||||
className={cn(
|
||||
buttonVariants({ variant: "outline" }),
|
||||
"mt-7 border-background/25 bg-transparent text-background hover:bg-background hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
آشنایی با رویکرد ما
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
<Section tone="muted" className="py-20 sm:py-24">
|
||||
<Container>
|
||||
<div className="mb-10 flex items-end justify-between gap-4">
|
||||
<div>
|
||||
<p className="text-xs font-bold text-primary">دانش برای عمل</p>
|
||||
<Heading level={2} className="mt-2 text-3xl sm:text-4xl">
|
||||
<Link href="/insights" className="hover:text-primary">
|
||||
{title}
|
||||
</Link>
|
||||
</Heading>
|
||||
</div>
|
||||
<Link
|
||||
href="/insights"
|
||||
className={cn(
|
||||
buttonVariants({ variant: "ghost" }),
|
||||
"hidden gap-2 text-primary sm:inline-flex",
|
||||
)}
|
||||
>
|
||||
همه بینشها <ArrowLeft className="size-4" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="grid gap-8 sm:grid-cols-2 lg:grid-cols-3 sm:gap-10">
|
||||
{ideaCards.map((article) => (
|
||||
<ArticleCard
|
||||
key={article.id}
|
||||
title={article.title}
|
||||
category={article.category}
|
||||
excerpt={article.excerpt}
|
||||
imageUrl={article.imageUrl}
|
||||
href={article.href}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function HomeEvents({
|
||||
events,
|
||||
title,
|
||||
seeAllLabel,
|
||||
}: {
|
||||
events: EventItem[];
|
||||
title: string;
|
||||
seeAllLabel: string;
|
||||
}) {
|
||||
return (
|
||||
<Section className="py-20 sm:py-24">
|
||||
<Container>
|
||||
<p className="text-center text-xs font-bold text-primary">در جریان یادگیری</p>
|
||||
<Heading level={2} className="mt-2 text-center text-3xl sm:text-4xl">
|
||||
{title}
|
||||
</Heading>
|
||||
<Separator className="mx-auto mt-5 max-w-16 bg-primary" />
|
||||
<div className="mt-10 grid gap-0 border-y border-border sm:grid-cols-2 lg:grid-cols-4">
|
||||
{events.map((event) => (
|
||||
<EventCard key={event.id} {...event} variant="home" />
|
||||
))}
|
||||
</div>
|
||||
<div className="mt-10 flex justify-center">
|
||||
<DotCta href="/events">{seeAllLabel}</DotCta>
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
|
||||
export function HomeRest({
|
||||
labels,
|
||||
carouselPrograms,
|
||||
intersections,
|
||||
stats,
|
||||
}: {
|
||||
labels: HomeLabels;
|
||||
carouselPrograms: Program[];
|
||||
intersections: IntersectionTopic[];
|
||||
stats: SiteStat[];
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Section tone="muted" className="py-20 sm:py-24">
|
||||
<Container>
|
||||
<div className="mb-10 max-w-3xl">
|
||||
<p className="text-xs font-bold text-primary">مرزهای تازهی کسبوکار</p>
|
||||
<Heading level={2} className="mt-2 text-3xl sm:text-4xl">{labels.intersectionsTitle}</Heading>
|
||||
<p className="mt-3 text-lg font-semibold leading-relaxed text-primary sm:text-xl">
|
||||
{labels.intersectionsSubtitle}
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{intersections.map((topic) => (
|
||||
<IntersectionCard key={topic.id} {...topic} />
|
||||
))}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
<Section className="relative overflow-hidden py-20 sm:py-24">
|
||||
<MetamorphField tone="light" density="sparse" />
|
||||
<Container className="relative z-[1]">
|
||||
<div className="mx-auto mb-10 max-w-2xl text-center">
|
||||
<Heading level={2}>{labels.moreThanDegree}</Heading>
|
||||
<p className="mt-4 text-base leading-relaxed text-muted-foreground sm:text-lg">
|
||||
{labels.moreThanDegreeBody}
|
||||
</p>
|
||||
</div>
|
||||
<ProgramCarousel
|
||||
title=""
|
||||
programs={carouselPrograms}
|
||||
keepExploringLabel={labels.keepExploring}
|
||||
hideTitle
|
||||
/>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
<Section tone="dark" className="relative overflow-hidden py-20 sm:py-28">
|
||||
<MetamorphField
|
||||
tone="dark"
|
||||
density="sparse"
|
||||
className="opacity-[0.4]"
|
||||
/>
|
||||
<Container className="relative z-[1] grid gap-12 lg:grid-cols-[1fr_auto] lg:items-end">
|
||||
<div className="max-w-3xl"><p className="text-xs font-bold text-background/60">همکاری با سازمانها</p><Heading level={2} className="mt-3 text-background sm:text-5xl">
|
||||
{labels.hireTitle}
|
||||
</Heading>
|
||||
<p className="mt-5 max-w-2xl text-base leading-relaxed text-background/75 sm:text-lg">
|
||||
{labels.hireBody}
|
||||
</p>
|
||||
</div><div>
|
||||
<DotCta href="/professional" onDark>
|
||||
{labels.registerCta}
|
||||
</DotCta>
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
<Section className="py-20 sm:py-24">
|
||||
<Container className="max-w-4xl text-center">
|
||||
<Heading
|
||||
level={2}
|
||||
className="text-sm font-bold uppercase tracking-wider text-muted-foreground"
|
||||
>
|
||||
{labels.missionTitle}
|
||||
</Heading>
|
||||
<p className="mt-5 text-2xl font-bold leading-relaxed text-foreground sm:text-3xl">
|
||||
{siteMission}
|
||||
</p>
|
||||
<div className="mt-12 grid gap-6 border-t border-border pt-10 sm:grid-cols-3">
|
||||
{stats.map((stat) => <div key={stat.id}><p className="text-3xl font-black text-primary sm:text-4xl"><AnimatedMetric value={stat.value} /></p><p className="mt-2 text-sm text-muted-foreground">{stat.label}</p></div>)}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
import Image from "next/image";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { DotCta } from "@/components/atoms/DotCta";
|
||||
import { Heading } from "@/components/atoms/Heading";
|
||||
import { MetamorphField } from "@/components/atoms/MetamorphField";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { QuoteBlock } from "@/components/molecules/Cards";
|
||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||
import { CategoryCourseExplorer } from "@/components/organisms/CategoryCourseExplorer";
|
||||
import type { Course, SiteStat, Testimonial } from "@/lib/types";
|
||||
import { AnimatedMetric } from "@/components/atoms/AnimatedMetric";
|
||||
|
||||
export function ProfessionalLandingTemplate({
|
||||
labels,
|
||||
courses,
|
||||
stats,
|
||||
testimonials,
|
||||
}: {
|
||||
labels: {
|
||||
pathways: string;
|
||||
exploreCourses: string;
|
||||
heroTitle: string;
|
||||
heroBody: string;
|
||||
findProgram: string;
|
||||
offeredBy: string;
|
||||
dppTitle: string;
|
||||
dppBody: string;
|
||||
statsTitle: string;
|
||||
rankTitle: string;
|
||||
testimonialsTitle: string;
|
||||
};
|
||||
courses: Course[];
|
||||
stats: SiteStat[];
|
||||
testimonials: Testimonial[];
|
||||
}) {
|
||||
return (
|
||||
<main id="main-content">
|
||||
<header className="relative isolate min-h-[42rem] overflow-hidden bg-chart-3 text-background">
|
||||
<div className="absolute inset-0">
|
||||
<Image
|
||||
src="https://images.unsplash.com/photo-1497366216548-37526070297c?w=1600&q=80"
|
||||
alt="نمایی از پردیس دانشگاه"
|
||||
fill
|
||||
priority
|
||||
className="object-cover opacity-35"
|
||||
sizes="100vw"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="absolute inset-0 bg-gradient-to-l from-chart-3 via-chart-3/85 to-chart-3/60"
|
||||
aria-hidden
|
||||
/>
|
||||
<MetamorphField
|
||||
tone="dark"
|
||||
className="inset-y-0 end-0 start-auto w-[min(72vw,36rem)] opacity-[0.5]"
|
||||
/>
|
||||
<div className="relative z-[2] flex min-h-[inherit] items-center py-12">
|
||||
<Container>
|
||||
<div className="max-w-3xl text-start">
|
||||
<div>
|
||||
<p className="text-sm font-semibold text-background/75">
|
||||
{labels.offeredBy}
|
||||
</p>
|
||||
<Heading
|
||||
as="h1"
|
||||
level={1}
|
||||
className="mt-4 text-4xl leading-tight text-background sm:text-6xl"
|
||||
>
|
||||
{labels.heroTitle}
|
||||
</Heading>
|
||||
<p className="mt-5 max-w-xl border-s border-accent ps-5 text-base leading-8 text-background/70">
|
||||
{labels.heroBody}
|
||||
</p>
|
||||
<div className="mt-6">
|
||||
<DotCta href="#programs" onDark>
|
||||
{labels.exploreCourses}
|
||||
</DotCta>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Section
|
||||
id="programs"
|
||||
tone="dark"
|
||||
className="relative scroll-mt-24 overflow-hidden py-20 sm:py-24"
|
||||
>
|
||||
<MetamorphField
|
||||
tone="dark"
|
||||
density="sparse"
|
||||
className="opacity-[0.28]"
|
||||
/>
|
||||
<Container className="relative z-[1]">
|
||||
<div id="courses" className="scroll-mt-24" />
|
||||
<div id="certificates" className="scroll-mt-24" />
|
||||
<div id="corporate" className="scroll-mt-24" />
|
||||
<p className="mb-6 text-lg font-semibold text-background/80">
|
||||
{labels.pathways}
|
||||
</p>
|
||||
<CategoryCourseExplorer
|
||||
courses={courses}
|
||||
findLabel={labels.findProgram}
|
||||
/>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
<Section id="digital" tone="accent" className="scroll-mt-24 py-16 sm:py-20">
|
||||
<Container>
|
||||
<Heading level={2} className="text-primary-foreground">
|
||||
{labels.dppTitle}
|
||||
</Heading>
|
||||
<p className="mt-3 max-w-3xl text-primary-foreground/80">
|
||||
{labels.dppBody}
|
||||
</p>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
<Section tone="muted" className="py-20 sm:py-24">
|
||||
<Container>
|
||||
<Heading level={2} className="mb-8 text-center">
|
||||
{labels.statsTitle}
|
||||
</Heading>
|
||||
<div className="grid gap-6 sm:grid-cols-3 sm:gap-8">
|
||||
{stats.map((stat) => (
|
||||
<div key={stat.id} className="text-center">
|
||||
<p className="text-4xl font-extrabold text-primary"><AnimatedMetric value={stat.value} /></p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">{stat.label}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
<Section className="py-20 sm:py-24">
|
||||
<Container className="text-center">
|
||||
<Heading level={2}>{labels.rankTitle}</Heading>
|
||||
<div className="mt-6 grid gap-4 sm:grid-cols-2">
|
||||
<SurfaceCard padded="md" className="text-start">
|
||||
<p className="text-3xl font-extrabold text-primary">#۱</p>
|
||||
<p className="mt-2 font-bold">از برترین دانشگاههای فنی کشور</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
دانشگاه صنعتی امیرکبیر
|
||||
</p>
|
||||
</SurfaceCard>
|
||||
<SurfaceCard padded="md" className="text-start">
|
||||
<p className="text-3xl font-extrabold text-primary">۶۰+</p>
|
||||
<p className="mt-2 font-bold">سال تجربه آموزش عالی</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
میراث علمی و صنعتی
|
||||
</p>
|
||||
</SurfaceCard>
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
<Section tone="dark" className="relative overflow-hidden py-20 sm:py-24">
|
||||
<MetamorphField tone="dark" density="sparse" className="opacity-25" />
|
||||
<Container className="relative z-[1]">
|
||||
<Heading level={2} className="mb-6 text-background">
|
||||
{labels.testimonialsTitle}
|
||||
</Heading>
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
{testimonials.map((item) => (
|
||||
<QuoteBlock key={item.id} {...item} />
|
||||
))}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion"
|
||||
import { cn } from "cn"
|
||||
import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"
|
||||
|
||||
function Accordion({ className, ...props }: AccordionPrimitive.Root.Props) {
|
||||
return (
|
||||
<AccordionPrimitive.Root
|
||||
data-slot="accordion"
|
||||
className={cn("flex w-full flex-col", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) {
|
||||
return (
|
||||
<AccordionPrimitive.Item
|
||||
data-slot="accordion-item"
|
||||
className={cn("not-last:border-b", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AccordionTrigger({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: AccordionPrimitive.Trigger.Props) {
|
||||
return (
|
||||
<AccordionPrimitive.Header className="flex">
|
||||
<AccordionPrimitive.Trigger
|
||||
data-slot="accordion-trigger"
|
||||
className={cn(
|
||||
"group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-start text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ms-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronDownIcon data-slot="accordion-trigger-icon" className="pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden" />
|
||||
<ChevronUpIcon data-slot="accordion-trigger-icon" className="pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
</AccordionPrimitive.Header>
|
||||
)
|
||||
}
|
||||
|
||||
function AccordionContent({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: AccordionPrimitive.Panel.Props) {
|
||||
return (
|
||||
<AccordionPrimitive.Panel
|
||||
data-slot="accordion-content"
|
||||
className="overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up"
|
||||
{...props}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</AccordionPrimitive.Panel>
|
||||
)
|
||||
}
|
||||
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
|
||||
@@ -0,0 +1,108 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Avatar({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: AvatarPrimitive.Root.Props & {
|
||||
size?: "default" | "sm" | "lg"
|
||||
}) {
|
||||
return (
|
||||
<AvatarPrimitive.Root
|
||||
data-slot="avatar"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {
|
||||
return (
|
||||
<AvatarPrimitive.Image
|
||||
data-slot="avatar-image"
|
||||
className={cn(
|
||||
"aspect-square size-full rounded-full object-cover",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarFallback({
|
||||
className,
|
||||
...props
|
||||
}: AvatarPrimitive.Fallback.Props) {
|
||||
return (
|
||||
<AvatarPrimitive.Fallback
|
||||
data-slot="avatar-fallback"
|
||||
className={cn(
|
||||
"flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="avatar-badge"
|
||||
className={cn(
|
||||
"absolute end-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
|
||||
"group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
|
||||
"group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
|
||||
"group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="avatar-group"
|
||||
className={cn(
|
||||
"group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AvatarGroupCount({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="avatar-group-count"
|
||||
className={cn(
|
||||
"relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
AvatarGroup,
|
||||
AvatarGroupCount,
|
||||
AvatarBadge,
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { mergeProps } from "@base-ui/react/merge-props"
|
||||
import { useRender } from "@base-ui/react/use-render"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "cn"
|
||||
|
||||
const badgeVariants = cva(
|
||||
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
||||
destructive:
|
||||
"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
||||
outline:
|
||||
"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
||||
ghost:
|
||||
"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
variant = "default",
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
|
||||
return useRender({
|
||||
defaultTagName: "span",
|
||||
props: mergeProps<"span">(
|
||||
{
|
||||
className: cn(badgeVariants({ variant }), className),
|
||||
},
|
||||
props,
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "badge",
|
||||
variant,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
@@ -0,0 +1,124 @@
|
||||
import * as React from "react"
|
||||
import { mergeProps } from "@base-ui/react/merge-props"
|
||||
import { useRender } from "@base-ui/react/use-render"
|
||||
import { cn } from "cn"
|
||||
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
|
||||
|
||||
function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
|
||||
return (
|
||||
<nav
|
||||
aria-label="breadcrumb"
|
||||
data-slot="breadcrumb"
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
|
||||
return (
|
||||
<ol
|
||||
data-slot="breadcrumb-list"
|
||||
className={cn(
|
||||
"flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="breadcrumb-item"
|
||||
className={cn("inline-flex items-center gap-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbLink({
|
||||
className,
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"a">) {
|
||||
return useRender({
|
||||
defaultTagName: "a",
|
||||
props: mergeProps<"a">(
|
||||
{
|
||||
className: cn("transition-colors hover:text-foreground", className),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "breadcrumb-link",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="breadcrumb-page"
|
||||
role="link"
|
||||
aria-disabled="true"
|
||||
aria-current="page"
|
||||
className={cn("font-normal text-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbSeparator({
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="breadcrumb-separator"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn("[&>svg]:size-3.5", className)}
|
||||
{...props}
|
||||
>
|
||||
{children ?? (
|
||||
<ChevronRightIcon className="rtl:rotate-180" />
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
function BreadcrumbEllipsis({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="breadcrumb-ellipsis"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"flex size-5 items-center justify-center [&>svg]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontalIcon
|
||||
/>
|
||||
<span className="sr-only">More</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Breadcrumb,
|
||||
BreadcrumbList,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbLink,
|
||||
BreadcrumbPage,
|
||||
BreadcrumbSeparator,
|
||||
BreadcrumbEllipsis,
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Button as ButtonPrimitive } from "@base-ui/react/button"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "cn"
|
||||
|
||||
const buttonVariants = cva(
|
||||
"group/button relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-xl border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-[background-color,color,border-color,box-shadow,transform] duration-300 outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
||||
outline:
|
||||
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
||||
ghost:
|
||||
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
||||
destructive:
|
||||
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default:
|
||||
"h-10 gap-2 px-4 has-data-[icon=inline-end]:pe-3 has-data-[icon=inline-start]:ps-3",
|
||||
xs: "h-6 gap-1 rounded-[min(var(--radius),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",
|
||||
sm: "h-9 gap-1.5 rounded-lg px-3 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-2.5 has-data-[icon=inline-start]:ps-2.5 [&_svg:not([class*='size-'])]:size-3.5",
|
||||
lg: "h-12 gap-2 px-6 has-data-[icon=inline-end]:pe-5 has-data-[icon=inline-start]:ps-5",
|
||||
icon: "size-10",
|
||||
"icon-xs":
|
||||
"size-6 rounded-[min(var(--radius),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
||||
"icon-sm":
|
||||
"size-7 rounded-[min(var(--radius),12px)] in-data-[slot=button-group]:rounded-lg",
|
||||
"icon-lg": "size-9",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Button({
|
||||
className,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
render,
|
||||
nativeButton,
|
||||
...props
|
||||
}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
|
||||
// Links/anchors must not use Button — prefer `buttonVariants` on <Link>.
|
||||
// If `render` is still passed, force nativeButton=false (last wins over ...props).
|
||||
const isNative = nativeButton ?? render == null
|
||||
|
||||
return (
|
||||
<ButtonPrimitive
|
||||
data-slot="button"
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
render={render}
|
||||
nativeButton={isNative}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Button, buttonVariants }
|
||||
@@ -0,0 +1,102 @@
|
||||
import * as React from "react"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Card({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-2xl bg-card py-(--card-spacing) text-sm text-card-foreground shadow-sm ring-1 ring-foreground/10 transition-[box-shadow,ring-color] duration-300 [--card-spacing:--spacing(4)] hover:shadow-lg hover:ring-primary/20 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-2xl *:[img:last-child]:rounded-b-2xl",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-header"
|
||||
className={cn(
|
||||
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-title"
|
||||
className={cn(
|
||||
"font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-action"
|
||||
className={cn(
|
||||
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-content"
|
||||
className={cn("px-(--card-spacing)", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-footer"
|
||||
className={cn(
|
||||
"flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardFooter,
|
||||
CardTitle,
|
||||
CardAction,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
|
||||
import { cn } from "cn"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { XIcon } from "lucide-react"
|
||||
|
||||
function Dialog({ ...props }: DialogPrimitive.Root.Props) {
|
||||
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
||||
}
|
||||
|
||||
function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {
|
||||
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
||||
}
|
||||
|
||||
function DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {
|
||||
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
||||
}
|
||||
|
||||
function DialogClose({ ...props }: DialogPrimitive.Close.Props) {
|
||||
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
||||
}
|
||||
|
||||
function DialogOverlay({
|
||||
className,
|
||||
...props
|
||||
}: DialogPrimitive.Backdrop.Props) {
|
||||
return (
|
||||
<DialogPrimitive.Backdrop
|
||||
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
|
||||
}: DialogPrimitive.Popup.Props & {
|
||||
showCloseButton?: boolean
|
||||
}) {
|
||||
return (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Popup
|
||||
data-slot="dialog-content"
|
||||
className={cn(
|
||||
"fixed top-1/2 start-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 rtl: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"
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="absolute top-2 end-2"
|
||||
size="icon-sm"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<XIcon
|
||||
/>
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
)}
|
||||
</DialogPrimitive.Popup>
|
||||
</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 render={<Button variant="outline" />}>
|
||||
Close
|
||||
</DialogPrimitive.Close>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
|
||||
return (
|
||||
<DialogPrimitive.Title
|
||||
data-slot="dialog-title"
|
||||
className={cn(
|
||||
"font-heading text-base leading-none font-medium",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DialogDescription({
|
||||
className,
|
||||
...props
|
||||
}: DialogPrimitive.Description.Props) {
|
||||
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,267 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Menu as MenuPrimitive } from "@base-ui/react/menu"
|
||||
import { cn } from "cn"
|
||||
import { ChevronRightIcon, CheckIcon } from "lucide-react"
|
||||
|
||||
function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
|
||||
return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {
|
||||
return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {
|
||||
return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuContent({
|
||||
align = "start",
|
||||
alignOffset = 0,
|
||||
side = "bottom",
|
||||
sideOffset = 4,
|
||||
className,
|
||||
...props
|
||||
}: MenuPrimitive.Popup.Props &
|
||||
Pick<
|
||||
MenuPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset"
|
||||
>) {
|
||||
return (
|
||||
<MenuPrimitive.Portal>
|
||||
<MenuPrimitive.Positioner
|
||||
className="isolate z-50 outline-none"
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
>
|
||||
<MenuPrimitive.Popup
|
||||
data-slot="dropdown-menu-content"
|
||||
className={cn("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-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-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
||||
{...props}
|
||||
/>
|
||||
</MenuPrimitive.Positioner>
|
||||
</MenuPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {
|
||||
return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuLabel({
|
||||
className,
|
||||
inset,
|
||||
...props
|
||||
}: MenuPrimitive.GroupLabel.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.GroupLabel
|
||||
data-slot="dropdown-menu-label"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:ps-7",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuItem({
|
||||
className,
|
||||
inset,
|
||||
variant = "default",
|
||||
...props
|
||||
}: MenuPrimitive.Item.Props & {
|
||||
inset?: boolean
|
||||
variant?: "default" | "destructive"
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.Item
|
||||
data-slot="dropdown-menu-item"
|
||||
data-inset={inset}
|
||||
data-variant={variant}
|
||||
className={cn(
|
||||
"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:ps-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {
|
||||
return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />
|
||||
}
|
||||
|
||||
function DropdownMenuSubTrigger({
|
||||
className,
|
||||
inset,
|
||||
children,
|
||||
...props
|
||||
}: MenuPrimitive.SubmenuTrigger.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.SubmenuTrigger
|
||||
data-slot="dropdown-menu-sub-trigger"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:ps-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRightIcon className="rtl:rotate-180 ms-auto" />
|
||||
</MenuPrimitive.SubmenuTrigger>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuSubContent({
|
||||
align = "start",
|
||||
alignOffset = -3,
|
||||
side = "inline-end",
|
||||
sideOffset = 0,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DropdownMenuContent>) {
|
||||
return (
|
||||
<DropdownMenuContent
|
||||
data-slot="dropdown-menu-sub-content"
|
||||
className={cn("w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 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-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 )}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuCheckboxItem({
|
||||
className,
|
||||
children,
|
||||
checked,
|
||||
inset,
|
||||
...props
|
||||
}: MenuPrimitive.CheckboxItem.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.CheckboxItem
|
||||
data-slot="dropdown-menu-checkbox-item"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pe-8 ps-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:ps-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span
|
||||
className="pointer-events-none absolute end-2 flex items-center justify-center"
|
||||
data-slot="dropdown-menu-checkbox-item-indicator"
|
||||
>
|
||||
<MenuPrimitive.CheckboxItemIndicator>
|
||||
<CheckIcon
|
||||
/>
|
||||
</MenuPrimitive.CheckboxItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</MenuPrimitive.CheckboxItem>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {
|
||||
return (
|
||||
<MenuPrimitive.RadioGroup
|
||||
data-slot="dropdown-menu-radio-group"
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuRadioItem({
|
||||
className,
|
||||
children,
|
||||
inset,
|
||||
...props
|
||||
}: MenuPrimitive.RadioItem.Props & {
|
||||
inset?: boolean
|
||||
}) {
|
||||
return (
|
||||
<MenuPrimitive.RadioItem
|
||||
data-slot="dropdown-menu-radio-item"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pe-8 ps-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:ps-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span
|
||||
className="pointer-events-none absolute end-2 flex items-center justify-center"
|
||||
data-slot="dropdown-menu-radio-item-indicator"
|
||||
>
|
||||
<MenuPrimitive.RadioItemIndicator>
|
||||
<CheckIcon
|
||||
/>
|
||||
</MenuPrimitive.RadioItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</MenuPrimitive.RadioItem>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuSeparator({
|
||||
className,
|
||||
...props
|
||||
}: MenuPrimitive.Separator.Props) {
|
||||
return (
|
||||
<MenuPrimitive.Separator
|
||||
data-slot="dropdown-menu-separator"
|
||||
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DropdownMenuShortcut({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"span">) {
|
||||
return (
|
||||
<span
|
||||
data-slot="dropdown-menu-shortcut"
|
||||
className={cn(
|
||||
"ms-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
DropdownMenu,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuRadioGroup,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuShortcut,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuSubContent,
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as React from "react"
|
||||
import { Input as InputPrimitive } from "@base-ui/react/input"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||
return (
|
||||
<InputPrimitive
|
||||
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,19 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Label({ className, ...props }: React.ComponentProps<"label">) {
|
||||
return (
|
||||
<label
|
||||
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,167 @@
|
||||
import { NavigationMenu as NavigationMenuPrimitive } from "@base-ui/react/navigation-menu"
|
||||
import { cva } from "class-variance-authority"
|
||||
import { cn } from "cn"
|
||||
import { ChevronDownIcon } from "lucide-react"
|
||||
|
||||
function NavigationMenu({
|
||||
align = "start",
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: NavigationMenuPrimitive.Root.Props &
|
||||
Pick<NavigationMenuPrimitive.Positioner.Props, "align">) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.Root
|
||||
data-slot="navigation-menu"
|
||||
className={cn(
|
||||
"group/navigation-menu relative flex max-w-max flex-1 items-center justify-center",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<NavigationMenuPositioner align={align} />
|
||||
</NavigationMenuPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
function NavigationMenuList({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithRef<typeof NavigationMenuPrimitive.List>) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.List
|
||||
data-slot="navigation-menu-list"
|
||||
className={cn(
|
||||
"group flex flex-1 list-none items-center justify-center gap-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function NavigationMenuItem({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithRef<typeof NavigationMenuPrimitive.Item>) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.Item
|
||||
data-slot="navigation-menu-item"
|
||||
className={cn("relative", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const navigationMenuTriggerStyle = cva(
|
||||
"group/navigation-menu-trigger inline-flex h-9 w-max items-center justify-center rounded-lg px-2.5 py-1.5 text-sm font-medium transition-all outline-none hover:bg-muted focus:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted data-open:bg-muted/50 data-open:hover:bg-muted data-open:focus:bg-muted"
|
||||
)
|
||||
|
||||
function NavigationMenuTrigger({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: NavigationMenuPrimitive.Trigger.Props) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.Trigger
|
||||
data-slot="navigation-menu-trigger"
|
||||
className={cn(navigationMenuTriggerStyle(), "group", className)}
|
||||
{...props}
|
||||
>
|
||||
{children}{" "}
|
||||
<ChevronDownIcon className="relative top-px ml-1 size-3 transition duration-300 group-data-popup-open/navigation-menu-trigger:rotate-180 group-data-open/navigation-menu-trigger:rotate-180" aria-hidden="true" />
|
||||
</NavigationMenuPrimitive.Trigger>
|
||||
)
|
||||
}
|
||||
|
||||
function NavigationMenuContent({
|
||||
className,
|
||||
...props
|
||||
}: NavigationMenuPrimitive.Content.Props) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.Content
|
||||
data-slot="navigation-menu-content"
|
||||
className={cn(
|
||||
"data-ending-style:data-activation-direction=left:translate-x-[50%] data-ending-style:data-activation-direction=right:translate-x-[-50%] data-starting-style:data-activation-direction=left:translate-x-[-50%] data-starting-style:data-activation-direction=right:translate-x-[50%] h-full w-auto p-1 transition-[opacity,transform,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] group-data-[viewport=false]/navigation-menu:rounded-lg group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:ring-1 group-data-[viewport=false]/navigation-menu:ring-foreground/10 group-data-[viewport=false]/navigation-menu:duration-300 data-ending-style:opacity-0 data-starting-style:opacity-0 data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 data-[motion^=from-]:animate-in data-[motion^=from-]:fade-in data-[motion^=to-]:animate-out data-[motion^=to-]:fade-out **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none group-data-[viewport=false]/navigation-menu:data-open:animate-in group-data-[viewport=false]/navigation-menu:data-open:fade-in-0 group-data-[viewport=false]/navigation-menu:data-open:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-closed:animate-out group-data-[viewport=false]/navigation-menu:data-closed:fade-out-0 group-data-[viewport=false]/navigation-menu:data-closed:zoom-out-95",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function NavigationMenuPositioner({
|
||||
className,
|
||||
side = "bottom",
|
||||
sideOffset = 8,
|
||||
align = "start",
|
||||
alignOffset = 0,
|
||||
...props
|
||||
}: NavigationMenuPrimitive.Positioner.Props) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.Portal>
|
||||
<NavigationMenuPrimitive.Positioner
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
className={cn(
|
||||
"isolate z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] data-instant:transition-none data-[side=bottom]:before:top-[-10px] data-[side=bottom]:before:right-0 data-[side=bottom]:before:left-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<NavigationMenuPrimitive.Popup className="data-[ending-style]:easing-[ease] xs:w-(--popup-width) relative h-(--popup-height) w-(--popup-width) origin-(--transform-origin) rounded-lg bg-popover text-popover-foreground shadow ring-1 ring-foreground/10 transition-[opacity,transform,width,height,scale,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] outline-none data-ending-style:scale-90 data-ending-style:opacity-0 data-ending-style:duration-150 data-starting-style:scale-90 data-starting-style:opacity-0">
|
||||
<NavigationMenuPrimitive.Viewport className="relative size-full overflow-hidden" />
|
||||
</NavigationMenuPrimitive.Popup>
|
||||
</NavigationMenuPrimitive.Positioner>
|
||||
</NavigationMenuPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function NavigationMenuLink({
|
||||
className,
|
||||
...props
|
||||
}: NavigationMenuPrimitive.Link.Props) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.Link
|
||||
data-slot="navigation-menu-link"
|
||||
className={cn(
|
||||
"flex items-center gap-2 rounded-lg p-2 text-sm transition-all outline-none hover:bg-muted focus:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 in-data-[slot=navigation-menu-content]:rounded-md data-active:bg-muted/50 data-active:hover:bg-muted data-active:focus:bg-muted [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function NavigationMenuIndicator({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithRef<typeof NavigationMenuPrimitive.Icon>) {
|
||||
return (
|
||||
<NavigationMenuPrimitive.Icon
|
||||
data-slot="navigation-menu-indicator"
|
||||
className={cn(
|
||||
"top-full z-1 flex h-1.5 items-end justify-center overflow-hidden data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:animate-in data-[state=visible]:fade-in",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
||||
</NavigationMenuPrimitive.Icon>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
NavigationMenu,
|
||||
NavigationMenuContent,
|
||||
NavigationMenuIndicator,
|
||||
NavigationMenuItem,
|
||||
NavigationMenuLink,
|
||||
NavigationMenuList,
|
||||
NavigationMenuTrigger,
|
||||
navigationMenuTriggerStyle,
|
||||
NavigationMenuPositioner,
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
|
||||
import { cn } from "cn"
|
||||
|
||||
function ScrollArea({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: ScrollAreaPrimitive.Root.Props) {
|
||||
return (
|
||||
<ScrollAreaPrimitive.Root
|
||||
data-slot="scroll-area"
|
||||
className={cn("relative", className)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Viewport
|
||||
data-slot="scroll-area-viewport"
|
||||
className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1"
|
||||
>
|
||||
{children}
|
||||
</ScrollAreaPrimitive.Viewport>
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
function ScrollBar({
|
||||
className,
|
||||
orientation = "vertical",
|
||||
...props
|
||||
}: ScrollAreaPrimitive.Scrollbar.Props) {
|
||||
return (
|
||||
<ScrollAreaPrimitive.Scrollbar
|
||||
data-slot="scroll-area-scrollbar"
|
||||
data-orientation={orientation}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-s data-vertical:border-s-transparent",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Thumb
|
||||
data-slot="scroll-area-thumb"
|
||||
className="relative flex-1 rounded-full bg-border"
|
||||
/>
|
||||
</ScrollAreaPrimitive.Scrollbar>
|
||||
)
|
||||
}
|
||||
|
||||
export { ScrollArea, ScrollBar }
|
||||
@@ -0,0 +1,200 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Select as SelectPrimitive } from "@base-ui/react/select"
|
||||
import { cn } from "cn"
|
||||
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
|
||||
|
||||
const Select = SelectPrimitive.Root
|
||||
|
||||
function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Group
|
||||
data-slot="select-group"
|
||||
className={cn("scroll-my-1 p-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Value
|
||||
data-slot="select-value"
|
||||
className={cn("flex flex-1 text-start", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectTrigger({
|
||||
className,
|
||||
size = "default",
|
||||
children,
|
||||
...props
|
||||
}: SelectPrimitive.Trigger.Props & {
|
||||
size?: "sm" | "default"
|
||||
}) {
|
||||
return (
|
||||
<SelectPrimitive.Trigger
|
||||
data-slot="select-trigger"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pe-2 ps-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SelectPrimitive.Icon
|
||||
render={
|
||||
<ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
|
||||
}
|
||||
/>
|
||||
</SelectPrimitive.Trigger>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectContent({
|
||||
className,
|
||||
children,
|
||||
side = "bottom",
|
||||
sideOffset = 4,
|
||||
align = "center",
|
||||
alignOffset = 0,
|
||||
alignItemWithTrigger = true,
|
||||
...props
|
||||
}: SelectPrimitive.Popup.Props &
|
||||
Pick<
|
||||
SelectPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
|
||||
>) {
|
||||
return (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Positioner
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
alignItemWithTrigger={alignItemWithTrigger}
|
||||
className="isolate z-50"
|
||||
>
|
||||
<SelectPrimitive.Popup
|
||||
data-slot="select-content"
|
||||
data-align-trigger={alignItemWithTrigger}
|
||||
className={cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-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-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}
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.List>{children}</SelectPrimitive.List>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Popup>
|
||||
</SelectPrimitive.Positioner>
|
||||
</SelectPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectLabel({
|
||||
className,
|
||||
...props
|
||||
}: SelectPrimitive.GroupLabel.Props) {
|
||||
return (
|
||||
<SelectPrimitive.GroupLabel
|
||||
data-slot="select-label"
|
||||
className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectItem({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: SelectPrimitive.Item.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Item
|
||||
data-slot="select-item"
|
||||
className={cn(
|
||||
"relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pe-8 ps-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
|
||||
{children}
|
||||
</SelectPrimitive.ItemText>
|
||||
<SelectPrimitive.ItemIndicator
|
||||
render={
|
||||
<span className="pointer-events-none absolute end-2 flex size-4 items-center justify-center" />
|
||||
}
|
||||
>
|
||||
<CheckIcon className="pointer-events-none" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</SelectPrimitive.Item>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectSeparator({
|
||||
className,
|
||||
...props
|
||||
}: SelectPrimitive.Separator.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Separator
|
||||
data-slot="select-separator"
|
||||
className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectScrollUpButton({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollUpArrow
|
||||
data-slot="select-scroll-up-button"
|
||||
className={cn(
|
||||
"top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronUpIcon
|
||||
/>
|
||||
</SelectPrimitive.ScrollUpArrow>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectScrollDownButton({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollDownArrow
|
||||
data-slot="select-scroll-down-button"
|
||||
className={cn(
|
||||
"bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronDownIcon
|
||||
/>
|
||||
</SelectPrimitive.ScrollDownArrow>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectLabel,
|
||||
SelectScrollDownButton,
|
||||
SelectScrollUpButton,
|
||||
SelectSeparator,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
"use client"
|
||||
|
||||
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Separator({
|
||||
className,
|
||||
orientation = "horizontal",
|
||||
...props
|
||||
}: SeparatorPrimitive.Props) {
|
||||
return (
|
||||
<SeparatorPrimitive
|
||||
data-slot="separator"
|
||||
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,138 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog"
|
||||
import { cn } from "cn"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { XIcon } from "lucide-react"
|
||||
|
||||
function Sheet({ ...props }: SheetPrimitive.Root.Props) {
|
||||
return <SheetPrimitive.Root data-slot="sheet" {...props} />
|
||||
}
|
||||
|
||||
function SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {
|
||||
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
||||
}
|
||||
|
||||
function SheetClose({ ...props }: SheetPrimitive.Close.Props) {
|
||||
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
|
||||
}
|
||||
|
||||
function SheetPortal({ ...props }: SheetPrimitive.Portal.Props) {
|
||||
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
|
||||
}
|
||||
|
||||
function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {
|
||||
return (
|
||||
<SheetPrimitive.Backdrop
|
||||
data-slot="sheet-overlay"
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetContent({
|
||||
className,
|
||||
children,
|
||||
side = "right",
|
||||
showCloseButton = true,
|
||||
...props
|
||||
}: SheetPrimitive.Popup.Props & {
|
||||
side?: "top" | "right" | "bottom" | "left"
|
||||
showCloseButton?: boolean
|
||||
}) {
|
||||
return (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
<SheetPrimitive.Popup
|
||||
data-slot="sheet-content"
|
||||
data-side={side}
|
||||
className={cn(
|
||||
"fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:translate-x-[-2.5rem] rtl:data-[side=left]:data-ending-style:-translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] rtl:data-[side=left]:data-starting-style:-translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-[2.5rem] rtl:data-[side=right]:data-ending-style:-translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] rtl:data-[side=right]:data-starting-style:-translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{showCloseButton && (
|
||||
<SheetPrimitive.Close
|
||||
data-slot="sheet-close"
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="absolute top-3 end-3"
|
||||
size="icon-sm"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<XIcon
|
||||
/>
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
)}
|
||||
</SheetPrimitive.Popup>
|
||||
</SheetPortal>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-header"
|
||||
className={cn("flex flex-col gap-0.5 p-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-footer"
|
||||
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {
|
||||
return (
|
||||
<SheetPrimitive.Title
|
||||
data-slot="sheet-title"
|
||||
className={cn(
|
||||
"font-heading text-base font-medium text-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetDescription({
|
||||
className,
|
||||
...props
|
||||
}: SheetPrimitive.Description.Props) {
|
||||
return (
|
||||
<SheetPrimitive.Description
|
||||
data-slot="sheet-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Sheet,
|
||||
SheetTrigger,
|
||||
SheetClose,
|
||||
SheetContent,
|
||||
SheetHeader,
|
||||
SheetFooter,
|
||||
SheetTitle,
|
||||
SheetDescription,
|
||||
}
|
||||
@@ -0,0 +1,723 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { mergeProps } from "@base-ui/react/merge-props"
|
||||
import { useRender } from "@base-ui/react/use-render"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "cn"
|
||||
|
||||
import { useIsMobile } from "@/hooks/use-mobile"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import {
|
||||
Sheet,
|
||||
SheetContent,
|
||||
SheetDescription,
|
||||
SheetHeader,
|
||||
SheetTitle,
|
||||
} from "@/components/ui/sheet"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip"
|
||||
import { PanelLeftIcon } from "lucide-react"
|
||||
|
||||
const SIDEBAR_COOKIE_NAME = "sidebar_state"
|
||||
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
|
||||
const SIDEBAR_WIDTH = "16rem"
|
||||
const SIDEBAR_WIDTH_MOBILE = "18rem"
|
||||
const SIDEBAR_WIDTH_ICON = "3rem"
|
||||
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
|
||||
|
||||
type SidebarContextProps = {
|
||||
state: "expanded" | "collapsed"
|
||||
open: boolean
|
||||
setOpen: (open: boolean) => void
|
||||
openMobile: boolean
|
||||
setOpenMobile: (open: boolean) => void
|
||||
isMobile: boolean
|
||||
toggleSidebar: () => void
|
||||
}
|
||||
|
||||
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
|
||||
|
||||
function useSidebar() {
|
||||
const context = React.useContext(SidebarContext)
|
||||
if (!context) {
|
||||
throw new Error("useSidebar must be used within a SidebarProvider.")
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
function SidebarProvider({
|
||||
defaultOpen = true,
|
||||
open: openProp,
|
||||
onOpenChange: setOpenProp,
|
||||
className,
|
||||
style,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
defaultOpen?: boolean
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
}) {
|
||||
const isMobile = useIsMobile()
|
||||
const [openMobile, setOpenMobile] = React.useState(false)
|
||||
|
||||
// This is the internal state of the sidebar.
|
||||
// We use openProp and setOpenProp for control from outside the component.
|
||||
const [_open, _setOpen] = React.useState(defaultOpen)
|
||||
const open = openProp ?? _open
|
||||
const setOpen = React.useCallback(
|
||||
(value: boolean | ((value: boolean) => boolean)) => {
|
||||
const openState = typeof value === "function" ? value(open) : value
|
||||
if (setOpenProp) {
|
||||
setOpenProp(openState)
|
||||
} else {
|
||||
_setOpen(openState)
|
||||
}
|
||||
|
||||
// This sets the cookie to keep the sidebar state.
|
||||
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
|
||||
},
|
||||
[setOpenProp, open]
|
||||
)
|
||||
|
||||
// Helper to toggle the sidebar.
|
||||
const toggleSidebar = React.useCallback(() => {
|
||||
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
|
||||
}, [isMobile, setOpen, setOpenMobile])
|
||||
|
||||
// Adds a keyboard shortcut to toggle the sidebar.
|
||||
React.useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
||||
(event.metaKey || event.ctrlKey)
|
||||
) {
|
||||
event.preventDefault()
|
||||
toggleSidebar()
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown)
|
||||
return () => window.removeEventListener("keydown", handleKeyDown)
|
||||
}, [toggleSidebar])
|
||||
|
||||
// We add a state so that we can do data-state="expanded" or "collapsed".
|
||||
// This makes it easier to style the sidebar with Tailwind classes.
|
||||
const state = open ? "expanded" : "collapsed"
|
||||
|
||||
const contextValue = React.useMemo<SidebarContextProps>(
|
||||
() => ({
|
||||
state,
|
||||
open,
|
||||
setOpen,
|
||||
isMobile,
|
||||
openMobile,
|
||||
setOpenMobile,
|
||||
toggleSidebar,
|
||||
}),
|
||||
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
||||
)
|
||||
|
||||
return (
|
||||
<SidebarContext.Provider value={contextValue}>
|
||||
<div
|
||||
data-slot="sidebar-wrapper"
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": SIDEBAR_WIDTH,
|
||||
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
||||
...style,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
className={cn(
|
||||
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</SidebarContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
function Sidebar({
|
||||
side = "left",
|
||||
variant = "sidebar",
|
||||
collapsible = "offcanvas",
|
||||
className,
|
||||
children,
|
||||
dir,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
side?: "left" | "right"
|
||||
variant?: "sidebar" | "floating" | "inset"
|
||||
collapsible?: "offcanvas" | "icon" | "none"
|
||||
}) {
|
||||
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
||||
|
||||
if (collapsible === "none") {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar"
|
||||
className={cn(
|
||||
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
||||
<SheetContent
|
||||
dir={dir}
|
||||
data-sidebar="sidebar"
|
||||
data-slot="sidebar"
|
||||
data-mobile="true"
|
||||
className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
side={side}
|
||||
>
|
||||
<SheetHeader className="sr-only">
|
||||
<SheetTitle>Sidebar</SheetTitle>
|
||||
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
||||
</SheetHeader>
|
||||
<div className="flex h-full w-full flex-col">{children}</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="group peer hidden text-sidebar-foreground md:block"
|
||||
data-state={state}
|
||||
data-collapsible={state === "collapsed" ? collapsible : ""}
|
||||
data-variant={variant}
|
||||
data-side={side}
|
||||
data-slot="sidebar"
|
||||
>
|
||||
{/* This is what handles the sidebar gap on desktop */}
|
||||
<div
|
||||
data-slot="sidebar-gap"
|
||||
className={cn(
|
||||
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
||||
"group-data-[collapsible=offcanvas]:w-0",
|
||||
"group-data-[side=right]:rotate-180",
|
||||
variant === "floating" || variant === "inset"
|
||||
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
||||
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
data-slot="sidebar-container"
|
||||
data-side={side}
|
||||
className={cn(
|
||||
"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
|
||||
// Adjust the padding for floating and inset variants.
|
||||
variant === "floating" || variant === "inset"
|
||||
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
||||
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-e group-data-[side=right]:border-s",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div
|
||||
data-sidebar="sidebar"
|
||||
data-slot="sidebar-inner"
|
||||
className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarTrigger({
|
||||
className,
|
||||
onClick,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const { toggleSidebar } = useSidebar()
|
||||
|
||||
return (
|
||||
<Button
|
||||
data-sidebar="trigger"
|
||||
data-slot="sidebar-trigger"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
className={cn(className)}
|
||||
onClick={(event) => {
|
||||
onClick?.(event)
|
||||
toggleSidebar()
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
<PanelLeftIcon className="rtl:rotate-180" />
|
||||
<span className="sr-only">Toggle Sidebar</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
|
||||
const { toggleSidebar } = useSidebar()
|
||||
|
||||
return (
|
||||
<button
|
||||
data-sidebar="rail"
|
||||
data-slot="sidebar-rail"
|
||||
aria-label="Toggle Sidebar"
|
||||
tabIndex={-1}
|
||||
onClick={toggleSidebar}
|
||||
title="Toggle Sidebar"
|
||||
className={cn(
|
||||
"absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
|
||||
"in-data-[side=left]:cursor-w-resize rtl:in-data-[side=left]:cursor-e-resize in-data-[side=right]:cursor-e-resize rtl:in-data-[side=right]:cursor-w-resize",
|
||||
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize rtl:[[data-side=left][data-state=collapsed]_&]:cursor-w-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize rtl:[[data-side=right][data-state=collapsed]_&]:cursor-e-resize",
|
||||
"group-data-[collapsible=offcanvas]:translate-x-0 rtl:group-data-[collapsible=offcanvas]:-translate-x-0 group-data-[collapsible=offcanvas]:after:start-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
|
||||
"[[data-side=left][data-collapsible=offcanvas]_&]:-end-2",
|
||||
"[[data-side=right][data-collapsible=offcanvas]_&]:-start-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
||||
return (
|
||||
<main
|
||||
data-slot="sidebar-inset"
|
||||
className={cn(
|
||||
"relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarInput({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Input>) {
|
||||
return (
|
||||
<Input
|
||||
data-slot="sidebar-input"
|
||||
data-sidebar="input"
|
||||
className={cn("h-8 w-full bg-background shadow-none", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-header"
|
||||
data-sidebar="header"
|
||||
className={cn("flex flex-col gap-2 p-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-footer"
|
||||
data-sidebar="footer"
|
||||
className={cn("flex flex-col gap-2 p-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarSeparator({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Separator>) {
|
||||
return (
|
||||
<Separator
|
||||
data-slot="sidebar-separator"
|
||||
data-sidebar="separator"
|
||||
className={cn("mx-2 w-auto bg-sidebar-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-content"
|
||||
data-sidebar="content"
|
||||
className={cn(
|
||||
"no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-group"
|
||||
data-sidebar="group"
|
||||
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarGroupLabel({
|
||||
className,
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"div"> & React.ComponentProps<"div">) {
|
||||
return useRender({
|
||||
defaultTagName: "div",
|
||||
props: mergeProps<"div">(
|
||||
{
|
||||
className: cn(
|
||||
"flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-group-label",
|
||||
sidebar: "group-label",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function SidebarGroupAction({
|
||||
className,
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"button"> & React.ComponentProps<"button">) {
|
||||
return useRender({
|
||||
defaultTagName: "button",
|
||||
props: mergeProps<"button">(
|
||||
{
|
||||
className: cn(
|
||||
"absolute top-3.5 end-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-group-action",
|
||||
sidebar: "group-action",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function SidebarGroupContent({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-group-content"
|
||||
data-sidebar="group-content"
|
||||
className={cn("w-full text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
|
||||
return (
|
||||
<ul
|
||||
data-slot="sidebar-menu"
|
||||
data-sidebar="menu"
|
||||
className={cn("flex w-full min-w-0 flex-col gap-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="sidebar-menu-item"
|
||||
data-sidebar="menu-item"
|
||||
className={cn("group/menu-item relative", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const sidebarMenuButtonVariants = cva(
|
||||
"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-start text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pe-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
outline:
|
||||
"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
|
||||
},
|
||||
size: {
|
||||
default: "h-8 text-sm",
|
||||
sm: "h-7 text-xs",
|
||||
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function SidebarMenuButton({
|
||||
render,
|
||||
isActive = false,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
tooltip,
|
||||
className,
|
||||
...props
|
||||
}: useRender.ComponentProps<"button"> &
|
||||
React.ComponentProps<"button"> & {
|
||||
isActive?: boolean
|
||||
tooltip?: string | React.ComponentProps<typeof TooltipContent>
|
||||
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
||||
const { isMobile, state } = useSidebar()
|
||||
const comp = useRender({
|
||||
defaultTagName: "button",
|
||||
props: mergeProps<"button">(
|
||||
{
|
||||
className: cn(sidebarMenuButtonVariants({ variant, size }), className),
|
||||
},
|
||||
props
|
||||
),
|
||||
render: !tooltip ? render : <TooltipTrigger render={render} />,
|
||||
state: {
|
||||
slot: "sidebar-menu-button",
|
||||
sidebar: "menu-button",
|
||||
size,
|
||||
active: isActive,
|
||||
},
|
||||
})
|
||||
|
||||
if (!tooltip) {
|
||||
return comp
|
||||
}
|
||||
|
||||
if (typeof tooltip === "string") {
|
||||
tooltip = {
|
||||
children: tooltip,
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
{comp}
|
||||
<TooltipContent
|
||||
side="right"
|
||||
align="center"
|
||||
hidden={state !== "collapsed" || isMobile}
|
||||
{...tooltip}
|
||||
/>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuAction({
|
||||
className,
|
||||
render,
|
||||
showOnHover = false,
|
||||
...props
|
||||
}: useRender.ComponentProps<"button"> &
|
||||
React.ComponentProps<"button"> & {
|
||||
showOnHover?: boolean
|
||||
}) {
|
||||
return useRender({
|
||||
defaultTagName: "button",
|
||||
props: mergeProps<"button">(
|
||||
{
|
||||
className: cn(
|
||||
"absolute top-1.5 end-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
showOnHover &&
|
||||
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-menu-action",
|
||||
sidebar: "menu-action",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function SidebarMenuBadge({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-menu-badge"
|
||||
data-sidebar="menu-badge"
|
||||
className={cn(
|
||||
"pointer-events-none absolute end-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSkeleton({
|
||||
className,
|
||||
showIcon = false,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
showIcon?: boolean
|
||||
}) {
|
||||
// Random width between 50 to 90%.
|
||||
const [width] = React.useState(() => {
|
||||
return `${Math.floor(Math.random() * 40) + 50}%`
|
||||
})
|
||||
|
||||
return (
|
||||
<div
|
||||
data-slot="sidebar-menu-skeleton"
|
||||
data-sidebar="menu-skeleton"
|
||||
className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
|
||||
{...props}
|
||||
>
|
||||
{showIcon && (
|
||||
<Skeleton
|
||||
className="size-4 rounded-md"
|
||||
data-sidebar="menu-skeleton-icon"
|
||||
/>
|
||||
)}
|
||||
<Skeleton
|
||||
className="h-4 max-w-(--skeleton-width) flex-1"
|
||||
data-sidebar="menu-skeleton-text"
|
||||
style={
|
||||
{
|
||||
"--skeleton-width": width,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
|
||||
return (
|
||||
<ul
|
||||
data-slot="sidebar-menu-sub"
|
||||
data-sidebar="menu-sub"
|
||||
className={cn(
|
||||
"mx-3.5 flex min-w-0 translate-x-px rtl:-translate-x-px flex-col gap-1 border-s border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSubItem({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"li">) {
|
||||
return (
|
||||
<li
|
||||
data-slot="sidebar-menu-sub-item"
|
||||
data-sidebar="menu-sub-item"
|
||||
className={cn("group/menu-sub-item relative", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarMenuSubButton({
|
||||
render,
|
||||
size = "md",
|
||||
isActive = false,
|
||||
className,
|
||||
...props
|
||||
}: useRender.ComponentProps<"a"> &
|
||||
React.ComponentProps<"a"> & {
|
||||
size?: "sm" | "md"
|
||||
isActive?: boolean
|
||||
}) {
|
||||
return useRender({
|
||||
defaultTagName: "a",
|
||||
props: mergeProps<"a">(
|
||||
{
|
||||
className: cn(
|
||||
"flex h-7 min-w-0 -translate-x-px rtl:translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
|
||||
className
|
||||
),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "sidebar-menu-sub-button",
|
||||
sidebar: "menu-sub-button",
|
||||
size,
|
||||
active: isActive,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarGroupAction,
|
||||
SidebarGroupContent,
|
||||
SidebarGroupLabel,
|
||||
SidebarHeader,
|
||||
SidebarInput,
|
||||
SidebarInset,
|
||||
SidebarMenu,
|
||||
SidebarMenuAction,
|
||||
SidebarMenuBadge,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
SidebarMenuSkeleton,
|
||||
SidebarMenuSub,
|
||||
SidebarMenuSubButton,
|
||||
SidebarMenuSubItem,
|
||||
SidebarProvider,
|
||||
SidebarRail,
|
||||
SidebarSeparator,
|
||||
SidebarTrigger,
|
||||
useSidebar,
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { cn } from "cn"
|
||||
|
||||
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="skeleton"
|
||||
className={cn("animate-pulse rounded-md bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Skeleton }
|
||||
@@ -0,0 +1,115 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="table-container"
|
||||
className="relative w-full overflow-x-auto"
|
||||
>
|
||||
<table
|
||||
data-slot="table"
|
||||
className={cn("w-full caption-bottom text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
||||
return (
|
||||
<thead
|
||||
data-slot="table-header"
|
||||
className={cn("[&_tr]:border-b", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
||||
return (
|
||||
<tbody
|
||||
data-slot="table-body"
|
||||
className={cn("[&_tr:last-child]:border-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
||||
return (
|
||||
<tfoot
|
||||
data-slot="table-footer"
|
||||
className={cn(
|
||||
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
||||
return (
|
||||
<tr
|
||||
data-slot="table-row"
|
||||
className={cn(
|
||||
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
||||
return (
|
||||
<th
|
||||
data-slot="table-head"
|
||||
className={cn(
|
||||
"h-10 px-2 text-start align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pe-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
||||
return (
|
||||
<td
|
||||
data-slot="table-cell"
|
||||
className={cn(
|
||||
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pe-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TableCaption({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"caption">) {
|
||||
return (
|
||||
<caption
|
||||
data-slot="table-caption"
|
||||
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Table,
|
||||
TableHeader,
|
||||
TableBody,
|
||||
TableFooter,
|
||||
TableHead,
|
||||
TableRow,
|
||||
TableCell,
|
||||
TableCaption,
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
"use client"
|
||||
|
||||
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Tabs({
|
||||
className,
|
||||
orientation = "horizontal",
|
||||
...props
|
||||
}: TabsPrimitive.Root.Props) {
|
||||
return (
|
||||
<TabsPrimitive.Root
|
||||
data-slot="tabs"
|
||||
data-orientation={orientation}
|
||||
className={cn(
|
||||
"group/tabs flex gap-2 data-horizontal:flex-col",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const tabsListVariants = cva(
|
||||
"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-muted",
|
||||
line: "gap-1 bg-transparent",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
function TabsList({
|
||||
className,
|
||||
variant = "default",
|
||||
...props
|
||||
}: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {
|
||||
return (
|
||||
<TabsPrimitive.List
|
||||
data-slot="tabs-list"
|
||||
data-variant={variant}
|
||||
className={cn(tabsListVariants({ variant }), className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
|
||||
return (
|
||||
<TabsPrimitive.Tab
|
||||
data-slot="tabs-trigger"
|
||||
className={cn(
|
||||
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
|
||||
"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
|
||||
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
|
||||
return (
|
||||
<TabsPrimitive.Panel
|
||||
data-slot="tabs-content"
|
||||
className={cn("flex-1 text-sm outline-none", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as React from "react"
|
||||
import { cn } from "cn"
|
||||
|
||||
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
return (
|
||||
<textarea
|
||||
data-slot="textarea"
|
||||
className={cn(
|
||||
"flex field-sizing-content min-h-28 w-full rounded-xl border border-input bg-background px-3.5 py-3 text-base shadow-sm transition-[border-color,box-shadow,background-color] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/20 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,65 @@
|
||||
"use client"
|
||||
|
||||
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip"
|
||||
import { cn } from "cn"
|
||||
|
||||
function TooltipProvider({
|
||||
delay = 0,
|
||||
...props
|
||||
}: TooltipPrimitive.Provider.Props) {
|
||||
return (
|
||||
<TooltipPrimitive.Provider
|
||||
data-slot="tooltip-provider"
|
||||
delay={delay}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
|
||||
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
||||
}
|
||||
|
||||
function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {
|
||||
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
||||
}
|
||||
|
||||
function TooltipContent({
|
||||
className,
|
||||
side = "top",
|
||||
sideOffset = 4,
|
||||
align = "center",
|
||||
alignOffset = 0,
|
||||
children,
|
||||
...props
|
||||
}: TooltipPrimitive.Popup.Props &
|
||||
Pick<
|
||||
TooltipPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset"
|
||||
>) {
|
||||
return (
|
||||
<TooltipPrimitive.Portal>
|
||||
<TooltipPrimitive.Positioner
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
className="isolate z-50"
|
||||
>
|
||||
<TooltipPrimitive.Popup
|
||||
data-slot="tooltip-content"
|
||||
className={cn(
|
||||
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-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-sm 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=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-start-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-end-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" />
|
||||
</TooltipPrimitive.Popup>
|
||||
</TooltipPrimitive.Positioner>
|
||||
</TooltipPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
||||
Reference in new issue
Block a user