{"name":"scope-css","version":"1.0.0","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dfcreative/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dfcreative/scope-css/issues"},"homepage":"https://github.com/dfcreative/scope-css#readme","gitHead":"ac751b37895f4bbce94d6dd2492bae4021a5a39b","_id":"scope-css@1.0.0","_shasum":"910456b2599a462a8eb68522f639bd2ec53c84b6","_from":".","_npmVersion":"3.7.2","_nodeVersion":"6.2.0","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"dist":{"shasum":"910456b2599a462a8eb68522f639bd2ec53c84b6","tarball":"http://registry-npm.ywwl.com/scope-css/download/scope-css-1.0.0.tgz","integrity":"sha512-gUjgFmGHDVDQdo+3sYjg/zb641LJLpwbS8mnAHI4LzE5n/WAqKRJIEkyC4P2y4TlaAPILEyRL9rDl+eIMzJA4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCPViSlE/8nSr3TDLr2mAYSYfKMHinQJJ0B/j66aCPtYAIhAO0k20xXhMJYl2WfQgnThpG0CB62XgdNMfbscnVI631D"}],"size":1419,"noattachment":false,"key":"/scope-css/-/scope-css-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/scope-css-1.0.0.tgz_1468916201354_0.5651975213550031"},"directories":{},"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":1468916202983,"_cnpm_publish_time":1468916202983,"dist-tags":{"latest":"2.0.0"}}