How to use css-to-react-native-transform - 9 common examples

To help you get started, we’ve selected a few css-to-react-native-transform 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 wordpress-mobile / gutenberg-mobile / sass-transformer.js View on Github external
const importerOptions = this.options;
				const incPaths = importerOptions.includePaths.slice( 0 ).split( ':' );
				if ( urlPath.dir.length > 0 ) {
					incPaths.unshift( path.resolve( path.dirname( filename ), urlPath.dir ) ); // add the file's dir to the search array
				}
				const f = findVariant( urlPath.name, exts, incPaths );

				if ( f ) {
					return { file: f };
				}

				return new Error( url + ' could not be resolved in ' + incPaths );
			},
		} );
		const css = result.css.toString();
		const cssObject = css2rn( css, { parseMediaQueries: true } );

		return upstreamTransformer.transform( {
			src: 'module.exports = ' + JSON.stringify( cssObject ),
			filename,
			options,
		} );
	}
	return upstreamTransformer.transform( { src, filename, options } );
}
github WordPress / gutenberg / sass-transformer-inside-gb.js View on Github external
const importerOptions = this.options;
				const incPaths = importerOptions.includePaths.slice( 0 ).split( ':' );
				if ( urlPath.dir.length > 0 ) {
					incPaths.unshift( path.resolve( path.dirname( filename ), urlPath.dir ) ); // add the file's dir to the search array
				}
				const f = findVariant( urlPath.name, exts, incPaths );

				if ( f ) {
					return { file: f };
				}

				return new Error( url + ' could not be resolved in ' + incPaths );
			},
		} );
		const css = result.css.toString();
		const cssObject = css2rn( css, { parseMediaQueries: true } );

		return upstreamTransformer.transform( {
			src: 'module.exports = ' + JSON.stringify( cssObject ),
			filename,
			options,
		} );
	}
	return upstreamTransformer.transform( { src, filename, options } );
}
github kristerkari / react-native-css-transformer / index.js View on Github external
module.exports.transform = function(src, filename, options) {
  if (typeof src === "object") {
    // handle RN >= 0.46
    ({ src, filename, options } = src);
  }

  if (filename.endsWith(".css")) {
    var cssObject = css2rn(src, { parseMediaQueries: true });

    return upstreamTransformer.transform({
      src: "module.exports = " + JSON.stringify(cssObject),
      filename,
      options
    });
  }
  return upstreamTransformer.transform({ src, filename, options });
};
github Tencent / omi / packages / cax-omip / scripts / taro-cli / src / rn / styleProcess.js View on Github external
function getStyleObject ({css, filePath}) {
  var styleObject = {}
  try {
    styleObject = transformCSS(css)
  } catch (err) {
    Util.printLog(Util.pocessTypeEnum.WARNING, 'css-to-react-native 报错', filePath)
    console.log(chalk.red(err.stack))
  }
  return styleObject
}
github birkir / hekla / scripts / jest-css-modules.js View on Github external
function process(src) {
  try {
    const cssObject = css2rn(src, { parseMediaQueries: false });
    return `module.exports = ${JSON.stringify(cssObject)}`;
  } catch (err) {
    return 'module.exports = {}';
  }
}
github jhen0409 / css-to-rn.macro / src / transform.js View on Github external
module.exports = function(path, state, types) {
  const source = path.get('quasi').evaluate().value

  if (!source) {
    fallback(path, state, types)
    return
  }

  path.replaceWith(serialize(cssToRN(source, { parseMediaQueries: true })))
}
github kristerkari / react-native-postcss-transformer / index.js View on Github external
.then(result => {
        var cssObject = css2rn(result.css, { parseMediaQueries: true });
        return upstreamTransformer.transform({
          src: "module.exports = " + JSON.stringify(cssObject),
          filename,
          options
        });
      });
  });
github kristerkari / react-native-sass-transformer / index.js View on Github external
function renderCSSToReactNative(css) {
  return css2rn(css, { parseMediaQueries: true });
}
github kristerkari / react-native-less-transformer / index.js View on Github external
function renderCSSToReactNative(css) {
  return css2rn(css, { parseMediaQueries: true });
}

css-to-react-native-transform

Convert CSS text to a React Native stylesheet object

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis

Popular css-to-react-native-transform functions