1.0.7 • Published 7 months ago

utils-deva v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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

JavaScript   HTML   CSS

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 :

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 devashishp1999@gmail.com

License

Hope this library will be helpful for you.

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago