How to use the css-parse function in css-parse

To help you get started, we’ve selected a few css-parse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github automat / controlkit.js / build / parse-css.js View on Github external
}

/*--------------------------------------------------------------------------------------------------------------------*/
// STYLESHEET PARSE
/*--------------------------------------------------------------------------------------------------------------------*/

import parse from "css-parse";
import Style from "../src/renderer/Style";

const CSS_PROPERTY_MAP    = Style.CSS_PROPERTY_MAP;
const PropertyType        = Style.PropertyType;
const STYLE_PROPERTY_INFO = Style.PROPERTY_INFO;

const dataPathCssOut = '../src/StyleSheet.js';
const dataPathCss = '../style/style.css';
const dataCss = parse(fs.readFileSync(dataPathCss, 'utf8'), {source : dataPathCss});

let rules = {};
for(let rule of dataCss.stylesheet.rules){
    if(rule.type !== 'rule'){
        continue;
    }
    let position = rule.position.start.line + ':' + rule.position.start.column;
    let selectors = rule.selectors[0].split(' ');
    if(selectors.length > 1){
        log(`unsupported nested selectors: "${rule.selectors}"`,position);
        continue;
    }
    let declarations = [];
    for(let declaration of rule.declarations){
        if(declaration.type !== 'declaration'){
            continue;
github GeekyAnts / vue-native-core / src / platforms / vue-native / scripts / compiler.js View on Github external
styles.forEach(function (v) {
    const cssAst = cssParse(v.content);
    cssParsed = Object.assign({}, cssParsed, parseCss(cssAst));
  });
github jmurzy / babel-plugin-transform-styles / src / index.js View on Github external
function toStyleSheet(styleData) {
  const { stylesheet: { rules } } = parser(styleData);
  const result = {};

  for (const { type: ruleType, selectors, declarations } of rules) {
    if (ruleType !== RULE) continue;

    for (const selector of selectors) {
      const s = selector.replace(/\.|#/g, '');
      result[s] = result[s] || {};

      for (const { type: declarationType, value, property } of declarations) {
        if (declarationType !== DECLARATION) continue;

        const propertyName = ['-ios-', '-android-'].reduce((m, v) => m.replace(v, ''), property);
        const camelizedPropName = camelize(propertyName);

        if (value) {

css-parse

CSS parser

MIT
Latest version published 10 years ago

Package Health Score

71 / 100
Full package analysis

Popular css-parse functions