{"name":"understyle","version":"2.0.1","description":"Functional style utilities for authoring JavaScript style objects","main":"dist/index.js","scripts":{"prepublish":"mkdir -p dist && babel src --out-dir dist","test":"ava -v"},"keywords":["style","css","css-in-js","utility"],"author":{"name":"Brent Jackson"},"license":"MIT","devDependencies":{"ava":"^0.15.2","babel-cli":"^6.11.4","babel-preset-es2015":"^6.9.0","babel-preset-stage-0":"^6.5.0","babel-register":"^6.11.5","standard":"^7.1.2"},"dependencies":{"deepmerge":"^1.3.1","object-assign":"^4.1.0","palx":"^1.0.2"},"ava":{"require":["babel-register"],"babel":"inherit"},"gitHead":"b1a87769eca50d50ad4e15ee48d44476adfb79f3","_id":"understyle@2.0.1","_shasum":"b3e86c050f2797d91f6515b9a482e084542717fd","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"jxnblk","email":"jxnblk@gmail.com"},"dist":{"shasum":"b3e86c050f2797d91f6515b9a482e084542717fd","tarball":"http://registry-npm.ywwl.com/understyle/download/understyle-2.0.1.tgz","integrity":"sha512-XKlCyt/VJgt4U3M2jUwHpW0NenRE537eOk1wGZfV98DKLC+O6kQvnzaqWr2aVxMAqYuxmXkqyMt66SDPpQM77Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG0z/To5k2hfYLDuhmyWY2eilxReALGlPOYgBIDwoNYbAiA56ApWHz4+rcjBK2U7pwKy7/fvioV4U9yQ9yCbJLYfxA=="}],"size":17257,"noattachment":false,"key":"/understyle/-/understyle-2.0.1.tgz"},"maintainers":[{"name":"jxnblk","email":"jxnblk@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/understyle-2.0.1.tgz_1482366287540_0.2870223477948457"},"directories":{},"readme":"\n# _understyle\n\nFunctional style utilities for authoring JavaScript style objects\n\n[![Build Status](https://travis-ci.org/jxnblk/understyle.svg?branch=master)](https://travis-ci.org/jxnblk/understyle)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n\n\n```sh\nnpm i understyle\n```\n\n```js\n// Example\nimport _style from 'understyle'\n\nconst style = _style({\n  m: 2,\n  flex: true\n})\n// { margin: 16, display: 'flex' }\n```\n\n### Usage in React, etc.\n\nUnderstyle is intended for use in functional component-based UI systems, like React.\nIt can be used in any framework and for either inline styles or\nwith any CSS-in-JS library.\n\n```js\n// Example component\nimport React from 'react'\nimport _style from 'understyle'\n\nconst MyComponent = ({ children, ...props }) => {\n  const style = {\n    ..._style(props),\n    color: 'tomato'\n  }\n\n  return <div style={style}>{children}</div>\n}\n\nexport default MyComponent\n```\n\n```js\n// Example component instance\nreturn (\n  <div>\n    <MyComponent p={2} mb={4}>\n      Hello\n    </MyComponent>\n  </div>\n)\n```\n\n## Props\n\nThe following keys can be passed in to understyle.\n\n### Display\n\n```js\n_style({ display: 'block' })\n```\n\n### Width\n\nThe `width` prop accepts number values.\nAny number larger than 1 is returned as a number, to be handled with React inline styles or other CSS-in-JS solutions.\nAny number between 0 and 1 will become a percentage width.\n\n```js\n_style({ width: 1 / 2 }) // { width: '50%' }\n_style({ width: 1 })     // { width: '100%' }\n_style({ width: 64 })    // { width: 64 }\n```\n\n### Margin\n\nMargin props are set based on a spacing scale for numbers 1–4.\nAny number above 4 will return the raw number value.\n\n```js\n_style({\n  margin: 0,        // margin: 0\n  marginBottom: 3,  // marginBottom: 32\n  marginX: 12       // marginLeft: 12, marginRight: 12\n})\n```\n\nShorthand props are also available.\n\n```js\n_style({\n  m: 0,   // margin: 0\n  mb: 3, // marginBottom: 32\n  mx: 12 // marginLeft: 12, marginRight: 12,\n})\n```\n\n### Padding\n\nPadding also supports longform and shorthand keys.\n\n```js\n_style({\n  p: 0,   // padding: 0\n  paddingLeft: 2, // paddingLeft: 16\n  py: 48  // paddingTop: 48, paddingBottom: 48\n})\n```\n\n### Typography\n\n```js\n_style({\n  fontSize: 16,     // fontSize: 16\n  align: 'center',  // textAlign: 'center'\n  bold: true,       // fontWeight: 'bold'\n  caps: true,       // textTransform: 'uppercase', letterSpacing: '.1em'\n})\n```\n\nFont size also accepts numbers representing steps on the configured type scale, for any number below 7\n\n```js\n_style({ fontSize: 1 })\n// fontSize: 48\n```\n\n### Flexbox\n\n```js\n_style({\n  flexWrap: 'wrap',     // flexWrap: 'wrap'\n  alignItems: 'center', // alignItems: 'center'\n  justifyContent: 'space-between', // justifyContent: 'space-between'\n  flexDirection: 'column', // flexDirection: 'column'\n  flexAuto: true,       // flex: '1 1 auto'\n  flexNone: true,       // flex: 'none'\n})\n```\n\n### Color\n\nColor props accept strings as either keys from the configured\ncolor object or raw color values.\n\n```js\n_style({\n  color: 'blue', // color: '#07c'\n  backgroundColor: 'tomato', // color: 'tomato'\n  borderColor: '#eee', // color: '#eee'\n})\n```\n\n### Border\n\n```js\n_style({ border: true })\n// border: '1px solid'\n\n_style({ border: false })\n// border: 0\n\n_style({ border: 3 })\n// border: '3px solid'\n\n_style({ borderTop: true })\n// borderTop: '1px solid'\n\n_style({ borderRight: true })\n// borderRight: '1px solid'\n\n_style({ borderBottom: true })\n// borderBottom: '1px solid'\n\n_style({ borderLeft: true })\n// borderLeft: '1px solid'\n```\n\n### Border Radius\n\n```js\n_style({ rounded: true })\n// borderRadius: 2\n\n_style({ rounded: false })\n// borderRadius: 0\n\n_style({ rounded: 'top' })\n// borderRadius: '2px 2px 0 0'\n\n_style({ rounded: 'right' })\n// borderRadius: '0 2px 2px 0'\n\n_style({ rounded: 'bottom' })\n// borderRadius: '0 0 2px 2px'\n\n_style({ rounded: 'left' })\n// borderRadius: '2px 0 0 2px'\n```\n\n### Responsive Styles\n\nAll props accept arrays to set styles for multiple breakpoints,\nwhere the first value is no breakpoint,\nthen the following values are from the small breakpoint up,\nfor a mobile-first styling approach.\n\n```js\n_style({\n  width: [\n    1,\n    1 / 2,\n    1 / 3,\n    1 / 4,\n  ]\n})\n// {\n//   width: '100%',\n//   '@media screen and (min-width:40em)': {\n//     width: '50%'\n//   },\n//   '@media screen and (min-width:52em)': {\n//     width: '33.333333%'\n//   },\n//   '@media screen and (min-width:64em)': {\n//     width: '25%'\n//   }\n// }\n```\n\nThis helps create a succinct syntax for use in React components.\n\n```js\n// Example\n<Box width={[ 1, 1/2, 1/3, 1/4 ]} />\n```\n\nArrays work for any understyle property,\nand null values can be passed to the array to skip breakpoints.\n\n```js\n_style({\n  margin: [ 0, null, 16, 32 ],\n  padding: [ null, null, 16, 32 ],\n  border: [ null, null, true ]\n})\n```\n\n\n### Shorthand Props\n\nUnderstyle provides shorthand props for setting common styles.\nEach shorthand prop accepts a boolean value.\n\n```js\n_style({\n  mb4: true\n})\n```\n\nThese are provided as a convenience for use in React.\n\n```jsx\n// Example\n<Button mb4 />\n```\n\nThe following boolean keys can be passed to understyle.\n\n- `block` - display block\n- `inlineBlock` - display inline-block\n- `inline`\n- `table`\n- `tableRow`\n- `tableCell`\n- `flex`\n- `inlineFlex`\n- `m0` - `m4`   - margin\n- `mt0` - `mt4` - margin-top\n- `mr0` - `mr4` - margin-right\n- `mb0` - `mb4` - margin-bottom\n- `ml0` - `ml4` - margin-left\n- `p0` - `p4`   - padding\n- `pt0` - `pt4` - padding-top\n- `pr0` - `pr4` - padding-right\n- `pb0` - `pb4` - padding-bottom\n- `pl0` - `pl4` - padding-left\n- `left` - text align left\n- `center` - text align center\n- `right` - text align right\n- `justify` - text align justify\n- `bg` - background color\n- `<COLOR>` - foreground color - e.g. `red`\n- `bg<COLOR>` - background color - e.g. `bgRed`\n- `border<COLOR>` - border color - e.g. `borderRed`\n\n[MIT License](LICENSE.md)\n\n","publish_time":1482366289533,"_cnpm_publish_time":1482366289533,"dist-tags":{"beta":"1.1.0-beta.1","latest":"2.0.4"}}