@styled-system/css
Advanced tools
Comparing version 1.0.0-1 to 1.0.0
@@ -34,4 +34,4 @@ "use strict"; | ||
var systemProps = ['theme', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'm', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'color', 'bg', 'backgroundColor', 'fontSize', 'fontWeight', 'lineHeight']; | ||
var systemRE = new RegExp("^(".concat(systemProps.join('|'), ")$")); | ||
var systemProps = [].concat(_toConsumableArray(Object.keys(_objectSpread({}, _styledSystem.space.propTypes, _styledSystem.color.propTypes, _styledSystem.fontFamily.propTypes, _styledSystem.fontSize.propTypes, _styledSystem.fontWeight.propTypes, _styledSystem.lineHeight.propTypes))), ['theme', 'mx', 'my', 'px', 'py', 'color']); | ||
var systemRegExp = new RegExp("^(".concat(systemProps.join('|'), ")$")); | ||
@@ -58,3 +58,3 @@ var styles = function styles(props) { | ||
if (!value || _typeof(value) !== 'object') continue; | ||
if (systemRE.test(key)) continue; | ||
if (systemRegExp.test(key)) continue; | ||
styles.push(_defineProperty({}, key, css(value)({ | ||
@@ -61,0 +61,0 @@ theme: theme |
39
index.js
@@ -16,35 +16,19 @@ import { | ||
const systemProps = [ | ||
...Object.keys({ | ||
...space.propTypes, | ||
...color.propTypes, | ||
...fontFamily.propTypes, | ||
...fontSize.propTypes, | ||
...fontWeight.propTypes, | ||
...lineHeight.propTypes, | ||
}), | ||
'theme', | ||
'margin', | ||
'marginTop', | ||
'marginRight', | ||
'marginBottom', | ||
'marginLeft', | ||
'padding', | ||
'paddingTop', | ||
'paddingRight', | ||
'paddingBottom', | ||
'paddingLeft', | ||
'm', | ||
'mt', | ||
'mr', | ||
'mb', | ||
'ml', | ||
'mx', | ||
'my', | ||
'p', | ||
'pt', | ||
'pr', | ||
'pb', | ||
'pl', | ||
'px', | ||
'py', | ||
'color', | ||
'bg', | ||
'backgroundColor', | ||
'fontSize', | ||
'fontWeight', | ||
'lineHeight', | ||
] | ||
const systemRE = new RegExp( | ||
const systemRegExp = new RegExp( | ||
`^(${systemProps.join('|')})$` | ||
@@ -65,2 +49,3 @@ ) | ||
export const css = style => (props = {}) => { | ||
@@ -75,3 +60,3 @@ const theme = props.theme || props | ||
if (!value || typeof value !== 'object') continue | ||
if (systemRE.test(key)) continue | ||
if (systemRegExp.test(key)) continue | ||
styles.push({ | ||
@@ -78,0 +63,0 @@ [key]: css(value)({ theme }) |
{ | ||
"name": "@styled-system/css", | ||
"version": "1.0.0-1", | ||
"version": "1.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist.js", |
# @styled-system/css | ||
Overload style objects with theme-aware Styled System props | ||
```sh | ||
@@ -23,1 +25,53 @@ npm i @styled-system/css | ||
``` | ||
```jsx | ||
// usage with the css prop | ||
import React from 'react' | ||
import css from '@styled-system/css' | ||
const Boop = props => | ||
<div | ||
{...props} | ||
css={css({ | ||
fontSize: [4, 5, 6], | ||
color: 'primary', | ||
})} | ||
/> | ||
``` | ||
## Props | ||
When using `@styled-system/css` with styled components, | ||
Styled System props can be used on the resulting component. | ||
```jsx | ||
<Beep | ||
color='primary' | ||
bg='black' | ||
/> | ||
``` | ||
The following style props will be available on the component: | ||
- `fontFamily` | ||
- `fontSize` | ||
- `fontWeight` | ||
- `lineHeight` | ||
- `color` | ||
- `bg` | ||
- `m` | ||
- `mt` | ||
- `mr` | ||
- `mb` | ||
- `ml` | ||
- `mx` | ||
- `my` | ||
- `p` | ||
- `pt` | ||
- `pr` | ||
- `pb` | ||
- `pl` | ||
- `px` | ||
- `py` | ||
MIT License |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6690
1
77
111