update remaining variable names for GeneratedCodeConfig
This commit is contained in:
parent
3723c81a04
commit
7bc368d9bf
@ -18,13 +18,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs";
|
||||||
import SettingsDialog from "./components/SettingsDialog";
|
import SettingsDialog from "./components/SettingsDialog";
|
||||||
import {
|
import { AppState, CodeGenerationParams, EditorTheme, Settings } from "./types";
|
||||||
AppState,
|
|
||||||
CodeGenerationParams,
|
|
||||||
EditorTheme,
|
|
||||||
GeneratedCodeConfig,
|
|
||||||
Settings,
|
|
||||||
} from "./types";
|
|
||||||
import { IS_RUNNING_ON_CLOUD } from "./config";
|
import { IS_RUNNING_ON_CLOUD } from "./config";
|
||||||
import { PicoBadge } from "./components/PicoBadge";
|
import { PicoBadge } from "./components/PicoBadge";
|
||||||
import { OnboardingNote } from "./components/OnboardingNote";
|
import { OnboardingNote } from "./components/OnboardingNote";
|
||||||
@ -40,6 +34,7 @@ import HistoryDisplay from "./components/history/HistoryDisplay";
|
|||||||
import { extractHistoryTree } from "./components/history/utils";
|
import { extractHistoryTree } from "./components/history/utils";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import ImportCodeSection from "./components/ImportCodeSection";
|
import ImportCodeSection from "./components/ImportCodeSection";
|
||||||
|
import { Stack } from "./lib/stacks/types";
|
||||||
|
|
||||||
const IS_OPENAI_DOWN = false;
|
const IS_OPENAI_DOWN = false;
|
||||||
|
|
||||||
@ -60,7 +55,7 @@ function App() {
|
|||||||
screenshotOneApiKey: null,
|
screenshotOneApiKey: null,
|
||||||
isImageGenerationEnabled: true,
|
isImageGenerationEnabled: true,
|
||||||
editorTheme: EditorTheme.COBALT,
|
editorTheme: EditorTheme.COBALT,
|
||||||
generatedCodeConfig: GeneratedCodeConfig.HTML_TAILWIND,
|
generatedCodeConfig: Stack.HTML_TAILWIND,
|
||||||
// Only relevant for hosted version
|
// Only relevant for hosted version
|
||||||
isTermOfServiceAccepted: false,
|
isTermOfServiceAccepted: false,
|
||||||
accessCode: null,
|
accessCode: null,
|
||||||
@ -85,7 +80,7 @@ function App() {
|
|||||||
if (!settings.generatedCodeConfig) {
|
if (!settings.generatedCodeConfig) {
|
||||||
setSettings((prev) => ({
|
setSettings((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
generatedCodeConfig: GeneratedCodeConfig.HTML_TAILWIND,
|
generatedCodeConfig: Stack.HTML_TAILWIND,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}, [settings.generatedCodeConfig, setSettings]);
|
}, [settings.generatedCodeConfig, setSettings]);
|
||||||
@ -289,15 +284,14 @@ function App() {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Rename everything to "stack" instead of "config"
|
function setStack(stack: Stack) {
|
||||||
function setStack(stack: GeneratedCodeConfig) {
|
|
||||||
setSettings((prev) => ({
|
setSettings((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
generatedCodeConfig: stack,
|
generatedCodeConfig: stack,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function importFromCode(code: string, stack: GeneratedCodeConfig) {
|
function importFromCode(code: string, stack: Stack) {
|
||||||
setIsImportedFromCode(true);
|
setIsImportedFromCode(true);
|
||||||
|
|
||||||
// Set up this project
|
// Set up this project
|
||||||
@ -333,8 +327,8 @@ function App() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<OutputSettingsSection
|
<OutputSettingsSection
|
||||||
generatedCodeConfig={settings.generatedCodeConfig}
|
stack={settings.generatedCodeConfig}
|
||||||
setGeneratedCodeConfig={(config) => setStack(config)}
|
setStack={(config) => setStack(config)}
|
||||||
shouldDisableUpdates={
|
shouldDisableUpdates={
|
||||||
appState === AppState.CODING || appState === AppState.CODE_READY
|
appState === AppState.CODING || appState === AppState.CODE_READY
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,18 +11,16 @@ import {
|
|||||||
} from "./ui/dialog";
|
} from "./ui/dialog";
|
||||||
import { Textarea } from "./ui/textarea";
|
import { Textarea } from "./ui/textarea";
|
||||||
import OutputSettingsSection from "./OutputSettingsSection";
|
import OutputSettingsSection from "./OutputSettingsSection";
|
||||||
import { GeneratedCodeConfig } from "../types";
|
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
|
import { Stack } from "../lib/stacks/types";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
importFromCode: (code: string, stack: GeneratedCodeConfig) => void;
|
importFromCode: (code: string, stack: Stack) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImportCodeSection({ importFromCode }: Props) {
|
function ImportCodeSection({ importFromCode }: Props) {
|
||||||
const [code, setCode] = useState("");
|
const [code, setCode] = useState("");
|
||||||
const [stack, setStack] = useState<GeneratedCodeConfig | undefined>(
|
const [stack, setStack] = useState<Stack | undefined>(undefined);
|
||||||
undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
const doImport = () => {
|
const doImport = () => {
|
||||||
if (code === "") {
|
if (code === "") {
|
||||||
@ -57,10 +55,8 @@ function ImportCodeSection({ importFromCode }: Props) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<OutputSettingsSection
|
<OutputSettingsSection
|
||||||
generatedCodeConfig={stack}
|
stack={stack}
|
||||||
setGeneratedCodeConfig={(config: GeneratedCodeConfig) =>
|
setStack={(config: Stack) => setStack(config)}
|
||||||
setStack(config)
|
|
||||||
}
|
|
||||||
label="Stack:"
|
label="Stack:"
|
||||||
shouldDisableUpdates={false}
|
shouldDisableUpdates={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -7,10 +7,10 @@ import {
|
|||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
} from "./ui/select";
|
} from "./ui/select";
|
||||||
import { Badge } from "./ui/badge";
|
import { Badge } from "./ui/badge";
|
||||||
import { GeneratedCodeConfig } from "../lib/stacks/types";
|
import { Stack } from "../lib/stacks/types";
|
||||||
import { STACK_DESCRIPTIONS } from "../lib/stacks/descriptions";
|
import { STACK_DESCRIPTIONS } from "../lib/stacks/descriptions";
|
||||||
|
|
||||||
function generateDisplayComponent(stack: GeneratedCodeConfig) {
|
function generateDisplayComponent(stack: Stack) {
|
||||||
const stackComponents = STACK_DESCRIPTIONS[stack].components;
|
const stackComponents = STACK_DESCRIPTIONS[stack].components;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -26,15 +26,15 @@ function generateDisplayComponent(stack: GeneratedCodeConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
generatedCodeConfig: GeneratedCodeConfig | undefined;
|
stack: Stack | undefined;
|
||||||
setGeneratedCodeConfig: (config: GeneratedCodeConfig) => void;
|
setStack: (config: Stack) => void;
|
||||||
label?: string;
|
label?: string;
|
||||||
shouldDisableUpdates?: boolean;
|
shouldDisableUpdates?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function OutputSettingsSection({
|
function OutputSettingsSection({
|
||||||
generatedCodeConfig,
|
stack,
|
||||||
setGeneratedCodeConfig,
|
setStack,
|
||||||
label = "Generating:",
|
label = "Generating:",
|
||||||
shouldDisableUpdates = false,
|
shouldDisableUpdates = false,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
@ -43,20 +43,16 @@ function OutputSettingsSection({
|
|||||||
<div className="grid grid-cols-3 items-center gap-4">
|
<div className="grid grid-cols-3 items-center gap-4">
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
<Select
|
<Select
|
||||||
value={generatedCodeConfig}
|
value={stack}
|
||||||
onValueChange={(value: string) =>
|
onValueChange={(value: string) => setStack(value as Stack)}
|
||||||
setGeneratedCodeConfig(value as GeneratedCodeConfig)
|
|
||||||
}
|
|
||||||
disabled={shouldDisableUpdates}
|
disabled={shouldDisableUpdates}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="col-span-2" id="output-settings-js">
|
<SelectTrigger className="col-span-2" id="output-settings-js">
|
||||||
{generatedCodeConfig
|
{stack ? generateDisplayComponent(stack) : "Select a stack"}
|
||||||
? generateDisplayComponent(generatedCodeConfig)
|
|
||||||
: "Select a stack"}
|
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
{Object.values(GeneratedCodeConfig).map((stack) => (
|
{Object.values(Stack).map((stack) => (
|
||||||
<SelectItem value={stack}>
|
<SelectItem value={stack}>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{generateDisplayComponent(stack)}
|
{generateDisplayComponent(stack)}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { GeneratedCodeConfig } from "./types";
|
import { Stack } from "./types";
|
||||||
|
|
||||||
export const STACK_DESCRIPTIONS: {
|
export const STACK_DESCRIPTIONS: {
|
||||||
[key in GeneratedCodeConfig]: { components: string[]; inBeta: boolean };
|
[key in Stack]: { components: string[]; inBeta: boolean };
|
||||||
} = {
|
} = {
|
||||||
html_tailwind: { components: ["HTML", "Tailwind"], inBeta: false },
|
html_tailwind: { components: ["HTML", "Tailwind"], inBeta: false },
|
||||||
react_tailwind: { components: ["React", "Tailwind"], inBeta: false },
|
react_tailwind: { components: ["React", "Tailwind"], inBeta: false },
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// Keep in sync with backend (prompts/types.py)
|
// Keep in sync with backend (prompts/types.py)
|
||||||
export enum GeneratedCodeConfig {
|
export enum Stack {
|
||||||
HTML_TAILWIND = "html_tailwind",
|
HTML_TAILWIND = "html_tailwind",
|
||||||
REACT_TAILWIND = "react_tailwind",
|
REACT_TAILWIND = "react_tailwind",
|
||||||
BOOTSTRAP = "bootstrap",
|
BOOTSTRAP = "bootstrap",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { GeneratedCodeConfig } from "./lib/stacks/types";
|
import { Stack } from "./lib/stacks/types";
|
||||||
|
|
||||||
export enum EditorTheme {
|
export enum EditorTheme {
|
||||||
ESPRESSO = "espresso",
|
ESPRESSO = "espresso",
|
||||||
@ -11,7 +11,7 @@ export interface Settings {
|
|||||||
screenshotOneApiKey: string | null;
|
screenshotOneApiKey: string | null;
|
||||||
isImageGenerationEnabled: boolean;
|
isImageGenerationEnabled: boolean;
|
||||||
editorTheme: EditorTheme;
|
editorTheme: EditorTheme;
|
||||||
generatedCodeConfig: GeneratedCodeConfig;
|
generatedCodeConfig: Stack;
|
||||||
// Only relevant for hosted version
|
// Only relevant for hosted version
|
||||||
isTermOfServiceAccepted: boolean;
|
isTermOfServiceAccepted: boolean;
|
||||||
accessCode: string | null;
|
accessCode: string | null;
|
||||||
@ -32,4 +32,3 @@ export interface CodeGenerationParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type FullGenerationSettings = CodeGenerationParams & Settings;
|
export type FullGenerationSettings = CodeGenerationParams & Settings;
|
||||||
export { GeneratedCodeConfig };
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user