Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

util-darkmode

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

util-darkmode

Utility package for managing Dark Mode on the web.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

设备主题模式监听

Build Status Coverage Status

安装

# 安装
npm i util-darkmode
# 或者 yarn add util-darkmode

更新记录

说明

/* ----------类型说明----------*/
export enum Theme {
    DARK = 'dark', // 暗黑模式
    LIGHT = 'light', // 明亮模式
    NO_PREF = 'no-preference', // 未设置
    NO_SUPP = 'no-support', // 不支持
}
export type DarkMode = (
    config: (activeTheme: Theme, themes: typeof Theme) => void
) => { removeListeners: () => void }

/* ----------使用方式----------*/
import { darkmode } from 'util-darkmode'

// 注册监听
const dm = darkmode((theme, themes) => {
    // 处理业务,也可直接判断 theme === 'dark'
    if (theme === Theme.DARK) {
        // ...
    }
})

// 注销监听
dm.removeListeners()

Keywords

FAQs

Package last updated on 09 Dec 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc