import CodeEditor from '../components/CodeEditor'; import { useEffect, useState } from 'react'; import ColorPicker from 'react-best-gradient-color-picker'; import Accordion from '../components/Accordian'; import Switch from '../components/Switch'; import { sendThemeUpdate } from '../hooks/ThemeManagment'; import { XMarkIcon } from '@heroicons/react/24/outline'; function ThemeCreator() { const [theme, setTheme] = useState({ name: '', description: '', defaultColour: '', CanChangeColour: true, CustomCSS: '', CustomImages: [] }); const generateImageId = () => { return '_' + Math.random().toString(36).substr(2, 9); }; const handleImageUpload = (event: React.ChangeEvent) => { const file = event.target.files?.[0]; if (file) { const reader = new FileReader(); reader.onload = () => { const imageUrl = reader.result as string; const imageId = generateImageId(); const variableName = `custom-image-${theme.CustomImages.length}`; const updatedTheme = { ...theme, CustomImages: [...theme.CustomImages, { id: imageId, url: imageUrl, variableName }], }; setTheme(updatedTheme); sendThemeUpdate(updatedTheme); }; reader.readAsDataURL(file); } }; const handleRemoveImage = (imageId: string) => { const updatedTheme = { ...theme, CustomImages: theme.CustomImages.filter((image) => image.id !== imageId), }; setTheme(updatedTheme); }; const handleImageVariableChange = (imageId: string, variableName: string) => { const updatedTheme = { ...theme, CustomImages: theme.CustomImages.map((image) => image.id === imageId ? { ...image, variableName } : image ), }; setTheme(updatedTheme); }; function CodeUpdate(value: string) { setTheme((prevTheme) => ({ ...prevTheme, CustomCSS: value, })); } const saveTheme = () => { // Save the theme to the database } useEffect(() => { sendThemeUpdate(theme); }, [theme]); return (

Theme Creator

Theme Name
setTheme({ ...theme, name: e.target.value })} className='w-full p-2 mb-4 transition-all duration-300 rounded-lg focus:outline-none ring-0 focus:ring-1 ring-zinc-100 dark:ring-zinc-700 dark:bg-zinc-900 dark:text-white' />
Description (optional)