react-style-js

1.0.2 • Public • Published

react-style-js

A simple Style/Script Wrapper that render expected tag for you base on the url/href/src you passed.

Install

npm install react-style-js

Example

var Stylejs = require('react-style-js');
// eleminate the gap between src/href/url props
React.renderToStaticMarkup(<Stylejs src="a/b/c.css" />);
React.renderToStaticMarkup(<Stylejs href="a/b/c.css" />);
React.renderToStaticMarkup(<Stylejs url="a/b/c.css" />);
// => <link href="/a/b/c.css" type="text/css" rel="stylesheet">

React.renderToStaticMarkup(<Stylejs src="a/b/c.js" />);
// => <script src="a/b/c.js"></script>

Why?

For some reason, I compiled scss/css/less/stylus into js file to let them support HMR, thus i needed the style tag to be automatically transformed into script tag. Moreover, the properties (rel, href, type) on <link> tag are always annoying so I decided to ignore them when create link tag;

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    17
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    17
  • 1.0.1
    2
  • 1.0.0
    2

Package Sidebar

Install

npm i react-style-js

Weekly Downloads

20

Version

1.0.2

License

MIT

Last publish

Collaborators

  • ssnau