All Projects → infinum → media-blender

infinum / media-blender

Licence: MIT license
Easy and predictable SASS/SCSS media queries

Programming Languages

CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to media-blender

Mq Scss
Extremely powerful Sass media query mixin. Allows you to create almost any media query you can imagine.
Stars: ✭ 122 (+369.23%)
Mutual labels:  mixins, breakpoint, media
styled-media-helper
💅 Helps manage media queries with styled components
Stars: ✭ 76 (+192.31%)
Mutual labels:  breakpoint, media, media-query
Styled Breakpoints
Simple and powerful tool for creating breakpoints in styled components and emotion. 💅
Stars: ✭ 428 (+1546.15%)
Mutual labels:  breakpoint, media
Styled Components Breakpoint
Utility function for using breakpoints with styled-components 💅.
Stars: ✭ 231 (+788.46%)
Mutual labels:  breakpoint, media
Sponge
The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
Stars: ✭ 241 (+826.92%)
Mutual labels:  mixins
Elena Lang
ELENA is a general-purpose language with late binding. It is multi-paradigm, combining features of functional and object-oriented programming. Rich set of tools are provided to deal with message dispatching : multi-methods, message qualifying, generic message handlers, run-time interfaces
Stars: ✭ 161 (+519.23%)
Mutual labels:  mixins
Mimic
mimic: Define your Deployments, Infrastructure and Configuration as a Go Code 🚀
Stars: ✭ 145 (+457.69%)
Mutual labels:  mixins
Accecss
AcceCSS A Sass Mixin That debug & check the accessibility of your designs
Stars: ✭ 132 (+407.69%)
Mutual labels:  mixins
wp-user-avatars
Allows registered users to upload and select their own avatars
Stars: ✭ 32 (+23.08%)
Mutual labels:  media
DownOnSpot
🎵 A Spotify music and playlist downloader written in Rust which also works with a free Spotify account
Stars: ✭ 309 (+1088.46%)
Mutual labels:  media
Pug Bootstrap
Bootstrap framework written completely using mixins in Pug
Stars: ✭ 212 (+715.38%)
Mutual labels:  mixins
Sassessentials
Repository for my tutorial course: Sass Essential Training on LinkedIn Learning and Lynda.com.
Stars: ✭ 167 (+542.31%)
Mutual labels:  mixins
WP-Media-Uploader
Easily create a custom media upload button in WordPress admin dashboard that you can use in your plugin
Stars: ✭ 25 (-3.85%)
Mutual labels:  media
Skeleton Sass
Skeleton Sass is a highly modular version of Skeleton CSS
Stars: ✭ 151 (+480.77%)
Mutual labels:  mixins
video-filename-parser
Scene release name parser
Stars: ✭ 40 (+53.85%)
Mutual labels:  media
Super module
SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base). This also succeeds ActiveSupport::Concern by offering lighter syntax
Stars: ✭ 133 (+411.54%)
Mutual labels:  mixins
Styled Components Spacing
Responsive margin and padding components for styled-components 💅.
Stars: ✭ 209 (+703.85%)
Mutual labels:  mixins
wp-original-media-path
Change the location for the uploads folder for WordPress
Stars: ✭ 22 (-15.38%)
Mutual labels:  media
Web Portfolio
Personal portfolio website made with the React
Stars: ✭ 207 (+696.15%)
Mutual labels:  mixins
Browser Hack Sass Mixins
Browser hack sass mixin - Apply your SCSS to a specific browser - CSS hacks for: IE, Chrome, Firefox, Edge, Opera
Stars: ✭ 170 (+553.85%)
Mutual labels:  mixins

media-blender

Easy and predictable media queries

Build Status NPM version Dependency Status devDependency Status

Installation

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:

@import 'media-blender';

$media-breakpoints: (
  mobile: 0 767,
  tablet: 768 991,
  desktop: 992 1199,
  large: 1200
);

The above values are overriding the default values. The default values are:

$media-breakpoints: (
  small: 0 543,
  mobile: 544 767,
  tablet: 768 991,
  desktop: 992 1199,
  large: 1200
) !default;

Usage

The media mixin is receiving one or more parameters - the breakpoints we want to match.

Examples

Small mobile screens only

Source:

@include media(small) {
  .element {
    color: red;
  }
}

Compiled:

@media (max-width: 543px) {
  .element {
    color: red;
  }
}

Tablet only

Source:

@include media(tablet) {
  .element {
    color: red;
  }
}

Compiled:

@media (min-width: 768px) and (max-width: 991px) {
  .element {
    color: red;
  }
}

Desktop

@include media(desktop large) {
  .element {
    color: red;
  }
}

Compiled:

@media (min-width: 992px) {
  .element {
    color: red;
  }
}

Tablet and large

@include media(tablet large) {
  .element {
    color: red;
  }
}

Compiled:

@media (min-width: 768px) and (max-width: 991px), (min-width: 1200px) {
  .element {
    color: red;
  }
}

Retina support

The mixin also supports retina screens via the retina query. It can be used alone, or in combination with other breakpoints.

Using only retina
@include media(retina) {
  .element {
    color: red;
  }
}

Compiled:

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .element {
    color: red;
  }
}
Combining retina with breakpoints
@include media(small mobile tablet retina) {
  .element {
    color: red;
  }
}

Compiled:

@media (max-width: 991px) and (-webkit-min-device-pixel-ratio: 2), (max-width: 991px) and (min-resolution: 192dpi) {
  .element {
    .color: red;
  }
}

Desktop-first and mobile-first support

We make writing mobile-first or desktop-first oriented media queries easier than ever by introducing the up and 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 goes for 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.

Using down syntax
@include media (tablet down) {
  .element {
    color: red;
  }
}

Compiled:

@media (max-width: 991px) {
  .element {
    color: red;
  }
}
Using up syntax
@include media (tablet up) {
  .element {
    color: red;
  }
}

Compiled:

@media (min-width: 768px) {
  .element {
    color: red;
  }
}

Orientation

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:

@include media(small mobile tablet, landscape) {
  .element {
    visibility: hidden;
  }
}

Compiled:

@media (max-width: 991px) and (orientation: landscape) {
  .element {
    visibility: hidden;
  }
}

Testing

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 test_sass.js 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

Changelog

2.0.0

  • Updated default breakpoints (Bootstrap 4 values)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].