@todovue/tv-ui 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +20 -20
  2. package/dist/entry.d.ts +2 -2
  3. package/dist/tv-ui.cjs.js +1 -1
  4. package/dist/tv-ui.css +1 -1
  5. package/dist/tv-ui.es.js +50 -49
  6. package/package.json +4 -2
  7. package/dist/.htaccess +0 -8
  8. package/dist/demos/tv-alert/CHANGELOG.md +0 -127
  9. package/dist/demos/tv-alert/README.md +0 -334
  10. package/dist/demos/tv-article/CHANGELOG.md +0 -221
  11. package/dist/demos/tv-article/README.md +0 -258
  12. package/dist/demos/tv-breadcrumbs/CHANGELOG.md +0 -135
  13. package/dist/demos/tv-breadcrumbs/README.md +0 -364
  14. package/dist/demos/tv-button/CHANGELOG.md +0 -158
  15. package/dist/demos/tv-button/README.md +0 -255
  16. package/dist/demos/tv-card/CHANGELOG.md +0 -158
  17. package/dist/demos/tv-card/README.md +0 -332
  18. package/dist/demos/tv-demo/CHANGELOG.md +0 -352
  19. package/dist/demos/tv-demo/README.md +0 -229
  20. package/dist/demos/tv-footer/CHANGELOG.md +0 -67
  21. package/dist/demos/tv-footer/README.md +0 -760
  22. package/dist/demos/tv-hero/CHANGELOG.md +0 -137
  23. package/dist/demos/tv-hero/README.md +0 -410
  24. package/dist/demos/tv-label/CHANGELOG.md +0 -138
  25. package/dist/demos/tv-label/README.md +0 -357
  26. package/dist/demos/tv-menu/CHANGELOG.md +0 -145
  27. package/dist/demos/tv-menu/README.md +0 -389
  28. package/dist/demos/tv-modal/CHANGELOG.md +0 -127
  29. package/dist/demos/tv-modal/README.md +0 -466
  30. package/dist/demos/tv-pagination/CHANGELOG.md +0 -125
  31. package/dist/demos/tv-pagination/README.md +0 -275
  32. package/dist/demos/tv-progress-bar/CHANGELOG.md +0 -84
  33. package/dist/demos/tv-progress-bar/README.md +0 -894
  34. package/dist/demos/tv-relative-time/CHANGELOG.md +0 -122
  35. package/dist/demos/tv-relative-time/README.md +0 -405
  36. package/dist/demos/tv-scroll-top/CHANGELOG.md +0 -69
  37. package/dist/demos/tv-scroll-top/README.md +0 -445
  38. package/dist/demos/tv-search/CHANGELOG.md +0 -155
  39. package/dist/demos/tv-search/README.md +0 -407
  40. package/dist/demos/tv-settings/CHANGELOG.md +0 -94
  41. package/dist/demos/tv-settings/README.md +0 -314
  42. package/dist/demos/tv-sidebar/CHANGELOG.md +0 -229
  43. package/dist/demos/tv-sidebar/README.md +0 -592
  44. package/dist/demos/tv-theme-button/CHANGELOG.md +0 -136
  45. package/dist/demos/tv-theme-button/README.md +0 -392
  46. package/dist/demos/tv-toc/CHANGELOG.md +0 -80
  47. package/dist/demos/tv-toc/README.md +0 -288
  48. package/dist/favicon.ico +0 -0
