- Implemented a new SettingsPage component for user preferences including appearance, behavior, and account security settings. - Added a ThemeToggle component to switch between light, dark, and system modes. - Created reusable UI components: AlertDialog, Avatar, Badge, Button, Card, Dialog, Input, Label, Progress, ScrollArea, Separator, Sheet, Skeleton, Tooltip. - Introduced utility functions for class name merging and formatting bytes/uptime. - Added a custom hook for media query handling
98 lines
3.8 KiB
TypeScript
98 lines
3.8 KiB
TypeScript
import * as React from 'react';
|
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
import { cn } from '@/lib/utils';
|
|
import { buttonVariants } from '@/components/ui/button';
|
|
|
|
const AlertDialog = AlertDialogPrimitive.Root;
|
|
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
|
|
const AlertDialogOverlay = React.forwardRef<
|
|
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
>(({ className, ...props }, ref) => (
|
|
<AlertDialogPrimitive.Overlay
|
|
ref={ref}
|
|
className={cn(
|
|
'fixed inset-0 z-50 bg-black/50 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',
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
));
|
|
AlertDialogOverlay.displayName = 'AlertDialogOverlay';
|
|
|
|
const AlertDialogContent = React.forwardRef<
|
|
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
|
>(({ className, ...props }, ref) => (
|
|
<AlertDialogPortal>
|
|
<AlertDialogOverlay />
|
|
<AlertDialogPrimitive.Content
|
|
ref={ref}
|
|
className={cn(
|
|
'fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-card p-6 shadow-lg outline-none',
|
|
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
</AlertDialogPortal>
|
|
));
|
|
AlertDialogContent.displayName = 'AlertDialogContent';
|
|
|
|
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
<div className={cn('flex flex-col gap-1.5 text-left', className)} {...props} />
|
|
);
|
|
|
|
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
<div className={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)} {...props} />
|
|
);
|
|
|
|
const AlertDialogTitle = React.forwardRef<
|
|
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
|
>(({ className, ...props }, ref) => (
|
|
<AlertDialogPrimitive.Title ref={ref} className={cn('text-lg font-semibold', className)} {...props} />
|
|
));
|
|
AlertDialogTitle.displayName = 'AlertDialogTitle';
|
|
|
|
const AlertDialogDescription = React.forwardRef<
|
|
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
|
>(({ className, ...props }, ref) => (
|
|
<AlertDialogPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
|
|
));
|
|
AlertDialogDescription.displayName = 'AlertDialogDescription';
|
|
|
|
const AlertDialogAction = React.forwardRef<
|
|
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
|
>(({ className, ...props }, ref) => (
|
|
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
|
));
|
|
AlertDialogAction.displayName = 'AlertDialogAction';
|
|
|
|
const AlertDialogCancel = React.forwardRef<
|
|
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
|
>(({ className, ...props }, ref) => (
|
|
<AlertDialogPrimitive.Cancel ref={ref} className={cn(buttonVariants({ variant: 'outline' }), 'mt-0', className)} {...props} />
|
|
));
|
|
AlertDialogCancel.displayName = 'AlertDialogCancel';
|
|
|
|
export {
|
|
AlertDialog,
|
|
AlertDialogPortal,
|
|
AlertDialogOverlay,
|
|
AlertDialogTrigger,
|
|
AlertDialogContent,
|
|
AlertDialogHeader,
|
|
AlertDialogFooter,
|
|
AlertDialogTitle,
|
|
AlertDialogDescription,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
};
|