css-scaffolder
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -1,1 +0,6 @@ | ||
export declare function extract(htmlString: string): string; | ||
interface ExtractOptions { | ||
ignorePatternForSingleClass?: RegExp; | ||
reset?: boolean; | ||
} | ||
export declare function extract(htmlString: string, options?: ExtractOptions): string; | ||
export {}; |
@@ -10,2 +10,3 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var reset_1 = require("./reset"); | ||
function getAttribute(el, attrName) { | ||
@@ -26,3 +27,4 @@ for (var i = 0; i < el.attrs.length; i += 1) { | ||
} | ||
function extract(htmlString) { | ||
function extract(htmlString, options) { | ||
if (options === void 0) { options = {}; } | ||
var selectors = []; | ||
@@ -58,2 +60,7 @@ var selectorFlag = new Map(); | ||
utils_1.combination(classNames.length, i).forEach(function (index) { | ||
if (index.length === 1 && | ||
options.ignorePatternForSingleClass && | ||
options.ignorePatternForSingleClass.test(classNames[index[0]])) { | ||
return; | ||
} | ||
var selector = index.map(function (cn) { return "." + classNames[cn]; }).join(''); | ||
@@ -68,5 +75,11 @@ addSelector(selector, el); | ||
fragment.childNodes.forEach(function (el) { return retrieveClassNames(el); }); | ||
var css = selectors.map(function (selector) { return selector.selector + " {" + (selector.style || '') + "}"; }).join('\n\n'); | ||
var css = selectors | ||
.map(function (selector) { | ||
var styleAttribute = selector.style || ''; | ||
var defaultStyle = options.reset ? reset_1.reset(selector.tagName) : ''; | ||
return selector.selector + " {" + defaultStyle + styleAttribute + "}"; | ||
}) | ||
.join('\n\n'); | ||
return standalone_1.format(css, { parser: 'css', plugins: [parser_postcss_1.default] }); | ||
} | ||
exports.extract = extract; |
{ | ||
"name": "css-scaffolder", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Scaffold CSS declarations from HTML", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# CSS Scaffolder | ||
Scaffold CSS declarations from HTML | ||
[Demo](https://css-scaffolder.netlify.com/) | ||
## License | ||
MIT |
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
5900
8
143
8