Angular playground

Nova v3.37.0

Preview

Angular

nv-alert migration

Moving from color, permanent and close to the current alert props.

← nv-alert

Migration Guide for nv-alert

In the latest version of the nv-alert component, we've made several important changes to the properties to improve usability and consistency. Below is a guide to help you update your existing alerts from version 2 to version 3.

Deprecations

1. prop color

The color property has been deprecated in favor of feedback. This change aligns the property name more closely with its function, which is to indicate the nature of the alert (e.g., information, warning, success, error).

Old Usage:

html<nv-alert color="primary"></nv-alert>

New Usage:

html<nv-alert feedback="information"></nv-alert>

Breaking Changes

1. prop permanent -> hidden

The permanent property has been replaced by hidden. In v2, permanent was used to make the alert always visible. Now, hidden controls the visibility inversely; the alert is visible by default, and setting hidden to true hides it.

Old Usage:

html<nv-alert permanent></nv-alert>

New Usage:

html<nv-alert hidden></nv-alert>

2. prop close -> dismissible

The close property has been renamed to dismissible. This new name better describes the property's functionality, which allows the alert to be closed by the user.

Old Usage:

html<nv-alert close></nv-alert>

New Usage:

html<nv-alert dismissible></nv-alert>

3. prop visible -> hidden (with added animation)

The visible property has been replaced with hidden and now always includes animation effects when the alert is shown or hidden.

Old Usage:

html<nv-alert visible></nv-alert>

New Usage:

html<nv-alert hidden></nv-alert>  // Remove or set to false to show the alert

4. event close -> closeClicked

The close event has been renamed to closeClicked. This is more descriptive of the event's purpose, as the hiding of the alert could be intercepted by the preventAutoClose prop.

Old Usage:

html<nv-alert @close="handleClose"></nv-alert>

New Usage:

html<nv-alert @closeClicked="handleClose"></nv-alert>

New Properties

1. heading: Provides a prop to pass text to the heading of the alert, instead of passing the markup directly.

New Usage:

html<nv-alert heading="Styles are now automatically applied to the alert heading."></nv-alert>

2. message: Provides a prop to pass text to the message of the alert.

New Usage:

html<nv-alert message="This is the body of the alert."></nv-alert>

3. 'preventAutoClose': Provides a prop to prevent the alert from hiding automatically when the close button is clicked. This is useful for externally controlled component behavior.

New Usage:

html<nv-alert dismissible prevent-auto-close></nv-alert>