1.3.6 • Published 4 years ago

hawesome-vue-extends v1.3.6

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

hawesome-vue-extends

A Vue modal component plugin based on Vuetify with Vuex.
Provides dialog, notification and loader for building a modern website.
Using Promise API refactor modal component to provide fluent experience.
Live Demo

Installation

NPM

$ npm install hawesome-vue-extends

Install hawesome-vue-extends via Vue.use():

// main.js or somewhere you initialize your app

// import import store from "../path/to/your/vuex/store.js" import Vue from "vue" import hawesomeVue from "hawesome-vue-extends"

// initialize global settings var options = { store, dialogSetting: { ... }, notifySetting: { ... }, loaderSetting: { ... } }

// install Vue.use(hawesomeVue, options)

Use component at `root (the most top-level)` component like:
```js
<template>
  <v-app>
    <HawesomeDialog />
    <HawesomeNotify />
    <HawesomeLoader />
    ...
  </v-app>
</template>

Usage

After Installing the plugin, $dialog, $notify and $loader will available on the Vue prototype.


Dialog

Live Demo

API

NameParameterReturn TypeDescription
talkval: stringfunc: (builder: DialogConfigBuilder) => voidPromise<null>setup and open dialog
hangUpvoidclose dialog

Global Settings

// import
import store from "../path/to/your/vuex/store.js"
import Vue from "vue"
import hawesomeVue from "hawesome-vue-extends"

// initialize global settings
var options = { 
  store,
  dialogSetting: {
    // hawesome-vue-extends/lib/dialog/dialogConfigAttribute
    title: "訊息", 
    confirmBtnTxt: "確認", 
    cancelBtnTxt: "取消"
  }
}

// install
Vue.use(hawesomeVue, options)

Basic Usage

// `this` points to the Vue instance
this.$dialog
  .talk("Lorem ipsum dolor sit amet.")
  .then(() => {
    // trigger after user clicks the confirm button
  })
  .catch(() => {
    // trigger after user clicks the cancel button
  })
  .finally(this.$dialog.hangUp);

Working With Builder

// `this` points to the Vue instance
this.$dialog
  .talk("嗨~大家今天過得好嗎?", builder => {
    builder 
      .set("width", 500)
      .set("themeColor", "info")
      .set("isShowCancelBtn", false)
  })
  .then(() => {
    // trigger after user clicks the confirm button
  })
  .catch(() => {
    // trigger after user clicks the cancel button
  })
  .finally(this.$dialog.hangUp);

Notify

Live Demo

API

NameParameterReturn TypeDescription
infonotiText: stringfunc: (builder: NotifyConfigBuilder) => voidPromise<null>push info notification
successnotiText: stringfunc: (builder: NotifyConfigBuilder) => voidPromise<null>push success notification
warningnotiText: stringfunc: (builder: NotifyConfigBuilder) => voidPromise<null>push warning notification
errornotiText: stringfunc: (builder: NotifyConfigBuilder) => voidPromise<null>push error notification
promisenotiText: stringfunc: (builder: NotifyConfigBuilder) => voidPromise<null>push notification without auto dismiss
pushnotiText: stringfunc: (builder: NotifyConfigBuilder) => voidPromise<null>push notification
resolveAllNotifyvoidresolve all notification
clearAllNotifyvoidclear all notification( p.s. not trigger then callback function)

Global Settings

// import
import store from "../path/to/your/vuex/store.js"
import Vue from "vue"
import hawesomeVue from "hawesome-vue-extends"

// initialize global settings
var options = { 
  store, 
  notifySetting: { 
    // hawesome-vue-extends/lib/notify/notifyConfigAttribute
    position: "bottomLeft", 
    timeout: 5 
  } 
}

// install
Vue.use(hawesomeVue, options)

Basic Usage

// `this` points to the Vue instance
this.$notify
  .info("Lorem, ipsum dolor.")
  .then(() => {
    console.log("resolved");
  });

Working With Builder

// `this` points to the Vue instance
this.$notify
  .push(
    "Lorem, ipsum dolor.",
    builder => {
      builder
        .setType("success")
        .setTimeout(5)
    })
  .then(() => {
    console.log("resolved");
  });

Loader

Live Demo

API

NameParameterReturn TypeDescription
onloaderText: stringvoidopen loader
offvoidclose loader

Global Settings

// import
import store from "../path/to/your/vuex/store.js"
import Vue from "vue"
import hawesomeVue from "hawesome-vue-extends"

// initialize global settings
var options = { 
  store, 
  loaderSetting: { 
    type: "linear"
  } 
}

// install
Vue.use(hawesomeVue, options)

Basic Usage

// `this` points to the Vue instance
this.$loader.on();
setTimeout(() => {
  this.$loader.off();
}, 2000);

// `this` points to the Vue instance
this.$loader.on("系統處理中,請稍後…");
setTimeout(() => {
  this.$loader.off();
}, 2000);

Tutorial

Live Demo

Working With Promise API

// `this` points to the Vue instance
this.$notify
  .promise("hello!!")
  .then(() => this.$dialog.talk("ready to start a tutorial?"))
  .then(() =>
    this.$dialog.talk(
      "we can use `Promise API` chaining a series of tasks.",
      builder => {
        builder
          .set("width", 500)
          .set("themeColor", "purple")
          .set("isShowCancelBtn", false)
          .set("confirmBtnTxt", "simulate async");
      }
    )
  )
  .then(
    () =>
      new Promise(resolve => {
        this.$loader.on();
        setTimeout(() => {
          this.$loader.off();
          resolve({ result: true, msg: "hope you enjoy!" });
        }, 2000);
      })
  )
  .then(rs => {
    if (rs.result) {
      this.$notify.success(rs.msg);
    }
  })
  .catch(() => {
    this.$notify.warning("ok. maybe next time.");
  })
  .finally(this.$dialog.hangUp);
1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.12

4 years ago

1.2.11

4 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.16

4 years ago

1.0.20

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago