Skip to content

Commit c88826e

Browse files
committed
chore(playground): use direct import instead
1 parent 3869f95 commit c88826e

File tree

9 files changed

+167
-20
lines changed

9 files changed

+167
-20
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"dev": "tsx scripts/watch.ts",
3838
"docs:build": "pnpm --filter @matechat/react-docs build",
3939
"docs:dev": "tsx scripts/watch.ts --project docs",
40-
"playground:build": "vite build --config playground/vite.config.ts",
41-
"preview": "vite --config playground/vite.config.ts",
40+
"playground:build": "pnpm --filter @matechat/react-playground build",
41+
"preview": "pnpm --filter @matechat/react-playground dev",
4242
"test": "vitest",
4343
"typecheck": "tsc --noEmit",
4444
"format": "biome format . --write",

playground/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>MateChat React Components</title>
6+
<title>MateChat React Playground</title>
77
</head>
88
<body>
99
<div id="app"></div>

playground/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@matechat/react-playground",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"license": "MIT",
7+
"author": {
8+
"email": "[email protected]",
9+
"name": "苏向夜"
10+
},
11+
"scripts": {
12+
"build": "vite build",
13+
"dev": "vite"
14+
},
15+
"dependencies": {
16+
"clsx": "^2.1.1",
17+
"tailwindcss": "^4.1.11"
18+
},
19+
"devDependencies": {
20+
"@tailwindcss/vite": "^4.1.11",
21+
"@types/react": "^19.1.8",
22+
"@types/react-dom": "^19.1.6",
23+
"@vitejs/plugin-react-swc": "^3.10.2",
24+
"react": "^19.1.0",
25+
"react-dom": "^19.1.0",
26+
"vite": "npm:rolldown-vite@^6.3.21"
27+
}
28+
}

playground/src/Chat.tsx

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,51 @@
11
import { MessageSquarePlus } from "lucide-react";
22
import { useMemo, useState } from "react";
3-
import { BubbleList } from "../../dist/bubble";
4-
import { Button } from "../../dist/button";
5-
import { FileUpload } from "../../dist/file-upload";
3+
import { BubbleList } from "@matechat/react/bubble";
4+
import { Button } from "@matechat/react/button";
5+
import { FileUpload } from "@matechat/react/file-upload";
66
import {
77
Prompt,
88
PromptDescription,
99
Prompts,
1010
PromptTitle,
11-
} from "../../dist/prompt";
12-
import { InputCount, Sender } from "../../dist/sender";
13-
import type { MessageParam } from "../../dist/utils";
14-
import { useChat } from "../../dist/utils/chat";
15-
import { useMateChat } from "../../dist/utils/core";
11+
} from "@matechat/react/prompt";
12+
import { InputCount, Sender } from "@matechat/react/sender";
13+
import type { MessageParam } from "@matechat/react/utils";
14+
import { useChat } from "@matechat/react/utils/chat";
15+
import { useMateChat } from "@matechat/react/utils/core";
1616

1717
const initialMessages: MessageParam[] = [
1818
{
1919
id: "1",
2020
role: "user",
21-
content: "Hello, how are you?",
21+
content: "How to use MateChat React?",
2222
align: "right",
2323
},
2424
{
2525
id: "2",
2626
role: "assistant",
27-
content:
28-
"I'm doing well, thank you! How can I assist you today? \
29-
I'm a language model, so I can understand and respond to a wide range of questions and requests. \
30-
I can help you with a variety of tasks, such as answering questions, providing information, or helping you with a specific problem.",
27+
content: `# Getting Started
28+
29+
## Prerequisites
30+
31+
MateChat React is a React frontend components and helpers library, we recommend that you use React 18 or above.
32+
33+
If you are looking for the Vue MateChat version, please visit [MateChat Vue](https://matechat.gitcode.com/).
34+
35+
## Quick Start
36+
37+
If you wish to try a brand-new MateChat React project, feel free to use the MateChat CLI to create a template project.
38+
39+
\`\`\`bash
40+
pnpm create matechat@latest
41+
\`\`\`
42+
43+
## Installation
44+
45+
\`\`\`bash
46+
pnpm add @matechat/react
47+
\`\`\`
48+
`,
3149
align: "left",
3250
},
3351
];
@@ -41,7 +59,7 @@ export function Chat() {
4159
initialMessages,
4260
{
4361
throwOnEmptyBackend: true,
44-
},
62+
}
4563
);
4664

4765
const footer = useMemo(() => {

playground/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createRoot } from "react-dom/client";
2-
import { App } from "./App.tsx";
2+
import { App } from "./App";
33
import "./style.css";
44

55
const container = document.getElementById("app") as HTMLElement;

playground/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"paths": {
5+
"@matechat/react": ["../src/index.ts"],
6+
"@matechat/react/*": ["../src/*"]
7+
}
8+
},
9+
"include": ["src"]
10+
}

playground/vite.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import tailwindcss from "@tailwindcss/vite";
22
import react from "@vitejs/plugin-react-swc";
3+
import path from "node:path";
34
import { createLogger, defineConfig } from "vite";
45

56
// Suppress warnings from Rolldown Vite
@@ -8,7 +9,11 @@ const logger = createLogger();
89
logger.warn = () => {};
910

1011
export default defineConfig({
11-
root: "./playground",
1212
plugins: [react(), tailwindcss()],
1313
customLogger: logger,
14+
resolve: {
15+
alias: {
16+
'@matechat/react': path.resolve(__dirname, "../src"),
17+
}
18+
}
1419
});

0 commit comments

Comments
 (0)