CoolFace
Apppublic

admin08077/Githubgemini

sourceHugging Faceotherupdated 10mo agoView on Hugging Face
0likes
ColorPaletteGenerator-Cvsu53-R.js.map1 linesDownload Raw Back to assets
1{"version":3,"file":"ColorPaletteGenerator-Cvsu53-R.js","sources":["../../components/features/ColorPaletteGenerator.tsx"],"sourcesContent":["import React, { useState, useCallback } from 'react';\nimport { HexColorPicker } from 'react-colorful';\nimport { generateColorPalette } from '../../services/index.ts';\nimport { SparklesIcon } from '../icons.tsx';\nimport { LoadingSpinner } from '../shared/index.tsx';\n\nexport const ColorPaletteGenerator: React.FC = () => {\n    const [baseColor, setBaseColor] = useState(\"#0047AB\");\n    const [palette, setPalette] = useState<string[]>(['#0047AB', '#3366CC', '#6688D1', '#99AADD', '#CCD3E8', '#F0F2F5']);\n    const [isLoading, setIsLoading] = useState<boolean>(false);\n    const [error, setError] = useState<string>('');\n\n    const handleGenerate = useCallback(async () => {\n        setIsLoading(true);\n        setError('');\n        try {\n            const result = await generateColorPalette(baseColor);\n            setPalette(result.colors);\n        } catch (err) {\n            const errorMessage = err instanceof Error ? err.message : 'An unknown error occurred.';\n            setError(`Failed to generate palette: ${errorMessage}`);\n        } finally {\n            setIsLoading(false);\n        }\n    }, [baseColor]);\n\n    const handleCopy = (color: string) => {\n        navigator.clipboard.writeText(color);\n    };\n\n    return (\n        <div className=\"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary\">\n            <header className=\"mb-6 text-center\">\n                <h1 className=\"text-3xl font-bold flex items-center justify-center\">\n                    <SparklesIcon />\n                    <span className=\"ml-3\">AI Color Palette Generator</span>\n                </h1>\n                <p className=\"text-text-secondary mt-1\">Pick a base color and let Gemini design a beautiful palette for you.</p>\n            </header>\n            <div className=\"flex-grow flex flex-col md:flex-row items-center justify-center gap-8\">\n                <div className=\"flex flex-col items-center gap-4\">\n                     <HexColorPicker color={baseColor} onChange={setBaseColor} className=\"!w-64 !h-64\"/>\n                     <div className=\"p-2 bg-surface rounded-md font-mono text-lg border border-border\" style={{color: baseColor}}>{baseColor}</div>\n                      <button\n                        onClick={handleGenerate}\n                        disabled={isLoading}\n                        className=\"btn-primary w-full flex items-center justify-center px-6 py-3\"\n                    >\n                        {isLoading ? <LoadingSpinner /> : 'Generate Palette'}\n                    </button>\n                    {error && <p className=\"text-red-500 text-sm mt-2\">{error}</p>}\n                </div>\n                <div className=\"flex flex-col gap-2 w-full max-w-sm\">\n                    <label className=\"text-sm font-medium text-text-secondary mb-2\">Generated Palette:</label>\n                    {isLoading ? (\n                         <div className=\"flex items-center justify-center h-48\"><LoadingSpinner /></div>\n                    ) : (\n                        palette.map((color) => (\n                            <div key={color} className=\"group flex items-center justify-between p-4 rounded-md shadow-md border border-border\" style={{ backgroundColor: color }}>\n                                <span className=\"font-mono font-bold text-black/70 mix-blend-overlay\">{color}</span>\n                                <button\n                                    onClick={() => handleCopy(color)}\n                                    className=\"opacity-0 group-hover:opacity-100 transition-opacity bg-white/30 hover:bg-white/50 px-3 py-1 rounded text-xs text-black font-semibold backdrop-blur-sm\">\n                                    Copy\n                                </button>\n                            </div>\n                        ))\n                    )}\n                </div>\n            </div>\n        </div>\n    );\n};"],"names":["ColorPaletteGenerator","baseColor","setBaseColor","useState","palette","setPalette","isLoading","setIsLoading","error","setError","handleGenerate","useCallback","result","generateColorPalette","err","errorMessage","handleCopy","color","jsxs","jsx","SparklesIcon","HexColorPicker","LoadingSpinner"],"mappings":"mWAMO,MAAMA,EAAkC,IAAM,CACjD,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAAA,SAAS,SAAS,EAC9C,CAACC,EAASC,CAAU,EAAIF,EAAAA,SAAmB,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,SAAS,CAAC,EAC7G,CAACG,EAAWC,CAAY,EAAIJ,EAAAA,SAAkB,EAAK,EACnD,CAACK,EAAOC,CAAQ,EAAIN,EAAAA,SAAiB,EAAE,EAEvCO,EAAiBC,EAAAA,YAAY,SAAY,CAC3CJ,EAAa,EAAI,EACjBE,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