@divyanshu013/media

Simplify media queries for CSS in JS

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@divyanshu013/media
Minified + gzip package size for @divyanshu013/media in KB

Readme

@divyanshu013/media 💃

@divyanshu013/media

Simplify media queries for CSS in JS

NpmVersion bundle size Maintainability codecov Build Status jest Downloads

Install

yarn add @divyanshu013/media

Usage

breakpoints

import { breakpoints } from '@divyanshu013/media';

// default breakpoints
console.log(breakpoints);
/*
{
  xsmall: 420,
  small: 576,
  medium: 768,
  large: 992,
  xlarge: 1200,
}
*/

min-width query

import { mediaMin } from '@divyanshu013/media';
import { css } from 'react-emotion';

const styles = css({
  [mediaMin.medium]: {
    fontSize: '1.2rem',
  },
});

max-width query

import { mediaMax } from '@divyanshu013/media';
import { css } from 'react-emotion';

const styles = css({
  [mediaMax.medium]: {
    fontSize: '0.9rem',
  },
});

create

import { create } from '@divyanshu013/media';

const breakpoints = {
  md: 768,
  xxl: 1600,
};

const mediaQMax = create(breakpoints, 'max');
const mediaQMin = create(breakpoints, 'min');

compose

Just like Object.assign. (Actually its just Object.assign 😛).

const media1 = {...};
const media2 = {...};

const mediaQ = compose(media1, media2);

// now use mediaQ

Inspiration

This library is inspired by emotion and facepaint.

Logo from EmojiOne.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.