Skip to content

Commit d796ecb

Browse files
committed
Create and implement split preview component
1 parent dcbbbdb commit d796ecb

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/app/converter.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from "react";
22

33
import AppFileSelect from "@/components/libresplit/AppFileSelect";
4-
import { AppMarkdownCodeBlock } from "@/components/libresplit/AppMarkdownCodeBlock";
4+
import { AppSplitPreview } from "@/components/libresplit/AppSplitPreview";
55
import init, { convert } from "@libresplit/libresplit-converter";
66
import wasmUrl from "@libresplit/libresplit-converter/libresplit_converter_bg.wasm?url";
77

@@ -54,8 +54,8 @@ export function Converter() {
5454
};
5555

5656
return (
57-
<div className="space-y-4">
58-
<div className="px-100">
57+
<div className="flex h-[calc(100vh-64px-24px)] flex-col space-y-4 overflow-hidden">
58+
<div className="shrink-0 px-[100px]">
5959
<AppFileSelect
6060
label="Select LiveSplit file:"
6161
value={selectedFile}
@@ -65,7 +65,7 @@ export function Converter() {
6565
/>
6666
</div>
6767

68-
<div className="flex items-center justify-center gap-2">
68+
<div className="flex shrink-0 items-center justify-center gap-2">
6969
<button
7070
onClick={handleSubmit}
7171
className="rounded bg-blue-600 px-4 py-2 text-white hover:bg-blue-700"
@@ -81,9 +81,15 @@ export function Converter() {
8181
</button>
8282
</div>
8383

84-
<div className="flex justify-center">
85-
{fileText && <AppMarkdownCodeBlock code={fileText} language="xml" />}
86-
{result && <AppMarkdownCodeBlock code={result} language="json" />}
84+
<div className="min-h-0 flex-1">
85+
<div className="flex h-full min-h-0 w-full items-stretch justify-center gap-4">
86+
{fileText && (
87+
<AppSplitPreview text={fileText} className="h-full flex-1" />
88+
)}
89+
{result && (
90+
<AppSplitPreview text={result} className="h-full flex-1" />
91+
)}
92+
</div>
8793
</div>
8894
</div>
8995
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
interface AppSplitPreviewProps {
2+
text: string;
3+
className?: string;
4+
}
5+
6+
export function AppSplitPreview({ text, className }: AppSplitPreviewProps) {
7+
return (
8+
<textarea
9+
readOnly
10+
value={text}
11+
wrap="off"
12+
spellCheck={false}
13+
aria-readonly="true"
14+
className={`h-full w-full resize-none ${className ?? ""}`}
15+
/>
16+
);
17+
}

0 commit comments

Comments
 (0)