Socket
Socket
Sign inDemoInstall

styled-media-helper

Package Overview
Dependencies
86
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    styled-media-helper

helper for media query


Version published
Weekly downloads
241
decreased by-7.31%
Maintainers
1
Install size
11.2 kB
Created
Weekly downloads
 

Changelog

Source

[2.0.2] - 2020-04-06

Changed

  • Updated devDependencies.

Readme

Source

:nail_care: styled-media-helper

Build Status Coverage Status NPM Version

This module makes easy to write media queries using styled-components.

Inspired by Bootstrap media-breakpoint-... mixins.

Installation

$ npm install styled-media-helper

Usage

const styled = require('styled-components').default;
const mediaHelper = require('styled-media-helper');

const media = mediaHelper({
  sm: 320,
  md: 768,
  lg: 1240
});

module.exports = styled.div`
  width: 100px;
  height: 100px;
  background-color: blue;

  ${media.up('lg')} {
    width: 150px;
  }

  // Output:
  //   @media (min-width: 1240px) {
  //     width: 150px;
  //   }


  ${media.down('sm')} {
    background-color: black;
  }

  // Output:
  //   @media (max-width: 767.98px) {
  //     background-color: black;
  //   }


  ${media.between('sm', 'lg')} {
    width: 200px;
  }

  // Output:
  //   @media (min-width: 320px) and (max-width: 1239.98px) {
  //     width: 200px;
  //   }


  ${media.only('md')} {
    background-color: green;
  }

  // Output:
  //   @media (min-width: 768px) and (max-width: 1239.98px) {
  //     background-color: green;
  //   }


  ${media.only('sm')} {
    background-color: green;
  }

  // Output:
  //   @media (min-width: 320px) and (max-width: 767.98px) {
  //     background-color: green;
  //   }


  ${media.only('lg')} {
    border-radius: 15px;
  }

  // Output:
  //   @media (min-width: 1240px) {
  //     border-radius: 15px;
  //   }
`;

License

The MIT License (MIT)

Keywords

FAQs

Last updated on 06 Apr 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc