@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.
- package/README.md +20 -20
- package/dist/entry.d.ts +2 -2
- package/dist/tv-ui.cjs.js +1 -1
- package/dist/tv-ui.css +1 -1
- package/dist/tv-ui.es.js +50 -49
- package/package.json +4 -2
- package/dist/.htaccess +0 -8
- package/dist/demos/tv-alert/CHANGELOG.md +0 -127
- package/dist/demos/tv-alert/README.md +0 -334
- package/dist/demos/tv-article/CHANGELOG.md +0 -221
- package/dist/demos/tv-article/README.md +0 -258
- package/dist/demos/tv-breadcrumbs/CHANGELOG.md +0 -135
- package/dist/demos/tv-breadcrumbs/README.md +0 -364
- package/dist/demos/tv-button/CHANGELOG.md +0 -158
- package/dist/demos/tv-button/README.md +0 -255
- package/dist/demos/tv-card/CHANGELOG.md +0 -158
- package/dist/demos/tv-card/README.md +0 -332
- package/dist/demos/tv-demo/CHANGELOG.md +0 -352
- package/dist/demos/tv-demo/README.md +0 -229
- package/dist/demos/tv-footer/CHANGELOG.md +0 -67
- package/dist/demos/tv-footer/README.md +0 -760
- package/dist/demos/tv-hero/CHANGELOG.md +0 -137
- package/dist/demos/tv-hero/README.md +0 -410
- package/dist/demos/tv-label/CHANGELOG.md +0 -138
- package/dist/demos/tv-label/README.md +0 -357
- package/dist/demos/tv-menu/CHANGELOG.md +0 -145
- package/dist/demos/tv-menu/README.md +0 -389
- package/dist/demos/tv-modal/CHANGELOG.md +0 -127
- package/dist/demos/tv-modal/README.md +0 -466
- package/dist/demos/tv-pagination/CHANGELOG.md +0 -125
- package/dist/demos/tv-pagination/README.md +0 -275
- package/dist/demos/tv-progress-bar/CHANGELOG.md +0 -84
- package/dist/demos/tv-progress-bar/README.md +0 -894
- package/dist/demos/tv-relative-time/CHANGELOG.md +0 -122
- package/dist/demos/tv-relative-time/README.md +0 -405
- package/dist/demos/tv-scroll-top/CHANGELOG.md +0 -69
- package/dist/demos/tv-scroll-top/README.md +0 -445
- package/dist/demos/tv-search/CHANGELOG.md +0 -155
- package/dist/demos/tv-search/README.md +0 -407
- package/dist/demos/tv-settings/CHANGELOG.md +0 -94
- package/dist/demos/tv-settings/README.md +0 -314
- package/dist/demos/tv-sidebar/CHANGELOG.md +0 -229
- package/dist/demos/tv-sidebar/README.md +0 -592
- package/dist/demos/tv-theme-button/CHANGELOG.md +0 -136
- package/dist/demos/tv-theme-button/README.md +0 -392
- package/dist/demos/tv-toc/CHANGELOG.md +0 -80
- package/dist/demos/tv-toc/README.md +0 -288
- package/dist/favicon.ico +0 -0
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `@todovue/tv-relative-time` will be documented in this file.
|
|
4
|
-
|
|
5
|
-
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
-
|
|
7
|
-
## [1.3.1] - 2026-01-27
|
|
8
|
-
|
|
9
|
-
### Changed
|
|
10
|
-
- Simplified the file list in `package.json` to include only essential assets.
|
|
11
|
-
- Simplified the build configuration by removing demo-specific logic.
|
|
12
|
-
- Enhanced GitHub Actions workflows to automate npm package publishing and GitHub release creation.
|
|
13
|
-
- Moved the `@todovue/tv-demo` component import from main.js to `Demo.vue` to localize its usage.
|
|
14
|
-
- Updated build commands to include `README.md` and `CHANGELOG.md` files in the public directory during the build process.
|
|
15
|
-
|
|
16
|
-
### Added
|
|
17
|
-
- Included the `src` directory in the `package.json` files list to ensure component source files are bundled in the package distribution.
|
|
18
|
-
|
|
19
|
-
### Removed
|
|
20
|
-
- Eliminated the global import of the `@todovue/tv-demo` component from `main.js`.
|
|
21
|
-
|
|
22
|
-
### Dependencies
|
|
23
|
-
- Updated `@todovue/tv-demo` to `^1.4.11`.
|
|
24
|
-
- Updated `vue` to `^3.5.27`.
|
|
25
|
-
- Updated `sass` to `^1.97.3`.
|
|
26
|
-
|
|
27
|
-
## [1.3.0] - 2026-01-19
|
|
28
|
-
|
|
29
|
-
### Added
|
|
30
|
-
- Introduced the `timeZone` property to support date formatting based on specific time zones.
|
|
31
|
-
- Introduced the `nowThreshold` property to allow customizable durations for the "just now" time display.
|
|
32
|
-
|
|
33
|
-
### Dependencies
|
|
34
|
-
- Updated the `@todovue/tv-demo` dependency to `^1.4.3`.
|
|
35
|
-
- Updated the `sass` dependency to `^1.97.2`.
|
|
36
|
-
- Updated the `vite` dependency to `^4.2.4`.
|
|
37
|
-
|
|
38
|
-
### Changed
|
|
39
|
-
- Enhanced tooltip behavior and updated cursor styles to dynamically respond to the user's date display preference.
|
|
40
|
-
|
|
41
|
-
### Removed
|
|
42
|
-
- Eliminated default tooltip text for unavailable dates to improve clarity and reduce UI clutter.
|
|
43
|
-
|
|
44
|
-
## [1.2.1] - 2025-12-19
|
|
45
|
-
|
|
46
|
-
### Added
|
|
47
|
-
- Added automatic publishing to the TODOvue cPanel in `release.yml` for each release, simplifying package distribution and updates.
|
|
48
|
-
- Added `package-lock.json` to the repository to ensure dependency consistency and facilitate version management across development and production environments.
|
|
49
|
-
|
|
50
|
-
### Changed
|
|
51
|
-
- Changed the `base` option in `vite.config.js` for website deployment in cpanel.
|
|
52
|
-
|
|
53
|
-
### Fixed
|
|
54
|
-
- Fixed repository URL in `package.json` to point to the correct GitHub repository.
|
|
55
|
-
- Fixed the token configuration used to generate the package in the GitHub Actions workflow `release.yml`.
|
|
56
|
-
|
|
57
|
-
### Dependencies
|
|
58
|
-
- Updated dependency versions in `package.json` to maintain compatibility and benefit from improvements and bug fixes in the used libraries.
|
|
59
|
-
|
|
60
|
-
## [1.2.0] - 2025-11-21
|
|
61
|
-
|
|
62
|
-
### Added
|
|
63
|
-
- Added `tsconfig.json` for proper type checking during build.
|
|
64
|
-
- Create `global.d.ts` to declare module for TypeScript users.
|
|
65
|
-
- The `@todovue/tv-label` component is now externalized from the final build, reducing bundle size.
|
|
66
|
-
- Added `CHANGELOG.md` in script to generate demo and documentation site.
|
|
67
|
-
|
|
68
|
-
### Dependencies
|
|
69
|
-
- Updated the `@todovue/tv-demo` dependency to `^1.2.1` to ensure compatibility with the latest changes.
|
|
70
|
-
|
|
71
|
-
## [1.1.2] - 2025-11-15
|
|
72
|
-
|
|
73
|
-
### Changed
|
|
74
|
-
- Removed CSS injection via `vite-plugin-css-injected-by-js` from the library build. Styles are now provided as a separate CSS file generated by Vite (`dist/*.css`) and must be explicitly imported in the host application (SPA or Nuxt).
|
|
75
|
-
- These changes improve compatibility with SSR/SSG environments, especially Nuxt 3/4, by avoiding runtime CSS injection.
|
|
76
|
-
|
|
77
|
-
## [1.1.1] - 2025-10-18
|
|
78
|
-
|
|
79
|
-
### Changed
|
|
80
|
-
- The library build now uses `src/entry.ts` (exports both the component and the plugin) instead of directly exporting the `.vue` file.
|
|
81
|
-
- CSS injection via JS has been removed for the library build (it is only kept for the demo), generating a `tv-relative-time.css` file optimized for SSR/Nuxt.
|
|
82
|
-
- Changed node-version to workflows release.yml to 20.
|
|
83
|
-
|
|
84
|
-
### Added
|
|
85
|
-
- Plugin installation support: `app.use(TvRelativeTime)` or `app.use(TvRelativeTimePlugin)`.
|
|
86
|
-
- Explicit export of the style file: `import '@todovue/tv-relative-time/style.css'`.
|
|
87
|
-
- Documentation for usage in SSR and Nuxt 3 applications.
|
|
88
|
-
|
|
89
|
-
## [1.1.0] - 2025-05-06
|
|
90
|
-
|
|
91
|
-
### Features
|
|
92
|
-
- Added localization support for relative time formatting (`es`, `fr`, `pt`, and `en` as default)
|
|
93
|
-
|
|
94
|
-
### Fixed
|
|
95
|
-
- Fixed date formatting issues by enforcing the UTC timezone
|
|
96
|
-
- Watched `date` and other props to ensure reactivity
|
|
97
|
-
- Updated package references and improved documentation consistency
|
|
98
|
-
|
|
99
|
-
## [1.0.0] - 2025-05-05
|
|
100
|
-
|
|
101
|
-
### Features
|
|
102
|
-
- Fully functional `<TvRelativeTime />` component.
|
|
103
|
-
- Live update support with customizable `updateInterval`.
|
|
104
|
-
- Compact mode via `compact` prop: displays formats like `2d`, `3w`, `1mo`, `1a`.
|
|
105
|
-
- Optional absolute date display using `showFullDate` prop.
|
|
106
|
-
- Tooltip support with accessible `<time>` tag and `aria-label`.
|
|
107
|
-
- Human-friendly phrasing for relative dates like `yesterday`, `last week` or `this Wednesday`.
|
|
108
|
-
- Detailed breakdown of time differences in years, months, weeks, and days (limited to two units for UI clarity).
|
|
109
|
-
- No external dependencies.
|
|
110
|
-
- Includes `useRelativeTime()` composable for shared logic.
|
|
111
|
-
|
|
112
|
-
### Accessibility
|
|
113
|
-
- Semantic `<time>` element with `datetime`, `title`, and `aria-label`.
|
|
114
|
-
|
|
115
|
-
[1.3.1]: https://github.com/TODOvue/tv-relative-time/pull/8/files
|
|
116
|
-
[1.3.0]: https://github.com/TODOvue/tv-relative-time/pull/7/files
|
|
117
|
-
[1.2.1]: https://github.com/TODOvue/tv-relative-time/pull/6/files
|
|
118
|
-
[1.2.0]: https://github.com/TODOvue/tv-relative-time/pull/5/files
|
|
119
|
-
[1.1.2]: https://github.com/TODOvue/tv-relative-time/pull/4/files
|
|
120
|
-
[1.1.1]: https://github.com/TODOvue/tv-relative-time/pull/3/files
|
|
121
|
-
[1.1.0]: https://github.com/TODOvue/tv-relative-time/pull/2/files
|
|
122
|
-
[1.0.0]: https://github.com/TODOvue/tv-relative-time/pull/1/files
|
|
@@ -1,405 +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 RelativeTime (TvRelativeTime)
|
|
5
|
-
A minimal and customizable Vue 3 component to display human-readable relative dates with live updates, compact formats, and multi-language support. Works seamlessly in Single Page Apps and Server-Side Rendered (SSR) environments (e.g. Nuxt 3).
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@todovue/tv-relative-time)
|
|
8
|
-
[](https://www.npmjs.com/package/@todovue/tv-relative-time)
|
|
9
|
-
[](https://www.npmjs.com/package/@todovue/tv-relative-time)
|
|
10
|
-

|
|
11
|
-

|
|
12
|
-

|
|
13
|
-

|
|
14
|
-

|
|
15
|
-

|
|
16
|
-
|
|
17
|
-
> Demo: https://ui.todovue.blog/relativetime
|
|
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
|
-
- [Usage Examples](#usage-examples)
|
|
26
|
-
- [Props](#props)
|
|
27
|
-
- [Multi-Language Support](#multi-language-support)
|
|
28
|
-
- [Composable (useRelativeTime)](#composable-userelativetime)
|
|
29
|
-
- [Customization & Formats](#customization--formats)
|
|
30
|
-
- [Accessibility](#accessibility)
|
|
31
|
-
- [SSR Notes](#ssr-notes)
|
|
32
|
-
- [Development](#development)
|
|
33
|
-
- [Changelog](#changelog)
|
|
34
|
-
- [Contributing](#contributing)
|
|
35
|
-
- [License](#license)
|
|
36
|
-
|
|
37
|
-
## Features
|
|
38
|
-
- **Human-readable formats**: "2 hours ago", "Yesterday", "In 3 days"
|
|
39
|
-
- **Compact mode**: `2h`, `1d`, `3w`, `2mo` for space-constrained UIs
|
|
40
|
-
- **Live updates**: Auto-refresh at configurable intervals (default 60s)
|
|
41
|
-
- **Multi-language**: Built-in support for English, Spanish, French, Portuguese
|
|
42
|
-
- **Full date display**: Optionally show absolute date alongside relative time
|
|
43
|
-
- **SSR-compatible**: Works with Nuxt 3 and other SSR frameworks
|
|
44
|
-
- **Lightweight & tree-shakeable**: Vue 3 marked as external dependency
|
|
45
|
-
- **Semantic HTML**: Renders as `<time>` element with proper `datetime` attribute
|
|
46
|
-
- **Accessible**: Includes `title` and `aria-label` for screen readers
|
|
47
|
-
|
|
48
|
-
## Installation
|
|
49
|
-
Using npm:
|
|
50
|
-
```bash
|
|
51
|
-
npm install @todovue/tv-relative-time
|
|
52
|
-
```
|
|
53
|
-
Using yarn:
|
|
54
|
-
```bash
|
|
55
|
-
yarn add @todovue/tv-relative-time
|
|
56
|
-
```
|
|
57
|
-
Using pnpm:
|
|
58
|
-
```bash
|
|
59
|
-
pnpm add @todovue/tv-relative-time
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Quick Start (SPA)
|
|
63
|
-
Global registration (main.js / main.ts):
|
|
64
|
-
```js
|
|
65
|
-
import { createApp } from 'vue'
|
|
66
|
-
import App from './App.vue'
|
|
67
|
-
import { TvRelativeTime } from '@todovue/tv-relative-time'
|
|
68
|
-
|
|
69
|
-
createApp(App)
|
|
70
|
-
.use(TvRelativeTime) // enables <TvRelativeTime /> globally
|
|
71
|
-
.mount('#app')
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Local import inside a component:
|
|
75
|
-
```vue
|
|
76
|
-
<script setup>
|
|
77
|
-
import { TvRelativeTime } from '@todovue/tv-relative-time'
|
|
78
|
-
|
|
79
|
-
const publishedDate = '2024-01-15T10:30:00Z'
|
|
80
|
-
</script>
|
|
81
|
-
|
|
82
|
-
<template>
|
|
83
|
-
<TvRelativeTime :date="publishedDate" />
|
|
84
|
-
</template>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Nuxt 4 / SSR Usage
|
|
88
|
-
Create a plugin file: `plugins/tv-relative-time.client.ts` (or without `.client` suffix as it's SSR-safe):
|
|
89
|
-
```ts
|
|
90
|
-
import { defineNuxtPlugin } from '#app'
|
|
91
|
-
import { TvRelativeTime } from '@todovue/tv-relative-time'
|
|
92
|
-
|
|
93
|
-
export default defineNuxtPlugin(nuxtApp => {
|
|
94
|
-
nuxtApp.vueApp.use(TvRelativeTime)
|
|
95
|
-
})
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Use anywhere in your Nuxt app:
|
|
99
|
-
```vue
|
|
100
|
-
<template>
|
|
101
|
-
<TvRelativeTime
|
|
102
|
-
:date="article.publishedAt"
|
|
103
|
-
lang="es"
|
|
104
|
-
show-full-date
|
|
105
|
-
/>
|
|
106
|
-
</template>
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Optional direct import (no plugin):
|
|
110
|
-
```vue
|
|
111
|
-
<script setup>
|
|
112
|
-
import { TvRelativeTime } from '@todovue/tv-relative-time'
|
|
113
|
-
</script>
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Component Registration Options
|
|
117
|
-
| Approach | When to use |
|
|
118
|
-
|------------------------------------------------------------------------------------|------------------------------------------------|
|
|
119
|
-
| Global via `app.use(TvRelativeTime)` | Many usages across app / design system install |
|
|
120
|
-
| Local named import `{ TvRelativeTime }` | Isolated / code-split contexts |
|
|
121
|
-
| Direct default import `import { TvRelativeTime } from '@todovue/tv-relative-time'` | Single usage or manual registration |
|
|
122
|
-
| Plugin with custom name | Custom component naming requirements |
|
|
123
|
-
|
|
124
|
-
## Usage Examples
|
|
125
|
-
|
|
126
|
-
### Basic usage
|
|
127
|
-
```vue
|
|
128
|
-
<TvRelativeTime :date="'2024-10-18T08:00:00Z'" />
|
|
129
|
-
<!-- Output: "2 hours ago" (depending on current time) -->
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Compact format
|
|
133
|
-
```vue
|
|
134
|
-
<TvRelativeTime :date="postDate" compact />
|
|
135
|
-
<!-- Output: "2h", "3d", "1w", etc. -->
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Show full date
|
|
139
|
-
```vue
|
|
140
|
-
<TvRelativeTime :date="eventDate" show-full-date />
|
|
141
|
-
<!-- Output: "3 days ago (October 15, 2024)" -->
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### Different language
|
|
145
|
-
```vue
|
|
146
|
-
<TvRelativeTime :date="createdAt" lang="es" />
|
|
147
|
-
<!-- Output: "Hace 2 horas" -->
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Custom update interval (every 10 seconds)
|
|
151
|
-
```vue
|
|
152
|
-
<TvRelativeTime :date="lastSeen" :update-interval="10000" />
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Combined features
|
|
156
|
-
```vue
|
|
157
|
-
<TvRelativeTime
|
|
158
|
-
:date="article.publishedAt"
|
|
159
|
-
lang="fr"
|
|
160
|
-
compact
|
|
161
|
-
show-full-date
|
|
162
|
-
:update-interval="30000"
|
|
163
|
-
/>
|
|
164
|
-
<!-- Output: "2h (18 octobre 2024)" -->
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Customizable Thresholds
|
|
168
|
-
```vue
|
|
169
|
-
<!-- "Just now" lasts for 5 minutes (300 seconds) -->
|
|
170
|
-
<TvRelativeTime :date="newPostDate" :now-threshold="300" />
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
## Props
|
|
174
|
-
|
|
175
|
-
| Prop | Type | Default | Required | Description |
|
|
176
|
-
|------------------|---------------|---------|----------|----------------------------------------------------------------------|
|
|
177
|
-
| `date` | String/Number | — | Yes | Date string (ISO 8601) or timestamp to format. |
|
|
178
|
-
| `updateInterval` | Number | `60000` | No | Interval in milliseconds for live updates (60s default). |
|
|
179
|
-
| `compact` | Boolean | `false` | No | If true, returns compact format (`2h`, `3d`, `1w`, `2mo`). |
|
|
180
|
-
| `showFullDate` | Boolean | `false` | No | If true, appends the full date next to the relative time. |
|
|
181
|
-
| `lang` | String | `'en'` | No | Language code: `'en'`, `'es'`, `'fr'`, `'pt'`. |
|
|
182
|
-
| `timeZone` | String | `'UTC'` | No | Target timezone (e.g. `'America/New_York'`). |
|
|
183
|
-
| `nowThreshold` | Number | `60` | No | Seconds threshold to show "A moment ago" instead of "0 minutes ago". |
|
|
184
|
-
|
|
185
|
-
### Prop Details
|
|
186
|
-
|
|
187
|
-
#### `date` (required)
|
|
188
|
-
Accepts:
|
|
189
|
-
- ISO 8601 date strings: `'2024-10-18T14:30:00Z'`
|
|
190
|
-
- JavaScript timestamps: `1697635800000`
|
|
191
|
-
- Any valid date string parseable by `new Date()`
|
|
192
|
-
|
|
193
|
-
#### `updateInterval`
|
|
194
|
-
Controls how often the component recalculates the relative time. Set to `0` to disable auto-updates (not recommended for live data).
|
|
195
|
-
|
|
196
|
-
#### `compact`
|
|
197
|
-
Perfect for space-constrained UIs like tables, cards, or mobile views:
|
|
198
|
-
- `false` (default): "2 hours ago", "Yesterday", "In 3 days"
|
|
199
|
-
- `true`: "2h", "1d", "3w", "2mo", "1y"
|
|
200
|
-
|
|
201
|
-
#### `showFullDate`
|
|
202
|
-
Useful for providing context:
|
|
203
|
-
- `false` (default): "2 days ago"
|
|
204
|
-
- `true`: "2 days ago (October 16, 2024)"
|
|
205
|
-
|
|
206
|
-
#### `lang`
|
|
207
|
-
Supported languages:
|
|
208
|
-
- `'en'`: English (default)
|
|
209
|
-
- `'es'`: Spanish / Español
|
|
210
|
-
- `'fr'`: French / Français
|
|
211
|
-
- `'pt'`: Portuguese / Português
|
|
212
|
-
|
|
213
|
-
## Multi-Language Support
|
|
214
|
-
|
|
215
|
-
The component includes built-in translations for 4 languages. Examples:
|
|
216
|
-
|
|
217
|
-
| Time difference | English (en) | Spanish (es) | French (fr) | Portuguese (pt) |
|
|
218
|
-
|-----------------|-------------------|---------------------|---------------------|----------------------|
|
|
219
|
-
| < 1 minute | A moment ago | Hace un momento | Il y a un instant | Há um momento |
|
|
220
|
-
| 2 hours ago | 2 hours ago | Hace 2 horas | Il y a 2 heures | Há 2 horas |
|
|
221
|
-
| Yesterday | Yesterday | Ayer | Hier | Ontem |
|
|
222
|
-
| 3 days ago | 3 days ago | Hace 3 días | Il y a 3 jours | Há 3 dias |
|
|
223
|
-
| Last week | Last week | La semana pasada | La semaine dernière | Semana passada |
|
|
224
|
-
| Tomorrow | Tomorrow | Mañana | Demain | Amanhã |
|
|
225
|
-
| In 5 days | In 5 days | En 5 días | Dans 5 jours | Em 5 dias |
|
|
226
|
-
|
|
227
|
-
### Compact format (all languages)
|
|
228
|
-
Compact format uses universal abbreviations:
|
|
229
|
-
- Minutes: `m` (e.g., `15m`)
|
|
230
|
-
- Hours: `h` (e.g., `3h`)
|
|
231
|
-
- Days: `d` (e.g., `5d`)
|
|
232
|
-
- Weeks: `w` (e.g., `2w`)
|
|
233
|
-
- Months: `mo` (e.g., `3mo`)
|
|
234
|
-
- Years: `y` (e.g., `1y`)
|
|
235
|
-
|
|
236
|
-
## Composable (useRelativeTime)
|
|
237
|
-
|
|
238
|
-
You can also use the underlying composable directly in your own logic:
|
|
239
|
-
|
|
240
|
-
```js
|
|
241
|
-
import useRelativeTime from '@todovue/tv-relative-time/composable/useRelativeTime'
|
|
242
|
-
|
|
243
|
-
const { getRelativeTime } = useRelativeTime()
|
|
244
|
-
|
|
245
|
-
const result = getRelativeTime('2024-10-15T10:00:00Z', false, false, 'en')
|
|
246
|
-
console.log(result.text) // "3 days ago"
|
|
247
|
-
console.log(result.tooltip) // "October 15, 2024"
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Composable signature
|
|
251
|
-
```js
|
|
252
|
-
getRelativeTime(dateString, isTableQuantity, compact, lang)
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
| Parameter | Type | Description |
|
|
256
|
-
|-------------------|---------|------------------------------------------------|
|
|
257
|
-
| `dateString` | String | Date to format |
|
|
258
|
-
| `isTableQuantity` | Boolean | If true, returns '-' when date is invalid |
|
|
259
|
-
| `compact` | Boolean | Enable compact format |
|
|
260
|
-
| `lang` | String | Language code (`'en'`, `'es'`, `'fr'`, `'pt'`) |
|
|
261
|
-
|
|
262
|
-
Returns:
|
|
263
|
-
```js
|
|
264
|
-
{
|
|
265
|
-
text: string, // Formatted relative time
|
|
266
|
-
tooltip: string // Full formatted date
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
## Customization & Formats
|
|
271
|
-
|
|
272
|
-
### Output Formats
|
|
273
|
-
|
|
274
|
-
#### Standard format (compact: false)
|
|
275
|
-
- "A moment ago" / "In a moment"
|
|
276
|
-
- "2 minutes ago" / "In 5 minutes"
|
|
277
|
-
- "1 hour ago" / "In 3 hours"
|
|
278
|
-
- "Yesterday" / "Tomorrow"
|
|
279
|
-
- "Last Monday" / "This Friday"
|
|
280
|
-
- "Last week" / "Next week"
|
|
281
|
-
- "3 weeks ago" / "In 2 weeks"
|
|
282
|
-
- "2 months ago" / "In 4 months"
|
|
283
|
-
- "1 year, 2 months ago"
|
|
284
|
-
|
|
285
|
-
#### Compact format (compact: true)
|
|
286
|
-
- "Now"
|
|
287
|
-
- "15m", "2h"
|
|
288
|
-
- "1d", "5d"
|
|
289
|
-
- "2w", "3w"
|
|
290
|
-
- "2mo", "6mo"
|
|
291
|
-
- "1y", "2y"
|
|
292
|
-
|
|
293
|
-
### Full Date Format
|
|
294
|
-
When `showFullDate` is enabled, the full date is formatted according to the selected language using `Intl.DateTimeFormat`:
|
|
295
|
-
- **en**: "October 18, 2024"
|
|
296
|
-
- **es**: "18 de octubre de 2024"
|
|
297
|
-
- **fr**: "18 octobre 2024"
|
|
298
|
-
- **pt**: "18 de outubro de 2024"
|
|
299
|
-
|
|
300
|
-
## Accessibility
|
|
301
|
-
|
|
302
|
-
The component is built with accessibility in mind:
|
|
303
|
-
|
|
304
|
-
### Semantic HTML
|
|
305
|
-
```html
|
|
306
|
-
<time
|
|
307
|
-
class="tv-relative-time"
|
|
308
|
-
datetime="2024-10-18T14:30:00Z"
|
|
309
|
-
title="October 18, 2024"
|
|
310
|
-
aria-label="October 18, 2024"
|
|
311
|
-
>
|
|
312
|
-
2 hours ago
|
|
313
|
-
</time>
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
### Key accessibility features:
|
|
317
|
-
- Uses semantic `<time>` element with `datetime` attribute
|
|
318
|
-
- Includes `title` attribute for tooltip on hover
|
|
319
|
-
- Includes `aria-label` with full date for screen readers
|
|
320
|
-
- Full date always available even when showing relative time
|
|
321
|
-
- Proper language attribute can be set on parent elements
|
|
322
|
-
|
|
323
|
-
### Best practices:
|
|
324
|
-
```vue
|
|
325
|
-
<!-- Good: Context is clear -->
|
|
326
|
-
<article lang="es">
|
|
327
|
-
<h2>{{ article.title }}</h2>
|
|
328
|
-
<TvRelativeTime :date="article.publishedAt" lang="es" />
|
|
329
|
-
</article>
|
|
330
|
-
|
|
331
|
-
<!-- Better: Additional context -->
|
|
332
|
-
<p>
|
|
333
|
-
Published <TvRelativeTime :date="publishedAt" show-full-date />
|
|
334
|
-
</p>
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
## SSR Notes
|
|
338
|
-
|
|
339
|
-
- **No direct DOM access**: Safe for SSR/Nuxt environments
|
|
340
|
-
- **Hydration-friendly**: Component state syncs properly on client
|
|
341
|
-
- **Universal rendering**: Works identically on server and client
|
|
342
|
-
- **Timezone handling**: Uses UTC by default for consistency
|
|
343
|
-
- **Auto-updates**: Live updates start only after client-side hydration
|
|
344
|
-
|
|
345
|
-
### Nuxt-specific considerations:
|
|
346
|
-
```vue
|
|
347
|
-
<!-- In Nuxt, this works everywhere -->
|
|
348
|
-
<template>
|
|
349
|
-
<div>
|
|
350
|
-
<TvRelativeTime :date="post.createdAt" />
|
|
351
|
-
</div>
|
|
352
|
-
</template>
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
The component will render the initial relative time on the server, then activate live updates on the client.
|
|
356
|
-
|
|
357
|
-
## Development
|
|
358
|
-
|
|
359
|
-
Clone the repository and install dependencies:
|
|
360
|
-
```bash
|
|
361
|
-
git clone https://github.com/TODOvue/tv-relative-time.git
|
|
362
|
-
cd tv-relative-time
|
|
363
|
-
yarn install
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
Run the development server with demo playground:
|
|
367
|
-
```bash
|
|
368
|
-
yarn dev
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
Build the library:
|
|
372
|
-
```bash
|
|
373
|
-
yarn build
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
Build demo site:
|
|
377
|
-
```bash
|
|
378
|
-
yarn build:demo
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Project structure
|
|
382
|
-
```
|
|
383
|
-
src/
|
|
384
|
-
├── components/
|
|
385
|
-
│ └── TvRelativeTime.vue # Main component
|
|
386
|
-
├── composable/
|
|
387
|
-
│ └── useRelativeTime.js # Core logic
|
|
388
|
-
├── locales/
|
|
389
|
-
│ └── relativeTime.js # Translations
|
|
390
|
-
├── demo/
|
|
391
|
-
│ └── Demo.vue # Demo playground
|
|
392
|
-
└── entry.ts # Library entry point
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
## Changelog
|
|
396
|
-
See [CHANGELOG.md](https://github.com/TODOvue/tv-relative-time/blob/main/CHANGELOG.md) for release history and updates.
|
|
397
|
-
|
|
398
|
-
## Contributing
|
|
399
|
-
PRs and issues welcome! Please read our [Contributing Guide](https://github.com/TODOvue/tv-relative-time/blob/main/CONTRIBUTING.md) and [Code of Conduct](https://github.com/TODOvue/tv-relative-time/blob/main/CODE_OF_CONDUCT.md).
|
|
400
|
-
|
|
401
|
-
## License
|
|
402
|
-
[MIT](https://github.com/TODOvue/tv-relative-time/blob/main/LICENSE) © TODOvue
|
|
403
|
-
|
|
404
|
-
### Attributions
|
|
405
|
-
Crafted for the TODOvue component ecosystem
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `@todovue/tv-scroll-top` 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.0.3] - 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 `vue` to `^3.5.27`.
|
|
26
|
-
- Updated `sass` to `^1.97.3`.
|
|
27
|
-
|
|
28
|
-
## [1.0.2] - 2026-01-21
|
|
29
|
-
|
|
30
|
-
### Added
|
|
31
|
-
- New `showOnScrollUp` prop to only display the button when scrolling up
|
|
32
|
-
- Scroll direction detection in `useScrollTop` composable
|
|
33
|
-
|
|
34
|
-
### Dependencies
|
|
35
|
-
- Updated `@todovue/tv-demo` to `^1.4.4`.
|
|
36
|
-
- Updated `sass` to `^1.97.2`.
|
|
37
|
-
- Updated `vite` to `^7.3.1`.
|
|
38
|
-
|
|
39
|
-
## [1.0.0] - 2025-12-30
|
|
40
|
-
|
|
41
|
-
### Added
|
|
42
|
-
- Initial release of TvScrollTop component
|
|
43
|
-
- Core scroll-to-top button functionality with smooth scroll behavior
|
|
44
|
-
- Configurable visibility `threshold` prop (default: 300px)
|
|
45
|
-
- Position variants: `left` and `right` placement options
|
|
46
|
-
- Beautiful entrance/exit animations with rotation and bounce effects
|
|
47
|
-
- Position-specific animations (right: slides from right with clockwise rotation, left: slides from left with counter-clockwise rotation)
|
|
48
|
-
- Backdrop blur effect for modern glass-morphism UI
|
|
49
|
-
- Hover and active state interactions with scale transforms
|
|
50
|
-
- Shadow elevation effects on hover
|
|
51
|
-
- `useScrollTop` composable for custom implementations
|
|
52
|
-
- SSR-safe implementation with proper window/document guards
|
|
53
|
-
- Nuxt 3 module support (`@todovue/tv-scroll-top/nuxt`)
|
|
54
|
-
- TypeScript support with full type definitions
|
|
55
|
-
- Accessibility features:
|
|
56
|
-
- ARIA label for screen readers
|
|
57
|
-
- Keyboard navigation support
|
|
58
|
-
- Semantic button element
|
|
59
|
-
- Focus indicators
|
|
60
|
-
- Automatic scroll event listener management with cleanup
|
|
61
|
-
- Vue 3 Transition component integration
|
|
62
|
-
- Zero runtime dependencies
|
|
63
|
-
- Tree-shakeable ES module build
|
|
64
|
-
- CommonJS build for compatibility
|
|
65
|
-
- Comprehensive documentation and examples
|
|
66
|
-
|
|
67
|
-
[1.0.3]: https://github.com/TODOvue/tv-scroll-top/pull/3/files
|
|
68
|
-
[1.0.2]: https://github.com/TODOvue/tv-scroll-top/pull/2/files
|
|
69
|
-
[1.0.0]: https://github.com/TODOvue/tv-scroll-top/pull/1/files
|