styled-breakpoints
Advanced tools
Comparing version 12.1.7 to 12.1.8
const { calcMaxWidth } = require('./calc-max-width'); | ||
exports.createBreakpointsApi = ({ breakpoints }) => { | ||
const keys = Object.keys(Object(breakpoints)); | ||
exports.createBreakpointsApi = ({ breakpoints = {} }) => { | ||
const indexMap = {}; | ||
const keys = Object.keys(breakpoints); | ||
const getNextKey = (key) => keys[keys.indexOf(key) + 1]; | ||
keys.forEach((key, index) => { | ||
indexMap[key] = index; | ||
}); | ||
@@ -11,2 +14,10 @@ const up = (min) => breakpoints[min]; | ||
const getNextKey = (key) => { | ||
const currentIndex = indexMap[key]; | ||
const nextIndex = currentIndex + 1; | ||
const isNotLastIndex = currentIndex < keys.length - 1; | ||
return isNotLastIndex ? keys[nextIndex] : undefined; | ||
}; | ||
const between = (min, max) => ({ | ||
@@ -18,3 +29,3 @@ min: up(min), | ||
const only = (key) => | ||
key === keys.at(-1) ? up(key) : between(key, getNextKey(key)); | ||
key !== keys.at(-1) ? between(key, getNextKey(key)) : up(key); | ||
@@ -21,0 +32,0 @@ return { |
{ | ||
"name": "styled-breakpoints", | ||
"version": "12.1.7", | ||
"version": "12.1.8", | ||
"description": "Simple and powerful css breakpoints for styled-components and emotion", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39440
343