Socket
Socket
Sign inDemoInstall

appearance-changed-event

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    appearance-changed-event

Adds `appearance-changed` event to the DOM to detect OS theme changes, using 1k of pure JavaScript.


Version published
Weekly downloads
2
Maintainers
1
Install size
11.2 kB
Created
Weekly downloads
 

Readme

Source

appearance-changed-event

Adds appearance-changed event to the DOM to detect OS theme changes, using 1k of pure JavaScript.

Usage

Add appearance-changed-event.min.js to your page and start listening for appearance-changed event.

// fires every time the OS theme changes
window.addEventListener('appearance-changed', function(e) {
  console.log(e.detail); // `light`, `dark`
});

It also exposes window.appearance which you can use to detect the current OS theme:

switch (window.appearance) {
    
    case 'light': {
       // do some light theme stuff
    } break;

    case 'dark': {
       // do some dark theme stuff
    } break;
}

Development

The project includes a node server, run the following then visit http://localhost:8080

git clone https://github.com/orca-scan/appearance-changed-event
cd appearance-changed-event
npm install
npm start

Update .min files

To create a new version of the minified appearance-changed-event.min.js file from source, tweak the version number in package.json and run npm run build

History

For change-log, check releases.

License

Licensed under MIT License © Orca Scan (build a barcode scanner app without code)

FAQs

Last updated on 15 Aug 2023

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