# @chcodes-hamza/notifications-toast

> toast notification libraby and custom element

Latest version **1.0.1** (published 2023-01-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install @chcodes-hamza/notifications-toast
pnpm add @chcodes-hamza/notifications-toast
yarn add @chcodes-hamza/notifications-toast
bun add @chcodes-hamza/notifications-toast
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-01-22 |
| First published | 2023-01-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | CHAOUCH Hamza |
| Maintainers | chcodes-hamza |
| Keywords | custom-elements, js, toast, notification |

## Links

- npm: https://www.npmjs.com/package/@chcodes-hamza/notifications-toast
- Repository: https://github.com/Hamza-chaouch/notifications-lib-element
- Homepage: https://github.com/Hamza-chaouch/notifications-lib-element#readme
- Issues: https://github.com/Hamza-chaouch/notifications-lib-element/issues
- npm.io page: https://npm.io/package/@chcodes-hamza/notifications-toast

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-01-22
- 1.0.0 — 2023-01-22

## README

# **Toast notification library & Custom element** 
![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/Hamza-chaouch/notifications-lib-element/main)  
![npm](https://img.shields.io/badge/npm-1.0.0-green)


This is a library which a class or a custom web component to display toast notifications in the positions that you configure.


![](preview.PNG)

## Usage 

### With npm
Install the package using npm or yarn

```bash
npm i  @chcodes-hamza/notifications-toast
# or
yarn add  @chcodes-hamza/notifications-toast
```

Then import it in your script

```js
import "./node_modules/@chcodes-hamza/notifications-toast/dist/Toast.js"
```

### With unpkg.com

```html
<script type="module" src="https://unpkg.com/@chcodes-hamza/notifications-toast"></script>
```

Then use the custom element in your html  `<toast-notifications> </toast-notifications>`.

```html
<toast-notifications options='{
      "text": "Custom element",
      "position": "top-right",
      "pauseOnHover": true,
      "pauseOnFocusLoss": true,
      "autoClose": 5000,
      "type":"sucess"
    }'></toast-notifications>
```

## Customization
### Attributes

| Attribute | Type | Description                                 |
|-----------|------|---------------------------------------------|
| options   | JSON | a JSON object that contains many properties |

#### Options Object: 

| Option       | Default          | Description                                                                                                               |
|--------------|------------------|---------------------------------------------------------------------------------------------------------------------------|
| text         | empty            | the text displayed in the toast                                                                                           |
| position     | top-right        | the postion where the toast will be displayed (top-right, top-left, top-center ,bottom-center, bottom-left , bottom-right) |
| pauseOnHover | true             | the toast progress bar stops when it s hovred                                                                             |
| pauseOnFocusLoss | true             | the toast progress bar stops when you leave the current window                                                            |
| autoClose    | 5000 ms          | the toast will be closed automaticly after the 5000ms if you wnat to make it disappear manually put it false              |
| type         | default template | customize the type of the toast (danger, info , success, warning)                                                         |
| showProgress | true             | enable the progress bar in the toast bottom                                                                               |
|  canClose | true             | give ability to close the toast                                                                                           |
|  onClose | ()=>{}           | customize the action after the toast is closed, callback as input                                                         |




### CSS Custom Properties


|  Property   |
|-----|
|  --text-color-default   |
|  --chcodes-notif-default   |
|  --chcodes-notif-default-progress   |
|   --chcodes-notif-info  |
|   --chcodes-notif-info-progress  |
|  --chcodes-notif-danger   |
|  --chcodes-notif-danger-progress   |
| --chcodes-notif-warning  |
| --chcodes-notif-warning-progress  |
| --chcodes-notif-sucess  |
| --chcodes-notif-sucess-progress  |

---
_Source: https://npm.io/package/@chcodes-hamza/notifications-toast · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
