MediaBreakpoints
JavaScript analog of Bootstrap SCSS media breakpoints mixins.
; const mb = XS: 0 SM: 576 MD: 768 LG: 992 XL: 1200; mb; // @include media-breakpoint-only(lg) { ... }mb; // @include media-breakpoint-up(lg) { ... }mb; // @include media-breakpoint-down(lg) { ... }mb; // @include media-breakpoint-between(sm, lg) { ... }
Install
npm i -S media-breakpoints
Usage
MediaBreakpoints is a singleton.
// MediaBreakpoints.js; ;
Subscribe on breakpoint changes:
// another-component.js; { console; // { current: 'MD', matched: ['XS', 'SM', 'MD'], flow: ['XS', 'SM', 'MD', 'LG', 'XL'] }} mb; // ... mb;