Socket
Socket
Sign inDemoInstall

darky

Package Overview
Dependencies
1
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    darky

Smart dark mode switcher (based on location and time)


Version published
Weekly downloads
15
increased by15.38%
Maintainers
1
Install size
53.3 kB
Created
Weekly downloads
 

Readme

Source

darky.js

NPM version NPM downloads

How to Install

At the beginning install the library in Your project via npm or Yarn:

$ npm install darky
$ yarn add darky

Getting Started

Connect using script tag in HTML:

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

Or 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
lightClassstring Class 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)
onAutofunctionnullcallback on smart switch() => { // code }
onLightfunctionnullcallback when dark mode is disabled() => { // code }
onDarkfunctionnullcallback when dark mode is enabled() => { // code }
onTogglefunctionnullcallback on dark/light mode toggle() => { // code }
onCacheClearfunctionnullcallback when location coordinates and midnight time in local storage cleared() => { // code }
onResetfunctionnullcallback on localStorage reset() => { // 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

Keywords

FAQs

Last updated on 29 Sep 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc