import React from 'react'; import { ColorScheme } from '../utils/colorSchemes'; import { generateYAML, generateJSON, generateXResources, generateTOML } from '../utils/exportFormats'; import Image from 'next/image'; import ColorPalette from './ColorPalette'; interface HistoryPopupProps { likedSchemes: ColorScheme[]; dislikedSchemes: ColorScheme[]; onClose: () => void; onClearHistory: () => void; // Add this line isDarkMode: boolean; outputFormat: string; } const HistoryPopup: React.FC = ({ likedSchemes, dislikedSchemes, onClose, onClearHistory, // Add this line isDarkMode, outputFormat }) => { const handleDownload = (scheme: ColorScheme) => { let content: string; let fileExtension: string; switch (outputFormat) { case 'json': content = generateJSON(scheme); fileExtension = 'json'; break; case 'xresources': content = generateXResources(scheme); fileExtension = 'Xresources'; break; case 'toml': content = generateTOML(scheme); fileExtension = 'toml'; break; case 'yaml': default: content = generateYAML(scheme); fileExtension = 'yaml'; } const blob = new Blob([content], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `${scheme.name.replace(/\s+/g, '_').toLowerCase()}.${fileExtension}`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }; const renderSchemeGrid = (schemes: ColorScheme[], title: string) => (

{title}

{schemes.map((scheme, index) => (

{scheme.name}

))}
); return (

Color Scheme History

{renderSchemeGrid(likedSchemes, "Liked Schemes")} {renderSchemeGrid(dislikedSchemes, "Disliked Schemes")}
); }; export default HistoryPopup;