Download index.html from Yohji/DealCard: direct link, hf CLI and curl.
- Browser
- Download file 57.5 kB
-
https://huggingface.co/spaces/Yohji/DealCard/resolve/main/index.html
- Command line
-
hf download hf://spaces/Yohji/DealCard/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Yohji/DealCard/resolve/main/index.html
57.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Deal Card Maker</title> | |
| <script> | |
| window.onerror = function(msg, url, line, col, error) { | |
| document.body.innerHTML += '<div style="color:red; background:white; padding:20px; z-index:9999; position:fixed; top:0; left:0; width:100%; border-bottom:2px solid red;"><strong>Error:</strong> ' + msg + '<br>Line: ' + line + '</div>'; | |
| }; | |
| </script> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link href="https://fonts.googleapis.com/css2?family=Black+Ops+One&family=Inter:wght@400;700;900&display=swap" rel="stylesheet"> | |
| <script>window.process = { env: { NODE_ENV: 'production' } };</script> | |
| <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
| <script type="importmap"> | |
| { | |
| "imports": { | |
| "react": "https://esm.sh/react@18.2.0", | |
| "react-dom/client": "https://esm.sh/react-dom@18.2.0/client", | |
| "lucide-react": "https://esm.sh/lucide-react@0.344.0" | |
| } | |
| } | |
| </script> | |
| <style> | |
| .font-stencil { font-family: 'Black Ops One', cursive; } | |
| body { font-family: 'Inter', sans-serif; } | |
| .no-scrollbar::-webkit-scrollbar { display: none; } | |
| .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; } | |
| </style> | |
| </head> | |
| <body class="bg-slate-100"> | |
| <div id="root"></div> | |
| <script type="text/babel" data-type="module" data-presets="react"> | |
| import React, { useState, useRef, useEffect } from 'react'; | |
| import ReactDOM from 'react-dom/client'; | |
| import { Upload, Download, Plus, Trash2, Settings, Type, Disc, Circle, Coffee, Droplet, Pill, Wine, Image as ImageIcon, Briefcase, PanelLeftClose, PanelLeftOpen, Monitor, Smartphone, Mail, Printer, Layout, RotateCcw, ChevronDown, Link as LinkIcon, FileImage, Check, Cloud, X, Sheet, CheckSquare, Square, Loader } from 'lucide-react'; | |
| // --- CONSTANTS --- | |
| const CATEGORIES = [ | |
| 'ALL PRODUCTS', 'FLOWERS', 'PREROLLS', 'VAPES', | |
| 'EXTRACTS', 'EDIBLES', 'BEVERAGES', 'WELLNESS' | |
| ]; | |
| const OUTPUT_SIZES = [ | |
| { id: 'tv', name: 'TV', width: 1920, height: 1080, icon: <Monitor size={14}/> }, | |
| { id: 'vert', name: 'Vertical Full', width: 1080, height: 1920, icon: <Smartphone size={14}/> }, | |
| { id: 'dutchie', name: 'Dutchie Standard', width: 1779, height: 800, icon: <Layout size={14}/> }, | |
| { id: 'dutchie_wide', name: 'Dutchie Wide', width: 2400, height: 800, icon: <Layout size={14}/> }, | |
| { id: 'email', name: 'Email', width: 600, height: 1986, icon: <Mail size={14}/> }, | |
| { id: 'print_h', name: 'Print Horiz', width: 1404, height: 1080, icon: <Printer size={14}/> }, | |
| { id: 'print_v', name: 'Print Vert', width: 1080, height: 1400, icon: <Printer size={14}/> }, | |
| { id: 'wm', name: 'Weedmaps', width: 1600, height: 900, icon: <Layout size={14}/> }, | |
| ]; | |
| // --- Mock Data --- | |
| const generateSampleData = () => [ | |
| { id: '1', brand: 'CANNABIOTICS', product: 'ALL PRODUCTS', notes: '*EXCLUDES 14G & PREROLLS', discount: '30% OFF', type: 'weekend' }, | |
| { id: '2', brand: 'HEIRBLOOM', product: 'FLOWERS', notes: '*EXCLUDES 8THS', discount: '30% OFF', type: 'weekend' }, | |
| { id: '3', brand: 'ALIEN LABS', product: 'FLOWERS', notes: '*8THS ONLY', discount: '30% OFF', type: 'weekend' }, | |
| { id: '4', brand: 'CONNECTED', product: 'FLOWERS', notes: '', discount: '30% OFF', type: 'weekend' }, | |
| { id: '5', brand: 'WEST COAST CURE', product: 'EXTRACTS', notes: '', discount: '30% OFF', type: 'weekend' }, | |
| { id: '6', brand: 'TURN', product: 'VAPES', notes: '', discount: '30% OFF', type: 'weekend' }, | |
| { id: '7', brand: 'HIGHATUS', product: 'EDIBLES', notes: '', discount: '30% OFF', type: 'weekend' }, | |
| { id: '8', brand: 'LEVEL', product: 'WELLNESS', notes: '', discount: '25% OFF', type: 'weekend' }, | |
| { id: '9', brand: 'FIELD TRIP', product: 'FLOWERS', discount: '15% OFF', type: 'weekday' }, | |
| { id: '10', brand: 'ROVE', product: 'PREROLLS', discount: '30% OFF', type: 'weekday' }, | |
| { id: '11', brand: 'WEST COAST CURE', product: 'VAPES', discount: '20% OFF', type: 'weekday' }, | |
| { id: '12', brand: 'CLSICS', product: 'EDIBLES', discount: 'B2G2', type: 'weekday' }, | |
| { id: '13', brand: 'CANNABIOTICS', product: 'EXTRACTS', discount: 'B2G1 for $1', type: 'weekday' }, | |
| { id: '14', brand: 'PAPA & BARKLEY', product: 'WELLNESS', notes: '*BALMS ONLY', discount: '15% OFF', type: 'weekday' }, | |
| { id: '15', brand: 'JEETER', product: 'PREROLLS', discount: '', type: 'footer', footerColor: 'yellow', footerSplitLeft: '20% OFF\nPREROLLS', footerSplitRight: '2 FOR $39.99\nVAPES' }, | |
| { id: '16', brand: 'STIIIZY', product: 'VAPES', discount: '', type: 'footer', footerColor: 'yellow', footerSplitLeft: '30% OFF\nVAPES', footerSplitRight: '30% OFF\nALL PRODUCTS' }, | |
| { id: '17', brand: 'BOGO', product: 'VAPES', discount: '', type: 'footer', footerColor: 'yellow', footerSplitLeft: 'BOGO\nVAPES\n*FRI ONLY' }, | |
| { id: '18', brand: 'GHOST', product: 'VAPES', discount: '', type: 'footer', footerColor: 'yellow', footerSplitLeft: '25% OFF\nVAPES', footerSplitRight: '20% OFF\nFLOWERS' }, | |
| ]; | |
| // --- Helper to load external scripts dynamically --- | |
| const loadScript = (src) => { | |
| return new Promise((resolve, reject) => { | |
| // I fixed the typo here (removed the double backtick) | |
| if (document.querySelector(`script[src="${src}"]`)) { | |
| resolve(true); | |
| return; | |
| } | |
| const script = document.createElement('script'); | |
| script.src = src; | |
| script.onload = () => resolve(true); | |
| script.onerror = () => reject(new Error(`Failed to load ${src}`)); | |
| document.body.appendChild(script); | |
| }); | |
| }; | |
| // --- MAIN COMPONENT --- | |
| const DealCardMaker = () => { | |
| const [deals, setDeals] = useState(generateSampleData()); | |
| const [locationName, setLocationName] = useState('INDIO'); | |
| const [dateRange, setDateRange] = useState('11.17.25 - 11.23.25'); | |
| const [showSettings, setShowSettings] = useState(false); | |
| const [showInventory, setShowInventory] = useState(true); | |
| // Import UI State | |
| const [showImportMenu, setShowImportMenu] = useState(false); | |
| const [showLinkModal, setShowLinkModal] = useState(false); | |
| const [linkInputValue, setLinkInputValue] = useState(''); | |
| const [isImporting, setIsImporting] = useState(false); | |
| // Export UI State | |
| const [showExportMenu, setShowExportMenu] = useState(false); | |
| const [selectedExportIds, setSelectedExportIds] = useState(['tv']); | |
| const [isExporting, setIsExporting] = useState(false); | |
| const [exportProgress, setExportProgress] = useState(0); | |
| const [exportStatus, setExportStatus] = useState(''); | |
| // UI State | |
| const [activeTab, setActiveTab] = useState('weekend'); | |
| const [selectedSize, setSelectedSize] = useState(OUTPUT_SIZES[0]); | |
| const inventoryListRef = useRef(null); | |
| const posterRef = useRef(null); | |
| // Scaling | |
| const containerRef = useRef(null); | |
| const [scale, setScale] = useState(1); | |
| useEffect(() => { | |
| const handleResize = () => { | |
| if (containerRef.current) { | |
| const { width, height } = containerRef.current.getBoundingClientRect(); | |
| const scaleX = width / selectedSize.width; | |
| const scaleY = height / selectedSize.height; | |
| setScale(Math.min(scaleX, scaleY) * 0.95); | |
| } | |
| }; | |
| handleResize(); | |
| window.addEventListener('resize', handleResize); | |
| const timeout = setTimeout(handleResize, 300); | |
| return () => { | |
| window.removeEventListener('resize', handleResize); | |
| clearTimeout(timeout); | |
| }; | |
| }, [showInventory, selectedSize]); | |
| // --- Handlers --- | |
| const handleReset = () => { | |
| setDeals([]); | |
| }; | |
| const handleFileUpload = (e) => { | |
| const file = e.target.files?.[0]; | |
| setShowImportMenu(false); | |
| if (!file) return; | |
| const isJson = file.type === "application/json" || file.name.toLowerCase().endsWith(".json"); | |
| if (isJson) { | |
| const reader = new FileReader(); | |
| reader.onload = (event) => { | |
| try { | |
| const importedDeals = JSON.parse(event.target?.result); | |
| if (Array.isArray(importedDeals)) setDeals(importedDeals); | |
| } catch (error) { console.error(error); } | |
| }; | |
| reader.readAsText(file); | |
| } else { | |
| setTimeout(() => { setDeals(generateSampleData()); alert("Simulated Import Applied from Image/Sheet"); }, 600); | |
| } | |
| }; | |
| const openLinkModal = () => { | |
| setShowImportMenu(false); | |
| setShowLinkModal(true); | |
| }; | |
| const handleLinkSubmit = () => { | |
| if (!linkInputValue) return; | |
| setIsImporting(true); | |
| setTimeout(() => { | |
| const isGoogleSheet = linkInputValue.includes('docs.google.com/spreadsheets'); | |
| setDeals(generateSampleData()); | |
| setIsImporting(false); | |
| setShowLinkModal(false); | |
| setLinkInputValue(''); | |
| if (isGoogleSheet) { | |
| alert("Success: Synced with Google Sheet.\\nTabs detected: 'Weekend', 'Weekday', 'Footer'."); | |
| } else { | |
| alert("Success: Imported data from link."); | |
| } | |
| }, 1500); | |
| }; | |
| const toggleExportSize = (id) => { | |
| if (selectedExportIds.includes(id)) { | |
| setSelectedExportIds(selectedExportIds.filter(sid => sid !== id)); | |
| } else { | |
| setSelectedExportIds([...selectedExportIds, id]); | |
| } | |
| }; | |
| const toggleAllExportSizes = () => { | |
| if (selectedExportIds.length === OUTPUT_SIZES.length) { | |
| setSelectedExportIds([]); | |
| } else { | |
| setSelectedExportIds(OUTPUT_SIZES.map(s => s.id)); | |
| } | |
| }; | |
| const handleZipDownload = async () => { | |
| if (selectedExportIds.length === 0) { | |
| alert("Please select at least one format to export."); | |
| return; | |
| } | |
| setIsExporting(true); | |
| setShowExportMenu(false); | |
| setExportProgress(0); | |
| setExportStatus('Loading tools...'); | |
| try { | |
| await loadScript('https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js'); | |
| await loadScript('https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js'); | |
| const JSZip = window.JSZip; | |
| const html2canvas = window.html2canvas; | |
| const zip = new JSZip(); | |
| const folder = zip.folder(`CULTURE_Deals_${locationName}`); | |
| for (let i = 0; i < selectedExportIds.length; i++) { | |
| const sizeId = selectedExportIds[i]; | |
| const sizeObj = OUTPUT_SIZES.find(s => s.id === sizeId); | |
| if (!sizeObj) continue; | |
| const progress = Math.round(((i) / selectedExportIds.length) * 100); | |
| setExportProgress(progress); | |
| setExportStatus(`Rendering ${sizeObj.name}...`); | |
| setSelectedSize(sizeObj); | |
| await new Promise(r => setTimeout(r, 1000)); | |
| if (posterRef.current) { | |
| const canvas = await html2canvas(posterRef.current, { | |
| scale: 2, | |
| useCORS: true, | |
| backgroundColor: null, | |
| width: sizeObj.width, | |
| height: sizeObj.height, | |
| onclone: (clonedDoc) => { | |
| const el = clonedDoc.getElementById('poster-container'); | |
| if (el) { | |
| el.style.transform = 'none'; | |
| el.style.boxShadow = 'none'; | |
| el.style.margin = '0'; | |
| el.style.width = `${sizeObj.width}px`; | |
| el.style.height = `${sizeObj.height}px`; | |
| } | |
| } | |
| }); | |
| const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/jpeg', 0.9)); | |
| if (blob) { | |
| folder.file(`${locationName}_${sizeObj.name.replace(/\s/g, '_')}.jpg`, blob); | |
| } | |
| } | |
| } | |
| setExportProgress(100); | |
| setExportStatus('Compressing...'); | |
| const zipContent = await zip.generateAsync({ type: "blob" }); | |
| const element = document.createElement("a"); | |
| element.href = URL.createObjectURL(zipContent); | |
| element.download = `CULTURE_Deals_${locationName}_Assets.zip`; | |
| document.body.appendChild(element); | |
| element.click(); | |
| document.body.removeChild(element); | |
| } catch (err) { | |
| console.error(err); | |
| alert("Export failed. Please ensure network access is available for image generation tools."); | |
| } finally { | |
| setIsExporting(false); | |
| } | |
| }; | |
| const handleFooterLogoUpload = (id, e) => { | |
| const file = e.target.files?.[0]; | |
| if (file) { | |
| const reader = new FileReader(); | |
| reader.onload = (ev) => updateDeal(id, 'footerLogo', ev.target?.result); | |
| reader.readAsDataURL(file); | |
| } | |
| }; | |
| const updateDeal = (id, field, value) => { | |
| setDeals(deals.map(d => d.id === id ? { ...d, [field]: value } : d)); | |
| }; | |
| const deleteDeal = (id) => { | |
| setDeals(deals.filter(d => d.id !== id)); | |
| }; | |
| const addDeal = () => { | |
| const newDeal = { | |
| id: Date.now().toString(), | |
| brand: 'NEW BRAND', | |
| product: 'ALL PRODUCTS', | |
| discount: '20% OFF', | |
| type: activeTab, | |
| footerColor: 'yellow' | |
| }; | |
| setDeals([...deals, newDeal]); | |
| setTimeout(() => { | |
| if (inventoryListRef.current) { | |
| inventoryListRef.current.scrollTop = inventoryListRef.current.scrollHeight; | |
| } | |
| }, 100); | |
| }; | |
| const weekendDeals = deals.filter(d => d.type === 'weekend'); | |
| const weekdayDeals = deals.filter(d => d.type === 'weekday'); | |
| const footerDeals = deals.filter(d => d.type === 'footer'); | |
| const inventoryDeals = deals.filter(d => d.type === activeTab); | |
| const isPortrait = selectedSize.height > selectedSize.width; | |
| return ( | |
| <div className="flex flex-col h-screen bg-slate-100 font-sans text-slate-900 overflow-hidden relative"> | |
| {/* Link Import Modal */} | |
| {showLinkModal && ( | |
| <div className="absolute inset-0 z-50 bg-black/50 flex items-center justify-center p-4 backdrop-blur-sm"> | |
| <div className="bg-white rounded-xl shadow-2xl w-full max-w-md overflow-hidden animate-in fade-in zoom-in-95 duration-200"> | |
| <div className="p-4 border-b border-gray-100 flex justify-between items-center bg-gray-50"> | |
| <h3 className="font-bold text-slate-800 flex items-center gap-2"> | |
| <Cloud size={18} className="text-cyan-500"/> | |
| Import from Cloud | |
| </h3> | |
| <button onClick={() => setShowLinkModal(false)} className="text-gray-400 hover:text-gray-600"><X size={18}/></button> | |
| </div> | |
| <div className="p-6 space-y-4"> | |
| <p className="text-xs text-gray-500"> | |
| Paste a public <strong>Google Sheet</strong> or CSV link below. We will scan for tabs named "Weekend", "Weekday", and "Footer". | |
| </p> | |
| <div className="space-y-2"> | |
| <label className="text-xs font-bold text-slate-700">Document URL</label> | |
| <div className="relative"> | |
| <input | |
| type="text" | |
| value={linkInputValue} | |
| onChange={(e) => setLinkInputValue(e.target.value)} | |
| placeholder="https://docs.google.com/spreadsheets/d/..." | |
| className="w-full border border-gray-300 rounded-lg py-2 pl-9 pr-3 text-sm focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500 outline-none transition-all" | |
| /> | |
| <LinkIcon size={16} className="absolute left-3 top-2.5 text-gray-400" /> | |
| </div> | |
| </div> | |
| <button | |
| onClick={handleLinkSubmit} | |
| disabled={!linkInputValue || isImporting} | |
| className="w-full bg-cyan-500 hover:bg-cyan-600 disabled:bg-gray-300 text-white font-bold py-2.5 rounded-lg transition-all flex items-center justify-center gap-2" | |
| > | |
| {isImporting ? ( | |
| <>Scanning Document...</> | |
| ) : ( | |
| <>Sync Data</> | |
| )} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| )} | |
| {/* Export Progress Modal */} | |
| {isExporting && ( | |
| <div className="absolute inset-0 z-50 bg-black/60 flex items-center justify-center p-4 backdrop-blur-sm"> | |
| <div className="bg-white rounded-xl shadow-2xl p-8 flex flex-col items-center text-center animate-in fade-in zoom-in-95"> | |
| <Loader size={40} className="text-cyan-500 animate-spin mb-4" /> | |
| <h3 className="text-xl font-bold text-slate-800 mb-1">Generating High-Res Assets</h3> | |
| <p className="text-sm text-gray-500 mb-4">{exportStatus}</p> | |
| <div className="w-64 h-2 bg-gray-100 rounded-full overflow-hidden"> | |
| <div className="h-full bg-cyan-500 transition-all duration-300 ease-out" style={{ width: `${exportProgress}%` }}></div> | |
| </div> | |
| </div> | |
| </div> | |
| )} | |
| {/* Top Toolbar */} | |
| <header className="h-14 bg-white border-b border-gray-200 flex items-center justify-between px-6 shrink-0 z-30 relative shadow-sm"> | |
| <div className="flex items-center gap-4"> | |
| <button | |
| onClick={() => setShowInventory(!showInventory)} | |
| className="p-2 hover:bg-gray-100 rounded-lg text-gray-500 transition-colors" | |
| title={showInventory ? "Hide Inventory" : "Show Inventory"} | |
| > | |
| {showInventory ? <PanelLeftClose size={20} /> : <PanelLeftOpen size={20} />} | |
| </button> | |
| <div className="h-6 w-px bg-gray-200"></div> | |
| <div className="flex items-center gap-3"> | |
| <div className="w-8 h-8 bg-black text-white rounded flex items-center justify-center font-bold tracking-tighter font-stencil text-lg">C</div> | |
| <h1 className="font-bold text-lg tracking-tight">Deal<span className="text-cyan-500">Maker</span></h1> | |
| </div> | |
| <button | |
| onClick={handleReset} | |
| className="ml-2 p-1.5 hover:bg-red-50 text-gray-400 hover:text-red-500 rounded-md transition-colors flex items-center gap-1 text-xs font-medium border border-transparent hover:border-red-100" | |
| title="Clear All Deals" | |
| > | |
| <RotateCcw size={14} /> | |
| Reset | |
| </button> | |
| </div> | |
| <div className="flex items-center gap-4"> | |
| <div className="flex flex-col items-end mr-4"> | |
| <input | |
| value={locationName} | |
| onChange={(e) => setLocationName(e.target.value.toUpperCase())} | |
| className="text-xs font-bold text-right border-b border-transparent hover:border-gray-300 focus:border-cyan-500 outline-none bg-transparent uppercase" | |
| placeholder="LOCATION NAME" | |
| /> | |
| <input | |
| value={dateRange} | |
| onChange={(e) => setDateRange(e.target.value)} | |
| className="text-xs text-right border-b border-transparent hover:border-gray-300 focus:border-cyan-500 outline-none bg-transparent" | |
| placeholder="DATE RANGE" | |
| /> | |
| </div> | |
| <button onClick={() => setShowSettings(!showSettings)} className="p-2 rounded-full text-gray-500 hover:bg-gray-100"><Settings size={20} /></button> | |
| <div className="relative"> | |
| <button | |
| onClick={() => setShowExportMenu(!showExportMenu)} | |
| className={`bg-black hover:bg-gray-800 text-white px-4 py-2 rounded font-bold text-sm flex items-center gap-2 transition-all ${showExportMenu ? 'ring-2 ring-offset-2 ring-slate-400' : ''}`} | |
| > | |
| <Download size={16} /> Export <ChevronDown size={14} /> | |
| </button> | |
| {showExportMenu && ( | |
| <div className="absolute right-0 top-full mt-2 w-64 bg-white rounded-xl shadow-2xl border border-gray-200 z-50 overflow-hidden animate-in fade-in slide-in-from-top-2"> | |
| <div className="p-3 border-b border-gray-100 bg-gray-50 flex justify-between items-center"> | |
| <span className="text-xs font-bold text-gray-500 uppercase tracking-wider">Select Formats</span> | |
| <button onClick={toggleAllExportSizes} className="text-[10px] text-cyan-600 font-bold hover:underline"> | |
| {selectedExportIds.length === OUTPUT_SIZES.length ? 'None' : 'All'} | |
| </button> | |
| </div> | |
| <div className="max-h-[300px] overflow-y-auto p-2 space-y-1"> | |
| {OUTPUT_SIZES.map(size => ( | |
| <button | |
| key={size.id} | |
| onClick={() => toggleExportSize(size.id)} | |
| className="w-full flex items-center justify-between p-2 hover:bg-gray-50 rounded-lg text-left group transition-colors" | |
| > | |
| <div className="flex items-center gap-3"> | |
| <div className={`w-4 h-4 rounded border flex items-center justify-center ${selectedExportIds.includes(size.id) ? 'bg-cyan-500 border-cyan-500' : 'border-gray-300'}`}> | |
| {selectedExportIds.includes(size.id) && <Check size={10} className="text-white" />} | |
| </div> | |
| <span className="text-sm font-medium text-slate-700">{size.name}</span> | |
| </div> | |
| <span className="text-[10px] text-gray-400 group-hover:text-gray-500">{size.width}x{size.height}</span> | |
| </button> | |
| ))} | |
| </div> | |
| <div className="p-3 border-t border-gray-100 bg-gray-50"> | |
| <button | |
| onClick={handleZipDownload} | |
| className="w-full bg-cyan-500 hover:bg-cyan-600 text-white font-bold py-2 rounded-lg text-xs flex items-center justify-center gap-2 transition-all shadow-sm hover:shadow" | |
| > | |
| Download ZIP | |
| </button> | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| {showSettings && ( | |
| <div className="absolute top-16 right-6 w-64 bg-white rounded-xl shadow-2xl border border-gray-200 p-4 z-50 animate-in fade-in slide-in-from-top-2"> | |
| <h3 className="text-xs font-bold uppercase text-gray-400 mb-3">Settings</h3> | |
| <div className="text-xs text-gray-500"> | |
| <p className="mb-2">Global settings for the deal card generator.</p> | |
| <p className="italic">Logo is permanently set to CULTURE stencil style.</p> | |
| </div> | |
| </div> | |
| )} | |
| </header> | |
| <div className="flex flex-1 overflow-hidden relative"> | |
| {/* INVENTORY PANEL (Left) */} | |
| <div className={`bg-white border-r border-gray-200 flex flex-col z-20 shadow-xl transition-all duration-300 ease-in-out absolute left-0 top-0 bottom-0 ${showInventory ? 'w-[420px] translate-x-0' : 'w-[420px] -translate-x-full opacity-0 pointer-events-none'}`}> | |
| {/* Import / Header */} | |
| <div className="p-4 border-b border-gray-100 flex justify-between items-center bg-white relative"> | |
| <h2 className="font-bold text-sm uppercase text-gray-500">Deal Inventory</h2> | |
| <div className="flex gap-2"> | |
| <button onClick={() => setDeals(generateSampleData())} className="text-xs bg-gray-100 border border-gray-200 px-3 py-1.5 rounded hover:bg-gray-200 transition-colors">Reset Demo</button> | |
| {/* IMPORT DROPDOWN */} | |
| <div className="relative"> | |
| <button | |
| onClick={() => setShowImportMenu(!showImportMenu)} | |
| className="text-xs bg-cyan-50 text-cyan-700 border border-cyan-100 px-3 py-1.5 rounded hover:bg-cyan-100 flex items-center gap-1 transition-colors" | |
| > | |
| <Upload size={12} /> Import <ChevronDown size={10} /> | |
| </button> | |
| {showImportMenu && ( | |
| <div className="absolute right-0 top-full mt-1 w-48 bg-white border border-gray-200 rounded-lg shadow-xl z-40 py-1 flex flex-col animate-in fade-in slide-in-from-top-2"> | |
| <button | |
| onClick={openLinkModal} | |
| className="text-left px-4 py-2 hover:bg-gray-50 text-xs font-medium text-gray-700 flex items-center gap-2 w-full" | |
| > | |
| <LinkIcon size={14} className="text-blue-500" /> From Link / Cloud | |
| </button> | |
| <label className="text-left px-4 py-2 hover:bg-gray-50 text-xs font-medium text-gray-700 flex items-center gap-2 cursor-pointer w-full"> | |
| <FileImage size={14} className="text-green-500"/> From Screenshot | |
| <input type="file" className="hidden" onChange={handleFileUpload} accept=".json,.jpg,.png,.xlsx" /> | |
| </label> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| {/* TABS */} | |
| <div className="flex border-b border-gray-200"> | |
| <button | |
| onClick={() => setActiveTab('weekend')} | |
| className={`flex-1 py-3 text-xs font-bold uppercase tracking-wider border-b-2 transition-colors ${activeTab === 'weekend' ? 'border-cyan-500 text-cyan-600 bg-cyan-50' : 'border-transparent text-gray-400 hover:text-gray-600'}`} | |
| > | |
| Weekend | |
| </button> | |
| <button | |
| onClick={() => setActiveTab('weekday')} | |
| className={`flex-1 py-3 text-xs font-bold uppercase tracking-wider border-b-2 transition-colors ${activeTab === 'weekday' ? 'border-pink-500 text-pink-600 bg-pink-50' : 'border-transparent text-gray-400 hover:text-gray-600'}`} | |
| > | |
| Weekday | |
| </button> | |
| <button | |
| onClick={() => setActiveTab('footer')} | |
| className={`flex-1 py-3 text-xs font-bold uppercase tracking-wider border-b-2 transition-colors ${activeTab === 'footer' ? 'border-yellow-500 text-yellow-700 bg-yellow-50' : 'border-transparent text-gray-400 hover:text-gray-600'}`} | |
| > | |
| Footer | |
| </button> | |
| </div> | |
| {/* LIST */} | |
| <div className={`flex-1 overflow-y-auto p-4 space-y-3 ${activeTab === 'weekend' ? 'bg-cyan-50/30' : activeTab === 'weekday' ? 'bg-pink-50/30' : 'bg-yellow-50/30'}`} ref={inventoryListRef}> | |
| {inventoryDeals.length === 0 && ( | |
| <div className="text-center py-8 text-gray-400 text-xs italic">No deals in this section.</div> | |
| )} | |
| {inventoryDeals.map((deal) => ( | |
| <div key={deal.id} className="bg-white border border-gray-200 p-3 rounded-lg shadow-sm hover:shadow-md transition-all group relative"> | |
| <div className="flex justify-between items-center mb-2"> | |
| <span className={`text-[10px] font-bold px-2 py-0.5 rounded uppercase ${ | |
| deal.type === 'weekend' ? 'bg-cyan-100 text-cyan-800' : | |
| deal.type === 'weekday' ? 'bg-pink-100 text-pink-800' : | |
| 'bg-yellow-100 text-yellow-800' | |
| }`}> | |
| {deal.type} | |
| </span> | |
| <div className="flex gap-2"> | |
| <button onClick={() => deleteDeal(deal.id)} className="text-gray-300 hover:text-red-500 transition-colors"><Trash2 size={14} /></button> | |
| </div> | |
| </div> | |
| {deal.type === 'footer' ? ( | |
| <div className="space-y-2"> | |
| <div className="flex items-center gap-2"> | |
| <label className="flex-1 flex items-center justify-center gap-2 p-2 border border-dashed border-gray-300 rounded hover:bg-yellow-50 cursor-pointer group transition-colors bg-gray-50"> | |
| <ImageIcon size={14} className="text-gray-400 group-hover:text-yellow-600"/> | |
| <span className="text-[10px] font-bold text-gray-500 group-hover:text-yellow-700 uppercase"> | |
| {deal.footerLogo ? 'Change Logo' : 'Brand Logo'} | |
| </span> | |
| <input type="file" className="hidden" onChange={(e) => handleFooterLogoUpload(deal.id, e)} accept="image/*"/> | |
| </label> | |
| {deal.footerLogo && ( | |
| <div className="w-9 h-9 rounded bg-white flex items-center justify-center border border-gray-200 shrink-0"> | |
| <img src={deal.footerLogo} alt="Brand" className="w-7 h-7 object-contain" /> | |
| </div> | |
| )} | |
| </div> | |
| <div className="grid grid-cols-2 gap-2"> | |
| <textarea rows={2} value={deal.footerSplitLeft || ''} onChange={(e) => updateDeal(deal.id, 'footerSplitLeft', e.target.value)} placeholder="Left Text" className="text-xs border border-gray-200 rounded p-2 w-full font-mono bg-gray-50 focus:bg-white focus:border-yellow-400 outline-none" /> | |
| <textarea rows={2} value={deal.footerSplitRight || ''} onChange={(e) => updateDeal(deal.id, 'footerSplitRight', e.target.value)} placeholder="Right Text" className="text-xs border border-gray-200 rounded p-2 w-full font-mono bg-gray-50 focus:bg-white focus:border-yellow-400 outline-none" /> | |
| </div> | |
| </div> | |
| ) : ( | |
| <div className="grid grid-cols-[1fr_80px] gap-2"> | |
| <div> | |
| <input type="text" value={deal.brand} onChange={(e) => updateDeal(deal.id, 'brand', e.target.value)} className="w-full font-bold text-sm border-b border-gray-100 focus:border-cyan-500 outline-none pb-1 mb-1 bg-transparent" placeholder="Brand Name" /> | |
| <div className="flex gap-2 items-center"> | |
| <input type="text" value={deal.notes || ''} onChange={(e) => updateDeal(deal.id, 'notes', e.target.value)} className="flex-1 text-[10px] text-gray-500 border-b border-gray-100 focus:border-cyan-500 outline-none bg-transparent" placeholder="Notes/Exclusions" /> | |
| <select value={deal.product} onChange={(e) => updateDeal(deal.id, 'product', e.target.value)} className="w-[90px] text-[9px] font-bold text-gray-600 bg-gray-50 border border-gray-200 rounded p-1 focus:border-cyan-500 outline-none"> | |
| {CATEGORIES.map(cat => (<option key={cat} value={cat}>{cat}</option>))} | |
| </select> | |
| </div> | |
| </div> | |
| <input type="text" value={deal.discount} onChange={(e) => updateDeal(deal.id, 'discount', e.target.value)} className="text-right font-bold text-red-500 border-b border-gray-100 focus:border-red-500 outline-none h-8 self-start bg-transparent" placeholder="30% OFF" /> | |
| </div> | |
| )} | |
| </div> | |
| ))} | |
| <button onClick={addDeal} className="w-full py-4 border-2 border-dashed border-gray-300 text-gray-400 rounded-lg hover:border-cyan-400 hover:text-cyan-600 hover:bg-white transition-all text-sm font-bold flex items-center justify-center gap-2 uppercase tracking-wide bg-transparent"> | |
| <Plus size={16} /> Add {activeTab} Deal | |
| </button> | |
| </div> | |
| </div> | |
| {/* PREVIEW PANEL (Right) */} | |
| <div className={`flex-1 bg-gray-200 flex flex-col overflow-hidden transition-all duration-300 ${showInventory ? 'ml-[420px]' : 'ml-0'}`}> | |
| {/* Size Tabs */} | |
| <div className="h-12 bg-white border-b border-gray-200 flex items-center px-4 gap-2 overflow-x-auto no-scrollbar"> | |
| {OUTPUT_SIZES.map((size) => ( | |
| <button | |
| key={size.id} | |
| onClick={() => setSelectedSize(size)} | |
| className={`flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-bold whitespace-nowrap transition-all border ${ | |
| selectedSize.name === size.name | |
| ? 'bg-slate-800 text-white border-slate-800' | |
| : 'bg-white text-slate-600 border-gray-200 hover:border-gray-400' | |
| }`} | |
| > | |
| {size.icon} | |
| {size.name} <span className="opacity-50 text-[9px] ml-1 font-normal">({size.width}x{size.height})</span> | |
| </button> | |
| ))} | |
| </div> | |
| {/* Canvas Area */} | |
| <div className="flex-1 flex items-center justify-center overflow-hidden bg-slate-200/50 p-8" ref={containerRef}> | |
| <div | |
| ref={posterRef} | |
| id="poster-container" | |
| style={{ | |
| width: `${selectedSize.width}px`, | |
| height: `${selectedSize.height}px`, | |
| transform: `scale(${scale})`, | |
| transformOrigin: 'center', | |
| boxShadow: '0 30px 80px -20px rgba(0, 0, 0, 0.3)' | |
| }} | |
| className="bg-white relative flex flex-col select-none overflow-hidden shrink-0 transition-all duration-500 ease-out" | |
| > | |
| {/* --- POSTER CONTENT START --- */} | |
| {/* HEADER */} | |
| <div className={`${isPortrait ? 'h-[7%]' : 'h-[10%]'} bg-black flex items-center justify-between px-[3%] shrink-0 z-10`}> | |
| <div className="flex items-center gap-[2%] h-full overflow-hidden flex-1"> | |
| <div className="h-full flex items-center shrink-0"> | |
| <h1 className={`${isPortrait ? 'text-[3em]' : 'text-[4em]'} font-black text-white tracking-tight italic uppercase leading-none font-stencil transform scale-y-110`} style={{ fontFamily: 'Black Ops One, cursive' }}>CULTURE</h1> | |
| </div> | |
| <div className="h-[40%] w-0.5 bg-gray-600 shrink-0"></div> | |
| <div className="flex flex-col justify-center min-w-0 flex-1"> | |
| <h2 className={`${isPortrait ? 'text-[1.5em]' : 'text-[2.5em]'} font-bold text-white uppercase tracking-wide leading-none truncate`}>{locationName} WEEKLY DEALS</h2> | |
| <p className={`${isPortrait ? 'text-[0.6em]' : 'text-[0.8em]'} text-gray-400 uppercase tracking-widest mt-[1%] truncate w-full`}>WE PRICE MATCH ALL PRODUCTS</p> | |
| </div> | |
| </div> | |
| <input | |
| type="text" | |
| value={dateRange} | |
| onChange={(e) => setDateRange(e.target.value)} | |
| className={`${isPortrait ? 'text-[2.2em]' : 'text-[3.2em]'} font-bold text-yellow-400 tracking-wide leading-none shrink-0 pl-4 bg-transparent border-none outline-none text-right w-[40%] uppercase placeholder:text-yellow-400/50`} | |
| placeholder="NOV 17 - NOV 23" | |
| /> | |
| </div> | |
| {/* BODY CONTAINER */} | |
| <div className={`flex-1 bg-[#4a4a4a] m-[2%] rounded-[30px] p-[2%] flex flex-col gap-[2%] relative shadow-inner overflow-hidden`}> | |
| {/* TOP SECTION */} | |
| <div className={`flex ${isPortrait ? 'flex-col gap-[2%]' : 'flex-row gap-[2%]'} flex-1 min-h-0`}> | |
| {/* WEEKEND SECTION */} | |
| <div className={`${isPortrait ? 'w-full h-[50%]' : 'w-[60%] h-full'} flex flex-col`}> | |
| <div className="h-[15%] bg-[#00c2cb] rounded-t-2xl flex items-center px-[4%] justify-between shrink-0 shadow-md"> | |
| <span className="text-[2.5em] font-bold text-white uppercase tracking-wide truncate">WEEKEND DEALS</span> | |
| <div className="bg-white text-[#00c2cb] px-[3%] py-[0.5%] rounded-full text-[1em] font-black uppercase shrink-0">FRI - SUN</div> | |
| </div> | |
| <div className="flex-1 bg-[#4a4a4a] py-[2%] flex flex-col gap-[2%] overflow-hidden"> | |
| {weekendDeals.map((deal) => ( | |
| <div key={deal.id} className="bg-white rounded-full flex-1 w-full flex items-center px-[3%] justify-between shadow-sm shrink-0 overflow-hidden min-h-0"> | |
| <div className="flex items-baseline gap-[3%] overflow-hidden flex-1 pr-[2%] min-w-0"> | |
| <span className="text-[1.5em] font-black text-black uppercase truncate">{deal.brand}</span> | |
| <span className="text-[0.8em] font-bold text-gray-500 uppercase truncate flex-shrink-1 min-w-0">{deal.notes}</span> | |
| </div> | |
| <div className="bg-[#ef3e42] text-white px-[2%] w-[30%] h-[80%] rounded-full font-black text-[1.6em] italic flex items-center justify-center transform skew-x-[-10deg] shrink-0 shadow-sm"> | |
| <div className="transform skew-x-[10deg] truncate w-full text-center">{deal.discount}</div> | |
| </div> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| {/* WEEKDAY SECTION */} | |
| <div className={`${isPortrait ? 'w-full h-[50%]' : 'w-[40%] h-full'} flex flex-col`}> | |
| <div className="h-[15%] bg-[#ff4081] rounded-t-2xl flex items-center px-[4%] justify-between shrink-0 shadow-md"> | |
| <span className="text-[2.5em] font-bold text-white uppercase tracking-wide truncate">WEEKDAY</span> | |
| <div className="bg-white text-[#ff4081] px-[3%] py-[0.5%] rounded-full text-[1em] font-black uppercase shrink-0">MON-THU</div> | |
| </div> | |
| <div className="flex-1 py-[2%] flex flex-wrap content-stretch gap-[2%] overflow-hidden"> | |
| {weekdayDeals.map((deal, idx) => { | |
| const isLastItem = idx === weekdayDeals.length - 1; | |
| const isOddCount = weekdayDeals.length % 2 !== 0; | |
| return ( | |
| <div | |
| key={deal.id} | |
| className={`bg-gradient-to-b from-white to-pink-50 rounded-xl px-[8%] py-[6%] relative shadow-sm flex flex-col justify-between overflow-hidden flex-grow shrink-0 ${isLastItem && isOddCount ? 'basis-[100%]' : 'basis-[48%]'} min-h-0`} | |
| > | |
| <div className="flex flex-col w-full min-w-0"> | |
| <span className="text-[1.2em] font-black text-[#d81b60] uppercase leading-none truncate w-full">{deal.brand}</span> | |
| <span className="text-[0.9em] font-bold text-black uppercase leading-tight truncate w-full mt-[2%]">{deal.product}</span> | |
| {deal.notes && <span className="text-[0.6em] text-gray-500 uppercase mt-[2%] leading-none truncate w-full">{deal.notes}</span>} | |
| </div> | |
| <div className="self-end bg-[#ef3e42] text-white w-auto min-w-[45%] h-[2.4em] px-[0.5em] rounded-lg font-black text-[1.6em] shadow-md flex items-center justify-center leading-none truncate"> | |
| {deal.discount} | |
| </div> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| </div> | |
| </div> | |
| {/* FOOTER SECTION */} | |
| <div className={`${isPortrait ? 'h-[12%] mt-auto' : 'h-[25%]'} flex gap-[2%] shrink-0 w-full min-h-0`}> | |
| {footerDeals.map((deal, idx) => { | |
| const isSingleItem = !deal.footerSplitRight; | |
| return ( | |
| <div key={deal.id} className="rounded-2xl overflow-hidden flex flex-col bg-black shadow-lg h-full min-h-0 flex-1"> | |
| <div className="h-[25%] w-full bg-[#ffeb3b] shrink-0 flex items-center justify-center px-[5%] overflow-hidden"> | |
| {deal.footerLogo ? ( | |
| <img src={deal.footerLogo} alt="Brand" className="h-[80%] w-auto object-contain" /> | |
| ) : ( | |
| <span className="text-[0.7em] font-bold text-yellow-800/30 uppercase tracking-widest">Premium Spot</span> | |
| )} | |
| </div> | |
| <div className="flex-1 flex items-center justify-center px-[5%] text-center overflow-hidden min-w-0"> | |
| {isSingleItem ? ( | |
| <div className="flex flex-col items-center w-full min-w-0 py-[5%]"> | |
| <pre className="font-black text-white text-[1.4em] uppercase leading-tight font-sans whitespace-pre-wrap overflow-hidden text-ellipsis w-full px-1">{deal.footerSplitLeft || deal.brand}</pre> | |
| <div className="text-[0.8em] text-gray-400 uppercase mt-[2%] truncate w-full px-1">{deal.notes}</div> | |
| </div> | |
| ) : ( | |
| <div className="flex w-full h-full items-center"> | |
| <div className="flex-1 border-r border-gray-700 h-[80%] flex items-center justify-center overflow-hidden min-w-0 px-1 py-[5%]"> | |
| <pre className="font-black text-white text-[1.2em] uppercase leading-none font-sans whitespace-pre-wrap text-center w-full overflow-hidden text-ellipsis">{deal.footerSplitLeft}</pre> | |
| </div> | |
| <div className="flex-1 flex items-center justify-center overflow-hidden h-[80%] min-w-0 px-1 py-[5%]"> | |
| <pre className="font-black text-white text-[1.2em] uppercase leading-none font-sans whitespace-pre-wrap text-center w-full overflow-hidden text-ellipsis">{deal.footerSplitRight}</pre> | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| <div className="bg-gray-900 text-gray-500 text-[0.6em] text-center py-[1%] uppercase font-bold shrink-0"> | |
| NOVEMBER 2025 | |
| </div> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| {/* LEGEND STRIP */} | |
| <div className="absolute bottom-[1%] left-[2%] right-[2%] flex justify-between items-center text-[0.7em] text-gray-400 uppercase font-bold tracking-wider h-[2%] shrink-0 overflow-hidden"> | |
| <div className="flex gap-[2%] items-center"> | |
| <span className="whitespace-nowrap">CATEGORY LEGEND:</span> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Circle size={'1em'}/> ALL PRODUCTS</div> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Pill size={'1em'}/> PREROLLS</div> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Disc size={'1em'}/> VAPES</div> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Type size={'1em'}/> FLOWERS</div> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Droplet size={'1em'}/> EXTRACTS</div> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Coffee size={'1em'}/> EDIBLES</div> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Wine size={'1em'}/> BEVERAGES</div> | |
| <div className="flex items-center gap-[0.2em] whitespace-nowrap"><Briefcase size={'1em'}/> WELLNESS</div> | |
| </div> | |
| <div className="text-right leading-tight min-w-0 hidden lg:block"> | |
| <div className="text-white truncate">*DEALS AVAILABLE AT {locationName}</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| }; | |
| const root = ReactDOM.createRoot(document.getElementById('root')); | |
| root.render(<DealCardMaker />); | |
| </script> | |
| </body> | |
| </html> |