-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Block Editing Functionality (#25)
feat: Implement Block Editing System - Add BlockEditor, FunctionEditor, IfEditor, and WhileEditor components - Create BlockEditorContext for managing editing state - Implement FunctionCombobox for function selection - Add BlockAdder for nested block creation - Update CodeGeneratorContext with codebaseInfo - Integrate Shadcn UI components (Popover, Command, Separator, Label) - Improve block manipulation (condition changes, nested function creation) - Enhance UI with clear selection button and improved layouts - Update dependencies and refactor imports
- Loading branch information
1 parent
16dd4b4
commit 098c781
Showing
21 changed files
with
932 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use client"; | ||
|
||
import { useBlockEditor } from "@/contexts/BlockEditorContext"; | ||
import { FunctionEditor } from "./FunctionEditor"; | ||
import { IfEditor } from "./IfEditor"; | ||
import { WhileEditor } from "./WhileEditor"; | ||
import { BlockAdder } from "./components/BlockAdder"; | ||
import { Button } from "@ui/button"; | ||
import { XCircleIcon } from "lucide-react"; | ||
|
||
export const BlockEditor = () => { | ||
const { currentBlock, setCurrentBlock } = useBlockEditor(); | ||
|
||
if (!currentBlock) return <EmptyBlockEditor />; | ||
|
||
return ( | ||
<div className="flex justify-start w-full pb-4 gap-x-4 relative"> | ||
{currentBlock.blockType === "functionCall" && ( | ||
<FunctionEditor block={currentBlock} /> | ||
)} | ||
{currentBlock.blockType === "if" && <IfEditor block={currentBlock} />} | ||
{currentBlock.blockType === "while" && ( | ||
<WhileEditor block={currentBlock} /> | ||
)} | ||
<Button | ||
variant="secondary" | ||
onClick={() => setCurrentBlock(null)} | ||
className="absolute right-0 top-0" | ||
> | ||
<XCircleIcon className="h-6 w-6 mr-2" /> | ||
Clear Selection | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
const EmptyBlockEditor = () => { | ||
return ( | ||
<div className="pb-4"> | ||
<BlockAdder /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.