Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
boomqueries
Advanced tools
BoomQueries is our take on element queries; sizing elements based on their container.
BoomQueries is our take on element queries - sizing elements based on their container.
As our product has grown to be more modular, we began to see the limitations of styling modular components across more granular scopes with media queries (main content areas, sidebars, etc.). The specificities of keeping up with all these variations started to take a toll on productivity and maintenance. While there are other element query implementations, we didn't find any that quite fit our needs. The benefits of our version are:
There's a few options to get up and running with BoomQueries:
git clone git://github.com/boomtownroi/boomqueries.git
bower install boomqueries --save
npm install boomqueries
Use boomQueries.add()
to register your component(s) with the BoomQueries library.
boomQueries.add('.component', [
[480, "component--md"],
[600, "component--lg"]
]);
In this example, .component will receive the .component--md modifier class when .component is 480px wide. At 600px wide, .component will receive the .component--lg modifier class and .component--md will be removed.
You can also register DOM nodes.
var component = document.createElement('div');
boomQueries.add(component, [
[480, "component--md"],
[600, "component--lg"]
]);
When registering DOM nodes, you can pass an additional third parameter, id, to reference your node later in the application.
var component = document.createElement('div');
boomQueries.add(component, [
[480, "component--md"],
[600, "component--lg"]
], 'myComponent');
// boomQueries.get('myComponent') you can get your node
// boomQueries.remove('myComponent') you can remove your node
You can also bulk add DOM nodes.
var components = [document.createElement('div'), document.createElement('div'), document.createElement('div'), document.createElement('div')];
boomQueries.add(components, [
[480, "component--md"],
[600, "component--lg"]
], 'myComponents');
// boomQueries.remove('myComponents') to remove them
You can also manage multiple classes for each break point by separating class names with a space.
var components = [document.createElement('div'), document.createElement('div'), document.createElement('div'), document.createElement('div')];
boomQueries.add(components, [
[480, "component--md mdClass"],
[600, "component--lg lgClass"]
], 'myComponents');
// boomQueries.remove('myComponents') to remove them
When you are working with a dynamic application that has lots of DOM changes, you should refresh your boomQueries after change.
boomQueries.refresh();
The refresh method will remove event listeners from watched nodes that are no longer in the DOM and grab newly added elements based on their css selector.
There are times when you would want to fire additional functionality on a node after it's been updated. You can do this by attaching a custom event listener to that node.
var component = document.createElement('div');
document.body.appendChild(component);
component.addEventListener('boomQueries_nodeUpdated', function(event){
console.log(event.detail);
});
We pass the callback an object about the recent update: offsetWidth
and currentBreak
You can remove components registered by BoomQueries by calling the remove
method and specifying either your custom id or css selector.
boomQueries.remove('myComponent');
You can freely add/remove components as needed throughout your app, so don't feel that you need to register them all at once!
Using Backbone, Angular, React, etc. to dynamically interact with DOM elements? You can easily "refresh" BoomQueries by calling the refresh()
method again:
boomQueries.refresh();
Anywhere you see window.boomQueries in our examples can be replaced with the CommonJS module version.
var boomQueries = require('boomqueries');
boomQueries.add(".component", [
[480, "component--md"],
[600, "component--lg"]
]);
boomQueries.remove(".component");
boomQueries.refresh();
If you need to see what nodes are currently being watched, you can log boomQueries.inspect()
If you need to see which css selectors are being followed/refreshed, you can log boomQueries.inspect('map')
And although it is not recommended, you can access the internal data for debugging purposes:
boomQueries.nodes
boomQueries.map
BoomQueries works in modern browsers that support requestAnimationFrame, but also has a fallback for browsers that don't; like IE9. If you'd like to bring older browsers up to speed, then adding this gist as a polyfill will give 'em the good stuff.
Have something you want to add to BoomQueries? Great! Here's a few helpful tips to get started:
We use GulpJS to compile BoomQueries, so make sure you have that and Node.js installed.
git clone git://github.com/boomtownroi/boomqueries.git
npm install
to add-in Gulp dependenciesgulp server
to fire up a browser (using BrowserSync) which will take care of compiling and reloading the page.BoomQueries is maintained by using the Semantic Versioning Specification (SemVer)
Copyright 2015 BoomTown under the MIT License
FAQs
BoomQueries is our take on element queries; sizing elements based on their container.
The npm package boomqueries receives a total of 8 weekly downloads. As such, boomqueries popularity was classified as not popular.
We found that boomqueries demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.