Socket
Socket
Sign inDemoInstall

fela-plugin-responsive-value

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-plugin-responsive-value

Fela plugin to resolve responsive array values


Version published
Weekly downloads
3.7K
decreased by-4.79%
Maintainers
1
Weekly downloads
 
Created
Source

fela-plugin-responsive-value

npm version npm downloads Bundlephobia

This plugin adds support for responsive values as pioneered by styled-system where one passes an array of values that later resolved to respective media queries.

Warning: This package might clash with fela-plugin-fallback-value and thus requires a list of whitelisted properties. We recommend using it before the fallback value.

Installation

yarn add fela-plugin-responsive-value

You may alternatively use npm i --save fela-plugin-responsive-value.

Usage

Make sure to read the documentation on how to use plugins.

import { createRenderer } from 'fela'
import responsiveValue from 'fela-plugin-responsive-value'

const renderer = createRenderer({
  plugins: [ responsiveValue() ]
})

Configuration

Parameters
 ParameterValueDefaultDescription
getMediaQueries(Function) Resolve the list of media queries used based on the values and props
properties(Object) A map of property-boolean pairs of which properties are resolved
Example
import { createRenderer } from 'fela'
import responsiveValue from 'fela-plugin-responsive-value'

// if we have 2 values, use default and large media query
// if we get 3, also use a tablet media query in between
const getMediaQueries = (values, props) => {
  if (values.length === 2) {
    return ["@media (min-width: 1024px)"]
  }

  return  ["@media (min-width: 800px)", "@media (min-width: 1024px)"]
}

const renderer = createRenderer({
  plugins: [ 
    responsiveValue(getMediaQueries, {
      padding: true,
      margin: true
    })
  ]
})

Example

Using the above example code:

Input
{
  margin: [0, 10]
  padding: [5, 10, 15]
}
Output
{
  margin: 0,
  padding: 5,
  "@media (min-width: 800px)": {
    padding: 10
  },
  "@media (min-width: 1024px)": {
    margin: 10,
    padding: 15
  }
}

License

Fela is licensed under the MIT License.
Documentation is licensed under Creative Commons License.
Created with ♥ by @robinweser and all the great contributors.

Keywords

FAQs

Package last updated on 14 Dec 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc