Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Merge branch 'main' into pr/122
Abi Raja45a64326f663
diff --cc frontend/src/App.tsxindex 060a6f3c,ed416da8..58e07e42--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@@ -57,8 -58,7 +59,8 @@@ function App());const [outputSettings, setOutputSettings] = useState<OutputSettings>({css: CSSOption.TAILWIND,- js: JSFrameworkOption.VANILLA,+ components: UIComponentOption.HTML,+ js: JSFrameworkOption.NO_FRAMEWORK,});const [shouldIncludeResultImage, setShouldIncludeResultImage] =useState<boolean>(false);diff --cc frontend/src/components/OutputSettingsSection.tsxindex 8f4200a0,cc927a59..9b734050--- a/frontend/src/components/OutputSettingsSection.tsx+++ b/frontend/src/components/OutputSettingsSection.tsx@@@ -5,16 -5,11 +5,18 @@@ importSelectItem,SelectTrigger,} from "./ui/select";- import { CSSOption, UIComponentOption, JSFrameworkOption, OutputSettings } from "../types";-import { CSSOption, JSFrameworkOption, OutputSettings } from "../types";+import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- } from "./ui/accordion";++ CSSOption,++ UIComponentOption,++ JSFrameworkOption,++ OutputSettings,++} from "../types";+import { capitalize } from "../lib/utils";import toast from "react-hot-toast";+import { useEffect } from "react";+ import { Label } from "@radix-ui/react-label";+ import { Button } from "./ui/button";+ import { Popover, PopoverTrigger, PopoverContent } from "./ui/popover";function displayCSSOption(option: CSSOption) {switch (option) {@@@ -55,7 -100,6 +107,7 @@@ function OutputSettingsSection(return {css: CSSOption.TAILWIND,js: JSFrameworkOption.REACT,- components: UIComponentOption.HTML++ components: UIComponentOption.HTML,};} else {return {@@@ -71,7 -115,6 +123,7 @@@setOutputSettings(() => ({css: CSSOption.TAILWIND,js: value as JSFrameworkOption,- components: UIComponentOption.HTML++ components: UIComponentOption.HTML,}));} else {setOutputSettings((prev) => ({@@@ -81,143 -124,77 +133,197 @@@}};+ const onUIComponentOptionChange = (value: string) => {+ if (value === UIComponentOption.IONIC) {+ setOutputSettings(() => ({+ css: CSSOption.TAILWIND,- js: JSFrameworkOption.VANILLA,- components: value as UIComponentOption++ js: JSFrameworkOption.NO_FRAMEWORK,++ components: value as UIComponentOption,+ }));+ } else {+ setOutputSettings((prev) => ({+ ...prev,+ components: value as UIComponentOption,+ }));+ }+ };+-- const checkUIComponentOptionOrDefault = (valueItem: UIComponentOption ) : UIComponentOption => {++ const checkUIComponentOptionOrDefault = (++ valueItem: UIComponentOption++ ): UIComponentOption => {+ switch (valueItem) {+ case UIComponentOption.IONIC:- if (outputSettings.js != JSFrameworkOption.VANILLA || outputSettings.css != CSSOption.TAILWIND) {- return UIComponentOption.HTML++ if (++ outputSettings.js != JSFrameworkOption.NO_FRAMEWORK ||++ outputSettings.css != CSSOption.TAILWIND++ ) {++ return UIComponentOption.HTML;+ }+ }+ return valueItem;- }++ };+- const checkCSSOptionOrDefault = (valueItem: CSSOption ) : CSSOption => {++ const checkCSSOptionOrDefault = (valueItem: CSSOption): CSSOption => {+ switch (valueItem) {+ default:+ return valueItem;+ }- }++ };+- const checkJSFrameworkOptionOrDefault = (valueItem: JSFrameworkOption ) : JSFrameworkOption => {++ const checkJSFrameworkOptionOrDefault = (++ valueItem: JSFrameworkOption++ ): JSFrameworkOption => {+ switch (valueItem) {+ case JSFrameworkOption.REACT:- if(outputSettings.css != CSSOption.TAILWIND) {- return JSFrameworkOption.VANILLA++ if (outputSettings.css != CSSOption.TAILWIND) {++ return JSFrameworkOption.NO_FRAMEWORK;+ }+ break;+ }+ return valueItem;- }++ };++ useEffect(() => {+ checkOutputSettingsOptions();+ }, [outputSettings]);++ const checkOutputSettingsOptions = () => {- if ( isHiddenOption(outputSettings.css) || isHiddenOption(outputSettings.js) || isHiddenOption(outputSettings.components))- {- setOutputSettings((prev) => {- return {- css: checkCSSOptionOrDefault(prev.css),- js: checkJSFrameworkOptionOrDefault(prev.js),- components: checkUIComponentOptionOrDefault(prev.components),- };- })- }++ if (++ isHiddenOption(outputSettings.css) ||++ isHiddenOption(outputSettings.js) ||++ isHiddenOption(outputSettings.components)++ ) {++ setOutputSettings((prev) => {++ return {++ css: checkCSSOptionOrDefault(prev.css),++ js: checkJSFrameworkOptionOrDefault(prev.js),++ components: checkUIComponentOptionOrDefault(prev.components),++ };++ });++ }+ };+- const isHiddenOption = ( option : CSSOption| JSFrameworkOption | UIComponentOption ) : boolean => {- if (Object.values(CSSOption).includes(option as CSSOption)){- return checkCSSOptionOrDefault(option as CSSOption) != option++ const isHiddenOption = (++ option: CSSOption | JSFrameworkOption | UIComponentOption++ ): boolean => {++ if (Object.values(CSSOption).includes(option as CSSOption)) {++ return checkCSSOptionOrDefault(option as CSSOption) != option;+ }- if (Object.values(JSFrameworkOption).includes(option as JSFrameworkOption)){- return checkJSFrameworkOptionOrDefault(option as JSFrameworkOption) != option++ if (++ Object.values(JSFrameworkOption).includes(option as JSFrameworkOption)++ ) {++ return (++ checkJSFrameworkOptionOrDefault(option as JSFrameworkOption) != option++ );+ }- if (Object.values(UIComponentOption).includes(option as UIComponentOption)){- return checkUIComponentOptionOrDefault(option as UIComponentOption) != option++ if (++ Object.values(UIComponentOption).includes(option as UIComponentOption)++ ) {++ return (++ checkUIComponentOptionOrDefault(option as UIComponentOption) != option++ );+ }- return true- }++ return true;++ };+return (- <Accordion type="single" collapsible className="w-full">- <AccordionItem value="item-1">- <AccordionTrigger>- <div className="flex gap-x-2">Output Settings </div>- </AccordionTrigger>- <AccordionContent className="gap-y-2 flex flex-col pt-2">- <div className="flex justify-between items-center pr-2">- <span className="text-sm">CSS</span>- <Select value={outputSettings.css} onValueChange={onCSSValueChange}>- <SelectTrigger className="w-[180px]">- {displayCSSOption(outputSettings.css)}- </SelectTrigger>- <SelectContent>- <SelectGroup>- <SelectItem value={CSSOption.TAILWIND}>Tailwind</SelectItem>- <SelectItem value={CSSOption.BOOTSTRAP}>Bootstrap</SelectItem>- </SelectGroup>- </SelectContent>- </Select>- </div>- <div className="flex justify-between items-center pr-2">- <span className="text-sm">JS Framework</span>- <Select- value={outputSettings.js}- onValueChange={onJsFrameworkChange}- >- <SelectTrigger className="w-[180px]">- {capitalize(outputSettings.js)}- </SelectTrigger>- <SelectContent>- <SelectGroup>- <SelectItem value={JSFrameworkOption.VANILLA}>- Vanilla- </SelectItem>- <SelectItem value={JSFrameworkOption.REACT} disabled={isHiddenOption(JSFrameworkOption.REACT)}>React</SelectItem>- </SelectGroup>- </SelectContent>- </Select>- </div>- <div className="flex justify-between items-center pr-2">- <span className="text-sm">Component Library</span>- <Select- value={outputSettings.components}- onValueChange={onUIComponentOptionChange}- >- <SelectTrigger className="w-[180px]">- {capitalize(outputSettings.components)}- </SelectTrigger>- <SelectContent>- <SelectGroup>- <SelectItem value={UIComponentOption.HTML}>HTML</SelectItem>- <SelectItem value={UIComponentOption.IONIC} disabled={isHiddenOption(UIComponentOption.IONIC)}>Ionic</SelectItem>- </SelectGroup>- </SelectContent>- </Select>- </div>- <div className="flex justify-between pr-2 mt-2">- <span className="text-sm text-gray-500">Output: {outputSettings.js} + {outputSettings.css} + {outputSettings.components}</span>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>+ <div className="flex flex-col gap-y-2 justify-between text-sm">+ {generateDisplayString(outputSettings)}{" "}+ {!shouldDisableUpdates && (+ <Popover>+ <PopoverTrigger asChild>+ <Button variant="outline">Customize</Button>+ </PopoverTrigger>+ <PopoverContent className="w-80 text-sm">+ <div className="grid gap-4">+ <div className="space-y-2">+ <h4 className="font-medium leading-none">Code Settings</h4>+ <p className="text-muted-foreground">+ Customize your code output+ </p>+ </div>+ <div className="grid gap-2">+ <div className="grid grid-cols-3 items-center gap-4">+ <Label htmlFor="output-settings-js">JS</Label>+ <Select+ value={outputSettings.js}+ onValueChange={onJsFrameworkChange}+ >+ <SelectTrigger+ className="col-span-2 h-8"+ id="output-settings-js"+ >+ {displayJSOption(outputSettings.js)}+ </SelectTrigger>+ <SelectContent>+ <SelectGroup>+ <SelectItem value={JSFrameworkOption.NO_FRAMEWORK}>+ No Framework+ </SelectItem>+ <SelectItem value={JSFrameworkOption.REACT}>+ React+ </SelectItem>+ </SelectGroup>+ </SelectContent>+ </Select>+ </div>+ <div className="grid grid-cols-3 items-center gap-4">+ <Label htmlFor="output-settings-css">CSS</Label>+ <Select+ value={outputSettings.css}+ onValueChange={onCSSValueChange}+ >+ <SelectTrigger+ className="col-span-2 h-8"+ id="output-settings-css"+ >+ {displayCSSOption(outputSettings.css)}+ </SelectTrigger>+ <SelectContent>+ <SelectGroup>+ <SelectItem value={CSSOption.TAILWIND}>+ Tailwind+ </SelectItem>+ <SelectItem value={CSSOption.BOOTSTRAP}>+ Bootstrap+ </SelectItem>+ </SelectGroup>+ </SelectContent>+ </Select>+ </div>++ <div className="grid grid-cols-3 items-center gap-4">++ <Label htmlFor="output-settings-component">Components</Label>++ <Select++ value={outputSettings.components}++ onValueChange={onUIComponentOptionChange}++ >++ <SelectTrigger++ id="output-settings-component"++ className="col-span-2 h-8"++ >++ {capitalize(outputSettings.components)}++ </SelectTrigger>++ <SelectContent>++ <SelectGroup>++ <SelectItem value={UIComponentOption.HTML}>++ HTML++ </SelectItem>++ <SelectItem++ value={UIComponentOption.IONIC}++ disabled={isHiddenOption(UIComponentOption.IONIC)}++ >++ Ionic++ </SelectItem>++ </SelectGroup>++ </SelectContent>++ </Select>++ </div>+ </div>+ </div>+ </PopoverContent>+ </Popover>+ )}+ </div>);}