forked from stackblitz-labs/bolt.diy
-
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: enhance workbench with code comparison
- Loading branch information
1 parent
3baefdb
commit f7f8572
Showing
5 changed files
with
540 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { memo } from 'react'; | ||
import { classNames } from '~/utils/classNames'; | ||
|
||
interface CodeComparisonProps { | ||
beforeCode: string; | ||
afterCode: string; | ||
language: string; | ||
filename: string; | ||
lightTheme: string; | ||
darkTheme: string; | ||
} | ||
|
||
export const CodeComparison = memo(({ | ||
beforeCode, | ||
afterCode, | ||
language, | ||
filename, | ||
lightTheme, | ||
darkTheme, | ||
}: CodeComparisonProps) => { | ||
return ( | ||
<div className="mx-auto w-full"> | ||
<div className="relative w-full overflow-hidden rounded-xl border border-bolt-elements-borderColor"> | ||
<div className="relative grid md:grid-cols-2 md:divide-x md:divide-bolt-elements-borderColor"> | ||
<div> | ||
<div className="flex items-center bg-bolt-elements-background-depth-1 p-2 text-sm"> | ||
<div className="i-ph:file mr-2 h-4 w-4" /> | ||
{filename} | ||
<span className="ml-auto">Original</span> | ||
</div> | ||
<pre className="h-full overflow-auto break-all bg-bolt-elements-background-depth-1 p-4 font-mono text-xs"> | ||
{beforeCode} | ||
</pre> | ||
</div> | ||
<div> | ||
<div className="flex items-center bg-bolt-elements-background-depth-1 p-2 text-sm"> | ||
<div className="i-ph:file mr-2 h-4 w-4" /> | ||
{filename} | ||
<span className="ml-auto">Modified</span> | ||
</div> | ||
<pre className="h-full overflow-auto break-all bg-bolt-elements-background-depth-1 p-4 font-mono text-xs"> | ||
{afterCode} | ||
</pre> | ||
</div> | ||
</div> | ||
<div className="absolute left-1/2 top-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-md bg-bolt-elements-background-depth-2 text-xs"> | ||
VS | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}); |
Oops, something went wrong.