# javascript-alert

> javascript class to alert messages

Latest version **1.1.4** (published 2023-11-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install javascript-alert
pnpm add javascript-alert
yarn add javascript-alert
bun add javascript-alert
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2023-11-18 |
| First published | 2023-11-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alamin |
| Maintainers | amincode1 |
| Keywords | alert, messages, javascript, js |

## Links

- npm: https://www.npmjs.com/package/javascript-alert
- Repository: https://github.com/amincode1/javascript-alert
- Homepage: https://github.com/amincode1/javascript-alert#readme
- Issues: https://github.com/amincode1/javascript-alert/issues
- npm.io page: https://npm.io/package/javascript-alert

## 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.1.4 (latest) — 2023-11-18
- 1.1.3 — 2023-11-18
- 1.1.2 — 2023-11-18
- 1.1.1 — 2023-11-18
- 1.1.0 — 2023-11-18
- 1.0.0 — 2023-11-18

## README

# javascript class to alert message

- Simple
- Easy to use
- Small size
# screenshot
![Screenshot](https://github.com/amincode1/alert.js/blob/main/Screenshots/1.png)

# Installation

```
npm i javascript-alert
```

# To use

```js
import {Alert} from "javascript-alert";

new Alert({
  text: 'Hello World !!',
});
```

# What this class can do

- Sending alerts
- Choose between a range of alert severity
- Set a time to hide the alert
- Keep the alert when the mouse cursor is fixed on it
- The ability to add a link when clicking on the alert
- The possibility of adding a function that works when clicking on the alert
- Control where alert appear
- Executing a function after the alert ends

# options

| name | default | type | description |
| --- | --- | --- | --- |
| limit | 5   | Integer | The time the alert disappears in seconds |
| location | 'tc' | String | Where the notification appears|
| clickUrl | null | String | The address of a website that you will go to when you click on the alert |
| clickFun | String | Function | A JavaScript function that runs when the logo is clicked |
| severity | 'success' | String | The serious type of poetry|
| after | null | Function | function run after alert end |

# option (location)

- ### 'tc' => top center
    
- ### 'tr' => top right
    
- ### 'tl' => top left
    
- ### 'bc' => bottom center
    
- ### 'br' => bottom right
    
- ### 'bl' => bottom left
    

# option (severity)

- ### 'success'
    
- ### 'info'
    
- ### 'warn'
    
- ### 'error'
    

# option (clickUrl) how to use

```js
new Alert({
  text: 'Hello World !!',
  severity: 'info',
  clickUrl: 'https://example.com'
})
```

# option (clickFun) how to use

```js
new Alert({
  text: 'Hello World !!',
  severity: 'info',
  clickFun: function(){
    console.log('Hello World !!');
  }
})
```

# option (after) how to use

```js
new Alert({
  text: 'Hello World !!',
  severity: 'info',
  after: function(){
    console.log('end alert..');
  }
})
```

# style

| style name | default |
| --- | --- |
| width | '400px' |
| textAlign | 'center' |
| padding | '20px 10px' |
| position | 'fixed' |
| borderRadius | '10px' |
| direction | 'ltr' |
| cursor | 'pointer' |
| fontWeight | 'bold' |
| borderBottom | 'solid 4px' |
| zIndex | '9'

# change style

```js
new Alert({
  text: 'Hello World !!',
  severity: 'info',
  style:{
    width: '200px',
    textAlign : 'left'
  }
})
```

- ### If the style is outside the table above a new style can be added via
    

```js
const new_alert = new Alert({
  text: 'Hello World !!',
  severity: 'warn',
});

 new_alert.alertItem.style.fontSize = '18px';
 new_alert.alertItem.style.fontFamily = 'any font';
```

# use in vue js
- ### call once and make its functionality available throughout your Vue application without explicitly calling it in each component, you can achieve this by creating a Vue plugin.
- ### make javascript-alert.js and put
```js
import { Alert } from "javascript-alert";
export default {
  install: function (app) {
    app.config.globalProperties.$alert = Alert;
  },
};
```

- ### in main.js 
```js
import { createApp } from "vue";
import App from "./App.vue";
import alertMessage from "@/your-path/javascript-alert.js";

createApp(App).use(alertMessage).mount("#app");

```

- ### now you can use alert in any component

```js
new this.$alert({
  text: 'Hello World !!'
});
```

---
_Source: https://npm.io/package/javascript-alert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
