styled-system
Advanced tools
Comparing version 1.0.0-13 to 1.0.0-14
@@ -21,2 +21,5 @@ 'use strict'; | ||
}; | ||
var em = function em(n) { | ||
return num(n) ? n + 'em' : n; | ||
}; | ||
var neg = function neg(n) { | ||
@@ -35,3 +38,3 @@ return n < 0; | ||
var mq = function mq(n) { | ||
return '@media screen and (min-width: ' + n + 'em)'; | ||
return '@media screen and (min-width: ' + em(n) + ')'; | ||
}; | ||
@@ -66,2 +69,3 @@ | ||
px: px, | ||
em: em, | ||
neg: neg, | ||
@@ -68,0 +72,0 @@ num: num, |
{ | ||
"name": "styled-system", | ||
"version": "1.0.0-13", | ||
"version": "1.0.0-14", | ||
"description": "Design system utilities for styled-components, glamorous, and other css-in-js libraries", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -220,2 +220,3 @@ # styled-system | ||
The default set of breakpoints aims to cover a wide range of devices from mobile to desktop. | ||
Breakpoints default to `em` but can be overridden by passing strings with unit appended. | ||
Breakpoints can be customized using styled-components' [ThemeProvider](#configuration). | ||
@@ -228,2 +229,7 @@ | ||
// @media screen and (min-width: 64em) | ||
[ '300px', '600px', '1200px' ] | ||
// @media screen and (min-width: 300px) | ||
// @media screen and (min-width: 600px) | ||
// @media screen and (min-width: 1200px) | ||
``` | ||
@@ -257,2 +263,5 @@ | ||
As opposed to the built-in configurations, arrays given to the `breakpoints`, `space`, and | ||
`fontSizes` theme properties can be of arbitrary lengths. | ||
```jsx | ||
@@ -259,0 +268,0 @@ import { ThemeProvider } from 'styled-components' |
@@ -6,2 +6,3 @@ const { breakpoints } = require('./constants') | ||
const px = n => num(n) ? n + 'px' : n | ||
const em = n => num(n) ? n + 'em' : n | ||
const neg = n => n < 0 | ||
@@ -11,3 +12,3 @@ const arr = n => Array.isArray(n) ? n : [ n ] | ||
const mq = n => `@media screen and (min-width: ${n}em)` | ||
const mq = n => `@media screen and (min-width: ${em(n)})` | ||
@@ -37,2 +38,3 @@ const breaks = props => [ | ||
px, | ||
em, | ||
neg, | ||
@@ -39,0 +41,0 @@ num, |
16
test.js
@@ -55,2 +55,9 @@ import test from 'ava' | ||
test('util.em adds em unit to numbers', t => { | ||
const a = util.em(1) | ||
const b = util.em('2px') | ||
t.is(a, '1em') | ||
t.is(b, '2px') | ||
}) | ||
test('util.neg checks for negative number', t => { | ||
@@ -109,2 +116,11 @@ const a = util.neg(0) | ||
test('util.breaks accepts non-em breakpoints', t => { | ||
const a = util.breaks({ | ||
theme: { | ||
breakpoints: ["600px"], | ||
}, | ||
}) | ||
t.deepEqual(a, [null, '@media screen and (min-width: 600px)']) | ||
}) | ||
test('util.media returns media query wrapped rules', t => { | ||
@@ -111,0 +127,0 @@ const a = util.media([])('hello') |
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
40554
1190
305
28