![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
vue-timeago3
Advanced tools
Readme
A time ago component for Vue.js 3 based on vue-timeago for Vue 2 by egoist.
vue-timeago3 is a tiny component for Vue.js 3, to show the time passed since a specific date. You simply pass a date and get somewhat like 10 seconds ago
, 3 weeks ago
, ...
printed by the component
distance to now | result |
---|---|
0 - 5 secs | less than 5 seconds ago |
5 - 10 secs | less than 10 seconds ago |
10 - 20 secs | less than 20 seconds ago |
20 - 40 secs | half a minute ago |
40 - 60 secs | less than a minute ago |
See date-fns/formatDistanceToNow for more details.
Visit the docs for more details!
// NPM
$ npm install vue-timeago3
// Yarn
$ yarn add vue-timeago3
To register the plugin simply import and register it using the new global vue3 api. As an alternative the plugin could be imported in specific components only.
// src/main.ts
import { createApp } from 'vue'
import timeago from 'vue-timeago3'
const app = createApp(App)
...
app.use(timeago) // register timeago
...
app.mount('#app')
During the registration of the component you can specify a set of options, which will mutate the plugin globally. If you don't want to define global settings, skip this section and use props instead. To use options, simply pass them during the registration as an object:
// src/main.ts
import { createApp } from 'vue'
import timeago from 'vue-timeago3'
const app = createApp(App)
...
// define options
const timeagoOptions = {
converterOptions: {
includeSeconds: false,
}
}
app.use(timeago, timeagoOptions) // register timeago with options
...
app.mount('#app')
As of version 1.0.0 the following options are available:
option | type | description |
---|---|---|
name | string | Register the component with a custom name. Default is: timeago |
locale | Locale (see date-fns/Locale) | The locale specifies the language which is used to render the date. All available date-fns locales are supported by default. |
converter | (date, converterOptions) => string | A converter that formats regular dates in x Seconds ago , or in xxx style. Check out the default converter which uses date-fns formatDistanceToNow |
converterOptions | Object | Pass some extra settings to the default converter mentioned above. It supports the main options of date-fns , namingly: includeSeconds - boolean - distances less than a minute are more detailed addSuffix - boolean - results specifies if now is earlier or later than the date passed useStrict - boolean - use strict units, does not use helpers like 'almost', 'over', 'less than' and the like |
Once the plugin is registered you can straight up use it in your app.
Basic usage:
<template>
<timeago :datetime="date"/>
</template>
<script>
...
data() {
return {
date: '2021-09-01'
}
}
...
</script
Instead of configurating the plugin during the registration, you can also configuate the component via props
.
property | type | required | default | description |
---|---|---|---|---|
datetime | string | Date | number | :heavy_check_mark: | The datetime used to calculate the "time ago" | |
autoUpdate | number | boolean | :x: | false | The period of time to update the component, in seconds. This can be omitted by setting it to 0 or false . The default value for true is 60 (seconds). Instead of passing true you can also pass a custom time. |
locale | Locale (see date-fns/Locale) | :x: | en | The locale specifies the language which is used to render the date. All available date-fns locales are supported by default. |
converter | date, converterOptions) => string | :x: | See plugin options above | |
converterOptions | Object | :x: | See plugin options above |
FAQs
vue-timeago3 is a tiny component for Vue.js 3, to show the time passed since a specific date. You simply pass a date and get somewhat like 10 seconds ago, 3 weeks ago, ... printed by the component
The npm package vue-timeago3 receives a total of 2,784 weekly downloads. As such, vue-timeago3 popularity was classified as popular.
We found that vue-timeago3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.