Overview
"Notiffy" is a TypeScript-based notification message UI.
Modern design created using pure CSS makes it accessible for everyone to learn and apply.
Customization is possible through provided properties and supports vanilla JavaScript as well as TypeScript.
Also Supports all frameworks and platforms that use JavaScript, such as React, Vue.js, and JSP.
Promises regular debugging and continuous updates. (at least one month apart)
Below are the core features provided by default.
1. Platform Independent
No extra installations for dependencies.
2. Four Types Available
Provides "Slip", "Mole", and "Alert" types for various uses besides the "Toast".
3. Varient Events
Event-based callback triggers can be utilized.
4. Most browsers Supported
Supports major browsers such as Chrome, Edge, Firefox and Safari.
5. Automatically Responsive Size
Delivers reactive type CSS automatically for tablet and mobile devices.
6. MIT License
It is free to use because it follows the MIT license.
Usage Cautions
Global CSS may affect "DIV", "SVG" and "Path" tag.
TypeScript is optional with minimal dependencies required for module building.
In case of using Node.js, it is advisable to opt for version 18.12.0 or newer. (if possible)
Installation
Select one of the following methods to add "Notiffy" to your project.
When using NPM.
npm install notiffy
When using YARN.
yarn add notiffy
When grab from CDN.
<!-- latest version -->
<script
src="https://cdn.jsdelivr.net/npm/notiffy/dist/index.js"></script>
<!-- if wanting specific version -->
<script
src="https://cdn.jsdelivr.net/npm/notiffy@1.0.0/dist/index.js"></script>
Quick Start
Declare module imports.
import {
Toast,
Slip,
Mole,
Alert }
from
"notiffy";
// or
const {
Toast,
Slip,
Mole,
Alert } =
require("notiffy");
// variable declaration
const {
Toast,
Slip,
Mole,
Alert } =
notiffy;
When using "Toast" example.
Toast.warning({
text:
"hello toast."
});
How To Apply
HTML apply example using CDN.
<!DOCTYPE html>
<html
lang="en">
<head>
<meta
charset="UTF-8"/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<script
src="https://cdn.jsdelivr.net/npm/notiffy/dist/index.js"></script>
</head>
<body>
<div>
<button
onclick="onClickButton()">Click here</button>
</div>
</body>
<script>
const {
Toast } =
notiffy; // global variable declaration
const
onClickButton = () => {
Toast.warning({
text: "hello warning toast."
});
};
</script>
</html>
Functional React apply example using an imported module. (basic)
import {
Toast }
from
"notiffy"; // import the module
const
Example = (): JSX.Element => {
const
onClickButton = (): void => {
Toast.warning({
text:
"hello warning toast."
});
};
return (
<div>
<button
onClick={
onClickButton }>Click
here</button>
</div>
);
};
Vue.js apply example using an imported module. (basic)
<template>
<div>
<button
@click="onClickButton">Click here</button>
</div>
</template>
<script
lang="ts">
import {
defineComponent }
from "vue";
import {
Toast }
from
"notiffy"; // import the module
export default
defineComponent({
name:
"ExampleView",
setup() {
const
onClickButton = (): void => {
Toast.warning({
text:
"hello warning toast."
});
};
return {
onClickButton
};
}
});
</script>
<style
scoped></style>
Examples
-
"Toast" appears at the center top of the screen.
There are a total of four types available.
Toast.warning({
text: "hello warning toast."
});Toast.error({
text: "hello error toast."
});Toast.success({
text: "hello success toast."
});Toast.info({
text: "hello info toast."
});Below is an example of a "Toast" lasting for 20 seconds. (unit is milliseconds)
When the icon property is set to "none", there is no time limit.
Toast.warning({
text: "hello toast.",
timeout: 20000
});Below is an example of a "Toast" featuring various SVG icons.
When the icon property is set to "none", the SVG icon is not visible.
Toast.warning({
text: "hello toast.",
icon: "outlined"
});Toast.warning({
text: "hello toast.",
icon: "shield"
});Toast.warning({
text: "hello toast.",
icon: "unadorned"
});Below is an example of "Toast" without a filled background color.
Toast.warning({
text: "hello notiffy.",
fill: false
}); -
"Slip" appears in the bottom right corner of the screen. (if text exceeds the width, it's partially omitted)
There are a total of four types available.
Slip.warning({
text: "hello warning slip."
});Slip.error({
text: "hello error slip."
});Slip.success({
text: "hello success slip."
});Slip.info({
text: "hello info slip."
});Below is an example of a "Slip" lasting for 20 seconds. (unit is milliseconds)
When "none" is set for the timeout property, there's no time limit.
Slip.warning({
text: "hello slip.",
timeout: 20000
});Below is an example of a "Slip" featuring various SVG icons.
When the icon property is set to "none", the SVG icon is not visible.
Slip.warning({
text: "hello slip.",
icon: "outlined"
});Slip.warning({
text: "hello slip.",
icon: "shield"
});Slip.warning({
text: "hello slip.",
icon: "unadorned"
});Below is an example of "Slip" without a filled background color.
Slip.warning({
text: "hello slip.",
fill: false
});Below is an example of "Slip" that appears on the left.
Slip.warning({
text: "hello slip.",
direction: "left"
}); -
"Mole" appears at the bottom of the screen. (if text exceeds the width, it's partially omitted)
There are a total of four types available.
Mole.warning({
text: "hello warning mole."
});Mole.error({
text: "hello error mole."
});Mole.success({
text: "hello success mole."
});Mole.info({
text: "hello info mole."
});Below is an example of a "Mole" lasting for 20 seconds. (unit is milliseconds)
When "none" is set for the timeout property, there's no time limit.
Mole.warning({
text: "hello mole.",
timeout: 20000
});Below is an example of a "Mole" featuring various SVG icons.
When the icon property is set to "none", the SVG icon is not visible.
Mole.warning({
text: "hello mole.",
icon: "outlined"
});Mole.warning({
text: "hello mole.",
icon: "shield"
});Mole.warning({
text: "hello mole.",
icon: "unadorned"
});Below is an example of "Mole" without a filled background color.
Mole.warning({
text: "hello mole.",
fill: false
});Below is an example of "Mole" that appears on the left.
Mole.warning({
text: "hello mole.",
direction: "left"
}); -
"Alert" appears on the center of the screen on a background layer.
There are a total of four types available.
Alert.warning({
text:"hello warning alert."
});Alert.error({
text: "hello error alert."
});Alert.success({
text: "hello success alert."
});Alert.info({
text: "hello info alert."
});Below is an example of "Alert" that displayed a title.
Alert.warning({
text: "hello alert.",
title: "this is title."
});Below is an example of a "Alert" lasting for 20 seconds. (unit is milliseconds)
By default, there is no time limit, but the timeout property allows setting the time limit.
Alert.warning({
text: "hello alert.",
timeout: 20000
});Below is an example of a "Alert" featuring various SVG icons.
When the icon property is set to "none", the SVG icon is not visible.
Alert.warning({
text: "hello alert.",
icon: "outlined"
});Alert.warning({
text: "hello alert.",
icon: "shield"
});Alert.warning({
text: "hello alert.",
icon: "unadorned"
});Below is an example of "Alert" without a filled background color.
Alert.warning({
text: "hello alert.",
fill: false
});Below is an example of "Alert" with a dark layer color.
Alert.warning({
text: "hello alert.",
overlay: "RGBA(0, 0, 0, 0.8)"
});
Properties
-
The properties that can be declared are as follows. (below are the default values)
Toast.warning({
id: null,
text: null,
timeout: 8000,
icon: "standard",
fill: true
});Name Type Description id String | Number classification id. text* String text displayed. timeout Number | "none" duration time. (m/s) icon "standard" | "outlined" | "shield" | "unadorned" | "none" SVG Icon displayed. fill Boolean background color filled. -
The properties that can be declared are as follows. (below are the default values)
Slip.warning({
id: null,
text: null,
timeout: 8000,
icon: "standard",
fill: true
direction: "right"
});Name Type Description id String | Number classification id. text* String text displayed. timeout Number | "none" duration time. (m/s) icon "standard" | "outlined" | "shield" | "unadorned" | "none" SVG Icon displayed. fill Boolean background color filled. direction "right" | "left" direction of appear. -
The properties that can be declared are as follows. (below are the default values)
Mole.warning({
id: null,
text: null,
timeout: 8000,
icon: "standard",
fill: true
direction: "center"
});Name Type Description id String | Number classification id. text* String text displayed. timeout Number | "none" duration time. (m/s) icon "standard" | "outlined" | "shield" | "unadorned" | "none" SVG Icon displayed. fill Boolean background color filled. direction "right" | "center" | "left" direction of appear. -
The properties that can be declared are as follows. (below are the default values)
Alert.warning({
id: null,
text: null,
title: null,
timeout: "none",
icon: "standard",
fill: true
overlay: "RGBA(0, 0, 0, 0.4)"
});Name Type Description id String | Number classification id. text* String text displayed below. title String text displayed above. timeout Number | "none" duration time. (m/s) icon "standard" | "outlined" | "shield" | "unadorned" | "none" SVG Icon displayed. fill Boolean background color filled. overlay String layer color.
Event
-
When clicking the message, an asynchronous callback event is triggered.
ID added is returned in the callback.
Check with the browser's developer tools.
Toast.warning({
id: 1
text: "hello toast."
}).then((response) => {
console.log("when clicked", response);
}).catch((error) => {
console.log(error);
}); -
When clicking the message, an asynchronous callback event is triggered.
ID added is returned in the callback.
Check with browser's developer tools.
Slip.warning({
id: 1
text: "hello slip."
}).then((response) => {
console.log("when clicked", response);
}).catch((error) => {
console.log(error);
}); -
When clicking the message, an asynchronous callback event is triggered.
ID added is returned in the callback.
Check with browser's developer tools.
Mole.warning({
id: 1
text: "hello mole."
}).then((response) => {
console.log("when clicked", response);
}).catch((error) => {
console.log(error);
}); -
When clicking the message, an asynchronous callback event is triggered.
ID added is returned in the callback.
Check with browser's developer tools.
Alert.warning({
id: 1
text: "hello alert."
}).then((response) => {
console.log("when clicked", response);
}).catch((error) => {
console.log(error);
});
Customize
Customize default colors by adding a style sheet file.
Create a style sheet for reference in the project and add it to the header.
Change the global CSS variable value to the color you want.
Recommend Hex-Code or RGBA for values. (below are the default values)
:root {
--notiffy-primary:
#ffffff;
--notiffy-secondary:
#f1f2f3;
--notiffy-warning:
#eb8e14;
--notiffy-warning-progress: #d77a00;
--notiffy-error:
#bd362f;
--notiffy-error-progress:
#a9221b;
--notiffy-success:
#3d8f3d;
--notiffy-success-progress: #297b29;
--notiffy-info:
#1679ab;
--notiffy-info-progress:
#026597;
--notiffy-overlay: RGBA(0,
0, 0, 0.4);
}
CSS Variable Name | Description |
---|---|
--notiffy-primary | font color. (when not filled) |
--notiffy-secondary | font color. (when filled) |
--notiffy-warning | main color for warning. |
--notiffy-warning-progress | progress bar color for warning. |
--notiffy-error | main color for error. |
--notiffy-error-progress | progress bar color for error. |
--notiffy-success | main color for success. |
--notiffy-success-progress | progress bar color for success. |
--notiffy-info | main color for info. |
--notiffy-info-progress | progress bar color for info. |
--notiffy-overlay | layer color for Alert. |
An element ID allows modification of various CSS attributes.
Verify the element attribute values using browser's developer tools and test it to prevent layout issues.
Please provide feedback on desired properties for possible inclusion in the next update.
(below are the examle using element ID)
#notiffy-toast > div {
border-radius:
0;
box-shadow:
none;
font-size:
14px;
font-family:
Noto Sans, sans-serif;
}
Support
Bugs or improvement requests on GitHub issues menu.
They will be addressed promptly as soon as possible.