Fix link titles, let history items be clickable, add cicd
Some checks failed
CI/CD Pipeline / build-and-test (push) Successful in 1m22s
CI/CD Pipeline / docker (push) Failing after 7s

This commit is contained in:
2024-09-10 15:07:54 -04:00
parent d3c2518c28
commit 7738605de3
3 changed files with 85 additions and 9 deletions

View File

@ -1,14 +1,15 @@
import React from 'react';
import { ColorScheme } from '../utils/colorSchemes';
import { ColorScheme, encodeThemeForUrl } from '../utils/colorSchemes';
import { generateYAML, generateJSON, generateXResources, generateTOML } from '../utils/exportFormats';
import Image from 'next/image';
import ColorPalette from './ColorPalette';
import { useRouter } from 'next/navigation';
interface HistoryPopupProps {
likedSchemes: ColorScheme[];
dislikedSchemes: ColorScheme[];
onClose: () => void;
onClearHistory: () => void; // Add this line
onClearHistory: () => void;
isDarkMode: boolean;
outputFormat: string;
}
@ -17,10 +18,12 @@ const HistoryPopup: React.FC<HistoryPopupProps> = ({
likedSchemes,
dislikedSchemes,
onClose,
onClearHistory, // Add this line
onClearHistory,
isDarkMode,
outputFormat
}) => {
const router = useRouter();
const handleDownload = (scheme: ColorScheme) => {
let content: string;
let fileExtension: string;
@ -55,19 +58,31 @@ const HistoryPopup: React.FC<HistoryPopupProps> = ({
URL.revokeObjectURL(url);
};
const handleThemeClick = (scheme: ColorScheme) => {
const encodedTheme = encodeThemeForUrl(scheme);
router.push(`/share/${encodedTheme}`);
};
const renderSchemeGrid = (schemes: ColorScheme[], title: string) => (
<div>
<h3 className="text-xl font-semibold mb-3">{title}</h3>
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-6">
{schemes.map((scheme, index) => (
<div key={`${scheme.name}-${index}`} className="bg-gray-100 dark:bg-gray-700 p-4 rounded-lg">
<div
key={`${scheme.name}-${index}`}
className="bg-gray-100 dark:bg-gray-700 p-4 rounded-lg cursor-pointer hover:shadow-lg transition-shadow duration-300"
onClick={() => handleThemeClick(scheme)}
>
<h3 className="text-sm font-semibold mb-2 truncate">{scheme.name}</h3>
<ColorPalette
colors={Object.values(scheme.colors.normal).concat(Object.values(scheme.colors.bright))}
size="small"
/>
<button
onClick={() => handleDownload(scheme)}
onClick={(e) => {
e.stopPropagation();
handleDownload(scheme);
}}
className="w-full bg-blue-500 text-white text-xs py-1 px-2 rounded hover:bg-blue-600 transition-colors duration-300 mt-2"
>
Download