Git Product home page Git Product logo

newsman's Introduction

Getting started

newsman is a light-weight user notification module for the Browser, with no dependencies. To use newsman, simply install it with NPM and require it with Browserify, as follows:

npm install newsman
require("newsman");

For your convenience, some basic styles are provided in newsman/src/styles.

Methods

notify()

Sends a small, non-interactive notification to the user. By default it is located at the bottom-right of the screen.

/**
* @param {string} msg - text message to display to user, max 120 characters.
*/
newsman.notify(msg);

The notification markup is very simple, it consists of a single "div". It gets two state css classes appended to it during its lifecycle (isInactive and isActive).

<div class="newsman__notification">
    msg
</div>

alert()

Displays a small modal window containing the provided message and a button (ok).

/**
* @param {string} msg - text message to display to users.
* @param {function} cb - callback function triggered when the user clicks the button.
*/
newsman.alert(msg, cb);

The alert window markup has 5 components (divs). The window event listener is always bound to newsman__window.

<div class="newsman__overlay">
  <div class="newsman__window">
    <div class="newsman__window__content"> msg </div>
    <div class="newsman__window__actionBar">
      <div class="newsman__button"> ok </div>
    </div>
  </div>
</div>

confirm()

Displays a small modal window containing the provided message and two buttons (ok and cancel).

/**
* @param {string} msg - text message to display to user.
* @param {function} cb - callback function triggered when the user clicks one of the buttons.
* If "ok", it calls the provided callback with the "true" argument, otherwise "false".
*/
newsman.confirm(msg, cb);

The confirm window markup has 6 components (divs). The window event listener is always bound to newsman__window.

<div class="newsman__overlay">
  <div class="newsman__window">
    <div class="newsman__window__content"> msg </div>
    <div class="newsman__window__actionBar">
      <div class="newsman__button"> cancel </div>
      <div class="newsman__button"> ok </div>
    </div>
  </div>
</div>

Only one Alert or Confirm window can be active at any given time. If you try to launch a second such window, newsman's method will return false and not do anything until the currently active window is deactivated (requires user action).

newsman's People

Contributors

sebastiendaniel avatar

Watchers

 avatar James Cloos 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.