Giter VIP home page Giter VIP logo

draftscripts.js's Introduction

DraftScripts Node.js Library e.g. (Vue, React, Angular, Vanilla JS, etc.)

A customizable Vue.js dialog component library with support for success, error, warning, and confirmation dialogs.

View Demo

NPM Version Download Stars LICENSE

Explore the documentation

Features

  • Customizable dialog types: success, error, warning, and confirm.
  • Supports both options API and composition API.
  • Promise-based API for handling user responses.
  • Customizable CSS class names for styling flexibility.
  • Built with Vite for fast and modern development.

Installation

Install the plugin using npm:

npm install @draftscripts/vue

Or using yarn:

yarn add @draftscripts/vue

Usage

Register the Plugin

In your main application file (e.g., main.js or main.ts), register the plugin:

import { createApp } from 'vue';
import App from './App.vue';
import { DialogPlugin } from '@draftscripts/vue';

const app = createApp(App);

const options = {
  // Custom options here
};

app.use(DialogPlugin, options);

app.mount('#app');

Options API Example

To open a dialog using the Options API:

export default {
  methods: {
    showDialog() {
      this.$openDialog('Message', { type: 'success' });
    },
    showConfirmDialog() {
      this.$openDialog('Message', { type: 'confirm' }).then((action) => {
        if (action) {
          console.log('Confirmed');
        }
      }).catch(() => {
        console.log('Rejected');
      });
    }
  }
};

Composition API Example

To open a dialog using the Composition API:

import { inject } from 'vue';

export default {
  setup() {
    const openDialog = inject('openDialog');

    const showDialog = () => {
      openDialog('Message', { type: 'success' });
    };

    const showConfirmDialog = () => {
      openDialog('Message', { type: 'confirm' }).then((action) => {
        if (action) {
          console.log('Confirmed');
        }
      }).catch(() => {
        console.log('Rejected');
      });
    };

    return {
      showDialog,
      showConfirmDialog
    };
  }
};
    

draftscripts.js's People

Contributors

kzamanbd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.