feat: implement Figlet, Pastel, and Unit tools with a unified layout

- Add Figlet text converter with font selection and history
- Add Pastel color palette generator and manipulation suite
- Add comprehensive Units converter with category-based logic
- Introduce AppShell with Sidebar and Header for navigation
- Modernize theme system with CSS variables and new animations
- Update project configuration and dependencies
This commit is contained in:
2026-02-22 21:35:53 +01:00
parent ff6bb873eb
commit 2000623c67
540 changed files with 338653 additions and 809 deletions

View File

@@ -0,0 +1,80 @@
'use client';
import figlet from 'figlet';
import type { FigletOptions } from '@/types/figlet';
import { loadFont } from './fontLoader';
/**
* Convert text to ASCII art using figlet
*/
export async function textToAscii(
text: string,
fontName: string = 'Standard',
options: FigletOptions = {}
): Promise<string> {
if (!text) {
return '';
}
try {
// Load the font
const fontData = await loadFont(fontName);
if (!fontData) {
throw new Error(`Font ${fontName} could not be loaded`);
}
// Parse and load the font into figlet
figlet.parseFont(fontName, fontData);
// Generate ASCII art
return new Promise((resolve, reject) => {
figlet.text(
text,
{
font: fontName,
horizontalLayout: options.horizontalLayout || 'default',
verticalLayout: options.verticalLayout || 'default',
width: options.width,
whitespaceBreak: options.whitespaceBreak ?? true,
},
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result || '');
}
}
);
});
} catch (error) {
console.error('Error generating ASCII art:', error);
throw error;
}
}
/**
* Generate ASCII art synchronously (requires font to be pre-loaded)
*/
export function textToAsciiSync(
text: string,
fontName: string = 'Standard',
options: FigletOptions = {}
): string {
if (!text) {
return '';
}
try {
return figlet.textSync(text, {
font: fontName as any,
horizontalLayout: options.horizontalLayout || 'default',
verticalLayout: options.verticalLayout || 'default',
width: options.width,
whitespaceBreak: options.whitespaceBreak ?? true,
});
} catch (error) {
console.error('Error generating ASCII art (sync):', error);
return '';
}
}