diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 6e37df8..5c43466 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState, ChangeEvent } from "react"; import ImageUpload from "./components/ImageUpload"; import CodePreview from "./components/CodePreview"; import Preview from "./components/Preview"; @@ -14,7 +14,9 @@ import { } from "react-icons/fa"; import { Switch } from "./components/ui/switch"; +// import { Label } from "./components/ui/label"; import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs"; import SettingsDialog from "./components/SettingsDialog"; @@ -49,6 +51,8 @@ function App() { const [appState, setAppState] = useState(AppState.INITIAL); const [generatedCode, setGeneratedCode] = useState(""); + const [enableCustomTailwindConfig, setEnableCustomTailwindConfig] = useState(false); + const [inputMode, setInputMode] = useState<"image" | "video">("image"); const [referenceImages, setReferenceImages] = useState([]); @@ -394,6 +398,44 @@ function App() { setAppState(AppState.CODE_READY); } + const handleFileChange = (event: ChangeEvent) => { + const target = event.target as HTMLInputElement; + const file: File = (target.files as FileList)[0]; + if (file) { + const reader = new FileReader(); + reader.onload = (e) => { + const content = e!.target!.result; + if (typeof content === 'string') { + setSettings((s: Settings) => ({ + ...s, + tailwindConfig: content, + })); + } else { + toast.error('Please select a valid Tailwind config file'); + } + }; + reader.readAsText(file); + } + }; + + const handleRemoveFile = () => { + try { + const input = document.getElementById('config-file') as HTMLInputElement; + const dt = new DataTransfer(); + if(input == null) { + return; + } + input.files = dt.files + setSettings((s: Settings) => ({ + ...s, + tailwindConfig: null, + })); + } catch (err) { + toast.error('Please select a valid Tailwind config file'); + } + }; + + return (
{IS_RUNNING_ON_CLOUD && } @@ -426,6 +468,29 @@ function App() { } /> +
+ Enable custom Tailwind configuration: + + setEnableCustomTailwindConfig(!enableCustomTailwindConfig) + } + /> +
+ + {enableCustomTailwindConfig && (
+ + +
)} + {showReactWarning && (
Sorry - React is not currently working with GPT-4 Turbo. Please diff --git a/frontend/src/components/SettingsDialog.tsx b/frontend/src/components/SettingsDialog.tsx index 0c3989c..79ae01d 100644 --- a/frontend/src/components/SettingsDialog.tsx +++ b/frontend/src/components/SettingsDialog.tsx @@ -1,4 +1,4 @@ -import React, { ChangeEvent } from "react"; +import React from "react"; import { Dialog, DialogClose, @@ -36,24 +36,6 @@ function SettingsDialog({ settings, setSettings }: Props) { })); }; - const handleFileChange = (event: ChangeEvent) => { - const target= event.target as HTMLInputElement; - const file: File = (target.files as FileList)[0]; - if (file) { - const reader = new FileReader(); - reader.onload = (e) => { - const content = e!.target!.result; - // Here you can set the file content to the settings - console.log(content); - setSettings((s: any) => ({ - ...s, - tailwindConfig: content, - })); - }; - reader.readAsText(file); - } - }; - return ( @@ -236,27 +218,6 @@ function SettingsDialog({ settings, setSettings }: Props) { - - - - Tailwind Configuration - -
- -
- -
-
-
-
-