项目作者: AnandChowdhary

项目描述 :
🎞️ Get a user's transparency preference
高级语言: TypeScript
项目地址: git://github.com/AnandChowdhary/prefers-reduced-transparency.git
创建时间: 2019-05-24T13:43:52Z
项目社区:https://github.com/AnandChowdhary/prefers-reduced-transparency

开源协议:MIT License

下载


🎞️ Prefers reduced transparency

Travis CI
Coverage Status
GitHub
Vulnerabilities
NPM type definitions
NPM
Minzipped size

NPM

Prefers reduced transparency is a package that tells you whether a user prefers less transparency. It’s based on the CSS @media (prefers-reduced-transparency), which is part of Media Queries Level 5. It’s around 700 bytes minified, 300 bytes gzipped.

⭐ Usage

Add the dependency from NPM:

  1. npm install prefers-reduced-transparency

Import the package:

  1. import prefersReducedTransparency from "prefers-reduced-transparency";

Then call the function:

  1. const contrastPreference = prefersReducedTransparency();
  2. // Returns "reduce" or "no-preference"

💡 Browser support

This package only works in browsers that natively support @media (prefers-reduced-transparency), so it just returns "no-preference" in unsupported browsers. Current browser support

By passing false as the argument, you can get "unsupported" as the value for unsupported browsers:

  1. const contrastPreference = prefersReducedTransparency(false);
  2. // Returns "reduce", "no-preference", or "unsupported"

🛠️ Development

Install dependencies:

  1. yarn

Compile Typescript to ES6 before publishing to NPM:

  1. yarn build

📀 Media Queries Level 5

📝 License

MIT