Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/rohintangirala/circadia.js
- Owner: rohintangirala
- Created: 2019-07-13T06:41:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-16T01:56:03.000Z (over 5 years ago)
- Last Synced: 2024-11-08T13:42:25.706Z (about 2 months ago)
- Topics: dark-theme, javascript, javascript-module, night-mode
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.