opc-notification-drawer is a webcomponent develped using lit elements for Red Hat One Platform for showing user notifications.
npm install @one-platform/opc-notification-drawer!Version
!Build Status

Opc-Notification-drawer is a special drawer web component developed using Lit elements for the Red Hat One Platform. It's used for providing notification lists to users.
Opc-Notification-drawer is implement under Red Hat design guidelines. Therefore the component uses Red Hat official font. This can be easily imported with google cdn at the top of HTML document.
``html`
href="https://fonts.googleapis.com/css2?family=Red+Hat+Display&display=swap"
rel="stylesheet"
/>
href="https://fonts.googleapis.com/css2?family=Red+Hat+Text&display=swap"
rel="stylesheet"
/>
Opc-notification-drawer contains two components.
- opc-notification-drawer: It's a simple drawer component, as a container for notifications.
- opc-notification-item: A customizable notification component that has styles based on variants of success, danger, warn.
opc-notification-drawer with opc-notification-item
It's drawer container component to contain all notifications required for the user. By using the default slot users can render there own custom Notification items. There is also a slot opc-notification__header-menu to provide drawer action menu like filter button.
Opc-notification-drawer component also provides opc-notification-item component that provides styling with multiple variants. It can be used inside opc-notification-drawer to avoid overhead of custom styled component. The component accept a key attribute which should be unique amoung list to identify the closed one.
`html`
variant="success"
key="notification1"
>
>Success alert description. This should tell the user more information
about the alert. This is a link. >
>Information alert description. This should tell the user more information
about the alert. >
>Danger alert description. This should tell the user more information
about the alert. This is a link. >
>Warn alert description. This should tell the user more information about
the alert. This is a link. >
`js`
document.querySelector('opc-notification-drawer').open();
!Image of opc-notification-drawer
- default slot: The body of opc-notification-drawer component.
- header : Container component for the header that contains title and menu buttons.
- header-menu: Menu buttons for the drawer on right to title.
- footer: Footer component of the drawer.
- default slot: The contents inside the notification item
- header : Container component for the header that contains notification title and close button.
- header-actions:Container component of the menu actions of the notification.
- titleString
- Type: notifications
- Default value:
`html`
- isOpenBoolean
- Type: false
- Default value:
`js`
document.querySelector('opc-notification-drawer').isOpen;
- open
- Description: To open the drawer.
`js`
document.querySelector('opc-notification-drawer').open();
- close
- Description: To close the drawer.
`js`
document.querySelector('opc-notification-drawer').close();
- toggle
- Description: To toggle the drawer states.
`js`
document.querySelector('opc-notification-drawer').toggle();
- variant'success'| 'info' | 'danger' | 'warn'
- Type: info
- Default value:
`html`
- titleString
- Type:
- Default value:
`html`
- keyString
- Type:
`html`
There are two events emitted by opc-notification-drawer emitter when drawer state changes.
1. opc-notification-drawer:open
Dispatched when drawer opens.
Example:
`js`
document
.querySelector('opc-notification-drawer')
.addEventListener('opc-notification-drawer:open', function (event) {
alert('drawer opened');
});
1. opc-notification-drawer:close
Dispatched when drawer closed.
Example:
`js`
document
.querySelector('opc-notification-drawer')
.addEventListener('opc-notification-drawer:close', function (event) {
alert('drawer closed');
});
1. opc-notification-item:close
Dispatched on clicking close button. It contains the payload of { key:string, title: string,}
Example:
`js`
document
.querySelector('opc-notification-item')
.addEventListener('opc-notification-item:close', (e) => {
alert(JSON.stringify(e.detail));
});
| CSS Variable name | Value |
| -------------------------------------------------- | ----------------- |
| --opc-notification-drawer__backdrop-color | #00000060 |--opc-notification-drawer__z-index
| | 9 | --opc-notification-drawer__width
| | 360px |--opc-notification-drawer__top
| | 0px |--opc-notification-drawer__right
| | #000 |--opc-notification-drawer__transition--default
| | 120ms ease-in-out |--opc-notification-item__variant--success
| | #f2faf2 |--opc-notification-item__variant--success-header
| | #1e4f18 |--opc-notification-item__variant--danger
| | #ee00001a |--opc-notification-item__variant--danger-header
| | #ee0000 |--opc-notification-item__variant--info
| | #316dc11a |--opc-notification-item__variant--info-header
| | #316dc1 |--opc-notification-item__variant--warn
| | #f9e0a2 |--opc-notification-item__variant--warn-header
| | #795600 |
| color | hex |
| ------- | --------- |
| success | #f2faf2 |
| danger | #ee00001a |
| info | #316dc11a |
| warn | #f9e0a2 |
`sh`
npm install
`sh`
npm install --save @one-platform/opc-notification-drawer
- Import component
`js`
import '@one-platform/opc-notification-drawer/dist/opc-notification-drawer';
- Add component in html
`html`
- In your app.module include the CUSTOM_ELEMENTS_SCHEMA and import the component
`js
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@one-platform/opc-notification-drawer/dist/opc-notification-drawer';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
`
- Add component in any component html template
`html`
- Import the component in App.js
`js`
import '@one-platform/opc-notification-drawer/dist/opc-notification-drawer';
- Add component in any component html render
`html`
- Run development server
`sh`
npm run dev opc-notification-drawer
`sh`
npm run build opc-notification-drawer
`sh``
npm run test
š¤ akhilmhdh