|
1 | 1 | # Vue Tree
|
2 | 2 |
|
3 |
| -A simple Vue component to beautify tree-like visualization. |
| 3 | +A simple Vue component to beautify tree-like visualizations. |
4 | 4 |
|
5 |
| -Important note: |
6 |
| -User of this component must have `whitespace: 'preserve'` defined in the vue compilerOptions. |
| 5 | +## Features |
| 6 | +- Render tree-like structures in a visually appealing way. |
| 7 | +- Fully customizable and lightweight. |
| 8 | +- Supports scoped styles for seamless integration. |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +Install the package via npm: |
| 13 | + |
| 14 | +```bash |
| 15 | +npm install @tlylt/vue-tree |
| 16 | +``` |
| 17 | + |
| 18 | +or yarn: |
| 19 | + |
| 20 | +```bash |
| 21 | +yarn add @tlylt/vue-tree |
| 22 | +``` |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +### Basic Usage |
| 27 | + |
| 28 | +Import and register the component in your Vue application: |
| 29 | + |
| 30 | +```ts |
| 31 | +import { createApp } from 'vue'; |
| 32 | +import App from './App.vue'; |
| 33 | +import { VueTree } from '@tlylt/vue-tree'; |
| 34 | + |
| 35 | +const app = createApp(App); |
| 36 | +app.use(VueTree); |
| 37 | +app.mount('#app'); |
| 38 | +``` |
| 39 | + |
| 40 | +### Example |
| 41 | + |
| 42 | +Use indentation (2 spaces) to indicate the level of nesting: |
| 43 | +```vue |
| 44 | +<template> |
| 45 | + <VueTree> |
| 46 | + C:/course/ |
| 47 | + textbook/ |
| 48 | + index.md |
| 49 | + index.md |
| 50 | + reading.md |
| 51 | + site.json |
| 52 | + </VueTree> |
| 53 | +</template> |
| 54 | +``` |
| 55 | + |
| 56 | +Expected: |
| 57 | +``` |
| 58 | +C:/course/ |
| 59 | +├── textbook/ |
| 60 | +│ └── index.md |
| 61 | +├── index.md |
| 62 | +├── reading.md |
| 63 | +└── site.json |
| 64 | +``` |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +## Important Notes |
| 69 | + |
| 70 | +To use this component, you must configure `whitespace: 'preserve'` in the Vue compiler options. This ensures that the tree structure is rendered correctly. |
| 71 | + |
| 72 | +### Vite Configuration |
| 73 | + |
| 74 | +Add the following to your `vite.config.ts`: |
7 | 75 |
|
8 |
| -vite.config.ts |
9 | 76 | ```ts
|
10 |
| - plugins: [vue( |
11 |
| - { |
12 |
| - template: { |
13 |
| - compilerOptions: { |
14 |
| - whitespace: "preserve", |
15 |
| - }, |
16 |
| - } |
| 77 | +plugins: [vue( |
| 78 | + { |
| 79 | + template: { |
| 80 | + compilerOptions: { |
| 81 | + whitespace: "preserve", |
| 82 | + }, |
17 | 83 | }
|
18 |
| - )], |
| 84 | + } |
| 85 | +)], |
19 | 86 | ```
|
20 | 87 |
|
21 |
| -within ts/js |
| 88 | +### Vue Configuration |
| 89 | + |
| 90 | +If you are using Vue programmatically, configure the compiler options as follows: |
| 91 | + |
22 | 92 | ```js
|
23 | 93 | const app = Vue.createApp({
|
24 | 94 | compilerOptions: {
|
25 | 95 | whitespace: 'preserve'
|
26 | 96 | }
|
27 |
| -}) |
28 |
| -``` |
| 97 | +}); |
| 98 | +``` |
| 99 | + |
| 100 | +### Props |
| 101 | +WIP |
| 102 | + |
| 103 | +Add details about the props supported by the component. |
| 104 | + |
| 105 | +### Events |
| 106 | +WIP |
| 107 | + |
| 108 | +Document any events emitted by the component. |
| 109 | + |
| 110 | +### Slots |
| 111 | +WIP |
| 112 | + |
| 113 | +Explain the slots available for customization. |
| 114 | + |
| 115 | +### Customization |
| 116 | +WIP |
| 117 | + |
| 118 | +Provide details on how to customize the component, such as styles or additional options. |
| 119 | + |
| 120 | +## License |
| 121 | + |
| 122 | +This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details. |
0 commit comments