feat(settings): restructure settings into payment, shipping, and rich page builder v2 with SEO and icons
Deploy Canina / deploy (push) Has been cancelled
Deploy Canina / deploy (push) Has been cancelled
This commit is contained in:
1 parent
aa10ee735f
commit
a291fa0c4a
22 files changed
+37783
-35567
No files matched your search
@@ -0,0 +1,182 @@
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import {
|
||||
X,
|
||||
Search,
|
||||
Check,
|
||||
Smile,
|
||||
Pill,
|
||||
ShieldCheck,
|
||||
HeartPulse,
|
||||
Sparkles,
|
||||
ShoppingBag,
|
||||
User,
|
||||
Building2,
|
||||
PhoneCall,
|
||||
Activity,
|
||||
Heart,
|
||||
Dog,
|
||||
BookOpen,
|
||||
FileText,
|
||||
Video,
|
||||
Award,
|
||||
Star,
|
||||
Truck,
|
||||
HelpCircle,
|
||||
MessageSquare,
|
||||
Globe,
|
||||
Settings,
|
||||
Flame,
|
||||
CheckCircle2,
|
||||
AlertCircle,
|
||||
ThumbsUp,
|
||||
Package,
|
||||
Layers,
|
||||
Compass,
|
||||
MapPin,
|
||||
Mail,
|
||||
Send,
|
||||
Zap,
|
||||
Tag,
|
||||
Gift,
|
||||
Clock,
|
||||
} from 'lucide-react';
|
||||
|
||||
interface IconPickerModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
currentIcon?: string;
|
||||
onSelect: (iconName: string) => void;
|
||||
}
|
||||
|
||||
export const ICON_REGISTRY: Record<string, React.ComponentType<{ className?: string }>> = {
|
||||
Pill,
|
||||
ShieldCheck,
|
||||
HeartPulse,
|
||||
Sparkles,
|
||||
ShoppingBag,
|
||||
User,
|
||||
Building2,
|
||||
PhoneCall,
|
||||
Activity,
|
||||
Heart,
|
||||
Dog,
|
||||
BookOpen,
|
||||
FileText,
|
||||
Video,
|
||||
Award,
|
||||
Star,
|
||||
Truck,
|
||||
HelpCircle,
|
||||
MessageSquare,
|
||||
Globe,
|
||||
Settings,
|
||||
Flame,
|
||||
CheckCircle2,
|
||||
AlertCircle,
|
||||
ThumbsUp,
|
||||
Package,
|
||||
Layers,
|
||||
Compass,
|
||||
MapPin,
|
||||
Mail,
|
||||
Send,
|
||||
Zap,
|
||||
Tag,
|
||||
Gift,
|
||||
Clock,
|
||||
Smile,
|
||||
};
|
||||
|
||||
export default function IconPickerModal({
|
||||
isOpen,
|
||||
onClose,
|
||||
currentIcon,
|
||||
onSelect,
|
||||
}: IconPickerModalProps) {
|
||||
const [search, setSearch] = useState('');
|
||||
|
||||
const filteredIcons = useMemo(() => {
|
||||
const query = search.toLowerCase().trim();
|
||||
return Object.keys(ICON_REGISTRY).filter((name) =>
|
||||
name.toLowerCase().includes(query)
|
||||
);
|
||||
}, [search]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-gray-900/60 backdrop-blur-sm font-vazir" dir="rtl">
|
||||
<div className="bg-white rounded-3xl w-full max-w-lg shadow-2xl overflow-hidden border border-gray-100 animate-in zoom-in-95 duration-200">
|
||||
{/* Header */}
|
||||
<div className="p-6 border-b border-gray-100 flex items-center justify-between bg-gray-50/50">
|
||||
<div>
|
||||
<h3 className="text-base font-black text-gray-900">انتخاب آیکون (Lucide Icons)</h3>
|
||||
<p className="text-xs text-gray-500 font-medium mt-0.5">آیکون مورد نظر برای این بخش را انتخاب کنید</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-2 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-xl transition-all cursor-pointer"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Search */}
|
||||
<div className="p-4 border-b border-gray-100 bg-white">
|
||||
<div className="relative">
|
||||
<Search className="w-4 h-4 text-gray-400 absolute right-3.5 top-3" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجوی نام آیکون (مانند Pill, Heart, Shield, Award)..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="w-full pr-10 pl-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-xs font-bold focus:outline-none focus:ring-2 focus:ring-purple-500"
|
||||
dir="ltr"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Icon Grid */}
|
||||
<div className="p-6 max-h-[360px] overflow-y-auto grid grid-cols-4 sm:grid-cols-6 gap-3">
|
||||
{filteredIcons.map((name) => {
|
||||
const IconComp = ICON_REGISTRY[name];
|
||||
const isSelected = currentIcon === name;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={name}
|
||||
type="button"
|
||||
onClick={() => {
|
||||
onSelect(name);
|
||||
onClose();
|
||||
}}
|
||||
className={`p-3 rounded-2xl flex flex-col items-center gap-1.5 transition-all border cursor-pointer group ${
|
||||
isSelected
|
||||
? 'bg-purple-600 text-white border-purple-600 shadow-md shadow-purple-200 scale-105'
|
||||
: 'bg-white hover:bg-purple-50 text-gray-700 border-gray-100 hover:border-purple-200 hover:text-purple-700'
|
||||
}`}
|
||||
>
|
||||
<IconComp className="w-6 h-6 transition-transform group-hover:scale-110" />
|
||||
<span className="text-[10px] font-mono font-bold truncate max-w-full" dir="ltr">
|
||||
{name}
|
||||
</span>
|
||||
{isSelected && <Check className="w-3 h-3 text-amber-300" />}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="p-4 border-t border-gray-100 flex justify-end bg-gray-50/50">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="px-5 py-2 text-xs font-bold text-gray-600 hover:bg-gray-200 rounded-xl transition-all cursor-pointer"
|
||||
>
|
||||
بستن
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
import React, { useRef } from 'react';
|
||||
import {
|
||||
Bold,
|
||||
Italic,
|
||||
Underline,
|
||||
Heading1,
|
||||
Heading2,
|
||||
Heading3,
|
||||
List,
|
||||
ListOrdered,
|
||||
Link,
|
||||
AlignRight,
|
||||
AlignCenter,
|
||||
AlignLeft,
|
||||
Palette,
|
||||
Undo,
|
||||
Redo,
|
||||
} from 'lucide-react';
|
||||
|
||||
interface RichTextEditorProps {
|
||||
value: string;
|
||||
onChange: (html: string) => void;
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const COLORS = [
|
||||
{ label: 'سیاه / پیشفرض', value: '#111827' },
|
||||
{ label: 'خاکستری', value: '#4b5563' },
|
||||
{ label: 'آبی کنینا', value: '#1d4ed8' },
|
||||
{ label: 'بنفش اختصاصی', value: '#7c3aed' },
|
||||
{ label: 'سبز درمانی', value: '#059669' },
|
||||
{ label: 'قرمز هشدار', value: '#dc2626' },
|
||||
{ label: 'کهربایی / زرد', value: '#d97706' },
|
||||
];
|
||||
|
||||
export default function RichTextEditor({
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
className = '',
|
||||
}: RichTextEditorProps) {
|
||||
const editorRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const exec = (command: string, val: string | undefined = undefined) => {
|
||||
document.execCommand(command, false, val);
|
||||
if (editorRef.current) {
|
||||
onChange(editorRef.current.innerHTML);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLink = () => {
|
||||
const url = prompt('آدرس لینک (URL) را وارد کنید:', 'https://');
|
||||
if (url) {
|
||||
exec('createLink', url);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInput = () => {
|
||||
if (editorRef.current) {
|
||||
onChange(editorRef.current.innerHTML);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`border border-gray-200 rounded-2xl bg-white overflow-hidden shadow-xs ${className}`}>
|
||||
{/* Toolbar */}
|
||||
<div className="bg-gray-50/80 border-b border-gray-100 p-2 flex flex-wrap items-center gap-1 text-gray-700">
|
||||
{/* Headings */}
|
||||
<div className="flex items-center gap-0.5 bg-white p-0.5 rounded-xl border border-gray-200">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('formatBlock', '<h1>')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg text-xs font-bold transition-colors cursor-pointer"
|
||||
title="تگ تیتر H1 (برای سئو)"
|
||||
>
|
||||
<Heading1 className="w-4 h-4 text-purple-700" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('formatBlock', '<h2>')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg text-xs font-bold transition-colors cursor-pointer"
|
||||
title="تگ تیتر H2"
|
||||
>
|
||||
<Heading2 className="w-4 h-4 text-purple-600" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('formatBlock', '<h3>')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg text-xs font-bold transition-colors cursor-pointer"
|
||||
title="تگ تیتر H3"
|
||||
>
|
||||
<Heading3 className="w-4 h-4 text-purple-500" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('formatBlock', '<p>')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg text-[11px] font-bold transition-colors cursor-pointer text-gray-600 px-2"
|
||||
title="پاراگراف عادی (P)"
|
||||
>
|
||||
P
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Basic Formats */}
|
||||
<div className="flex items-center gap-0.5 bg-white p-0.5 rounded-xl border border-gray-200">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('bold')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="Bold"
|
||||
>
|
||||
<Bold className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('italic')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="Italic"
|
||||
>
|
||||
<Italic className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('underline')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="Underline"
|
||||
>
|
||||
<Underline className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Alignment */}
|
||||
<div className="flex items-center gap-0.5 bg-white p-0.5 rounded-xl border border-gray-200">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('justifyRight')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="راستچین"
|
||||
>
|
||||
<AlignRight className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('justifyCenter')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="وسطچین"
|
||||
>
|
||||
<AlignCenter className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('justifyLeft')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="چپچین"
|
||||
>
|
||||
<AlignLeft className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Lists & Link */}
|
||||
<div className="flex items-center gap-0.5 bg-white p-0.5 rounded-xl border border-gray-200">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('insertUnorderedList')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="لیست بالتدار"
|
||||
>
|
||||
<List className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('insertOrderedList')}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
||||
title="لیست شمارهدار"
|
||||
>
|
||||
<ListOrdered className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleLink}
|
||||
className="p-1.5 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer text-blue-600"
|
||||
title="درج لینک"
|
||||
>
|
||||
<Link className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Color Palette */}
|
||||
<div className="flex items-center gap-1 bg-white px-2 py-1 rounded-xl border border-gray-200">
|
||||
<Palette className="w-3.5 h-3.5 text-gray-400" />
|
||||
<div className="flex items-center gap-1">
|
||||
{COLORS.map((c) => (
|
||||
<button
|
||||
key={c.value}
|
||||
type="button"
|
||||
onClick={() => exec('foreColor', c.value)}
|
||||
className="w-3.5 h-3.5 rounded-full border border-black/10 cursor-pointer hover:scale-125 transition-transform"
|
||||
style={{ backgroundColor: c.value }}
|
||||
title={c.label}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Undo / Redo */}
|
||||
<div className="flex items-center gap-0.5 ms-auto">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('undo')}
|
||||
className="p-1.5 hover:bg-gray-200 rounded-lg transition-colors cursor-pointer"
|
||||
title="Undo"
|
||||
>
|
||||
<Undo className="w-3.5 h-3.5 text-gray-500" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => exec('redo')}
|
||||
className="p-1.5 hover:bg-gray-200 rounded-lg transition-colors cursor-pointer"
|
||||
title="Redo"
|
||||
>
|
||||
<Redo className="w-3.5 h-3.5 text-gray-500" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Editable Area */}
|
||||
<div
|
||||
ref={editorRef}
|
||||
contentEditable
|
||||
onInput={handleInput}
|
||||
dangerouslySetInnerHTML={{ __html: value }}
|
||||
data-placeholder={placeholder}
|
||||
className="p-4 min-h-[140px] max-h-[350px] overflow-y-auto outline-none text-xs leading-relaxed text-gray-800 font-vazir empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400"
|
||||
dir="rtl"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user