css-styled
Advanced tools
Comparing version 0.2.6 to 1.0.0
import { StyledInjector } from "./types"; | ||
export default function styled(css: string): StyledInjector; | ||
declare function styled(css: string): StyledInjector; | ||
export * from "./types"; | ||
export default styled; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.6 | ||
version: 1.0.0 | ||
*/ | ||
@@ -82,2 +82,7 @@ 'use strict'; | ||
/** | ||
* Create an styled object that can be defined and inserted into the css. | ||
* @param - css styles | ||
*/ | ||
function styled(css) { | ||
@@ -84,0 +89,0 @@ var injectClassName = "rCS" + getHash(css); |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.6 | ||
version: 1.0.0 | ||
*/ | ||
@@ -80,2 +80,7 @@ import { splitComma } from '@daybrush/utils'; | ||
/** | ||
* Create an styled object that can be defined and inserted into the css. | ||
* @param - css styles | ||
*/ | ||
function styled(css) { | ||
@@ -82,0 +87,0 @@ var injectClassName = "rCS" + getHash(css); |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.6 | ||
version: 1.0.0 | ||
*/ | ||
@@ -181,2 +181,7 @@ (function (global, factory) { | ||
/** | ||
* Create an styled object that can be defined and inserted into the css. | ||
* @param - css styles | ||
*/ | ||
function styled(css) { | ||
@@ -183,0 +188,0 @@ var injectClassName = "rCS" + getHash(css); |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.6 | ||
version: 1.0.0 | ||
*/ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).styled=n()}(this,function(){"use strict";var e=function(e){for(var n=5381,t=e.length;t;)n=33*n^e.charCodeAt(--t);return n>>>0},l=['"',"'",'\\"',"\\'"];function c(e,n,t,r){for(var o=t;o<r;++o){var i=n[o].trim();if(i===e)return o;var u=o;if("("===i?u=c(")",n,o+1,r):-1<l.indexOf(i)&&(u=c(i,n,o+1,r)),-1===u)break;o=u}return-1}function f(e){return function(e,n){for(var t=new RegExp("(\\s*"+(n||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=e.split(t).filter(Boolean),o=r.length,i=[],u=[],f=0;f<o;++f){var a=r[f].trim(),d=f;if("("===a)d=c(")",r,f+1,o);else{if(")"===a)throw new Error("invalid format");if(-1<l.indexOf(a))d=c(a,r,f+1,o);else if(a===n){u.length&&(i.push(u.join("")),u=[]);continue}}-1===d&&(d=o-1),u.push(r.slice(f,d+1).join("")),f=d}return u.length&&i.push(u.join("")),i}(e,",")}function d(e,n,t,r){var o,i,u=document.createElement("style");return u.setAttribute("type","text/css"),u.setAttribute("data-styled-id",e),t.nonce&&u.setAttribute("nonce",t.nonce),u.innerHTML=(o=e,i=n,t.original?i:i.replace(/([^};{\s}][^};{]*|^\s*){/gm,function(e,n){var t=n.trim();return(t?f(t):[""]).map(function(e){var n=e.trim();return 0===n.indexOf("@")?n:-1<n.indexOf(":global")?n.replace(/\:global/g,""):-1<n.indexOf(":host")?""+n.replace(/\:host/g,"."+o):n?"."+o+" "+n:"."+o}).join(", ")+" {"})),(r||document.head||document.body).appendChild(u),u}return function(i){var u,f="rCS"+e(i).toString(36),a=0;return{className:f,inject:function(e,n){void 0===n&&(n={});var t,r=function(e){if(e&&e.getRootNode){var n=e.getRootNode();if(11===n.nodeType)return n}}(e),o=0===a;return(r||o)&&(t=d(f,i,n,r)),o&&(u=t),r||++a,{destroy:function(){r?(e.removeChild(t),t=null):(0<a&&--a,0===a&&u&&(u.parentNode.removeChild(u),u=null))}}}}}}); | ||
//# sourceMappingURL=styled.min.js.map |
{ | ||
"name": "css-styled", | ||
"version": "0.2.6", | ||
"version": "1.0.0", | ||
"description": "This component is a lightweight, simple line style component.", | ||
@@ -15,6 +15,6 @@ "main": "./dist/styled.cjs.js", | ||
"test": "jest --watchAll", | ||
"coverage": "jest --coverage && print-coveralls --sort=desc", | ||
"prerelease": "npm run build && prerelease --dirs=dist", | ||
"release": "npm run build && release --dirs=dist", | ||
"release:init": "npm run build && release -i --dirs=dist", | ||
"coverage": "jest --coverage && print-coveralls --sort=desc,doc", | ||
"prerelease": "npm run build && npm run doc && prerelease --dirs=dist,doc", | ||
"release": "npm run build && npm run doc && release --dirs=dist", | ||
"release:init": "npm run build && npm run doc && release -i --dirs=dist", | ||
"packages": "pvu --path=packages --update=react-css-styled --build=react-css-styled --publish=react-css-styled" | ||
@@ -21,0 +21,0 @@ }, |
<p align="middle" >Logo</p> | ||
<h2 align="middle">css-styled</h2> | ||
@@ -9,3 +8,3 @@ <p align="middle"> | ||
</p> | ||
<p align="middle">description</p> | ||
<p align="middle">This component is a lightweight, simple line style component.</p> | ||
@@ -28,4 +27,20 @@ ## 📄 API Documents | ||
## 🚀 How to use | ||
code | ||
```ts | ||
import styled from "css-styled"; | ||
const cssStyled = styled(` | ||
{ | ||
display: block; | ||
} | ||
.a { | ||
display: none; | ||
} | ||
`); | ||
const result = cssStyled.inject(document.body); | ||
result.destroy(); | ||
``` | ||
## ⭐️ Show Your Support | ||
@@ -32,0 +47,0 @@ Please give a ⭐️ if this project helped you! |
import { getHash, injectStyle, getShadowRoot } from "./utils"; | ||
import { StyledInjector, InjectOptions } from "./types"; | ||
export default function styled(css: string): StyledInjector { | ||
/** | ||
* Create an styled object that can be defined and inserted into the css. | ||
* @param - css styles | ||
*/ | ||
function styled(css: string): StyledInjector { | ||
const injectClassName = "rCS" + getHash(css); | ||
@@ -46,1 +50,2 @@ let injectCount = 0; | ||
export * from "./types"; | ||
export default styled; |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @typedef | ||
* @property - Unique class name of the corresponding css | ||
* @property - Insert css into the document owned by the target element. | ||
*/ | ||
export interface StyledInjector { | ||
@@ -5,2 +10,7 @@ className: string; | ||
} | ||
/** | ||
* @typedef | ||
* @property - Whether to put the unique class name of css or show it as original | ||
* @property - csp nonce id | ||
*/ | ||
export interface InjectOptions { | ||
@@ -10,4 +20,9 @@ original: boolean; | ||
} | ||
/** | ||
* @typedef | ||
* @property - Remove css. | ||
*/ | ||
export interface InjectResult { | ||
destroy(): void; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
56163
746
0
82