0.1.4 • Published 3 years ago

dtoaster v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

DToaster

- Basic and viable toasts with progressbar and high customizabillity

DEMO

Alt Text Alt Text

Requisites

VueJS >= 2.x

Install

$ npm i dtoaster

Usage

You can import and use the module everywhere in your app using:

app.js:

import 'dtoaster/dist/dtoaster.css'
import DToaster from 'dtoaster'
import ToasterPresets from './json/toast_presets.json' //Your predefined toasts presets (optionally)

Vue.use(DToaster, {
  presets: ToasterPresets,
  position: 'top-right', //toasts container position on the screen
  containerOffset: '45px', //toasts container offset from top/bottom of the screen
})

anycomponent.vue:

this.$dtoast.pop({
  preset: "your_preset",
  heading: `Custom Heading`,
  content:  `Custom content`,
  {...}
})

Predefined toasts (presets)

You can create a json file with array of objects which are predefined toasts with all your options you want. Every preset must be associated with a name, which is used in loading the particular preset in a toast

Example of a json file:

[
    {
        "name" : "success",
        "icon" : "mdi mdi-checkbox-multiple-marked-circle-outline",
        "icon_size" : "32px",
        "duration" : "2500",
        "background" : "rgba(32,105,156,.9)",
        "height" : "75px",
        "color" : "#FFFFFF",
        "show_progress_timeout" : "true",
        "progress_background" : "#5a9fdc",
        "progress_thumb_bg" : "rgba(32,105,156,.9)"
    },

    {
        "name" : "error",
        "icon" : "mdi mdi-close-circle-outline",
        "icon_size" : "32px",
        "duration" : "2500",
        "background" : "#ff1e1e",
        "height" : "75px",
        "color" : "#FFFFFF",
        "show_progress_timeout" : "true",
        "progress_background" : "rgb(255 175 175)",
        "progress_thumb_bg" : "#ff1e1e"
    }
]

You can then use a specific preset by providing its name when 'popping' a toast:

  this.$dtoast.pop({
    preset: "success",
    {...}
  })

This will create a toast with the options from your desired preset, which eliminate the need of re-typing every option every time you pop the same toast

You can override specific preset option for a toast, leaving others unchanged

  this.$dtoast.pop({
    preset: "success",
    color: "red",
    heading: "Toast with a different heading",
    content: "Toast with a different content",
    {...}
  })

Toast Options

OptionTypeFunctionDefaultAvailable
toastVerticalOffsetStringVertical offset of each toast5pxnull, --
positionStringPosition of the toast containertop-righttop-right, top-left, bottom-right, bottom-left
widthStringToast's width300px--
heightStringToast's height75px--
nameStringUsed preset name--null, --
headingStringToast's heading----
contentStringToast's content----
iconStringToast's icon class----
icon_sizeStringToast's icon font-size23px--
transitionStringToast's transitioningslideslide, more to come
durationStringToast's duration1000--
backgroundStringToast's background colorblack--
colorStringToast's font colorwhite--
show_progress_timeoutStringShow the progressbartrue--
progress_backgroundStringProgressbar's background colortomato--
progress_thumb_bgStringProgressbar's thumb colorred--
_styleStringAny style to override on the toast--{prop: value, ...}

Container Options

OptionTypeFunctionDefaultAvailable
containerVerticalOffsetStringVertical offset of the container35pxnull, --
containerSideOffsetStringSide offset of the container5pxnull, --

If you feel the need to thank me

BTC - bc1q8zhwxa5l6zg3amxten5rmetdkrz4sp78qzl5c4

ETH - 0x5e251964ACD0765694Bff190D88a6a727D986912

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago