{"name":"scope-css","version":"1.2.1","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":{"escaper":"^2.5.3","slugify":"^1.3.1","strip-css-comments":"^3.0.0"},"gitHead":"59d0ff1739012475ee6b0fdaf3ba2dac5eb10c81","_id":"scope-css@1.2.1","_npmVersion":"6.4.1","_nodeVersion":"8.11.1","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"integrity":"sha512-UjLRmyEYaDNiOS673xlVkZFlVCtckJR/dKgr434VMm7Lb+AOOqXKdAcY7PpGlJYErjXXJzKN7HWo4uRPiZZG0Q==","shasum":"c35768bc900cad030a3e0d663a818c0f6a57f40e","tarball":"http://registry-npm.ywwl.com/scope-css/download/scope-css-1.2.1.tgz","fileCount":4,"unpackedSize":5169,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbxbhJCRA9TVsSAnZWagAAldYQAILHPQ+5VeOgC9DVBHKX\nQuH+NiuUX7Edw74NAF+eqDs+K4pFOPqJHeqNQ2lpqvnIvOTykjCPYomGkldE\n3u7ecYaHPJh1qHalI7TYrNSYbX4bx4KGGfVvqalWIIXQQ2Tjes3RWwQZqJdc\nG4neVT5NGUncfHVRJZGpDs6J5YzTItUvkMIWhSXzSVHGl3FgDRSQiO76bnIp\nvHf3BZkB+RnGLgx7B2M4pBFRULSH+cwYeXkIhRvofcyheFtGXMcuSFolatWk\nmr+qWqF1j8jDUMRfZiUN+8/8ZNPa32ypm8/lBaqkCQMFTDnKxvF7hh7MbYsc\nDRmkI40YQyeuhRpTvTv92bAtcV7OzgqgOFtqR6bhqWnTUANmdm39bDTx+287\n3JqrpX49aJO4rTPix6By8qqCNS7je9TMwfDBvszJYFNLnQrrMJaRSKAsfukj\nmhIfBbBaYV/wzEfYW82E8S7jfuP+34zIBIuMfD6Kn12THWCfnca+uAZ/m/NW\nBDZGAnRl1jszJsWv+JMgVEN/QdPhuTdZn7pIMjUxAgYqefZ++UsGNtwMbqO2\nUxHRVH7JAzVERPdo0OFxUOGvqkx4C4tMuBhKre8LKZOkOW8fUQiPh50QzCXw\nTE9Ve1CSLwgwi+N2OWTKrqbQZKFmD7bLNFAoKIAMMe7lvua/GIwrjiouWyqn\nGBWl\r\n=U42G\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5gRBhGQK6JSn91dgHhLFBsKSd5IP64QhvTljLz2RiFgIhANOsZV6JoCXE7bwoGPZdWVJkkxHPwS3COkVSsbTcgoUx"}],"size":2258,"noattachment":false,"key":"/scope-css/-/scope-css-1.2.1.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scope-css_1.2.1_1539684424626_0.18791407062693555"},"_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":1539684424717,"_cnpm_publish_time":1539684424717,"dist-tags":{"latest":"2.0.0"}}