Astronaut Library .js
Notify
A small library for notification messages in your Projects or Web Applications.
How to use:
Opções:
Option | Type | Values | Description |
---|---|---|---|
message: | String | text | Define the Message |
icon: | String | Define an Icon | |
link: | Object | {object} | Define Links |
type: | String | text | Defines the notification type |
theme: | String | text | Define theme dark |
style: | Object | {object} | Define your own notification style |
autoClose: | Boolean/Number | true/miliseconds | Sets automatic closing |
Icon:
Define an Icon with URL
Define an Icon with tag SVG
astronaut.notify({
message: 'Main message -> Secondary message',
icon: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person" viewBox="0 0 16 16"><path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10z"></path></svg>'
})
Define an Icon with others tags HTML too
Link:
Define links to message or icon
Option | Type | Values | Description |
---|---|---|---|
message: | String | url | Redirect link when clicking on message |
icon: | String | url | Redirect link when clicking on icon |
target: | String | _blank | Open link in new tab |
Style:
Define your own notification style
Option | Type | Default | Description |
---|---|---|---|
position: | String | ' |
Change the position of the notification on the screen, Other options : 'top -> right', 'bottom -> right' or 'bottom -> left' |
background: | String | ' |
Change background color, other option ' Second parameter is optional, he declare background blur |
color: | String | ' |
Change font color |
border: | String | ' |
Change border color |
margin: | String | '2rem 2rem' | Notification distance from the sides of the screen |
iconColor: | String | ' |
Change icon color |
iconBackground: | String | ' |
Change icon background |
iconSize: | String | '2.2rem' | Change icon size |
closeColor: | String | ' |
Change icon 'close' color |
closeBackground: | String | ' |
Change icon 'close' background |
closeSize: | String | '0.8rem' | Change icon 'close' size |
filter: | String | 'none' | Add a filter to the notification |
timeout: | String | '0.5s' | Notification appearance animation time |
Tip: If you want to define a default style for all your notifications, define a variable in your main script file or script tag before any notify call. to store your styles.
var styleForNotify = {
background: '#574b8799 -> 5px', //Example with background blur
color: '#e9e9e9',
iconSize: '80%',
iconBackground: '#3b395c',
border: '#e9e9e9',
closeColor: '#574b87'
};
astronaut.notify({
message: 'Main message -> Secondary message',
icon: 'src/img/astronaut.head.svg',
style: styleForNotify
})