@redhat-cloud-services/frontend-components-notifications
TypeScript icon, indicating that this package has built-in type declarations

4.1.1 • Public • Published

RedHat Cloud Services frontend components - notifications

npm version

This package has portal component that shows toast notifications based on PF4 alert component.

Installation

With NPM

npm i -S @redhat-cloud-services/frontend-components-notifications

With yarn

yarn add @redhat-cloud-services/frontend-components-notifications

This package is dependent on @redhat-cloud-services/frontend-components-utilities it will automatically install it trough direct dependencies.

Treeshaking

In order not to decrease your bundle size you you should either import components trough direct imports or use babel plugin to change relative imports to direct imports. You can mix both direct imports and babel plugin, it's just convenient to use the babel plugin so you don't have to change all of your imports.

Direct imports

It's recommended to use absolute import paths for improved build times. Import will be automatically resolved to ESM or CJS version of the build based on the environment.

import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux';

Migration V2 -> V3

V3 of the packages has introduced improved build output for absolute import paths, It's no longer required to point towards ESM/CJS asset. This is now resolved at build time by the asset.

Remove ESM/CJS references

// v2
import NotificationsPortal from '@redhat-cloud-services/frontend-components-notifications/esm/NotificationsPortal';
// v3
import NotificationPortal from '@redhat-cloud-services/frontend-components-notifications/NotificationPortal';

Notification reducer, actions and action types have changed import path

The correct import path is now at: @redhat-cloud-services/frontend-components-notifications/redux

For example:

// v2
import { addNotification, ADD_NOTIFICATION } from '@redhat-cloud-services/frontend-components-notifications/cjs/actions';
// v3
import { notificationsReducer, addNotification, ADD_NOTIFICATION } from '@redhat-cloud-services/frontend-components-notifications/redux';
import notificationsMiddleware from '@redhat-cloud-services/frontend-components-notifications/notificationsMiddleware';

Adjust babel transform import config

If you are using babel transform imports plugin, you need to change the import path.

// v2
{
  transform: (importName) => `@redhat-cloud-services/frontend-components-notifications/esm/${importName}`
}
// v3
{
  transform: (importName) => `@redhat-cloud-services/frontend-components-notifications/${importName}`
}

Babel plugins

There are 2 plugins that can be used to change relative imports to direct imports

Since our components require a bit more setting up, we are recommending using babel-plugin-transform-imports.

Change your babel config to be javascript config babel.config.js so you can use JS functions to properly transform your imports

notificationsMapper = {
    addNotification: 'redux',
    removeNotification: 'redux',
};
module.exports = {
    presets: [
        // your presets go here
    ],
    plugins: [
        // your plugins
        [
            'transform-imports',
            {
              '@redhat-cloud-services/frontend-components-notifications': {
                transform: (importName) =>
                  `@redhat-cloud-services/frontend-components-notifications/${notificationsMapper[importName] || importName}`,
                preventFullImport: true,
              }
            },
            'frontend-notifications'
        ]
        // other plugins, for instance PF transform imports and such as well
    ]
};

List of bundles

  • index - the entire notifications bundle, should be used as fallback if something does not exists in other modules
  • notificationsMiddleware - middleware function to hook into your redux
  • actions - list of notifications actions
  • actionTypes - list of redux action types
  • NotificationPortal - portal to render your notifications to
  • notifications - redux reducers are exported in this file

Documentation Links

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.1.1185latest
4.0.0-beta.02beta

Version History

VersionDownloads (Last 7 Days)Published
4.1.1185
4.1.1-03
4.1.01,447
4.0.4238
4.0.32
4.0.250
4.0.12
4.0.016
3.2.16267
3.2.152
4.0.0-beta.02
3.2.1454
3.2.132
3.2.1260
3.2.1114
3.2.1011
3.2.943
3.2.83
3.2.723
3.2.618
3.2.572
3.2.472
3.2.32
3.2.246
3.2.12
3.2.02
3.1.045
3.0.42
3.0.34
3.0.24
3.0.12
3.0.04
3.0.0-beta.42
3.0.0-beta.32
3.0.0-beta.22
3.0.0-beta.12
3.0.0-beta.02
2.2.423
2.2.32
2.2.217
2.2.12
2.2.02
2.1.22
2.1.12
2.1.04
2.1.0-beta2
2.0.42
2.0.32
2.0.22
2.0.12
2.0.1-beta23
2.0.1-beta3
2.0.02
2.0.0-beta42
2.0.0-beta32
2.0.0-beta23
2.0.0-beta2
1.0.42
1.0.32
1.0.22
1.0.12
1.0.03
0.0.5-RC22
0.0.5-beta3
0.0.6-rc52
0.0.6-rc43
0.0.6-rc32
0.0.6-rc24
0.0.6-rc12
0.0.72
0.0.63
0.0.52
0.0.42
0.0.32
0.0.23
0.0.13

Package Sidebar

Install

npm i @redhat-cloud-services/frontend-components-notifications

Weekly Downloads

1,921

Version

4.1.1

License

Apache-2.0

Unpacked Size

97.6 kB

Total Files

95

Last publish

Collaborators

  • lesamo
  • jozefhartinger
  • karelhala
  • ryelo
  • kruai
  • hyperkid