Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Rename History to Versions, restyle version list and panel header
Abi Raja5dafde8a4272
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex a00dfeae..54bb3547 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -12,6 +12,7 @@ import toast from "react-hot-toast";import { Stack } from "./lib/stacks";import { CodeGenerationModel } from "./lib/models";import useBrowserTabIndicator from "./hooks/useBrowserTabIndicator";+import { LuChevronLeft } from "react-icons/lu";// import TipLink from "./components/messages/TipLink";import { useAppStore } from "./store/app-store";import { useProjectStore } from "./store/project-store";@@ -560,15 +561,16 @@ function App() {{showContentPanel && (<div className="lg:fixed lg:inset-y-0 lg:left-16 lg:z-40 lg:flex lg:w-[calc(28rem-4rem)] lg:flex-col border-r border-gray-200 bg-white dark:bg-zinc-950 dark:text-white">{isHistoryOpen ? (- <div className="flex-1 overflow-y-auto sidebar-scrollbar-stable px-6">- <div className="mt-4">- <div className="flex items-center justify-between mb-2">- <h1 className="text-lg font-semibold">History</h1>+ <div className="flex-1 overflow-y-auto sidebar-scrollbar-stable px-4">+ <div className="mt-3">+ <div className="flex items-center justify-between mb-3 px-1">+ <h2 className="text-xs font-medium uppercase tracking-wider text-gray-400 dark:text-gray-500">Versions</h2><buttononClick={() => setIsHistoryOpen(false)}- className="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 text-sm"+ className="flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors">- Close+ <LuChevronLeft className="w-3.5 h-3.5" />+ Back to editor</button></div><HistoryDisplaydiff --git a/frontend/src/components/history/HistoryDisplay.tsx b/frontend/src/components/history/HistoryDisplay.tsxindex e8bd2870..65a3275f 100644--- a/frontend/src/components/history/HistoryDisplay.tsx+++ b/frontend/src/components/history/HistoryDisplay.tsx@@ -1,16 +1,8 @@import toast from "react-hot-toast";-import classNames from "classnames";--import { Badge } from "../ui/badge";import { renderHistory } from "./utils";-import {- Collapsible,- CollapsibleContent,- CollapsibleTrigger,-} from "../ui/collapsible";-import { Button } from "../ui/button";-import { CaretSortIcon } from "@radix-ui/react-icons";import { useProjectStore } from "../../store/project-store";+import { BsChevronDown, BsChevronRight } from "react-icons/bs";+import { useState } from "react";interface Props {shouldDisableReverts: boolean;@@ -18,6 +10,7 @@ interface Props {export default function HistoryDisplay({ shouldDisableReverts }: Props) {const { commits, head, setHead } = useProjectStore();+ const [expandedHash, setExpandedHash] = useState<string | null>(null);// Put all commits into an array and sort by created date (oldest first)const flatHistory = Object.values(commits).sort(@@ -28,60 +21,93 @@ export default function HistoryDisplay({ shouldDisableReverts }: Props) {// Annotate history items with a summary, parent version, etc.const renderedHistory = renderHistory(flatHistory);- return renderedHistory.length === 0 ? null : (- <div className="flex flex-col h-full">- <h1 className="font-bold mb-2">Versions</h1>- <ul className="space-y-0 flex flex-col-reverse">- {renderedHistory.map((item, index) => (- <li key={index}>- <Collapsible>- <div- className={classNames(- "flex items-center justify-between space-x-2 w-full pr-2",- "border-b cursor-pointer",- {- " hover:bg-black hover:text-white": item.hash === head,- "bg-slate-500 text-white": item.hash === head,- }- )}+ if (renderedHistory.length === 0) return null;++ return (+ <div className="flex flex-col gap-1">+ {[...renderedHistory].reverse().map((item, _reverseIndex) => {+ const versionNumber = renderedHistory.length - _reverseIndex;+ const isActive = item.hash === head;+ const isExpanded = expandedHash === item.hash;++ return (+ <div+ key={item.hash}+ className={`rounded-lg transition-colors ${+ isActive+ ? "bg-gray-100 dark:bg-zinc-800"+ : "hover:bg-gray-50 dark:hover:bg-zinc-800/50"+ }`}+ >+ <div+ className="flex items-center gap-3 px-3 py-2.5 cursor-pointer"+ onClick={() =>+ shouldDisableReverts+ ? toast.error(+ "Please wait for code generation to complete before viewing an older version."+ )+ : setHead(item.hash)+ }+ >+ {/* Version number badge */}+ <span+ className={`shrink-0 text-xs font-medium ${+ isActive+ ? "text-gray-900 dark:text-white"+ : "text-gray-400 dark:text-gray-500"+ }`}>- <div- className="flex justify-between truncate flex-1 p-2"- onClick={() =>- shouldDisableReverts- ? toast.error(- "Please wait for code generation to complete before viewing an older version."- )- : setHead(item.hash)- }+ v{versionNumber}+ </span>++ {/* Summary */}+ <div className="flex-1 min-w-0">+ <p+ className={`text-sm truncate ${+ isActive+ ? "font-medium text-gray-900 dark:text-white"+ : "text-gray-600 dark:text-gray-400"+ }`}>- <div className="flex gap-x-1 truncate">- <h2 className="text-sm truncate">{item.summary}</h2>- {item.parentVersion !== null && (- <h2 className="text-sm">- (parent: v{item.parentVersion})- </h2>- )}- </div>- <h2 className="text-sm">v{index + 1}</h2>- </div>- <CollapsibleTrigger asChild>- <Button variant="ghost" size="sm" className="h-6">- <CaretSortIcon className="h-4 w-4" />- <span className="sr-only">Toggle</span>- </Button>- </CollapsibleTrigger>+ {item.summary}+ </p>+ {item.parentVersion !== null && (+ <p className="text-xs text-gray-400 dark:text-gray-500">+ from v{item.parentVersion}+ </p>+ )}+ </div>++ {/* Type label + expand */}+ <span className="shrink-0 text-[10px] uppercase tracking-wider text-gray-400 dark:text-gray-500">+ {item.type}+ </span>+ <button+ onClick={(e) => {+ e.stopPropagation();+ setExpandedHash(isExpanded ? null : item.hash);+ }}+ className="shrink-0 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 p-0.5"+ >+ {isExpanded ? (+ <BsChevronDown className="w-3 h-3" />+ ) : (+ <BsChevronRight className="w-3 h-3" />+ )}+ </button>+ </div>++ {/* Expanded details */}+ {isExpanded && (+ <div className="px-3 pb-2.5 pl-12">+ <p className="text-xs text-gray-500 dark:text-gray-400 break-words">+ {item.summary}+ </p></div>- <CollapsibleContent className="w-full bg-slate-300 p-2">- <div>Full prompt: {item.summary}</div>- <div className="flex justify-end">- <Badge>{item.type}</Badge>- </div>- </CollapsibleContent>- </Collapsible>- </li>- ))}- </ul>+ )}+ </div>+ );+ })}</div>);}diff --git a/frontend/src/components/sidebar/IconStrip.tsx b/frontend/src/components/sidebar/IconStrip.tsxindex fae96a51..2c045606 100644--- a/frontend/src/components/sidebar/IconStrip.tsx+++ b/frontend/src/components/sidebar/IconStrip.tsx@@ -65,7 +65,7 @@ function IconStrip({}`}><LuClock className="w-[18px] h-[18px]" />- <span className="text-[10px] leading-none">History</span>+ <span className="text-[10px] leading-none">Versions</span></button>)}