{"name":"babel-plugin-styless","version":"1.0.1","description":"Style your components declaratively with familiar less syntax","main":"dist/index.js","source":"src/index.js","repository":{"type":"git","url":"https://github.com/jean343/styless.git"},"author":{"name":"Jean-Philippe Bergeron","email":"bergeron.jeanphilippe@gmail.com"},"license":"MIT","scripts":{"test":"yarn run clean && yarn run build && jest","watch":"jest --watch","clean":"jest --clearCache","build":"babel -d dist/ src/","prepare":"yarn run build","semantic-release":"semantic-release","travis-deploy-once":"travis-deploy-once"},"jest":{"testURL":"http://localhost/"},"dependencies":{"less":"^3.8.1","less-vars-to-js":"^1.3.0","tinycolor2":"^1.4.1"},"devDependencies":{"babel-cli":"^6.26.0","babel-jest":"^23.4.2","babel-preset-env":"^1.7.0","babel-preset-react":"^6.24.1","jest":"^23.4.2","jest-styled-components":"^5.0.1","react":"^16.4.2","react-dom":"^16.4.2","react-test-renderer":"^16.4.2","semantic-release":"^15.9.9","styled-components":"^3.4.1","travis-deploy-once":"^5.0.2"},"licenseText":"MIT License\n\nCopyright (c) 2018 Jean-Philippe Bergeron\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"babel-plugin-styless@1.0.1","dist":{"shasum":"aeaf501a102fc888b70e54bc91efad44adfc6539","tarball":"http://registry-npm.ywwl.com/babel-plugin-styless/download/babel-plugin-styless-1.0.1.tgz","integrity":"sha512-Ow8GWwxSAQWjFTXPBSecBCldGFCenUfUNq6KXpNWybK9T2XihaTTy48jFF7FYSqRs0aMjiYFsNFHkBVFXhoTTw==","fileCount":61,"unpackedSize":48610,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbeMMQCRA9TVsSAnZWagAAFl8P/22GWDrA+j+o6OVaP0v9\nDNGzdZZIIsKRdOgHI9xzwlPlB4y03CNOcYc+zl7SWXGtAEMgPTyzQhvBmHYr\nYdou7UcPfmhmerxzSPrxOM1c/aWGXLfyJ6VdD+F6v9Z7J/490PRRCoFuVeh2\nLy03HUfNwbljEESyogwlqiHL318T0UTrokamBXSJu2yKLgn/zwW8TxEEUqqW\n/ENDCaps7OvYQbA1Ami3PpbrxbK6WYI3ndPihHy9GjVpH+gl5qFp0ZZdJfLj\nPIDu80KYxdlJORSox6wPKePNMVx3DdcVS6Cs/qgt5wyHoOcl1e5eaq1YblwQ\n7gopDV0uJSwKlsSGK93RLaynRRbvLg5uPm+NhKqjPv+EP0C40oEz5XTkgjuB\nz7Xeqb2IiGXZj9O/P83AnHwdZQnnlGkgtG1EzlwTjExsdWG/a9Dq+V0zqQox\nW3B1N4kLHLoc2FMW6y5F4GdE/0/UC03IDZFhmxSKjcXp+Q76o7iAJMzhTveo\nxxsdY2czAfYcpbntvvWnU+sv1Kukn1YaemahIRfJYJKJ5Zo8q6FgjM/oylc+\n+4QjhxpFUXUILwWphK9ii17Vy0lQ7zYfGp57y6HlV60CMqbHd7WU3O3udisx\n9u3QQ7r3T0dvjo50xHhwX3Ld0S6BS2+TlGOK4+6ndRFcK/Q2N3MfFkJmis5e\n+py4\r\n=FpEs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGcDuBU0hIW5u1ocfcsst6EBRG76SadB5FY7mhtEutevAiEAu1RNEeckat16tqkT7Yxyq6k2mVS/AiE/96GFpkDsmTw="}],"size":13087,"noattachment":false,"key":"/babel-plugin-styless/-/babel-plugin-styless-1.0.1.tgz"},"maintainers":[{"name":"jean343","email":"bergeron.jeanphilippe@gmail.com"}],"_npmUser":{"name":"jean343","email":"bergeron.jeanphilippe@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-styless_1.0.1_1534640911876_0.011815216188072242"},"_hasShrinkwrap":false,"readme":"[![Build Status](https://travis-ci.org/jean343/styless.svg?branch=master)](https://travis-ci.org/jean343/styless)\n[![npm](https://img.shields.io/npm/v/babel-plugin-styless.svg)](https://www.npmjs.com/package/babel-plugin-styless)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![style: styled-components](https://img.shields.io/badge/style-%F0%9F%92%85%20styled--components-orange.svg?colorB=daa357&colorA=db748e)](https://github.com/styled-components/styled-components)\n\n# :gem:Styless:gem:\n\nStyless enables [less](http://lesscss.org/) syntax in your [styled-components](https://www.styled-components.com)\n\n## Installation\n```sh\n$ yarn add --dev babel-plugin-styless\n```\n\n**.babelrc**\n\n```json\n{\n  \"plugins\": [\"babel-plugin-styless\"]\n}\n```\n\nNote that `styless` should appear before `babel-plugin-styled-components` if used.\n\n## Key features\n- Simplifies the code\n\n    use `@main` instead of `${props => props.theme.main}`\n\n- Uses variables directly in your styled components\n```less\n    @size: if(@small, 4px, 10px);\n```\n\n- Uses operations directly in your styled components\n\n    use `@size * 3` instead of `${props => parseFloat(props.size) * 3 + \"px\"}`\n\n- Uses functions directly in your styled components.\n```less\n    color: darken(@highlight, 5%);\n```\n    There is no need to import `darken`.\n\n- Supports `rgb`, `hsl` and `hsv` color spaces\n```less\n    color: hsv(90, 100%, 50%);\n```\n\n- Migrate less to styled-components seamlessly.\n\n    There is no confusion when transitioning from less to styled-components caused by `width: 3px * 2`.\n\n- Supports variable overwritten\n```less\n    const Button = styled.button`\n        @highlight: blue;                           // can be overwritten by theme or props\n        background: darken(@highlight, 5%);         // make green darken by 5%\n    `;\n```\n\n```jsx   \n    <ThemeProvider theme={{highlight: \"red\"}}>\n        <Button highlight=\"green\">click me</Button> // green (set in props) overwrites red (set in theme)\n    </ThemeProvider>\n```\n\n- Supports imports and mixins\n```less\n    const Button = styled.button`\n        @import (reference) \"variables\";\n        .bg-light-blue;\n    `;\n```\n\n- Supports css props\n```less\n    <button css=\"color: @color;\"/>\n    <button css={`color: @color;`}/>\n    <button css={css`color: @color;`}/>\n```\n\n- Still supports the styled-components syntax for more complex jobs!\n```jsx\n    `${props => props.main}`\n```\n\n## Your first Styless component\n```less\nconst Button = styled.button`\n    @main: palevioletred;\n    @size: 1em;\n    \n    font-size: @size;\n    margin: @size;\n    padding: @size / 4 @size;\n    border-radius: @size / 2;\n    \n    color: @main;\n    border: 2px solid @main;\n    background-color: white;\n`;\n```\n```jsx\n<Button>Normal</Button>\n<Button main=\"mediumseagreen\">Themed</Button>\n<Button main=\"mediumseagreen\" size=\"1.5em\">Themed large</Button>\n```\n\nThis is what you'll see in your browser :tada:, play with it on [codesandbox](https://codesandbox.io/s/p30ywzqkr7)\n\n![](https://i.imgur.com/vb7wo7i.png)\n\n## Advanced Styless component example\n```less\nconst Button = styled.button`\n    @faded: fade(black, 21%);\n    @size: if(@small, 4px, 10px);\n    cursor: pointer;\n    cursor: if(@disabled, not-allowed);\n    color: hsv(0, 0%, 99%);\n    padding: @size @size * 3;\n    border: 1px solid @faded;\n    border-bottom: 4px solid @faded;\n    border-radius: ${4}px;\n    text-shadow: 0 1px 0 @faded;\n    background: linear-gradient(@highlight 0%, darken(@highlight, 5%) 100%);\n    &:active {\n        background: darken(@highlight, 10%);\n    }\n`;\n```\n```jsx\n// Notice that the @highlight variable is resolved from the theme, and overwritten from a props in the second button.\n<ThemeProvider theme={{highlight: \"palevioletred\"}}>\n    <Button>Click me</Button>\n    <Button highlight=\"hsl(153, 100%, 33%)\">Or me</Button>\n    <Button disabled small>But not me</Button>\n</ThemeProvider>\n```\n\nThis is what you'll see in your browser :tada:, play with it on [codesandbox](https://codesandbox.io/s/6zq4jyo5qz)\n\n![](https://i.imgur.com/01eETHm.png)\n\n\n*Note* that with [webstorm-styled-components](https://github.com/styled-components/webstorm-styled-components),\nwe get syntax highlighting, color preview and ctrl+click access to variables!\n![](https://i.imgur.com/t8Qw6ty.png\")\n\n## FAQ\n - How to refer to a `constants.less` file, see the receipe for [theme](docs/receipe-theme.md).\n - Cool, how does it work? Head over to the [explanations](docs/explanation.md).\n - Why less? The `@color` systax reduces the confusion from `$color` when comparing to the SC syntax `${props}`. If there is enough demand, a scss plugin could be created.\n - The styled-components mixins such as `${hover};` must be terminated with a semi colon. The following will not work. \n```less\nconst Button = styled.button`\n  ${hover}\n  color: red;\n`;\n```\n - How to import a less files for all components? As SC components are small in nature, it can be convenient to have a common less file be imported in all components. Add the following to your `.babelrc` to have `common.less` imported automatically.\n ```\n [\n   \"styless\",\n   {\n     \"cwd\": \"babelrc\",\n     \"import\": \"../less/common.less\"\n   }\n ]\n```\n","publish_time":1534640911938,"_cnpm_publish_time":1534640911938,"dist-tags":{"latest":"1.4.25"}}