0.7.2 • Published 5 years ago

darkli v0.7.2

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

Darkli

Small and clean lightbox script

NPM version Dependencies LICENSE downloads_npm

Demo

https://akccakcctw.github.io/darkli/demo/

Usage

1. CSS & JS Files

Directly download the files below

Or using from CDN

2. Include Files To Website/App

In your html file:

<!DOCTYPE html>
<html>
<head>
  ...
  <link rel="stylesheet" href="path/to/darkli.min.css">
</head>
<body>
  ...
  <script src="path/to/darkli.min.js"></script>
</body>
</html>

3. Add Darkli HTML Layout

<div class="darkli">
  <button class="darkli-close"></button>
  <div class="darkli-content" data-darkli-content="c1">
    <!-- contents... -->
  </div>
  <div class="darkli-content" data-darkli-content="c2">
    <!-- contents... -->
  </div>
</div>

4. Initialize

// deafult
const darkli = new Darkli();

// with custom config
const darkli = new Darkli({ heightAuto: true });

Parameters

ParameterTypeDefaultDescription
boxstring'.darkli'
contentsstring'.darkli-content'
btnOpensstring'data-darkli'
btnClosestring'.darkli .darkli-close'
heightAutobooleanfalseSet to true and box will adopt its content height
closeKeysarray27, 8keyCode: 27(esc), 8(backspace)
beforeOpenfunctionWill be executed before open
afterOpenfunctionWill be executed after open
beforeClosefunctionWill be executed before close
afterClosefunctionWill be executed after close

Methods

MethodDescription
darkli.open(content)open specific box
darkli.close()close box
darkli.create({box, content})create box

Development

Prerequisites

Getting Started

Before coding, you need to install packages for development, we choose gulp as our build system.

# install all building tools and dependencies
$ npm install # or yarn

Usage

# Build `sass`, `javascript`, `demo` and minified files:
$ npm start # or `npm run gulp`

# Build `sass`, `javascript`, and then watch file
$ npm run gulp watch

# Uglify and minify `.css` and `.js` files
$ npm run gulp min

# You can also use these commands below
$ npm run gulp js
$ npm run gulp css
$ npm run gulp js-min
$ npm run gulp css-min

Checking gulpfile.js for more details.

Testing

Unit test

# Lint and then do unit test with AVA
$ npm test

$ npm run ava

$ npm run ava:watch

End-to-End test

We use Nightwatch.js as our E2E test tool.

Before test, you should start a localhost server at 8000 port, use gulp task to start it:

$ npm run gulp localhost

Then you can start the E2E test:

$ npm run e2e

# firefox
$ npm run e2e:firefox

Show File Structure

Just type follow command to view the graphical file structure in your terminal.

$ npm run tree

License

MIT

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago