@todovue/tv-ui 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +207 -0
- package/dist/.htaccess +8 -0
- package/dist/demos/tv-alert/CHANGELOG.md +127 -0
- package/dist/demos/tv-alert/README.md +334 -0
- package/dist/demos/tv-article/CHANGELOG.md +221 -0
- package/dist/demos/tv-article/README.md +258 -0
- package/dist/demos/tv-breadcrumbs/CHANGELOG.md +135 -0
- package/dist/demos/tv-breadcrumbs/README.md +364 -0
- package/dist/demos/tv-button/CHANGELOG.md +158 -0
- package/dist/demos/tv-button/README.md +255 -0
- package/dist/demos/tv-card/CHANGELOG.md +158 -0
- package/dist/demos/tv-card/README.md +332 -0
- package/dist/demos/tv-demo/CHANGELOG.md +352 -0
- package/dist/demos/tv-demo/README.md +229 -0
- package/dist/demos/tv-footer/CHANGELOG.md +67 -0
- package/dist/demos/tv-footer/README.md +760 -0
- package/dist/demos/tv-hero/CHANGELOG.md +137 -0
- package/dist/demos/tv-hero/README.md +410 -0
- package/dist/demos/tv-label/CHANGELOG.md +138 -0
- package/dist/demos/tv-label/README.md +357 -0
- package/dist/demos/tv-menu/CHANGELOG.md +145 -0
- package/dist/demos/tv-menu/README.md +389 -0
- package/dist/demos/tv-modal/CHANGELOG.md +127 -0
- package/dist/demos/tv-modal/README.md +466 -0
- package/dist/demos/tv-pagination/CHANGELOG.md +125 -0
- package/dist/demos/tv-pagination/README.md +275 -0
- package/dist/demos/tv-progress-bar/CHANGELOG.md +84 -0
- package/dist/demos/tv-progress-bar/README.md +894 -0
- package/dist/demos/tv-relative-time/CHANGELOG.md +122 -0
- package/dist/demos/tv-relative-time/README.md +405 -0
- package/dist/demos/tv-scroll-top/CHANGELOG.md +69 -0
- package/dist/demos/tv-scroll-top/README.md +445 -0
- package/dist/demos/tv-search/CHANGELOG.md +155 -0
- package/dist/demos/tv-search/README.md +407 -0
- package/dist/demos/tv-settings/CHANGELOG.md +94 -0
- package/dist/demos/tv-settings/README.md +314 -0
- package/dist/demos/tv-sidebar/CHANGELOG.md +229 -0
- package/dist/demos/tv-sidebar/README.md +592 -0
- package/dist/demos/tv-theme-button/CHANGELOG.md +136 -0
- package/dist/demos/tv-theme-button/README.md +392 -0
- package/dist/demos/tv-toc/CHANGELOG.md +80 -0
- package/dist/demos/tv-toc/README.md +288 -0
- package/dist/entry.d.ts +48 -0
- package/dist/favicon.ico +0 -0
- package/dist/tv-ui.cjs.js +1 -0
- package/dist/tv-ui.css +1 -0
- package/dist/tv-ui.d.ts +6 -0
- package/dist/tv-ui.es.js +92 -0
- package/nuxt.js +58 -0
- package/package.json +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cristhian Daza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
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 UI (TvUi)
|
|
5
|
+
An **umbrella** package for Vue 3 that installs and re-exports the official `@todovue/*` components.
|
|
6
|
+
|
|
7
|
+
> Important: **this is NOT a monorepo**. `@todovue/tv-ui` is a library that declares dependencies on each `@todovue/tv-*` component (by the version published on npm), and re-exports them for unified consumption.
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@todovue/tv-ui)
|
|
10
|
+
[](https://www.npmjs.com/package/@todovue/tv-ui)
|
|
11
|
+
[](https://www.npmjs.com/package/@todovue/tv-ui)
|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
> Demo / docs: https://ui.todovue.blog
|
|
20
|
+
|
|
21
|
+
## Table of contents
|
|
22
|
+
- [Features](#features)
|
|
23
|
+
- [Installation](#installation)
|
|
24
|
+
- [Quick Start (SPA)](#quick-start-spa)
|
|
25
|
+
- [Using styles](#using-styles)
|
|
26
|
+
- [Nuxt (SSR) / Nuxt Module](#nuxt-ssr--nuxt-module)
|
|
27
|
+
- [Exported components](#exported-components)
|
|
28
|
+
- [Registration options](#registration-options)
|
|
29
|
+
- [SSR notes](#ssr-notes)
|
|
30
|
+
- [Development](#development)
|
|
31
|
+
- [Contributing](#contributing)
|
|
32
|
+
- [License](#license)
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
- **One-time install** to get TODOvue components available.
|
|
36
|
+
- **Vue plugin**: `app.use(TvUi)` registers components globally.
|
|
37
|
+
- **Re-exports**: you can import specific components from `@todovue/tv-ui`.
|
|
38
|
+
- Compatible with **SPA** (Vite/Vue CLI) and **SSR** (Nuxt) as long as your app imports the styles.
|
|
39
|
+
- **Does not bundle Vue nor the `@todovue/*` packages** into the build: they remain external dependencies (great for ecosystems and tree-shaking).
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
With npm:
|
|
43
|
+
```bash
|
|
44
|
+
npm install @todovue/tv-ui
|
|
45
|
+
```
|
|
46
|
+
With yarn:
|
|
47
|
+
```bash
|
|
48
|
+
yarn add @todovue/tv-ui
|
|
49
|
+
```
|
|
50
|
+
With pnpm:
|
|
51
|
+
```bash
|
|
52
|
+
pnpm add @todovue/tv-ui
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> Node requirement for this repo: `>= 20.19.0`.
|
|
56
|
+
|
|
57
|
+
## Quick Start (SPA)
|
|
58
|
+
Global registration (main.js / main.ts):
|
|
59
|
+
```js
|
|
60
|
+
import { createApp } from 'vue'
|
|
61
|
+
import App from './App.vue'
|
|
62
|
+
|
|
63
|
+
// Styles (see “Using styles” section)
|
|
64
|
+
import '@todovue/tv-ui/style.css'
|
|
65
|
+
|
|
66
|
+
import TvUi from '@todovue/tv-ui'
|
|
67
|
+
|
|
68
|
+
createApp(App)
|
|
69
|
+
.use(TvUi) // enables <TvButton />, <TvCard />, etc. globally
|
|
70
|
+
.mount('#app')
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Usage in a component:
|
|
74
|
+
```vue
|
|
75
|
+
<template>
|
|
76
|
+
<TvButton variant="success" icon="check">Save</TvButton>
|
|
77
|
+
</template>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Local import (named export) if you prefer granular control:
|
|
81
|
+
```vue
|
|
82
|
+
<script setup>
|
|
83
|
+
import '@todovue/tv-ui/style.css'
|
|
84
|
+
import { TvButton, TvCard } from '@todovue/tv-ui'
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<template>
|
|
88
|
+
<TvCard>
|
|
89
|
+
<TvButton>Action</TvButton>
|
|
90
|
+
</TvCard>
|
|
91
|
+
</template>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Using styles
|
|
95
|
+
`@todovue/tv-ui` exposes a styles entry:
|
|
96
|
+
|
|
97
|
+
- Recommended import:
|
|
98
|
+
```js
|
|
99
|
+
import '@todovue/tv-ui/style.css'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This points to `./dist/tv-ui.css` (via `exports["./style.css"]`).
|
|
103
|
+
|
|
104
|
+
### What about per-component styles?
|
|
105
|
+
You can also import styles from each package:
|
|
106
|
+
```js
|
|
107
|
+
import '@todovue/tv-button/style.css'
|
|
108
|
+
import '@todovue/tv-card/style.css'
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This is useful if you:
|
|
112
|
+
- only use 1–2 components,
|
|
113
|
+
- want to control exactly what CSS gets into your bundle,
|
|
114
|
+
- or are migrating gradually.
|
|
115
|
+
|
|
116
|
+
## Nuxt (SSR) / Nuxt Module
|
|
117
|
+
This package publishes a Nuxt module at `@todovue/tv-ui/nuxt` that **injects the CSS** of `@todovue/*` packages into `nuxt.options.css`.
|
|
118
|
+
|
|
119
|
+
### Setup
|
|
120
|
+
```ts
|
|
121
|
+
// nuxt.config.ts
|
|
122
|
+
export default defineNuxtConfig({
|
|
123
|
+
modules: [
|
|
124
|
+
'@todovue/tv-ui/nuxt'
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Plugin registration (optional)
|
|
130
|
+
You can register all components globally:
|
|
131
|
+
```ts
|
|
132
|
+
// plugins/tv-ui.ts
|
|
133
|
+
import { defineNuxtPlugin } from '#app'
|
|
134
|
+
import TvUi from '@todovue/tv-ui'
|
|
135
|
+
|
|
136
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
137
|
+
nuxtApp.vueApp.use(TvUi)
|
|
138
|
+
})
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Or import them locally:
|
|
142
|
+
```vue
|
|
143
|
+
<script setup>
|
|
144
|
+
import { TvButton } from '@todovue/tv-ui'
|
|
145
|
+
</script>
|
|
146
|
+
|
|
147
|
+
<template>
|
|
148
|
+
<TvButton>Hello</TvButton>
|
|
149
|
+
</template>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Exported components
|
|
153
|
+
Currently `@todovue/tv-ui` re-exports:
|
|
154
|
+
|
|
155
|
+
- `TvAlert`
|
|
156
|
+
- `TvArticle`
|
|
157
|
+
- `TvBreadcrumbs`
|
|
158
|
+
- `TvButton`
|
|
159
|
+
- `TvCard`
|
|
160
|
+
- `TvDemo`
|
|
161
|
+
- `TvFooter`
|
|
162
|
+
- `TvHero`
|
|
163
|
+
- `TvLabel`
|
|
164
|
+
- `TvMenu`
|
|
165
|
+
- `TvModal`
|
|
166
|
+
- `TvPagination`
|
|
167
|
+
- `TvProgressBar`
|
|
168
|
+
- `TvRelativeTime`
|
|
169
|
+
- `TvScrollTop`
|
|
170
|
+
- `TvSearch`
|
|
171
|
+
- `TvSettings`
|
|
172
|
+
- `TvSidebar`
|
|
173
|
+
- `TvThemeButton`
|
|
174
|
+
- `TvToc`
|
|
175
|
+
|
|
176
|
+
## Registration options
|
|
177
|
+
| Approach | Example | When to use |
|
|
178
|
+
|---------------------|---------------------------------------------|------------------------------------------------------|
|
|
179
|
+
| Global via plugin | `app.use(TvUi)` | You use many components across the whole app |
|
|
180
|
+
| Local import | `import { TvButton } from '@todovue/tv-ui'` | Isolated views, code-splitting, fine-grained control |
|
|
181
|
+
| Individual packages | `import TvButton from '@todovue/tv-button'` | If you want to install/update components separately |
|
|
182
|
+
|
|
183
|
+
## SSR notes
|
|
184
|
+
- This package does not assume a DOM during plugin installation.
|
|
185
|
+
- Still, SSR compatibility depends on each `@todovue/*` component not accessing `window/document` at render time.
|
|
186
|
+
- In Nuxt, the `@todovue/tv-ui/nuxt` module takes care of registering global CSS for you.
|
|
187
|
+
|
|
188
|
+
## Development
|
|
189
|
+
Available scripts:
|
|
190
|
+
- `dev`: copies `README.md`/`CHANGELOG.md` from `node_modules/@todovue/*` into `public/demos/*` and starts Vite.
|
|
191
|
+
- `build`: library build (ESM + CJS) + types.
|
|
192
|
+
- `build:demo`: builds the demo (target `demo`) and copies `README.md`/`CHANGELOG.md` to `public/`.
|
|
193
|
+
|
|
194
|
+
Commands:
|
|
195
|
+
```bash
|
|
196
|
+
npm run dev
|
|
197
|
+
npm run build
|
|
198
|
+
npm run build:demo
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Contributing
|
|
202
|
+
PRs and issues are welcome. See:
|
|
203
|
+
- `CONTRIBUTING.md`
|
|
204
|
+
- `CODE_OF_CONDUCT.md`
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
MIT © TODOvue
|
package/dist/.htaccess
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.2.1] - 2026-01-27
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Simplified the file list in `package.json` to include only essential assets.
|
|
12
|
+
- Simplified the build configuration by removing demo-specific logic.
|
|
13
|
+
- Enhanced GitHub Actions workflows to automate npm package publishing and GitHub release creation.
|
|
14
|
+
- Moved the `@todovue/tv-demo` component import from main.js to `Demo.vue` to localize its usage.
|
|
15
|
+
- Updated build commands to include `README.md` and `CHANGELOG.md` files in the public directory during the build process.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Included the `src` directory in the `package.json` files list to ensure component source files are bundled in the package distribution.
|
|
19
|
+
|
|
20
|
+
### Removed
|
|
21
|
+
- Eliminated the global import of the `@todovue/tv-demo` component from `main.js`.
|
|
22
|
+
|
|
23
|
+
### Dependencies
|
|
24
|
+
- Updated `@todovue/tv-demo` to `^1.4.11`.
|
|
25
|
+
- Updated `@todovue/tv-button` to `^1.2.5`.
|
|
26
|
+
- Updated `vue` to `^3.5.27`.
|
|
27
|
+
- Updated `sass` to `^1.97.3`.
|
|
28
|
+
|
|
29
|
+
## [1.2.0] - 2026-01-20
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
- Enhanced the Alert component with support for customizable icons and titles.
|
|
33
|
+
- Added action slots to the Alert component to support interactive elements within notifications.
|
|
34
|
+
|
|
35
|
+
### Dependencies
|
|
36
|
+
- Updated the `@todovue/tv-button` dependency to `^1.2.4`.
|
|
37
|
+
- Updated the `@todovue/tv-demo` dependency to `^1.4.4`.
|
|
38
|
+
- Updated the `sass` dependency to `^1.97.2`.
|
|
39
|
+
- Updated the `vite` dependency to `^7.3.1`.
|
|
40
|
+
|
|
41
|
+
## [1.1.1] - 2025-12-19
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- Added automatic publishing to the TODOvue cPanel in `release.yml` for each release, simplifying package distribution and updates.
|
|
45
|
+
- Added `package-lock.json` to the repository to ensure dependency consistency and facilitate version management across development and production environments.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
- Changed the `base` option in `vite.config.js` for website deployment in cpanel.
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
- Fixed repository URL in `package.json` to point to the correct GitHub repository.
|
|
52
|
+
- Fixed the token configuration used to generate the package in the GitHub Actions workflow `release.yml`.
|
|
53
|
+
|
|
54
|
+
### Dependencies
|
|
55
|
+
- Updated dependency versions in `package.json` to maintain compatibility and benefit from improvements and bug fixes in the used libraries.
|
|
56
|
+
|
|
57
|
+
## [1.1.0] - 2025-11-21
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
- Added `nux.js` configuration file for Nuxt 4 integration.
|
|
61
|
+
- Added `tsconfig.json` for proper type checking during build.
|
|
62
|
+
- Create `global.d.ts` to declare module for TypeScript users.
|
|
63
|
+
- Added Nuxt module for automatic style injection and auto-registration of the `TvAlert` component.
|
|
64
|
+
- The `@todovue/tv-alert` component is now externalized from the final build, reducing bundle size.
|
|
65
|
+
- Added `CHANGELOG.md` in script to generate demo and documentation site.
|
|
66
|
+
|
|
67
|
+
### Dependencies
|
|
68
|
+
- Updated the `@todovue/tv-demo` dependency to `^1.2.1` to ensure compatibility with the latest changes.
|
|
69
|
+
- Updated the `@todovue/tv-button` dependency to `^1.2.2` to ensure compatibility with the latest changes.
|
|
70
|
+
|
|
71
|
+
## [1.0.2] - 2025-11-18
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
- **BREAKING FIX**: Exported `useAlert` composable from the library entry point (`src/entry.ts`). Previously, the composable was not accessible when importing from `@todovue/tv-alert`, causing errors when trying to use `import { useAlert } from '@todovue/tv-alert'`.
|
|
75
|
+
- Fixed incorrect imports in demo files that were importing from `@todovue/tv-button` instead of `@todovue/tv-alert`.
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
- Proper exports in both ESM and CJS bundles for `useAlert`.
|
|
79
|
+
|
|
80
|
+
## [1.0.1] - 2025-11-15
|
|
81
|
+
|
|
82
|
+
### Changed
|
|
83
|
+
- Styles are now served as a separate CSS file (`dist/tv-alert.css`) generated by Vite during the build process.
|
|
84
|
+
- Users must now explicitly import the stylesheet in their application:
|
|
85
|
+
- For Vue/Vite SPA: `import '@todovue/tv-alert/style.css'` in `main.ts`
|
|
86
|
+
- For Nuxt 3/4: Add `'@todovue/tv-alert/style.css'` to the `css` array in `nuxt.config.ts`
|
|
87
|
+
|
|
88
|
+
### Added
|
|
89
|
+
- Added `sideEffects` field to `package.json` to support proper tree-shaking with CSS files.
|
|
90
|
+
- Added `./style.css` export path in `package.json` for explicit CSS imports.
|
|
91
|
+
- Improved SSR/SSG compatibility, especially for Nuxt 3/4 applications.
|
|
92
|
+
|
|
93
|
+
### Dependencies
|
|
94
|
+
- Removed dependency on `vite-plugin-css-injected-by-js` from `devDependencies`
|
|
95
|
+
|
|
96
|
+
## [1.0.0] - 2025-11-11
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
- Initial release of TvAlert component
|
|
100
|
+
- Multiple alert types: `info`, `success`, `warning`, `error`
|
|
101
|
+
- Six position options: `top-right`, `top-center`, `top-left`, `bottom-right`, `bottom-center`, `bottom-left`
|
|
102
|
+
- Auto-dismiss functionality with customizable duration
|
|
103
|
+
- Progress bar showing remaining time
|
|
104
|
+
- Pause on hover feature (configurable via `pauseOnHover` option)
|
|
105
|
+
- Optional close button (configurable via `showClose` option)
|
|
106
|
+
- Stack multiple alerts in the same position with configurable max limit
|
|
107
|
+
- Composable API `useAlert` with programmatic methods
|
|
108
|
+
- Type-specific convenience methods: `alert.info()`, `alert.success()`, `alert.warning()`, `alert.error()`
|
|
109
|
+
- Generic `alert.open()` method with full options support
|
|
110
|
+
- Smooth slide-in/slide-out transitions based on position
|
|
111
|
+
- ARIA accessibility attributes (`aria-live`, `role`, `aria-label`)
|
|
112
|
+
- SSR compatibility (works with Nuxt 3 and other SSR frameworks)
|
|
113
|
+
- Vue 3 plugin support for global registration
|
|
114
|
+
- TypeScript definitions
|
|
115
|
+
- SCSS styling with customizable variables
|
|
116
|
+
- Icon slot support for custom icons per alert type
|
|
117
|
+
- Alert management methods: `removeAlert()`, `clearAll()`
|
|
118
|
+
- Reactive alerts array access
|
|
119
|
+
- Tree-shakeable ES module build
|
|
120
|
+
|
|
121
|
+
[1.2.1]: https://github.com/TODOvue/todovue-alert/pull/8/files
|
|
122
|
+
[1.2.0]: https://github.com/TODOvue/todovue-alert/pull/7/files
|
|
123
|
+
[1.1.1]: https://github.com/TODOvue/todovue-alert/pull/6/files
|
|
124
|
+
[1.1.0]: https://github.com/TODOvue/todovue-alert/pull/5/files
|
|
125
|
+
[1.0.2]: https://github.com/TODOvue/todovue-alert/pull/4/files
|
|
126
|
+
[1.0.1]: https://github.com/TODOvue/todovue-alert/pull/3/files
|
|
127
|
+
[1.0.0]: https://github.com/TODOvue/todovue-alert/pull/1/files
|
|
@@ -0,0 +1,334 @@
|
|
|
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 Alert (TvAlert)
|
|
5
|
+
A flexible, framework‑agnostic Vue 3 alert/notification component with multiple positions, types, progress bar, pause on hover, and customization utilities. Ship it in Single Page Apps or Server-Side Rendered (SSR) environments (e.g. Nuxt 3) with zero DOM assumptions.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@todovue/tv-alert)
|
|
8
|
+
[](https://www.npmjs.com/package/@todovue/tv-alert)
|
|
9
|
+
[](https://www.npmjs.com/package/@todovue/tv-alert)
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
> Demo: https://ui.todovue.blog/alert
|
|
18
|
+
|
|
19
|
+
## Table of Contents
|
|
20
|
+
- [Features](#features)
|
|
21
|
+
- [Installation](#installation)
|
|
22
|
+
- [Quick Start (SPA)](#quick-start-spa)
|
|
23
|
+
- [Nuxt 4 / SSR Usage](#nuxt-4--ssr-usage)
|
|
24
|
+
- [Component Registration Options](#component-registration-options)
|
|
25
|
+
- [Props](#props)
|
|
26
|
+
- [Alert Options](#alert-options)
|
|
27
|
+
- [Composable API (useAlert)](#composable-api-usealert)
|
|
28
|
+
- [Positions](#positions)
|
|
29
|
+
- [Alert Types](#alert-types)
|
|
30
|
+
- [Customization (Styles / Theming)](#customization-styles--theming)
|
|
31
|
+
- [Accessibility](#accessibility)
|
|
32
|
+
- [SSR Notes](#ssr-notes)
|
|
33
|
+
- [Development](#development)
|
|
34
|
+
- [Contributing](#contributing)
|
|
35
|
+
- [License](#license)
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
- Multiple alert types: info, success, warning, error
|
|
39
|
+
- Six position options: top-right, top-center, top-left, bottom-right, bottom-center, bottom-left
|
|
40
|
+
- Auto-dismiss with customizable duration
|
|
41
|
+
- Progress bar showing remaining time
|
|
42
|
+
- Pause on hover (configurable)
|
|
43
|
+
- Optional close button
|
|
44
|
+
- Stack multiple alerts in the same position (with max limit)
|
|
45
|
+
- Programmatic API via composable (`useAlert`)
|
|
46
|
+
- Smooth slide-in/slide-out transitions
|
|
47
|
+
- Works in SPA and SSR (Nuxt 3) contexts
|
|
48
|
+
- Tree-shake friendly (Vue marked external in library build)
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
Using npm:
|
|
52
|
+
```bash
|
|
53
|
+
npm install @todovue/tv-alert
|
|
54
|
+
```
|
|
55
|
+
Using yarn:
|
|
56
|
+
```bash
|
|
57
|
+
yarn add @todovue/tv-alert
|
|
58
|
+
```
|
|
59
|
+
Using pnpm:
|
|
60
|
+
```bash
|
|
61
|
+
pnpm add @todovue/tv-alert
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start (SPA)
|
|
65
|
+
Global registration (main.js / main.ts):
|
|
66
|
+
```js
|
|
67
|
+
import { createApp } from 'vue'
|
|
68
|
+
import App from './App.vue'
|
|
69
|
+
|
|
70
|
+
import '@todovue/tv-alert/style.css'
|
|
71
|
+
import { TvAlert } from '@todovue/tv-alert'
|
|
72
|
+
|
|
73
|
+
const app = createApp(App)
|
|
74
|
+
app.component('TvAlert', TvAlert)
|
|
75
|
+
app.mount('#app')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
In your root component (App.vue):
|
|
79
|
+
```vue
|
|
80
|
+
<template>
|
|
81
|
+
<div id="app">
|
|
82
|
+
<TvAlert />
|
|
83
|
+
<router-view />
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Using the alert in any component:
|
|
89
|
+
```vue
|
|
90
|
+
<script setup>
|
|
91
|
+
import { useAlert } from '@todovue/tv-alert'
|
|
92
|
+
|
|
93
|
+
const { api } = useAlert()
|
|
94
|
+
const alert = api()
|
|
95
|
+
|
|
96
|
+
function showNotification() {
|
|
97
|
+
alert.success('Operation completed successfully!')
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<template>
|
|
102
|
+
<button @click="showNotification">Show Alert</button>
|
|
103
|
+
</template>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Nuxt 4 / SSR Usage
|
|
107
|
+
|
|
108
|
+
**Step 1:** Add the stylesheet to your `nuxt.config.ts`:
|
|
109
|
+
```ts
|
|
110
|
+
// nuxt.config.ts
|
|
111
|
+
export default defineNuxtConfig({
|
|
112
|
+
modules: [
|
|
113
|
+
'@todovue/tv-alert/nuxt'
|
|
114
|
+
]
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Step 2:** Create a plugin file: `plugins/tv-alert.client.ts` (client-only is fine, or without suffix for SSR as it is safe):
|
|
119
|
+
```ts
|
|
120
|
+
import { defineNuxtPlugin } from '#app'
|
|
121
|
+
import { TvAlert } from '@todovue/tv-alert'
|
|
122
|
+
|
|
123
|
+
export default defineNuxtPlugin(nuxtApp => {
|
|
124
|
+
nuxtApp.vueApp.component('TvAlert', TvAlert)
|
|
125
|
+
})
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Step 3:** Add the component to your app.vue or layout:
|
|
129
|
+
```vue
|
|
130
|
+
<template>
|
|
131
|
+
<div>
|
|
132
|
+
<TvAlert />
|
|
133
|
+
<NuxtPage />
|
|
134
|
+
</div>
|
|
135
|
+
</template>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Use anywhere:
|
|
139
|
+
```vue
|
|
140
|
+
<script setup>
|
|
141
|
+
import { useAlert } from '@todovue/tv-alert'
|
|
142
|
+
|
|
143
|
+
const { api } = useAlert()
|
|
144
|
+
const alert = api()
|
|
145
|
+
|
|
146
|
+
function notify() {
|
|
147
|
+
alert.info('Welcome to our app!')
|
|
148
|
+
}
|
|
149
|
+
</script>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Component Registration Options
|
|
153
|
+
| Approach | When to use |
|
|
154
|
+
|-------------------------------------------------------------------|------------------------------------------------|
|
|
155
|
+
| Global via `app.use(TvAlert)` | Recommended - single instance across app |
|
|
156
|
+
| Local named import `{ TvAlert }` | When you need multiple alert containers |
|
|
157
|
+
| Direct default import `import TvAlert from '@todovue/tv-alert'` | Single usage or manual registration |
|
|
158
|
+
|
|
159
|
+
## Props
|
|
160
|
+
The `TvAlert` component accepts the following props:
|
|
161
|
+
|
|
162
|
+
| Prop | Type | Default | Description |
|
|
163
|
+
|------|--------|---------|--------------------------------------------------|
|
|
164
|
+
| max | Number | 8 | Maximum number of alerts to display per position |
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
```vue
|
|
168
|
+
<TvAlert :max="5" />
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Alert Options
|
|
172
|
+
When calling `alert.open()` or type-specific methods, you can pass an options object:
|
|
173
|
+
|
|
174
|
+
| Option | Type | Default | Description |
|
|
175
|
+
|---------------|---------|--------------|-------------------------------------------------------|
|
|
176
|
+
| title | String | null | Optional bold title above the message |
|
|
177
|
+
| message | String | '' | The message to display in the alert |
|
|
178
|
+
| type | String | 'info' | Alert type: 'info', 'success', 'warning', or 'error' |
|
|
179
|
+
| position | String | 'top-right' | Position of the alert (see Positions section) |
|
|
180
|
+
| duration | Number | 4000 | Duration in milliseconds (0 = never auto-dismiss) |
|
|
181
|
+
| showClose | Boolean | true | Show/hide close button |
|
|
182
|
+
| pauseOnHover | Boolean | true | Pause auto-dismiss timer on mouse hover |
|
|
183
|
+
| showProgress | Boolean | true | Show/hide progress bar |
|
|
184
|
+
| icon | String | null | Custom icon implementation (not widely used) |
|
|
185
|
+
| customIcon | String | null | SVG/HTML string for a custom icon replacing default |
|
|
186
|
+
| actions | Array | [] | Array of action buttons: `{ label, handler(item) }` |
|
|
187
|
+
| allowHtml | Boolean | false | Allow HTML content in the message |
|
|
188
|
+
|
|
189
|
+
Example:
|
|
190
|
+
```js
|
|
191
|
+
alert.open({
|
|
192
|
+
message: 'Custom alert',
|
|
193
|
+
type: 'warning',
|
|
194
|
+
position: 'bottom-center',
|
|
195
|
+
duration: 6000,
|
|
196
|
+
showClose: true,
|
|
197
|
+
pauseOnHover: true,
|
|
198
|
+
showProgress: true
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Composable API (useAlert)
|
|
203
|
+
The `useAlert` composable provides methods to manage alerts programmatically:
|
|
204
|
+
|
|
205
|
+
```js
|
|
206
|
+
import { useAlert } from '@todovue/tv-alert'
|
|
207
|
+
|
|
208
|
+
const { api, addAlert, removeAlert, clearAll, alerts } = useAlert()
|
|
209
|
+
|
|
210
|
+
// Get the simplified API
|
|
211
|
+
const alert = api()
|
|
212
|
+
|
|
213
|
+
// Type-specific methods
|
|
214
|
+
alert.info('Information message')
|
|
215
|
+
alert.success('Success message')
|
|
216
|
+
alert.warning('Warning message')
|
|
217
|
+
alert.error('Error message')
|
|
218
|
+
|
|
219
|
+
// Generic method with full options
|
|
220
|
+
alert.open({
|
|
221
|
+
message: 'Custom alert',
|
|
222
|
+
type: 'info',
|
|
223
|
+
position: 'top-center',
|
|
224
|
+
duration: 5000
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
// Direct methods
|
|
228
|
+
addAlert({ message: 'Direct call', type: 'success' })
|
|
229
|
+
clearAll() // Remove all alerts
|
|
230
|
+
|
|
231
|
+
// Access reactive alerts array
|
|
232
|
+
console.log(alerts.value) // Array of current alerts
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### API Methods
|
|
236
|
+
|
|
237
|
+
| Method | Parameters | Returns | Description |
|
|
238
|
+
|-----------------|------------------|---------|--------------------------------------|
|
|
239
|
+
| api() | none | Object | Returns simplified alert API |
|
|
240
|
+
| alert.info() | message, options | Number | Show info alert, returns alert ID |
|
|
241
|
+
| alert.success() | message, options | Number | Show success alert, returns alert ID |
|
|
242
|
+
| alert.warning() | message, options | Number | Show warning alert, returns alert ID |
|
|
243
|
+
| alert.error() | message, options | Number | Show error alert, returns alert ID |
|
|
244
|
+
| alert.open() | options | Number | Show alert with custom options |
|
|
245
|
+
| addAlert() | options | Number | Add alert directly |
|
|
246
|
+
| removeAlert() | id | void | Remove specific alert by ID |
|
|
247
|
+
| clearAll() | none | void | Remove all alerts |
|
|
248
|
+
|
|
249
|
+
## Positions
|
|
250
|
+
TvAlert supports six different positions:
|
|
251
|
+
|
|
252
|
+
- `top-right` (default)
|
|
253
|
+
- `top-center`
|
|
254
|
+
- `top-left`
|
|
255
|
+
- `bottom-right`
|
|
256
|
+
- `bottom-center`
|
|
257
|
+
- `bottom-left`
|
|
258
|
+
|
|
259
|
+
Example:
|
|
260
|
+
```js
|
|
261
|
+
alert.success('Top left notification', { position: 'top-left' })
|
|
262
|
+
alert.warning('Bottom center notification', { position: 'bottom-center' })
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Alert Types
|
|
266
|
+
Four alert types are available, each with its own color scheme:
|
|
267
|
+
|
|
268
|
+
- `info` - Blue themed (informational messages)
|
|
269
|
+
- `success` - Green themed (success/completion messages)
|
|
270
|
+
- `warning` - Orange/Yellow themed (warning messages)
|
|
271
|
+
- `error` - Red themed (error/critical messages)
|
|
272
|
+
|
|
273
|
+
Examples:
|
|
274
|
+
```js
|
|
275
|
+
alert.info('This is an information alert')
|
|
276
|
+
alert.success('Operation completed successfully!')
|
|
277
|
+
alert.warning('Please review your input')
|
|
278
|
+
alert.error('An error occurred')
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Customization (Styles / Theming)
|
|
282
|
+
The component uses SCSS variables for theming. You can customize the appearance by overriding the CSS variables or by modifying the SCSS variables:
|
|
283
|
+
|
|
284
|
+
Colors are automatically applied based on the alert type. The component includes:
|
|
285
|
+
- Type-specific background colors
|
|
286
|
+
- Progress bar animations
|
|
287
|
+
- Smooth slide transitions
|
|
288
|
+
- Hover effects
|
|
289
|
+
|
|
290
|
+
For advanced customization, you can override the CSS classes:
|
|
291
|
+
```css
|
|
292
|
+
.tv-alert {
|
|
293
|
+
/* Custom styles */
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.tv-alert--success {
|
|
297
|
+
/* Custom success styles */
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.tv-alert__progress-bar {
|
|
301
|
+
/* Custom progress bar */
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Accessibility
|
|
306
|
+
- Each alert container has `aria-live="polite"` for screen reader announcements
|
|
307
|
+
- Individual alerts have `role="status"` for proper ARIA semantics
|
|
308
|
+
- Close buttons include `aria-label` for accessibility
|
|
309
|
+
- Keyboard navigation supported (close button is focusable)
|
|
310
|
+
|
|
311
|
+
## SSR Notes
|
|
312
|
+
- No direct DOM (`window` / `document`) access in source → safe for SSR
|
|
313
|
+
- Styles are automatically applied when you import the library
|
|
314
|
+
- Works seamlessly with Nuxt 3 and other SSR frameworks
|
|
315
|
+
- The composable uses Vue's reactivity system, compatible with SSR
|
|
316
|
+
|
|
317
|
+
## Development
|
|
318
|
+
```bash
|
|
319
|
+
git clone https://github.com/TODOvue/tv-alert.git
|
|
320
|
+
cd tv-alert
|
|
321
|
+
npm install
|
|
322
|
+
npm run dev # run demo playground
|
|
323
|
+
npm run build # build library
|
|
324
|
+
```
|
|
325
|
+
Local demo served from Vite using `index.html` + `src/demo` examples.
|
|
326
|
+
|
|
327
|
+
## Contributing
|
|
328
|
+
PRs and issues welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
|
|
329
|
+
|
|
330
|
+
## License
|
|
331
|
+
MIT © TODOvue
|
|
332
|
+
|
|
333
|
+
### Attributions
|
|
334
|
+
Crafted for the TODOvue component ecosystem
|