@@ -1,288 +0,0 @@
1
- <p align="center"><img width="150" src="https://res.cloudinary.com/dcdfhi8qz/image/upload/v1763663056/uqqtkgp1lg3xdplutpga.png" alt="TODOvue logo">
2
- </p>
3
-
4
- # TODOvue TOC Component (TvToc)
5
- A lightweight Vue 3 component to render a Table of Contents (TOC) for your articles or documentation, with smooth scrolling and nested sections support.
6
-
7
- [![npm](https://img.shields.io/npm/v/@todovue/tv-toc.svg)](https://www.npmjs.com/package/@todovue/tv-toc)
8
- [![npm downloads](https://img.shields.io/npm/dm/@todovue/tv-toc.svg)](https://www.npmjs.com/package/@todovue/tv-toc)
9
- [![npm total downloads](https://img.shields.io/npm/dt/@todovue/tv-toc.svg)](https://www.npmjs.com/package/@todovue/tv-toc)
10
- ![License](https://img.shields.io/github/license/TODOvue/tv-toc)
11
- ![Release Date](https://img.shields.io/github/release-date/TODOvue/tv-toc)
12
- ![Bundle Size](https://img.shields.io/bundlephobia/minzip/@todovue/tv-toc)
13
- ![Node Version](https://img.shields.io/node/v/@todovue/tv-toc)
14
- ![Last Commit](https://img.shields.io/github/last-commit/TODOvue/tv-toc)
15
- ![Stars](https://img.shields.io/github/stars/TODOvue/tv-toc?style=social)
16
-
17
- > Demo: https://ui.todovue.blog/toc
18
-
19
- ## Table of Contents
20
- - [Features](#features)
21
- - [Installation](#installation)
22
- - [Usage of Styles](#usage-of-styles)
23
- - [Quick Start (SPA)](#quick-start-spa)
24
- - [Nuxt 4 / SSR Usage](#nuxt-4--ssr-usage)
25
- - [Component Registration Options](#component-registration-options)
26
- - [Props](#props)
27
- - [Composable: useToc](#composable-usetoc)
28
- - [Customization (Styles)](#customization-styles)
29
- - [SSR Notes](#ssr-notes)
30
- - [Examples](#examples)
31
- - [Development](#development)
32
- - [Contributing](#contributing)
33
- - [License](#license)
34
-
35
- ## Features
36
- - Simple and focused Table of Contents (TOC) component for Vue 3.
37
- - Supports nested sections via children links.
38
- - Smooth scrolling to headings using `scrollIntoView`.
39
- - URL hash is updated using `history.pushState` for better navigation and shareable links.
40
- - Works in SPA (Vite, Vue CLI) and Nuxt 3 (with client-side rendering constraints).
41
- - Ships with minimal, customizable styles.
42
-
43
- ## Installation
44
- Using npm:
45
- ```bash
46
- npm install @todovue/tv-toc
47
- ```
48
- Using yarn:
49
- ```bash
50
- yarn add @todovue/tv-toc
51
- ```
52
- Using pnpm:
53
- ```bash
54
- pnpm add @todovue/tv-toc
55
- ```
56
-
57
- ## Usage of Styles
58
-
59
- ### Vue/Vite (SPA)
60
- Import the CSS generated by the library in your main entry file:
61
- ```ts
62
- // main.ts
63
- import { createApp } from 'vue'
64
- import App from './App.vue'
65
-
66
- import '@todovue/tv-toc/style.css'
67
- import { TvToc } from '@todovue/tv-toc'
68
-
69
- const app = createApp(App)
70
- app.component('TvToc', TvToc)
71
- app.mount('#app')
72
- ```
73
-
74
- ### Nuxt 3/4
75
- Add the library's CSS to your Nuxt configuration:
76
- ```ts
77
- // nuxt.config.ts
78
- export default defineNuxtConfig({
79
- modules: [
80
- '@todovue/tv-toc/nuxt'
81
- ]
82
- })
83
- ```
84
-
85
- ## Quick Start (SPA)
86
- Global registration (main.js / main.ts):
87
- ```js
88
- import { createApp } from 'vue'
89
- import App from './App.vue'
90
- import TvToc from '@todovue/tv-toc'
91
-
92
- createApp(App)
93
- .component('TvToc', TvToc)
94
- .mount('#app')
95
- ```
96
- Local import inside a component:
97
- ```vue
98
- <script setup>
99
- import { TvToc } from '@todovue/tv-toc'
100
-
101
- const toc = {
102
- title: 'On this page',
103
- links: [
104
- { id: 'introduction', text: 'Introduction' },
105
- {
106
- id: 'getting-started',
107
- text: 'Getting started',
108
- children: [
109
- { id: 'installation', text: 'Installation' },
110
- { id: 'basic-usage', text: 'Basic usage' },
111
- ],
112
- },
113
- { id: 'api', text: 'API Reference' },
114
- ],
115
- }
116
- </script>
117
-
118
- <template>
119
- <div class="page-layout">
120
- <main class="page-content">
121
- <h2 id="introduction">Introduction</h2>
122
- <!-- ... -->
123
- <h2 id="getting-started">Getting started</h2>
124
- <h3 id="installation">Installation</h3>
125
- <h3 id="basic-usage">Basic usage</h3>
126
- <!-- ... -->
127
- <h2 id="api">API Reference</h2>
128
- </main>
129
-
130
- <aside class="page-toc">
131
- <TvToc :toc="toc" />
132
- </aside>
133
- </div>
134
- </template>
135
- ```
136
-
137
- ## Nuxt 4 / SSR Usage
138
- Create a plugin file: `plugins/tv-toc.client.ts` (client-only because it uses `document` and `history` under the hood when scrolling):
139
- ```ts
140
- import { defineNuxtPlugin } from '#app'
141
- import TvToc from '@todovue/tv-toc'
142
-
143
- export default defineNuxtPlugin(nuxtApp => {
144
- nuxtApp.vueApp.component('TvToc', TvToc)
145
- })
146
- ```
147
- Use anywhere (recommended inside `<client-only>` when using Nuxt 3):
148
- ```vue
149
- <template>
150
- <client-only>
151
- <TvToc :toc="toc" />
152
- </client-only>
153
- </template>
154
- ```
155
- Direct import (no plugin):
156
- ```vue
157
- <script setup>
158
- import { TvToc } from '@todovue/tv-toc'
159
- </script>
160
-
161
- <template>
162
- <TvToc :toc="toc" />
163
- </template>
164
- ```
165
-
166
- ## Component Registration Options
167
- | Approach | When to use |
168
- |-----------------------------------------------|-----------------------------------|
169
- | Global via `app.component('TvToc', TvToc)` | Frequent use across the app |
170
- | Local named import `{ TvToc }` | Isolated/code-split contexts |
171
- | Direct default import `import TvToc from ...` | Single use or manual registration |
172
-
173
- ## Props
174
- | Name | Type | Default | Description | Required |
175
- |-----------------|---------|------------|----------------------------------------------------------------------------|----------|
176
- | toc | Object | - | TOC configuration: title and list of links (with optional nested children) | `true` |
177
- | marker | Boolean | `false` | Whether to display a visual marker for the active item. | `false` |
178
- | collapsible | Boolean | `false` | Whether sublists can be collapsed/expanded. | `false` |
179
- | activeClass | String | `'active'` | Custom CSS class for the active item. | `false` |
180
- | observerOptions | Object | `{}` | options to pass to the IntersectionObserver (rootMargin, threshold, etc). | `false` |
181
-
182
- ### `toc` shape
183
- ```ts
184
- type TocLink = {
185
- id: string
186
- text: string
187
- children?: TocLink[]
188
- }
189
-
190
- type Toc = {
191
- title?: string
192
- links: TocLink[]
193
- }
194
- ```
195
- - `title`: Optional title shown at the top of the TOC (`h3`).
196
- - `links`: Array of top-level sections.
197
- - `id`: Must match the `id` attribute of the target heading in your content.
198
- - `text`: Label shown in the TOC.
199
- - `children`: Optional array of subsections, rendered as nested list.
200
-
201
- ## Composable: `useToc`
202
- This composable is used internally by `TvToc` but can also be imported directly if needed.
203
-
204
- ```ts
205
- import { useToc } from '@todovue/tv-toc'
206
-
207
- const { formatId, scrollToId } = useToc(links, {
208
- rootMargin: '0px 0px -50% 0px'
209
- })
210
- ```
211
-
212
- ### API
213
- | Name | Type | Description |
214
- |------------|--------------------------|----------------------------------------------------------------|
215
- | formatId | `(id: string) => string` | Returns a hash-based id string (e.g. `"#section-id"`). |
216
- | scrollToId | `(id: string) => void` | Smooth scrolls to the element with that `id` and updates hash. |
217
-
218
- > Note: `scrollToId` accesses `document` and `history`, so it should run only in the browser (e.g. in event handlers or inside `onMounted`).
219
-
220
- ## Customization (Styles)
221
- The component ships with minimal default styles, exposed through the built CSS file and scoped CSS classes.
222
-
223
- Main CSS classes:
224
- - `.tv-toc` — Root `<nav>` container.
225
- - `.tv-toc-title` — Title of the TOC.
226
- - `.tv-toc-list` — Top-level list container.
227
- - `.tv-toc-item` — Top-level list item.
228
- - `.tv-toc-link` — Anchor for top-level items.
229
- - `.tv-toc-sublist` — Nested list container for children.
230
- - `.tv-toc-subitem` — Nested list item.
231
- - `.tv-toc-sublink` — Anchor for nested items.
232
-
233
- You can override these styles in your own global stylesheet:
234
- ```css
235
- /* example overrides */
236
- .tv-toc {
237
- font-size: 0.9rem;
238
- }
239
-
240
- .tv-toc-link,
241
- .tv-toc-sublink {
242
- color: #4b5563;
243
- }
244
-
245
- .tv-toc-link:hover,
246
- .tv-toc-sublink:hover {
247
- color: #111827;
248
- }
249
- ```
250
-
251
- If you are using SCSS, you can also rely on your own design tokens and overrides. The package itself internally uses SCSS (see `src/assets/scss/_variables.scss` and `src/assets/scss/style.scss`).
252
-
253
- ## SSR Notes
254
- - The component can be rendered on the server (template is static), but scrolling behavior uses browser APIs.
255
- - `scrollToId` uses `document.getElementById` and `history.pushState`; these are only invoked in event handlers on the client.
256
- - When using Nuxt 3, prefer registering `TvToc` in a `*.client.ts` plugin or wrap usages in `<client-only>` to avoid hydration edge cases in environments with stricter SSR.
257
-
258
- ## Examples
259
- This repository includes a small demo application built with Vite.
260
-
261
- - Basic TOC example.
262
- - Blog-like layout with nested headings.
263
-
264
- To run the demo locally, see the [Development](#development) section.
265
-
266
- ## Development
267
- ```bash
268
- git clone https://github.com/TODOvue/tv-toc.git
269
- cd tv-toc
270
- npm install
271
- npm run dev # run local demo
272
- npm run build # build library
273
- ```
274
- The local demo is served with Vite using `index.html` and examples in `src/demo`.
275
-
276
- To build the standalone demo used for documentation:
277
- ```bash
278
- npm run build:demo
279
- ```
280
-
281
- ## Contributing
282
- PRs and issues are welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
283
-
284
- ## License
285
- MIT © TODOvue
286
-
287
- ### Attributions
288
- Crafted for the TODOvue component ecosystem
package/dist/favicon.ico DELETED
Binary file