media-blender2.1.0 • Public • Published
Easy and predictable media queries
npm install --save media-blender
Configuration (breakpoint definition)
The breakpoints are defined with a SCSS map. The smallest breakpoint should start with 0, and the largest should only have one value if the other is infinity:
The above values are overriding the default values. The default values are:
The media mixin is receiving one or more parameters - the breakpoints we want to match.
Small mobile screens only
Tablet and large
The mixin also supports retina screens via the
retina query. It can be used alone,
or in combination with other breakpoints.
Using only retina
Combining retina with breakpoints
Desktop-first and mobile-first support
We make writing mobile-first or desktop-first oriented media queries easier than ever
by introducing the
down keywords. You can now say
tablet up, and this will
target tablets, and all other devices with a screen of at least that size. The reverse
tablet down. This will include all devices with a screen size no larger than
that defined for the tablet upper breakpoint. This also works for your custom breakpoints,
if you define them. It relies on the breakpoints, not their order of definition in the map.
Other than the breakpoints, you can also specify orientation, as an optional second argument to the mixin. For example, you can specify all mobile devices and tablets in landscape mode as so:
The mixin and its functions are unit tested using True.
All of the tests are defined in the
test/ directory and are SCSS files themselves. To add
your own tests, create a new
.scss file in
test/ and add the file name to the
file. The tests are run using Mocha.
Running the tests
To run the tests, run this command:
npm run test
Additionally, tests and linters can be run continuously through the watch mode, via:
npm run watch
- Updated default breakpoints (Bootstrap 4 values)