diff --git a/packages/vue/README.md b/packages/vue/README.md index b1ffc81d7..d5ee95396 100644 --- a/packages/vue/README.md +++ b/packages/vue/README.md @@ -45,9 +45,9 @@ declare module "*.vue" { ``` @@ -55,11 +55,10 @@ declare module "*.vue" { ```ts // index.ts -import { createApp } from "vue" import { render } from "@opentui/vue" import App from "./App.vue" -render(createApp(App)) +render(App) ``` ### 6. Create a build script build.ts. @@ -104,9 +103,9 @@ bun run dist/index.js ## Note -Important Note on +Important Note on `` -The component only accepts plain text as a direct child. For styled text or text chunks, you must use the content prop. +The `` component only accepts plain text as a direct child. For styled text or text chunks, you must use the content prop. ```jsx ``` @@ -156,9 +155,9 @@ useKeyboard((key: KeyEvent) => { ``` @@ -188,9 +187,9 @@ const dimensions = useTerminalDimensions() ``` @@ -250,7 +249,7 @@ export class ConsoleButtonRenderable extends BoxRenderable { #### 2. Register the new component -In your application's entry point (e.g., `main.ts`), import the `extend` function and your custom component. Then, call `extend` with an object where the key is the component's tag name (in camelCase) and the value is the component class. +In your application's entry point (e.g., `main.ts`), import the `extend` function and your custom component. Then, call `extend` with an object where the key is the component's tag name (in PascalCase) and the value is the component class. `main.ts`: @@ -260,7 +259,7 @@ import { ConsoleButtonRenderable } from "./CustomButtonRenderable" import App from "./App.vue" // Register the custom component -extend({ consoleButtonRenderable: ConsoleButtonRenderable }) +extend({ ConsoleButton: ConsoleButtonRenderable }) // Render the app render(App) @@ -279,7 +278,7 @@ import { ConsoleButtonRenderable } from "./CustomButtonRenderable" declare module "@opentui/vue" { export interface OpenTUIComponents { - consoleButtonRenderable: typeof ConsoleButtonRenderable + ConsoleButton: typeof ConsoleButtonRenderable } } ``` @@ -288,21 +287,21 @@ _Note: Make sure this file is included in your `tsconfig.json`._ #### 4. Use your custom component -Now you can use `` in your Vue components just like any other OpenTUI component. +Now you can use `` in your Vue components just like any other OpenTUI component. `ExtendExample.vue`: ```vue diff --git a/packages/vue/example/ASCII.vue b/packages/vue/example/ASCII.vue index 9be77dd30..853ec6fc2 100644 --- a/packages/vue/example/ASCII.vue +++ b/packages/vue/example/ASCII.vue @@ -1,5 +1,6 @@ diff --git a/packages/vue/example/Animation.vue b/packages/vue/example/Animation.vue new file mode 100644 index 000000000..ffbdc11b5 --- /dev/null +++ b/packages/vue/example/Animation.vue @@ -0,0 +1,182 @@ + + + diff --git a/packages/vue/example/App.vue b/packages/vue/example/App.vue index bd2fbf609..37143eaec 100644 --- a/packages/vue/example/App.vue +++ b/packages/vue/example/App.vue @@ -5,18 +5,28 @@ import Counter from "./Counter.vue" import StyledText from "./Styled-Text.vue" import TabSelect from "./TabSelect.vue" import ScrollBox from "./ScrollBox.vue" +import Code from "./Code.vue" +import Diff from "./Diff.vue" +import Textarea from "./Textarea.vue" +import Animation from "./Animation.vue" +import LineNumber from "./LineNumber.vue" import { ref } from "vue" import ExtendExample from "./ExtendExample.vue" -import { useCliRenderer } from ".." +import { useKeyboard } from "@opentui/vue" const exampleOptions = [ - { name: "ASCII", description: "Assci text example", value: "ascii" }, + { name: "ASCII", description: "ASCII text example", value: "ascii" }, { name: "Counter", description: "Counter example", value: "counter" }, { name: "Login Form", description: "A simple login form example", value: "login" }, { name: "Styled Text", description: "Text with various styles applied", value: "styledText" }, { name: "Tab Select", description: "Tabs", value: "tabSelect" }, { name: "Extend", description: "Extend example", value: "extend" }, { name: "ScrollBox", description: "ScrollBox example", value: "scrollBox" }, + { name: "Code", description: "Syntax highlighting demo", value: "code" }, + { name: "Diff", description: "Diff view demo", value: "diff" }, + { name: "Textarea", description: "Interactive editor demo", value: "textarea" }, + { name: "Animation", description: "Timeline animation demo", value: "animation" }, + { name: "Line Number", description: "Line numbers demo", value: "lineNumber" }, ] type ExampleOption = (typeof exampleOptions)[number] @@ -29,8 +39,7 @@ const onSelectExample = (i: number) => { selectedExample.value = selectedOption } -const renderer = useCliRenderer() -renderer.keyInput.on("keypress", (key) => { +useKeyboard((key) => { if (key.name === "escape") { selectedExample.value = null } @@ -48,14 +57,19 @@ const selectStyles = { flexGrow: 1 } - - + +