Skip to content

Commit cc90706

Browse files
feat: add Ink (Terminal) support to the example site
Add @git-diff-view/cli visibility on the main site — Ink/Terminal now appears in the hero framework list and as a Quick Start tab with a Sandpack code example and terminal screenshot preview. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a412fdd commit cc90706

4 files changed

Lines changed: 97 additions & 2 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
2+
import { SandpackCodeEditor, SandpackLayout, SandpackProvider } from "@codesandbox/sandpack-react";
3+
import { Box, Card, useMantineColorScheme } from "@mantine/core";
4+
import { IconTerminal2 } from "@tabler/icons-react";
5+
6+
export const CliPlayGround = () => {
7+
const { colorScheme } = useMantineColorScheme();
8+
9+
return (
10+
<Card className="p-0" withBorder>
11+
<Box className="flex items-center px-2 py-2 font-sans text-[14px]">
12+
<IconTerminal2 size="16" color="#22c55e" className="mr-2" /> Ink (Terminal)
13+
</Box>
14+
<SandpackProvider
15+
template="vite-react-ts"
16+
theme={colorScheme === "dark" ? "dark" : "light"}
17+
files={{
18+
"/app.tsx": `import { render } from "ink";
19+
import { DiffView, DiffFile, DiffModeEnum } from "@git-diff-view/cli";
20+
21+
const diffString = \`--- a/file.ts
22+
+++ b/file.ts
23+
@@ -1,3 +1,3 @@
24+
const greeting = "hello";
25+
-console.log(greeting);
26+
+console.log(\\\`\\\${greeting} world\\\`);
27+
export default greeting;
28+
\`;
29+
30+
const diffFile = new DiffFile(
31+
"file.ts", "", "file.ts", "",
32+
[diffString], "ts", "ts"
33+
);
34+
diffFile.init();
35+
diffFile.buildSplitDiffLines();
36+
diffFile.buildUnifiedDiffLines();
37+
38+
render(
39+
<DiffView
40+
diffFile={diffFile}
41+
diffViewMode={DiffModeEnum.Unified}
42+
diffViewHighlight={true}
43+
diffViewTheme="dark"
44+
/>
45+
);
46+
`,
47+
}}
48+
>
49+
{/* @ts-ignore */}
50+
<SandpackLayout style={{ ["--sp-layout-height"]: "450px" }}>
51+
<SandpackCodeEditor showTabs />
52+
<Box className="flex flex-1 items-center justify-center overflow-hidden">
53+
<img
54+
src="https://raw.githubusercontent.com/MrWangJustToDo/MyAgent/main/edit-diff-view.png"
55+
alt="@git-diff-view/cli terminal rendering"
56+
className="block w-full object-cover object-top"
57+
/>
58+
</Box>
59+
</SandpackLayout>
60+
</SandpackProvider>
61+
</Card>
62+
);
63+
};

ui/react-example/src/components/PlayGround/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from "./ReactPlayGround";
22
export * from "./VuePlayGround";
33
export * from "./SolidPlayGround";
44
export * from "./SveltePlayGround";
5+
export * from "./CliPlayGround";

ui/react-example/src/views/Main/MainContent.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
IconSparkles,
2626
IconStar,
2727
IconDownload,
28+
IconTerminal2,
2829
} from "@tabler/icons-react";
2930
import { useMemo, useState, useEffect } from "react";
3031

@@ -166,6 +167,12 @@ export const MainContent = () => {
166167
Svelte
167168
</Text>
168169
</Group>
170+
<Group gap="xs" className="inline-flex">
171+
<IconTerminal2 className="animate-float" color="#22c55e" size={24} style={{ animationDelay: "2s" }} />
172+
<Text span className="text-lg font-semibold">
173+
Ink (Terminal)
174+
</Text>
175+
</Group>
169176
</Group>
170177

171178
<Highlight highlight={["feature-rich", "GitHub-style"]} color={color} className="text-lg">

ui/react-example/src/views/Main/StartContent.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Container, Space, Title, Text, Box, Badge, Tabs, rem, useMantineColorScheme } from "@mantine/core";
2-
import { IconBrandReact, IconBrandVue, IconCode } from "@tabler/icons-react";
2+
import { IconBrandReact, IconBrandVue, IconCode, IconTerminal2 } from "@tabler/icons-react";
33

4-
import { ReactPlayGround, VuePlayGround } from "../../components/PlayGround";
4+
import { ReactPlayGround, VuePlayGround, CliPlayGround } from "../../components/PlayGround";
55

66
export const StartContent = () => {
77
const iconStyle = { width: rem(16), height: rem(16) };
@@ -39,6 +39,9 @@ export const StartContent = () => {
3939
<Tabs.Tab value="vue" leftSection={<IconBrandVue style={iconStyle} />} className="text-base">
4040
Vue
4141
</Tabs.Tab>
42+
<Tabs.Tab value="cli" leftSection={<IconTerminal2 style={iconStyle} />} className="text-base">
43+
Ink (Terminal)
44+
</Tabs.Tab>
4245
</Tabs.List>
4346

4447
<Tabs.Panel value="react">
@@ -82,6 +85,27 @@ export const StartContent = () => {
8285
<VuePlayGround />
8386
</Box>
8487
</Tabs.Panel>
88+
89+
<Tabs.Panel value="cli">
90+
<Box
91+
className="rounded-xl border border-solid p-6"
92+
style={{
93+
borderColor: colorScheme === "light" ? "#f1f3f5" : "var(--mantine-color-dark-5)",
94+
backgroundColor: colorScheme === "light" ? "#f8f9fa" : "var(--mantine-color-dark-6)",
95+
}}
96+
>
97+
<Box className="mb-4 flex items-center gap-3">
98+
<IconTerminal2 size={24} className="text-green-500" />
99+
<Title order={3} size="h4">
100+
Ink (Terminal) Example
101+
</Title>
102+
</Box>
103+
<Text c="dimmed" mb="lg" className="text-base">
104+
Render beautiful diffs directly in your terminal using Ink and React. Powered by @git-diff-view/cli.
105+
</Text>
106+
<CliPlayGround />
107+
</Box>
108+
</Tabs.Panel>
85109
</Tabs>
86110
</Box>
87111
</Box>

0 commit comments

Comments
 (0)