-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Fix bugs and implement remaining template-related features
- Loading branch information
Showing
9 changed files
with
312 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,3 +106,7 @@ h4 { | |
p { | ||
@apply text-xs; | ||
} | ||
|
||
.cm-editor { | ||
outline: none !important; | ||
} |
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
72 changes: 72 additions & 0 deletions
72
crates/web/frontend/src/components/dump-block/dump-block.tsx
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,72 @@ | ||
import { cn } from "@/lib/utils"; | ||
import ActionButton from "../action-button/action-button"; | ||
import { Redo, Trash } from "lucide-react"; | ||
import { notify } from "@/lib/notify"; | ||
|
||
interface Props extends React.HTMLAttributes<HTMLDivElement> { | ||
onDump: () => void; | ||
onDumpMessage?: string; | ||
lines: number; | ||
onDelete?: () => void; | ||
onDeleteMessage?: string; | ||
} | ||
|
||
export const DumpBlock = ({ | ||
onDump, | ||
onDumpMessage, | ||
lines, | ||
onDelete, | ||
onDeleteMessage, | ||
children, | ||
className, | ||
...props | ||
}: Props) => { | ||
const handleDump = () => { | ||
onDumpMessage && notify.success(onDumpMessage); | ||
onDump(); | ||
}; | ||
|
||
const handleDelete = () => { | ||
onDeleteMessage && notify.success(onDeleteMessage); | ||
onDelete?.(); | ||
}; | ||
|
||
return ( | ||
<div className={cn("relative group flex justify-between", className)} {...props}> | ||
{children} | ||
<div | ||
className={cn( | ||
"max-w-0 transition-all", | ||
lines > 2 ? "group-hover:max-w-10" : "group-hover:max-w-20 flex", | ||
)} | ||
> | ||
<ActionButton | ||
side={lines > 2 ? "right" : "bottom"} | ||
containerClassName={cn( | ||
"min-h-10 flex items-center justify-center border-l", | ||
lines > 2 && onDelete ? "h-1/2 border-b" : "h-full", | ||
)} | ||
className="h-full w-10 border-0" | ||
description="Dump content into the editor" | ||
onClick={handleDump} | ||
> | ||
<Redo className="w-3 h-3" /> | ||
</ActionButton> | ||
{onDelete && ( | ||
<ActionButton | ||
side={lines > 2 ? "right" : "bottom"} | ||
containerClassName={cn( | ||
"min-h-10 flex items-center justify-center border-l", | ||
lines > 2 ? "h-1/2" : "h-full", | ||
)} | ||
className="h-full w-10 border-0" | ||
description="Delete from history" | ||
onClick={handleDelete} | ||
> | ||
<Trash className="w-3 h-3" /> | ||
</ActionButton> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.