- typography: font-semibold/font-medium → font-bold throughout (card, dialog, empty-state, notification-bell, quiz-experience, questions-panel, profile-manage) - borders: border → border-2 for content containers (leaderboard error, notifications page, quiz pass screen, quiz option tiles, learning-panel error) - admin IA: remove Card-in-SectionPanel nesting from announce-panel, challenges-panel, physical-orders-panel; SectionPanel gains optional actions slot - announce-panel: flat composer + live preview; history as flat list; cancel-edit button - lockout: raw textarea → Textarea design-system component - global-search: delete component and all references (feature removed) - progress.tsx: dir="ltr" for correct RTL fill direction; remove rtl:me-auto
110 lines
4.1 KiB
TypeScript
110 lines
4.1 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
import { X } from "lucide-react";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
const Dialog = DialogPrimitive.Root;
|
|
const DialogTrigger = DialogPrimitive.Trigger;
|
|
const DialogPortal = DialogPrimitive.Portal;
|
|
const DialogClose = DialogPrimitive.Close;
|
|
|
|
const DialogOverlay = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
>(({ className, ...props }, ref) => (
|
|
<DialogPrimitive.Overlay
|
|
ref={ref}
|
|
className={cn(
|
|
"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-300",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
));
|
|
DialogOverlay.displayName = "DialogOverlay";
|
|
|
|
const DialogContent = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
>(({ className, children, ...props }, ref) => (
|
|
<DialogPortal>
|
|
<DialogOverlay />
|
|
<DialogPrimitive.Content
|
|
ref={ref}
|
|
className={cn(
|
|
// Base (mobile-first): full-width bottom sheet with safe-area clearance
|
|
"fixed bottom-0 left-0 right-0 z-50 grid w-full max-w-none gap-4 border border-border bg-popover shadow-md duration-300",
|
|
"rounded-t-2xl rounded-b-none p-5 pb-[max(1.25rem,env(safe-area-inset-bottom))]",
|
|
"max-h-[90svh] overflow-y-auto",
|
|
"translate-x-0 translate-y-0",
|
|
"data-[state=open]:animate-in data-[state=open]:slide-in-from-bottom-4",
|
|
"data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom-full",
|
|
// Desktop (sm+): centered modal
|
|
"sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:max-w-lg sm:max-h-[calc(100svh-4rem)] sm:rounded-md sm:p-6",
|
|
"sm:-translate-x-1/2 sm:-translate-y-1/2",
|
|
"sm:data-[state=open]:zoom-in-95 sm:data-[state=closed]:zoom-out-95",
|
|
"sm:data-[state=open]:fade-in-0 sm:data-[state=closed]:fade-out-0",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{/* Mobile drag handle affordance */}
|
|
<span className="mx-auto -mt-1 mb-2 block h-1.5 w-10 shrink-0 rounded-full bg-muted-foreground/20 sm:hidden" aria-hidden />
|
|
{children}
|
|
<DialogPrimitive.Close className="absolute end-4 top-4 grid h-8 w-8 place-items-center rounded-full opacity-70 transition-opacity hover:opacity-100 focus:outline-none sm:h-auto sm:w-auto sm:rounded-sm">
|
|
<X className="h-4 w-4" />
|
|
<span className="sr-only">بستن</span>
|
|
</DialogPrimitive.Close>
|
|
</DialogPrimitive.Content>
|
|
</DialogPortal>
|
|
));
|
|
DialogContent.displayName = "DialogContent";
|
|
|
|
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-start", className)} {...props} />
|
|
);
|
|
DialogHeader.displayName = "DialogHeader";
|
|
|
|
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
|
);
|
|
DialogFooter.displayName = "DialogFooter";
|
|
|
|
const DialogTitle = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
>(({ className, ...props }, ref) => (
|
|
<DialogPrimitive.Title
|
|
ref={ref}
|
|
className={cn("text-lg font-bold leading-none tracking-tight", className)}
|
|
{...props}
|
|
/>
|
|
));
|
|
DialogTitle.displayName = "DialogTitle";
|
|
|
|
const DialogDescription = React.forwardRef<
|
|
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
>(({ className, ...props }, ref) => (
|
|
<DialogPrimitive.Description
|
|
ref={ref}
|
|
className={cn("text-sm text-muted-foreground", className)}
|
|
{...props}
|
|
/>
|
|
));
|
|
DialogDescription.displayName = "DialogDescription";
|
|
|
|
export {
|
|
Dialog,
|
|
DialogPortal,
|
|
DialogOverlay,
|
|
DialogTrigger,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogHeader,
|
|
DialogFooter,
|
|
DialogTitle,
|
|
DialogDescription,
|
|
}; |