1.0.1 • Published 6 years ago

darky v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

darky.js

NPM version NPM downloads

How to Install

At the beginning connect the library with Your project:

using script tag in HTML:

<script src="/directory/to/library/folder/darky.js"></script>

or via command line:

$ npm install darky
$ yarn add darky

Getting Started

If you added library via package manager use CommonJS/ES6 import:

const Darky = require('darky'); // CommonJS
import Darky from 'darky'; // ES6

Next use library with:

Vanilla JavaScript e.g:

const darky = new Darky({
  // options...
});

Functions

Switch between light and dark mode:

darky.toggle();

• Switch mode automatically (based on time, location and sun position):

darky.auto();

• Reset localStorage data:

darky.reset();

Options

NameTypeDefaultDescriptionAvailable options
lightClassstringClass added to body when light mode is activeName of the class
darkClassstringdarkClass added to body when dark mode is activeName of the class
cachebooleantruecache location coordinates in local storage for one daytrue (enable), false (disable)
cacheClearbooleantrueclear location coordinates in local storage everyday at midnighttrue (enable), false (disable)
autobooleantrueenable smart switch on script inittrue (enable), false (disable)
onLightfunctionnullcallback when dark mode is disabled() => { // code }
onDarkfunctionnullcallback when dark mode is enabled() => { // code }
onCacheClearfunctionnullcallback when location coordinates and midnight time in local storage cleared() => { // code }

Event

smartDark event will output sun position times and user geolocation latitude & longitude

License

This project is licensed under the MIT License © 2018-present Jakub Biesiada

1.1.0-beta.1

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.0.0-beta.2

6 years ago

1.0.0-beta.1

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.7

6 years ago

0.6.6

6 years ago

0.6.5

6 years ago

0.6.0

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago