Skip to content

Commit

Permalink
move stack info to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
abi committed Jan 9, 2024
1 parent a8b562e commit 3723c81
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
7 changes: 4 additions & 3 deletions frontend/src/components/OutputSettingsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
SelectItem,
SelectTrigger,
} from "./ui/select";
import { GeneratedCodeConfig, STACK_DESCRIPTION } from "../types";
import { Badge } from "./ui/badge";
import { GeneratedCodeConfig } from "../lib/stacks/types";
import { STACK_DESCRIPTIONS } from "../lib/stacks/descriptions";

function generateDisplayComponent(stack: GeneratedCodeConfig) {
const stackComponents = STACK_DESCRIPTION[stack].components;
const stackComponents = STACK_DESCRIPTIONS[stack].components;

return (
<div>
Expand Down Expand Up @@ -59,7 +60,7 @@ function OutputSettingsSection({
<SelectItem value={stack}>
<div className="flex items-center">
{generateDisplayComponent(stack)}
{STACK_DESCRIPTION[stack].inBeta && (
{STACK_DESCRIPTIONS[stack].inBeta && (
<Badge className="ml-2" variant="secondary">
Beta
</Badge>
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/lib/stacks/descriptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { GeneratedCodeConfig } from "./types";

export const STACK_DESCRIPTIONS: {
[key in GeneratedCodeConfig]: { components: string[]; inBeta: boolean };
} = {
html_tailwind: { components: ["HTML", "Tailwind"], inBeta: false },
react_tailwind: { components: ["React", "Tailwind"], inBeta: false },
bootstrap: { components: ["Bootstrap"], inBeta: false },
vue_tailwind: { components: ["Vue", "Tailwind"], inBeta: true },
ionic_tailwind: { components: ["Ionic", "Tailwind"], inBeta: true },
svg: { components: ["SVG"], inBeta: true },
};
9 changes: 9 additions & 0 deletions frontend/src/lib/stacks/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Keep in sync with backend (prompts/types.py)
export enum GeneratedCodeConfig {
HTML_TAILWIND = "html_tailwind",
REACT_TAILWIND = "react_tailwind",
BOOTSTRAP = "bootstrap",
VUE_TAILWIND = "vue_tailwind",
IONIC_TAILWIND = "ionic_tailwind",
SVG = "svg",
}
24 changes: 3 additions & 21 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import { GeneratedCodeConfig } from "./lib/stacks/types";

export enum EditorTheme {
ESPRESSO = "espresso",
COBALT = "cobalt",
}

// Keep in sync with backend (prompts/types.py)
export enum GeneratedCodeConfig {
HTML_TAILWIND = "html_tailwind",
REACT_TAILWIND = "react_tailwind",
BOOTSTRAP = "bootstrap",
VUE_TAILWIND = "vue_tailwind",
IONIC_TAILWIND = "ionic_tailwind",
SVG = "svg",
}

export const STACK_DESCRIPTION: {
[key in GeneratedCodeConfig]: { components: string[]; inBeta: boolean };
} = {
html_tailwind: { components: ["HTML", "Tailwind"], inBeta: false },
react_tailwind: { components: ["React", "Tailwind"], inBeta: false },
bootstrap: { components: ["Bootstrap"], inBeta: false },
vue_tailwind: { components: ["Vue", "Tailwind"], inBeta: true },
ionic_tailwind: { components: ["Ionic", "Tailwind"], inBeta: true },
svg: { components: ["SVG"], inBeta: true },
};

export interface Settings {
openAiApiKey: string | null;
openAiBaseURL: string | null;
Expand Down Expand Up @@ -51,3 +32,4 @@ export interface CodeGenerationParams {
}

export type FullGenerationSettings = CodeGenerationParams & Settings;
export { GeneratedCodeConfig };

0 comments on commit 3723c81

Please sign in to comment.