o0101 / c3s

:crayon: CSSS - Cascading Scoped Style Sheets, aka C3S.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

maskingtape.css (1.1.0) npm

Block off where you want your styles to apply. Control the drips, er... I mean, the cascade.

This just applies a random class to all rules in a stylesheet (supports compound selectors), you can then apply that class to an element to prevent those styles leaking out to apply to other elements.

Usage

$ npm install --save maskingtape.css
<link rel=stylesheet href=/styles/components/widget.css>
...
<widget class="full-width">...</widtget>
...
<script>
  import {scope} from './maskingtape.css/c3s.js';
  
  const {prefix} = scope('/styles/component/widget.css');
  widgetEl.classList.add(prefix);
  // styles in widget are now scoped
</script>

If you want an alternate way of using this (that manages the class adding under the hood as well as other things (like dynamic DOM changes) check out Dynamic Style Sheets

Notes

  • Currently supports CORS sheets, via "crossorigin" HTML5 attribute.

About

:crayon: CSSS - Cascading Scoped Style Sheets, aka C3S.

License:GNU General Public License v3.0


Languages

Language:JavaScript 89.0%Language:HTML 7.7%Language:CSS 2.8%Language:Shell 0.4%