Files
figlet-ui/components/converter/FigletConverter.tsx

289 lines
9.4 KiB
TypeScript
Raw Permalink Normal View History

'use client';
import * as React from 'react';
import { TextInput } from './TextInput';
import { FontPreview } from './FontPreview';
import { FontSelector } from './FontSelector';
import { TextTemplates } from './TextTemplates';
import { HistoryPanel } from './HistoryPanel';
import { ComparisonMode } from './ComparisonMode';
import { Button } from '@/components/ui/Button';
import { Card } from '@/components/ui/Card';
import { GitCompare } from 'lucide-react';
import { textToAscii } from '@/lib/figlet/figletService';
import { getFontList } from '@/lib/figlet/fontLoader';
import { debounce } from '@/lib/utils/debounce';
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
import { addRecentFont } from '@/lib/storage/favorites';
import { addToHistory, type HistoryItem } from '@/lib/storage/history';
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
import { decodeFromUrl, updateUrl, getShareableUrl } from '@/lib/utils/urlSharing';
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
import { useToast } from '@/components/ui/Toast';
import { cn } from '@/lib/utils/cn';
import type { FigletFont } from '@/types/figlet';
export function FigletConverter() {
const [text, setText] = React.useState('Figlet UI');
const [selectedFont, setSelectedFont] = React.useState('Standard');
const [asciiArt, setAsciiArt] = React.useState('');
const [fonts, setFonts] = React.useState<FigletFont[]>([]);
const [isLoading, setIsLoading] = React.useState(false);
const [isComparisonMode, setIsComparisonMode] = React.useState(false);
const [comparisonFonts, setComparisonFonts] = React.useState<string[]>([]);
const [comparisonResults, setComparisonResults] = React.useState<Record<string, string>>({});
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
const { addToast } = useToast();
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
// Load fonts and check URL params on mount
React.useEffect(() => {
getFontList().then(setFonts);
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
// Check for URL parameters
const urlState = decodeFromUrl();
if (urlState) {
if (urlState.text) setText(urlState.text);
if (urlState.font) setSelectedFont(urlState.font);
}
}, []);
// Generate ASCII art
const generateAsciiArt = React.useCallback(
debounce(async (inputText: string, fontName: string) => {
if (!inputText) {
setAsciiArt('');
setIsLoading(false);
return;
}
setIsLoading(true);
try {
const result = await textToAscii(inputText, fontName);
setAsciiArt(result);
} catch (error) {
console.error('Error generating ASCII art:', error);
setAsciiArt('Error generating ASCII art. Please try a different font.');
} finally {
setIsLoading(false);
}
}, 300),
[]
);
// Trigger generation when text or font changes
React.useEffect(() => {
generateAsciiArt(text, selectedFont);
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
// Track recent fonts
if (selectedFont) {
addRecentFont(selectedFont);
}
// Update URL
updateUrl(text, selectedFont);
}, [text, selectedFont, generateAsciiArt]);
// Copy to clipboard
const handleCopy = async () => {
if (!asciiArt) return;
try {
await navigator.clipboard.writeText(asciiArt);
addToHistory(text, selectedFont, asciiArt);
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
addToast('Copied to clipboard!', 'success');
} catch (error) {
console.error('Failed to copy:', error);
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
addToast('Failed to copy', 'error');
}
};
// Download as text file
const handleDownload = () => {
if (!asciiArt) return;
const blob = new Blob([asciiArt], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `figlet-${selectedFont}-${Date.now()}.txt`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
};
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
// Share (copy URL to clipboard)
const handleShare = async () => {
const shareUrl = getShareableUrl(text, selectedFont);
try {
await navigator.clipboard.writeText(shareUrl);
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
addToast('Shareable URL copied!', 'success');
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
} catch (error) {
console.error('Failed to copy URL:', error);
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
addToast('Failed to copy URL', 'error');
feat: add dark mode, fuzzy search, favorites, and URL sharing Implemented Phases 5-7 of the implementation plan with major UX enhancements: **Dark Mode (Phase 9)** - Added ThemeToggle component with localStorage persistence - System preference detection - Smooth theme transitions - Moon/Sun icon toggle in header **Fuzzy Search with Fuse.js (Phase 5)** - Integrated Fuse.js for intelligent font search - 30% threshold for flexible matching - Search by font name and filename - Clear button for search input - Much better than simple string matching **Favorites & Recent Fonts System (Phase 7)** - localStorage-based favorites with heart icon toggle - Auto-tracking of recently used fonts (max 10) - Filter tabs: All / Favorites / Recent - Favorite hearts visible on hover - Red filled heart for favorited fonts - Stats showing favorite and recent counts **Shareable URLs (Phase 6)** - Encode text + font in URL parameters - Auto-load from URL on page load - Share button copies URL to clipboard - Clean URL updates without page reload - Perfect for sharing ASCII art creations **Enhanced Font Selector** - 3-tab filter system (All/Favorites/Recent) - Visual feedback for selected fonts - Empty states for each filter - Font count statistics - Heart icon for quick favoriting - Recent fonts sorted by usage order **UX Improvements** - Copy feedback ("Copied to clipboard! ✓") - Share feedback ("URL copied to clipboard! ✓") - Responsive button layout - Better empty states - Improved accessibility with aria-labels **Tech Highlights** - Client-side localStorage management - URL encoding/decoding utilities - React hooks for state management - Fuse.js fuzzy search integration - Theme persistence across sessions The app now has professional-grade features rivaling any modern web app! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:28:27 +01:00
}
};
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
// Random font
const handleRandomFont = () => {
if (fonts.length === 0) return;
const randomIndex = Math.floor(Math.random() * fonts.length);
setSelectedFont(fonts[randomIndex].name);
addToast(`Random font: ${fonts[randomIndex].name}`, 'info');
};
const handleSelectTemplate = (templateText: string) => {
setText(templateText);
addToast(`Template applied: ${templateText}`, 'info');
};
const handleSelectHistory = (item: HistoryItem) => {
setText(item.text);
setSelectedFont(item.font);
addToast(`Restored from history`, 'info');
};
// Comparison mode handlers
const handleToggleComparisonMode = () => {
const newMode = !isComparisonMode;
setIsComparisonMode(newMode);
if (newMode && comparisonFonts.length === 0) {
// Initialize with current font
setComparisonFonts([selectedFont]);
}
addToast(newMode ? 'Comparison mode enabled' : 'Comparison mode disabled', 'info');
};
const handleAddToComparison = (fontName: string) => {
if (comparisonFonts.includes(fontName)) {
addToast('Font already in comparison', 'info');
return;
}
if (comparisonFonts.length >= 6) {
addToast('Maximum 6 fonts for comparison', 'info');
return;
}
setComparisonFonts([...comparisonFonts, fontName]);
addToast(`Added ${fontName} to comparison`, 'success');
};
const handleRemoveFromComparison = (fontName: string) => {
setComparisonFonts(comparisonFonts.filter((f) => f !== fontName));
addToast(`Removed ${fontName} from comparison`, 'info');
};
const handleCopyComparisonFont = async (fontName: string, result: string) => {
try {
await navigator.clipboard.writeText(result);
addToHistory(text, fontName, result);
addToast(`Copied ${fontName} to clipboard!`, 'success');
} catch (error) {
console.error('Failed to copy:', error);
addToast('Failed to copy', 'error');
}
};
const handleDownloadComparisonFont = (fontName: string, result: string) => {
const blob = new Blob([result], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `figlet-${fontName}-${Date.now()}.txt`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
};
// Generate comparison results
React.useEffect(() => {
if (!isComparisonMode || comparisonFonts.length === 0 || !text) return;
const generateComparisons = async () => {
const results: Record<string, string> = {};
for (const fontName of comparisonFonts) {
try {
results[fontName] = await textToAscii(text, fontName);
} catch (error) {
console.error(`Error generating ASCII art for ${fontName}:`, error);
results[fontName] = 'Error generating ASCII art';
}
}
setComparisonResults(results);
};
generateComparisons();
}, [isComparisonMode, comparisonFonts, text]);
return (
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
{/* Left Column - Input and Preview */}
<div className="lg:col-span-2 space-y-6">
{/* Comparison Mode Toggle */}
<Card className="scale-in">
<div className="p-4 flex items-center justify-between">
<div className="flex items-center gap-2">
<GitCompare className={cn(
"h-4 w-4",
isComparisonMode ? "text-primary" : "text-muted-foreground"
)} />
<span className="text-sm font-medium">Comparison Mode</span>
{isComparisonMode && comparisonFonts.length > 0 && (
<span className="text-xs px-2 py-0.5 bg-primary/10 text-primary rounded-full font-medium slide-down">
{comparisonFonts.length} {comparisonFonts.length === 1 ? 'font' : 'fonts'}
</span>
)}
</div>
<Button
variant={isComparisonMode ? 'default' : 'outline'}
size="sm"
onClick={handleToggleComparisonMode}
className={cn(isComparisonMode && "shadow-lg")}
>
{isComparisonMode ? 'Disable' : 'Enable'}
</Button>
</div>
</Card>
<TextTemplates onSelectTemplate={handleSelectTemplate} />
<HistoryPanel onSelectHistory={handleSelectHistory} />
<TextInput
value={text}
onChange={setText}
placeholder="Type your text here..."
/>
{isComparisonMode ? (
<ComparisonMode
text={text}
selectedFonts={comparisonFonts}
fontResults={comparisonResults}
onRemoveFont={handleRemoveFromComparison}
onCopyFont={handleCopyComparisonFont}
onDownloadFont={handleDownloadComparisonFont}
/>
) : (
<FontPreview
text={asciiArt}
font={selectedFont}
isLoading={isLoading}
onCopy={handleCopy}
onDownload={handleDownload}
onShare={handleShare}
/>
)}
</div>
{/* Right Column - Font Selector */}
<div className="lg:col-span-1">
<FontSelector
fonts={fonts}
selectedFont={selectedFont}
onSelectFont={setSelectedFont}
feat: add toast notifications, random font, and font info display Major UX enhancements for better user feedback and discovery: **Toast Notification System** - Beautiful toast notifications with 3 types (success/error/info) - Auto-dismiss after 3 seconds - Slide-in animation from right - Color-coded by type (green/red/blue) - Dark mode support - Close button for manual dismiss - ToastProvider context for global access - Non-blocking UI overlay **Random Font Discovery** - Shuffle button in font selector - One-click random font selection - Toast notification shows selected font - Perfect for discovering new fonts - Located next to "Select Font" header **Enhanced Font Preview** - Font name badge display - Character count statistics - Line count statistics - Better visual hierarchy - Responsive stat display **Improved Feedback** - Toast on copy: "Copied to clipboard!" - Toast on share: "Shareable URL copied!" - Toast on random: "Random font: FontName" - Error toasts for failed operations - Removed temporary text replacement **Smooth Animations** - Slide-in animation for toasts - Fade-in animation class - Custom keyframe animations - CSS utility classes - Smooth transitions throughout **Technical Improvements** - useToast custom hook - Context-based state management - Auto-cleanup with setTimeout - Unique toast IDs - TypeScript types for toast system - Proper event propagation **Better UX** - No more jarring text replacements - Non-intrusive notifications - Professional feedback system - Discoverable random feature - Informative preview stats The app now feels polished and professional with proper user feedback! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 13:21:13 +01:00
onRandomFont={handleRandomFont}
isComparisonMode={isComparisonMode}
comparisonFonts={comparisonFonts}
onAddToComparison={handleAddToComparison}
/>
</div>
</div>
);
}