Small and clean lightbox script
https://akccakcctw.github.io/darkli/demo/
Directly download the files below
- CSS ( view in GitHub )
- JS ( view in GitHub )
Or using from CDN
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>
<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>
// deafult
const darkli = new Darkli();
// with custom config
const darkli = new Darkli({ heightAuto: false });
Parameter | Type | Default | Description |
---|---|---|---|
box | string | '.darkli' | |
contents | string | '.darkli-content' | |
btnOpens | string | '[data-darkli]' | |
btnClose | string | '.darkli .darkli-close' | |
bodyNoScroll | boolean | true | controll whether body should fixed when modal open |
heightAuto | boolean | true | Set to true and box will adopt its content height |
closeKeys | array | [27, 8] | keyCode: 27(esc), 8(backspace) |
beforeOpen | function | Will be executed before open | |
afterOpen | function | Will be executed after open | |
beforeClose | function | Will be executed before close | |
afterClose | function | Will be executed after close |
Method | Description |
---|---|
darkli.open(content) |
open specific box |
darkli.close() |
close box |
darkli.create({box, content}) |
create box |
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
# Build for development (watch file change)
$ npm run dev
# Build for production
$ npm run prod
Checking gulpfile.babel.js for more details.
Unit test
# Run unit test with AVA
$ npm run test:unit
$ npm run ava:watch
End-to-End test
We use Nightwatch.js as our E2E test tool.
# Run e2e test
$ npm run test:e2e
Just type follow command to view the graphical file structure in your terminal.
$ npm run tree