GithubHelp home page GithubHelp logo

paologf / smalltalk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coderaiser/smalltalk

0.0 1.0 0.0 315 KB

Promise-based Alert, Confirm and Prompt replacement

License: MIT License

CSS 8.05% HTML 6.70% JavaScript 85.25%

smalltalk's Introduction

Smalltalk License NPM version Dependency Status Build Status Coverage

Simple Promise-based replacement of native Alert, Confirm and Prompt.

Install

npm i smalltalk

API

First things first, require smalltalk with:

const smalltalk = require('smalltalk');

You can also use native version with:

const smalltalk = require('smalltalk/native');

In every method of smalltalk last parameter options is optional and could be used to prevent handling of cancel event.

{
    cancel: true /* default */
}

smalltalk.alert(title, message)

Alert

smalltalk
    .alert('Error', 'There was an error!')
    .then(() => {
        console.log('ok');
    });

smalltalk.confirm(title, message [, options])

Confirm

smalltalk
    .confirm('Question', 'Are you sure?')
    .then(() => {
        console.log('yes');
    })
    .catch(() => {
        console.log('no');
    });

smalltalk.prompt(title, message, value [, options])

Prompt

smalltalk
    .prompt('Question', 'How old are you?', '10')
    .then((value) => {
        console.log(value);
    })
    .catch(() => {
        console.log('cancel');
    });

Use type='password' for password fields:

smalltalk
    .prompt('Question', 'How old are you?', '10', {
        type: 'password',
    })
    .then((value) => {
        console.log(value);
    })
    .catch(() => {
        console.log('cancel');
    });

Bundlers

When webpack rollup or browserify used, you can import es5 version with:

import smalltalk from 'smalltalk/legacy';

License

MIT

smalltalk's People

Contributors

coderaiser avatar googee avatar laurent22 avatar

Watchers

paologf 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.