Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rohintangirala/circadia.js

Simple JavaScript module to enable night mode based on color contrast ratios
https://github.com/rohintangirala/circadia.js

dark-theme javascript javascript-module night-mode

Last synced: 2 days ago
JSON representation

Simple JavaScript module to enable night mode based on color contrast ratios

Awesome Lists containing this project

README

        

# circadia.js
Simple JavaScript module to enable night/dark mode in front end web projects. Zero dependencies. Adjusts text color to ensure readability based on contrast ratios between background and foreground.

Currently works for static web pages. More features to come...stay tuned. Feature requests and suggestions for improvement always welcome.

### How to use:
Simply add the `circadia.js` file to your project and add the following `script` element to your HTML file:
```html

```
In another JavaScript file, first create an instance of the `Circadia` class:
```javascript
let circadia = new Circadia();
```
Then, call the following methods to activate or deactivate the dark theme on your webpage, respectively:
```javascript
circadia.activate();

circadia.deactivate();
```
The activation state is stored in the browser's cache and is preserved when the page is reloaded or when the browser restarts.