feat(admin): standardize UI components, modal viewports, URL syncing, and add live monitoring
Deploy Canina / deploy (push) Successful in 31s

This commit is contained in:
parsa aghaei committed 2026-08-23 08:40:37 +03:30
1 parent 828c90b4c6
commit 9d63f9a7a4
213 files changed
+247967 -244416

No files matched your search

@@ -1,22 +1,34 @@
import React from 'react';
export type BadgeVariant = 'success' | 'warning' | 'danger' | 'info' | 'purple' | 'gray';
export type BadgeVariant =
| 'success'
| 'warning'
| 'danger'
| 'info'
| 'purple'
| 'blue'
| 'gray'
| 'slate'
| 'rose';
export interface BadgeProps {
variant?: BadgeVariant;
children: React.ReactNode;
icon?: React.ReactNode;
className?: string;
size?: 'sm' | 'md';
size?: 'xs' | 'sm' | 'md';
}
const variantStyles: Record<BadgeVariant, string> = {
success: 'bg-emerald-50 text-emerald-700 border-emerald-200',
warning: 'bg-amber-50 text-amber-700 border-amber-200',
danger: 'bg-red-50 text-red-700 border-red-200',
rose: 'bg-rose-50 text-rose-700 border-rose-200',
info: 'bg-sky-50 text-sky-700 border-sky-200',
blue: 'bg-blue-50 text-blue-700 border-blue-200',
purple: 'bg-purple-50 text-purple-700 border-purple-200',
gray: 'bg-gray-50 text-gray-700 border-gray-200',
slate: 'bg-slate-100 text-slate-700 border-slate-200',
};
export default function Badge({
@@ -26,14 +38,20 @@ export default function Badge({
className = '',
size = 'md',
}: BadgeProps) {
const sizeStyle = size === 'sm' ? 'px-2 py-0.5 text-[10px]' : 'px-2.5 py-1 text-xs';
const sizeStyle =
size === 'xs'
? 'px-2 py-0.5 text-[10px]'
: size === 'sm'
? 'px-2.5 py-0.5 text-[11px]'
: 'px-3 py-1 text-xs';
return (
<span
className={`inline-flex items-center gap-1.5 font-bold font-vazir rounded-full border shadow-xs ${variantStyles[variant]} ${sizeStyle} ${className}`}
className={`inline-flex items-center gap-1.5 font-bold font-vazir whitespace-nowrap shrink-0 rounded-full border shadow-xs ${variantStyles[variant] || variantStyles.gray} ${sizeStyle} ${className}`}
>
{icon && <span className="shrink-0">{icon}</span>}
{children}
{icon && <span className="shrink-0 flex items-center">{icon}</span>}
<span className="whitespace-nowrap">{children}</span>
</span>
);
}
@@ -0,0 +1,111 @@
import React, { useEffect } from 'react';
import { X } from 'lucide-react';
export interface ModalProps {
isOpen: boolean;
onClose: () => void;
title: React.ReactNode;
icon?: React.ComponentType<{ className?: string }>;
children: React.ReactNode;
footer?: React.ReactNode;
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | 'full';
className?: string;
bodyClassName?: string;
}
const maxWidthClasses: Record<NonNullable<ModalProps['maxWidth']>, string> = {
sm: 'max-w-sm',
md: 'max-w-md',
lg: 'max-w-lg',
xl: 'max-w-xl',
'2xl': 'max-w-2xl',
'3xl': 'max-w-3xl',
'4xl': 'max-w-4xl',
'5xl': 'max-w-5xl',
full: 'max-w-[95vw]',
};
export default function Modal({
isOpen,
onClose,
title,
icon: Icon,
children,
footer,
maxWidth = '2xl',
className = '',
bodyClassName = '',
}: ModalProps) {
useEffect(() => {
if (isOpen) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
return () => {
document.body.style.overflow = '';
};
}, [isOpen]);
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape' && isOpen) {
onClose();
}
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [isOpen, onClose]);
if (!isOpen) return null;
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4 md:p-6 bg-black/60 backdrop-blur-xs font-vazir animate-in fade-in duration-200"
dir="rtl"
onClick={onClose}
>
<div
className={`bg-white rounded-3xl w-full ${maxWidthClasses[maxWidth]} max-h-[92dvh] sm:max-h-[88vh] flex flex-col border border-gray-100 shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200 ${className}`}
onClick={(e) => e.stopPropagation()}
>
{/* Fixed Header */}
<div className="flex items-center justify-between px-5 sm:px-7 py-4 border-b border-gray-100 shrink-0 bg-white">
<div className="flex items-center gap-2.5 min-w-0">
{Icon && (
<div className="w-8 h-8 rounded-xl bg-purple-50 text-purple-600 flex items-center justify-center shrink-0">
<Icon className="w-4 h-4" />
</div>
)}
<h3 className="text-base sm:text-lg font-black text-gray-900 truncate">
{title}
</h3>
</div>
<button
type="button"
onClick={onClose}
className="w-8 h-8 rounded-xl bg-gray-50 text-gray-400 hover:text-gray-700 hover:bg-gray-100 flex items-center justify-center transition-colors shrink-0 cursor-pointer"
aria-label="بستن"
>
<X className="w-4 h-4" />
</button>
</div>
{/* Scrollable Body */}
<div
className={`p-5 sm:p-7 overflow-y-auto flex-1 overscroll-contain text-xs sm:text-sm text-gray-700 space-y-4 ${bodyClassName}`}
>
{children}
</div>
{/* Fixed Footer */}
{footer && (
<div className="px-5 sm:px-7 py-4 bg-gray-50/80 border-t border-gray-100 flex flex-wrap items-center justify-end gap-3 shrink-0">
{footer}
</div>
)}
</div>
</div>
);
}
@@ -0,0 +1,51 @@
import React from 'react';
import { ArrowUpDown, ArrowUp, ArrowDown } from 'lucide-react';
export interface ThSortProps {
column: string;
label: React.ReactNode;
currentSortBy: string;
currentSortOrder: 'asc' | 'desc';
onSort: (column: string) => void;
className?: string;
align?: 'right' | 'center' | 'left';
}
export default function ThSort({
column,
label,
currentSortBy,
currentSortOrder,
onSort,
className = '',
align = 'right',
}: ThSortProps) {
const isSorted = currentSortBy === column;
const alignClasses =
align === 'left'
? 'justify-start text-left'
: align === 'center'
? 'justify-center text-center'
: 'justify-start text-right';
return (
<th
onClick={() => onSort(column)}
className={`p-4 font-black text-xs text-gray-600 hover:text-purple-700 cursor-pointer select-none transition-colors group ${className}`}
>
<div className={`flex items-center gap-1.5 ${alignClasses}`}>
<span className="group-hover:text-purple-600 transition-colors">{label}</span>
{isSorted ? (
currentSortOrder === 'asc' ? (
<ArrowUp className="w-3.5 h-3.5 text-purple-600 shrink-0" />
) : (
<ArrowDown className="w-3.5 h-3.5 text-purple-600 shrink-0" />
)
) : (
<ArrowUpDown className="w-3.5 h-3.5 text-gray-300 group-hover:text-gray-400 shrink-0 transition-colors" />
)}
</div>
</th>
);
}