{"name":"scope-css","version":"1.2.0","description":"Scope each css rule with a selector, ie. nest into parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dy/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dy/scope-css/issues"},"homepage":"https://github.com/dy/scope-css#readme","devDependencies":{"cln":"^1.1.0","tape":"^4.9.1"},"dependencies":{"slugify":"^1.3.1","strip-css-comments":"^3.0.0"},"gitHead":"9383a8e2dc64eb2cd59035251c949ce4dff9bf80","_id":"scope-css@1.2.0","_npmVersion":"6.4.1","_nodeVersion":"8.11.1","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"integrity":"sha512-ldFalYicqqbsq83zA1nTrtMTzhaveoCD1tsfGQ4fsD3MBq/36bPq8I7bRvflf4NtadpxNvwBPygd73MtgtFdSw==","shasum":"99ca63bbc09024a151809104586ff6214aa0787d","tarball":"http://registry-npm.ywwl.com/scope-css/download/scope-css-1.2.0.tgz","fileCount":4,"unpackedSize":4936,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbv7wuCRA9TVsSAnZWagAAQtYP/RGIjHjYtdxi8FCvVmsK\nYGelBr4mqh72IkooWdHi5phDWg0GmXmQE20njMSSvh6s0bZ1DNwfaaDmMIPx\nTqFCoVHZLJyNtbmKM59UEewQJqgF+itdG89g4Y5Ml0TNEo/5Df7ah1eevOaN\n8toW+DUTLkUT72TViTwrTVjK43IRpPLpmEFRtGhAdnxzpA/DjIr9IpkdMWn7\nZjdG09VUPP5Vp6IXwC4kpGsGwWx5GDGLEBjjEaVke1Xxy1U+ES0DBzQbH4kb\nSAJM4874v8M79wxXlVO4MpqIqRHQXj+TmSIaPsIh+/Zwoy/T1cshn1ix9h0H\n7S8V2lUFrVXGTNivwdiCng3feU6oZLO1z3AqpjqwN8nj0gMnkIxacpZKnx3b\nHinVP+uWzmovfX9Ux+wNo9OQ6zIqdME5SLKt/r8ZHUDJSML5055rF7ekrhch\n8BO8rHU6L+83aXv7AtfeKcoJ1coGFQ2xwY3HPKtyllzvCYJV/xpuN2qDusLg\nb7WEFnqsq0NZLAmqoFCjZ11QEshfXEptcurl2bkfxFnb30Yi2wfRSN33s5pS\nt9wAG9Ti/30VqDw0jsHHyqcDmToz5YR9QZB7I+UEvqmKOE1JZLksI+SJ0xAE\n68Udm4xscqzsexmS2wUPKOT3b0KeHc0j6OFMlufha5mtLCXbqY8/vCUHNYLH\nQE0u\r\n=X1G6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6fAmYwoPAVUPXCJ5Jlfs6EphyVy85P3wxWnsNPN/2ZAIgFJXq+S2JCJGSmWaTTq9J1HOj/tZJlcQRduOCeKO8vsI="}],"size":2183,"noattachment":false,"key":"/scope-css/-/scope-css-1.2.0.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scope-css_1.2.0_1539292205240_0.33929626231554133"},"_hasShrinkwrap":false,"readme":"# scope-css [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges) [![Build Status](https://img.shields.io/travis/dy/scope-css.svg)](https://travis-ci.org/dy/scope-css)\r\n\r\nPrefix or nest each style selector in a css string. Useful to create namespaced css for components, themes, applications, modular css etc. Also it is tiny.\r\n\r\n## Usage\r\n\r\n[![npm install scope-css](https://nodei.co/npm/scope-css.png?mini=true)](https://npmjs.org/package/scope-css/)\r\n\r\n```js\r\nconst scope = require('scope-css');\r\n\r\nscope(`\r\n.my-component {}\r\n.my-component-element {}\r\n`, '.parent');\r\n\r\n/*\r\n`\r\n.parent .my-component {}\r\n.parent .my-component-element {}\r\n`\r\n*/\r\n```\r\n\r\n## API\r\n\r\n## css = scope(css, parent, options?)\r\n\r\nReturn css string with each rule prefixed with the parent selector. Note that `parent` selector itself will be ignored. Also each `:host` keyword will be replaced with `parent` value. Example:\r\n\r\n```js\r\nscope(`\r\n\t.panel {}\r\n\t:host {}\r\n\t:host .my-element {}\r\n\t.panel .my-element {}\r\n\t.my-element {}\r\n`, '.panel');\r\n\r\n/*\r\n`\r\n\t.panel {}\r\n\t.panel {}\r\n\t.panel .my-element {}\r\n\t.panel .my-element {}\r\n\t.panel .my-element {}\r\n`\r\n*/\r\n```\r\n\r\nOptions can scope keyframes via `{ keyframes: bool|prefixStr }` option, eg.\r\n\r\n```js\r\nscope(`\r\n\t.panel {\r\n\t\tanimation: infinite loading 4s;\r\n\t}\r\n\t@keyframes loading {\r\n\t\tfrom { top: 0; }\r\n\t\tto { top: 100px; }\r\n\t}\r\n`, '.panel', { keyframes: true })\r\n\r\n/*\r\n`\r\n.panel {\r\n\tanimation: infinite panel-loading 4s;\r\n}\r\n@keyframes panel-loading {\r\n\tfrom { top: 0; }\r\n\tto { top: 100px; }\r\n`)\r\n*/\r\n```\r\n\r\n## css = scope.replace(css, 'replacement $1$2')\r\n\r\nApply replace to css, where `$1` is matched selectors and `$2` is rules for the selectors. It does not do any self/host detection, so use it for more flexible replacements.\r\n\r\n```js\r\nscope.replace(`\r\n\t.my-component, .my-other-component {\r\n\t\tpadding: 0;\r\n\t}\r\n`, '$1');\r\n\r\n// `.my-component, my-other-component`\r\n```\r\n\r\n## Credits\r\n\r\nBased on [this question](http://stackoverflow.com/questions/12575845/what-is-the-regex-of-a-css-selector).\r\n","publish_time":1539292205357,"_cnpm_publish_time":1539292205357,"dist-tags":{"latest":"2.0.0"}}