Giter Site home page Giter Site logo

styled-jsx-plugin-stylus's Introduction

styled-jsx-plugin-stylus

Build Status npm

Use Stylus with styled-jsx 💥

Usage

Install the package first.

npm install --save-dev styled-jsx-plugin-stylus

Install the stylus version you need (it is a peer dependency).

npm install --save-dev stylus

Next, add styled-jsx-plugin-stylus to the styled-jsx's plugins in your babel configuration:

{
  "plugins": [
    [
      "styled-jsx/babel",
      { "plugins": ["styled-jsx-plugin-stylus"] }
    ]
  ]
}

stylus options

To pass options to stylus before preprocessing begins, use an optional object in the babel config:

{
  plugins: [
    [
      "styled-jsx/babel",
      {
      	 plugins: [
      	 	[ 
      	 		"styled-jsx-plugin-stylus"
      	 		{ 
      	 			use(style) {
      	 				return style
      	 					.include('/path/to/module')
      	 					.define(...)
      	 					.set(...);
      	 			}
      	 		}
      	 	]
      	}
    ]
  ]
}

More information is available in the stylus docs: http://stylus-lang.com/docs/js.html#usefn

Notes

styled-jsx-plugin-stylus uses styled-jsx's plugin system which is supported from version 2.

Read more on their repository for further info.

This plugin is a bare minimum implementation. More to come.

License

MIT

styled-jsx-plugin-stylus's People

Contributors

omardelarosa avatar a-ignatov-parc avatar

Stargazers

Richard CMK avatar Nihey Takizawa avatar Timothy Kempf avatar Yuya Kanai avatar Иван Вольнов avatar Vince avatar freemember007 avatar Robert Reinhard avatar Ivan Mikhailov avatar Alexey Elizarov avatar Ionut-Cristian Florescu avatar Jadson Lourenço avatar Juan David Castro avatar Fellipe Chagas avatar

Watchers

James Cloos avatar  avatar

Forkers

a-ignatov-parc

styled-jsx-plugin-stylus's Issues

Error passing stylus options

I am trying to use your stylus options example to import a stylus file containing variable defitions before rendering. Here is my .babelrc

{
  "presets": [
    [
      "next/babel",
      {
        "styled-jsx/babel": {
          "plugins": [
            "styled-jsx-plugin-stylus",
            {
              use(style) {
                return style.import('assets/definitions.styl');
              }
            }
          ]
        }
      }
    ]
  ]
}

I am getting the following error:

Error while parsing JSON - Expected ']' instead of '{' at line 9 column 11 of the JSON5 data.

I think that Next babel dosn't like that function in the json. Have you gotten this functionality to work yourself? I'm using this with Next.js.

Using js variable inside styled-jsx component

When I put js variable inside <style jsx> component I get an error: StyleSheet: "insertRule" accepts only strings.

So, this works:

<style jsx>{`
    p
        color: blue
`}</style>

but this doesn't:

const s = `
    p
        color: blue
`
<style jsx>{s}</style>

Is there a way to make this work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.