:bell: Powerful toast notification system for Vue and Nuxt.
Notivue, NotivueKeyboard - Both exported components are now wrapped in a ClientOnly
component by default. Before this release, this was only applied to the Nuxt module auto-imported components.
Provenance Statements - Notivue is now published via GitHub actions using provenance statements introduced by NPM this month in order to improve supply-chain security and transparency.
Notivue Core - Configuration properties have been converted from shallow refs to refs. This reduces a bit the bundle size and removes the requirement of calling triggerRef
when updating nested properties such as config.notifications.global
.
Nuxt Module - Streamlined type modules declaration and removed client-only versions of Notivue and NotivueKeyboard as they're now unneccessary.
NotivueKeyboard - Lowered the default value of maxAnnouncements
prop from 3 to 2.
Package - The bundled output now only includes JavaScript APIs not greater than ES2015.
import 'notivue/animations.css'
with your file path.0
to 0.01
in any translate/scale/rotate
keyframe transform property. This fixes a lightningcss bug that occurs if it is used by the end-user as css minifier (via Vite config).transform: scale < 1
in enter animations, causing notifications to be cleared earlier.onBeforeUnmount
hook.dir=rtl
.Animations
and Position
types in the module declaration as imported types do not work within Nuxt module declaration.prefers-reduced-motion
and transitionData
. They are now only updated when appropriate, improving performance.clearAll
class to the wrapper element. Now this is done the "vue-way" by passing a reactive value to the attribute, instead of using classList.add
.item.clear
method when the swipe threshold is met. Instead it first transitions the opacity to 0, then it calls item.destroy
. This ensures that the leave animation is never called while providing an overall better UX.NotivueSwipe - You can now choose which method to call when clearing the notification via the new destroy
prop. By default is set to false
which means that the leave animation will be played when clearing.
Notivue Core - Fixed a bug where queued promises were not updated properly due to a regression introduced in v1.3.0 - #21
Nuxt Module
Add addPlugin
boolean to module options. This won't initialize the notivue store via createNotivue
leaving to you the implementation while still providing auto imports. Can be used for example, to export the push reference if using ssr: false
.
Notivue Core The push object is now frozen to prevent accidental tampering.
Nuxt Module Hardcoded configuration types which were not retained when imported from outside.
push
in single-page appsStarting from this release, you can now push notifications from any file/component without worrying about calling usePush
in the setup function of a Vue component (only in single-page apps).
You should now be able to call push
from virutally anywhere in your client-code as long as such code is used in the Vue App.
While usePush
and notivue
can still be used as usual and updating to 1.3.0
won't break your code, you should update it as follows:
- import { notivue } from 'notivue'
+ import { createNotivue } from 'notivue'
const app = createApp(App)
// app.use(...), app.use(...), ...
// Place it at THE END of the app.use() chain, just right before app.mount()
- app.use(notivue)
+ export const push = createNotivue(app)
Remember to state export const push...
at the end of your plugins chain, just right before calling app.mount()
.
Then in any file, component or template:
- import { usePush } from 'notivue'
+ import { push } from './main'
push.success('Something good has been pushed!)
Check the documentation website on how to configure
push
auto-import.
Notivue now ships with a nuxt module that you can add to your nuxt config, it provides automatic plugin installation, auto imports and built-in client-only mounting of Notivue root components.
Migration:
Update to latest via pnpm add notivue@latest
Delete plugins/notivue.client.ts
and any auto-import previously configured via files or nuxt config.
Install the module:
export default defineNuxtConfig({
modules: ['notivue/nuxt'],
css: [
'notivue/notifications.css',
'notivue/animations.css'
],
notivue: {
// Options
}
})
<ClientOnly>
wrapper around Notivue components and most important, any component import:<script setup>
- import { Notivue, Notifications } from 'notivue'
- <ClientOnly>
<Notivue v-slot="item">
<Notifications :item="item" />
</Notivue>
- </ClientOnly>
npx nuxi cleanup && npx nuxi dev
Please note that
usePush
must still be used on Nuxt installations.
onAutoClear
and onManualClear
push callbackspush.success({
message: 'This is a sucess message',
props: { isCustom: true },
onAutoClear(item) {
console.log(item.props.isCustom, item.message) // true, 'This is a sucess message'
},
onManualClear(item) {
console.log(item.props.isCustom, item.message) // true, 'This is a sucess message'
},
})
You can now pass a ref to both message
and title
push options. This allows to create notifications like this one:
const message = ref('Begin uploading...')
push.promise(message) // or push.promise({ message, title...
message.value = 'Uploading file 1/4'
// ...
Add hideClose
prop, which is by default set to false. This can be handy if you're lazy, and you don't want to import, clone and edit the icons
object.
Add maxAnnouncements
prop, which is by default set to 3
. Leave notifications that announce the exit from the stream and the ability to re-enter using the combination key are now pushed only the first three times.
auto
. After taking a look at the projects using Notivue, I noticed that the majority of the users are pushing notifications with very short messages.If you prefer to have a fixed min-width, replicate the previous behavior by setting the variable --nv-min-width
to your theme:
<Notifications
:item="item"
:theme="{ ...materialTheme, '--nv-min-width': '360px' }"
/>
0.925
to 1
rems and default spacing from 0.5
to 0.625
rems.materialTheme
background colors to improve accessibility and match WCAG 2 Contrast and Color Requirements.This release brings various bug fixes introduced in the yesterday's minor release (1.2.0) and a refactor of the configuration types.
NotivueConfig
type couldn't be imported in an SFC because of a complex generic that vue-sfc-compiler
couldn't process. Issue
touch-action: none
on any child of the notification.useLastFocused
composable, which was returning a wrong element.Infinity
.