Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
media-query-facade
Advanced tools
Do stuff via JavaScript when the media queries on a document change. For efficiency it uses window.matchMedia under the hood.
import MQFacade from 'media-query-facade'
const mq = new MQFacade({
small: 'only screen and (max-width: 480px)',
medium: 'only screen and (min-width: 480px) and (max-width: 720px)'
})
const changeColour = colour => () => {
document.body.style.backgroundColor = colour
}
mq.on('small', changeColour('blue'))
mq.on('medium', changeColour('green'))
mq.on('only screen and (min-width: 720px)', changeColour('red'))
There is a working version of the above in the example
dir. First run npm start
, then point a browser at localhost:8080
.
Initialise a new MQFacade
. Media query aliases
may also be provided up front.
Register an alias
for a query
, or register a number of aliases at once via an object.
mq.registerAlias('small', '(max-width: 100px)')
mq.registerAlias({
small: '(max-width: 100px)',
medium: '(max-width: 200px)'
})
Register a callback
which will be executed with the given context
on entry of the given query
or alias. If context
is not specified, it will default to the mq
instance.
mq.on('(max-width: 400px)', () => {})
mq.on('smartphones', () => {}, {})
Remove all callbacks for all queries:
mq.off()
Remove all callbacks for a query
or alias:
mq.off('(max-width: 400px)')
Remove a callback
for a query
or alias:
mq.off('(max-width: 400px)', () => {})
Remove a callback
with a context
for a query
or alias:
mq.off('(max-width: 400px)', () => {}, {})
$ npm install media-query-facade --save
There are also UMD builds available via unpkg:
MIT
FAQs
A nicer JavaScript media query API.
The npm package media-query-facade receives a total of 1 weekly downloads. As such, media-query-facade popularity was classified as not popular.
We found that media-query-facade demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.