# darky

> Smart dark mode switcher (based on location and time)

Latest version **1.0.1** (published 2018-09-29) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install darky
pnpm add darky
yarn add darky
bun add darky
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-09-29 |
| First published | 2018-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 34.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jakub Biesiada |
| Maintainers | jbiesiada |
| Keywords | JavaScript, dark, night, switch, smart, sun |

## Links

- npm: https://www.npmjs.com/package/darky
- Repository: https://github.com/JB1905/darky.js
- Homepage: https://github.com/JB1905/darky.js#readme
- Issues: https://github.com/JB1905/darky.js/issues
- npm.io page: https://npm.io/package/darky

## Dependencies (1)

- [suncalc](https://npm.io/package/suncalc.md) ^1.8.0

## Recent versions

- 1.0.1 (latest) — 2018-09-29
- 1.1.0-beta.1 (beta) — 2018-09-30
- 1.0.0 — 2018-09-06
- 1.0.0-beta.2 — 2018-09-03
- 1.0.0-beta.1 — 2018-09-02
- 0.8.0 — 2018-08-27
- 0.7.0 — 2018-08-05
- 0.6.7 — 2018-08-01
- 0.6.6 — 2018-07-31
- 0.6.5 — 2018-07-18
- 0.6.0 — 2018-07-17
- 0.5.3 — 2018-07-16
- 0.5.2 — 2018-07-12
- 0.5.1 — 2018-07-07

## README

# [darky.js](https://github.com/jb1905/darky.js)

[![NPM version](http://img.shields.io/npm/v/darky.svg?style=flat-square)](https://www.npmjs.com/package/darky)
[![NPM downloads](http://img.shields.io/npm/dm/darky.svg?style=flat-square)](https://www.npmjs.com/package/darky)

## How to Install
At the beginning install the library in Your project via npm or Yarn:
```sh
$ npm install darky
$ yarn add darky
```

## Getting Started
**Connect using script tag in HTML:**
```html
<script src="/directory/to/library/folder/darky.js"></script>
```

**Or CommonJS/ES6 import:**
```js
const Darky = require('darky'); // CommonJS
import Darky from 'darky'; // ES6
```

Next use library with:

**&bull; Vanilla JavaScript e.g:**
```js
const darky = new Darky({
  // options...
});
```

## Functions
**&bull; Switch between light and dark mode:**
```js
darky.toggle();
```

**• Switch mode automatically (based on time, location and sun position):**
```js
darky.auto();
```

**• Reset localStorage data:**
```js
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)
**onAuto** | function | `null` | callback on smart switch | `() => { // code }`
**onLight** | function | `null` | callback when dark mode is disabled | `() => { // code }`
**onDark** | function | `null` | callback when dark mode is enabled | `() => { // code }`
**onToggle** | function | `null` | callback on dark/light mode toggle | `() => { // code }`
**onCacheClear** | function | `null` | callback when location coordinates and midnight time in local storage cleared | `() => { // code }`
**onReset** | function | `null` | callback 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

---
_Source: https://npm.io/package/darky · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
