utils-deva
v1.0.7
Published
utility functions and classes at finger-tips
Downloads
60
Maintainers
Readme
About The Project
Every website need some common elements to be implemented for a consistent UI/UX. Here are some simple UI components and funtionalities just a function call away. These all classes & functions are a solution to the problems that I faced while developing various websites, I bundled them together here.
Use these functionalities because:
- Your time should be focused on creating something amazing. A project that solves a problem and helps others
- You shouldn't be writing the same code over and over again.
- You should implement DRY principles to the rest of your life :smile:
Built With
Installation
• Include the main.js
file in your project and create a new instance of a class.
<script src="path/to/main.js"></script>
<!-- OR -->
<script src="https://cdn.jsdelivr.net/gh/devashishp1999/utils-deva@main/main.min.js"></script>
<script>
const toast = new Toast();
toast.show(); // Show default toast
</script>
npm i utils-deva
https://devashishp1999.github.io/utils-deva/main.min.js
or
https://cdn.jsdelivr.net/gh/devashishp1999/utils-deva@main/main.min.js
List of Classes :
The Toast class provides a simple and flexible way to create and manage toast notifications in your web application. It allows you to easily customize the look, position and behavior of the toasts, and provides methods for showing, hiding and removing toasts.
Showing a Toast
To show a toast, call the show()
method on the Toast instance and pass in an options object.
toast.show({
text: "Hello World",
position: "top",
duration: 3,
styles: {
backgroundColor: "red",
color: "white",
fontSize: "20px",
},
animations: {
slideIn: "1s",
},
fonts: {
fontFamily: "Arial",
},
});
Removing a Toast
To remove a specific toast, call the remove()
method on the Toast instance and pass in the toast element as an argument.
toast.remove(toastElement);
Removing All Toasts
To remove all toasts, call the removeAll()
method on the Toast instance.
toast.removeAll();
Configuration
The options object passed to the show()
method can include the following properties:
Example
const toast = new Toast();
toast.show({
text: "Hello World",
position: "top",
duration: 2.5,
styles: {
backgroundColor: "red",
color: "white",
fontSize: "20px",
},
animations: {
slideIn: "1s",
},
fonts: {
fontFamily: "Arial",
},
});
This will create a new toast with the text "Hello World" and position it on the top of the screen and it will be removed after 3000ms. Also the toast will slide in from 1s with custom background color, color and font size and font family.
Browser Support
This library uses querySelector
and appendChild
which are supported by all modern browsers.
Docs are not updated : Contact [email protected]
License
Hope this library will be helpful for you.