1.0.1 • Published 6 years ago
darky v1.0.1
darky.js
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
Name | Type | Default | Description | Available options |
---|---|---|---|---|
lightClass | string |
| Class added to body when light mode is active | Name of the class |
darkClass | string | dark | Class added to body when dark mode is active | Name of the class |
cache | boolean | true | cache location coordinates in local storage for one day | true (enable), false (disable) |
cacheClear | boolean | true | clear location coordinates in local storage everyday at midnight | true (enable), false (disable) |
auto | boolean | true | enable smart switch on script init | true (enable), false (disable) |
onLight | function | null | callback when dark mode is disabled | () => { // code } |
onDark | function | null | callback when dark mode is enabled | () => { // code } |
onCacheClear | function | null | callback 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
7 years ago
0.6.7
7 years ago
0.6.6
7 years ago
0.6.5
7 years ago
0.6.0
7 years ago
0.5.3
7 years ago
0.5.2
7 years ago
0.5.1
7 years ago
0.5.0
7 years ago