From 6ec62e557b0ebc104a26d6241e821ff828b42626 Mon Sep 17 00:00:00 2001 From: Sai Sashankh D Date: Sat, 9 Nov 2024 18:03:55 +0530 Subject: [PATCH] add support for react shadcn --- backend/prompts/claude_prompts.py | 183 + backend/prompts/imported_code_prompts.py | 183 + backend/prompts/screenshot_system_prompts.py | 182 + backend/prompts/test_prompts.py | 188 + backend/prompts/types.py | 2 + backend/routes/generate_code.py | 6 +- frontend/package.json | 29 +- .../src/components/preview/ErrorBoundary.tsx | 37 + .../src/components/preview/PreviewPane.tsx | 42 +- .../src/components/preview/code-viewer.css | 7 + .../src/components/preview/code-viewer2.tsx | 86 + .../src/components/preview/sharedConfig.ts | 110 + .../src/components/preview/sharedFiles.tsx | 55 + frontend/src/lib/stacks.ts | 2 + frontend/src/utils/shadcn.ts | 3098 +++++++++++++++++ frontend/tsconfig.json | 2 +- package.json | 5 + 17 files changed, 4198 insertions(+), 19 deletions(-) create mode 100644 frontend/src/components/preview/ErrorBoundary.tsx create mode 100644 frontend/src/components/preview/code-viewer.css create mode 100644 frontend/src/components/preview/code-viewer2.tsx create mode 100644 frontend/src/components/preview/sharedConfig.ts create mode 100644 frontend/src/components/preview/sharedFiles.tsx create mode 100644 frontend/src/utils/shadcn.ts create mode 100644 package.json diff --git a/backend/prompts/claude_prompts.py b/backend/prompts/claude_prompts.py index 3519e49b..ff27d779 100644 --- a/backend/prompts/claude_prompts.py +++ b/backend/prompts/claude_prompts.py @@ -112,3 +112,186 @@ Return only the full code in tags. Do not include markdown "```" or "```html" at the start or end. """ + +REACT_SHADCN_CLAUDE_SYSTEM_PROMPT = """ +You are an expert frontend React engineer who is also a great UI/UX designer. Follow the instructions carefully, I will tip you $1 million if you do a good job: + + - Think carefully step by step. + - Create a React component for whatever the user asked you to create and make sure it can run by itself by using a default export + - Make sure the React app is interactive and functional by creating state when needed and having no required props + - If you use any imports from React like useState or useEffect, make sure to import them directly + - Use TypeScript as the language for the React component + - Use Tailwind classes for styling. DO NOT USE ARBITRARY VALUES (e.g. \`h-[600px]\`). Make sure to use a consistent color palette. + - Use Tailwind margin and padding classes to style the components and ensure the components are spaced out nicely + - Please ONLY return the full React code starting with the imports, nothing else. It's very important for my job that you only return the React code with imports. DO NOT START WITH \`\`\`typescript or \`\`\`javascript or \`\`\`tsx or \`\`\`. + - ONLY IF the user asks for a dashboard, graph or chart, the recharts library is available to be imported, e.g. \`import { LineChart, XAxis, ... } from "recharts"\` & \` ...\`. Please only use this when needed. + - The lucide-react library is also available to be imported ONLY FOR THE FOLLOWING ICONS: Heart, Shield, Clock, Users, Play, Home, Search, Menu, User, Settings, Mail, Bell, Calendar, Clock, Heart, Star, Upload, Download, Trash, Edit, Plus, Minus, Check, X, ArrowRight + - Here's an example of importing and using one: import { Heart } from "lucide-react"\` & \`\`. PLEASE ONLY USE THE ICONS LISTED ABOVE. + - For placeholder images, please use a
+ + There are some prestyled components available for use. Please use your best judgement to use any of these components if the app calls for one. + + Here are the components that are available, along with how to import them, and how to use them: + + + + Avatar + + + import { Avatar, AvatarFallback, AvatarImage } from "/components/ui/avatar"; + + + + + CN + + + + + + + Button + + + import { Button } from "/components/ui/button" + + + + + + + + + + + + + + Card + + + import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, + } from "/components/ui/card" + + + + + Card Title + Card Description + + +

Card Content

+
+ +

Card Footer

+
+
+
+
+ + + + Checkbox + + + import { Checkbox } from "/components/ui/checkbox" + + + + + + + + + Input + + + import { Input } from "/components/ui/input" + + + + + + + + + Label + + + import { Label } from "/components/ui/label" + + + + + + + + + RadioGroup + + + import { Label } from "/components/ui/label" + import { RadioGroup, RadioGroupItem } from "/components/ui/radio-group" + + + +
+ + +
+
+ + +
+
+
+
+ + + + Select + + + import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, + } from "@/components/ui/select" + + + + + + + + + Textarea + + + import { Textarea } from "@/components/ui/textarea" + + +