Code Monkey home page Code Monkey logo

rebem-jsx's Introduction

babel-plugin-transform-rebem-jsx

maintenance npm travis deps

Babel plugin allowing you to use BEM props for composing classNames in JSX like in reBEM.

Install

$ npm i -S babel-plugin-transform-rebem-jsx

.babelrc

{
  "plugins": ["transform-rebem-jsx"]
}

Usage

<div block="beep"></div>
<div block="beep" elem="boop"></div>
<div block="beep" mods={{ foo: 'bar' }}></div>
<div block="beep" mix={{ block: 'boop' }}></div>
<div class="beep"></div>
<div class="beep__boop"></div>
<div class="beep beep_foo_bar"></div>
<div class="beep boop"></div>

Notes

Environment variables

process.env.NODE_ENV must be available. For example in webpack you can do this with DefinePlugin:

plugins: [
    new webpack.DefinePlugin({
        'process.env': {
            NODE_ENV: JSON.stringify(process.env.NODE_ENV)
        }
    })
]

Custom delimeters

Default delimeters are _ for modifiers and __ for elements, but you can change it with special environment variables:

plugins: [
    new webpack.DefinePlugin({
        'process.env': {
            REBEM_MOD_DELIM: JSON.stringify('--'),
            REBEM_ELEM_DELIM: JSON.stringify('~~')
        }
    })
]

TODO

  • docs
  • move tasks to start-runner
  • actual tests
  • more tests

rebem-jsx's People

Contributors

mistadikay avatar

Stargazers

aym avatar Felipe Orlando avatar Dmitrii Kanatnikov avatar João Campos avatar Vladimir Trebushchuk avatar Jerome Quere avatar Derek Harmel avatar Nicolas Andersen avatar Jed avatar Łukasz Kolek avatar Sunny Gonnabathula avatar  avatar Sergey Petushkov avatar Ben Parnell avatar Rowell Heria avatar Mitch Chen avatar Justin avatar Duncan_Du avatar U-Yeong Ju avatar Dmitry Chusovitin avatar Vadim Zhulanov avatar Eirik L. Vullum avatar merotan avatar Andrey Kolmakov avatar tsuyoshi wada avatar bokuweb avatar Kir Belevich avatar

Watchers

Aleksei Gurianov avatar Kir Belevich avatar  avatar James Cloos avatar Vladimir Trebushchuk avatar

Forkers

nicolasandersen

rebem-jsx's Issues

Warnings

2016-07-05 18 34 38

I have this warnings, any chance to remove them?

Add inheriting the parent block

I want use it like this:

<div block="button">
  <span elem="text">{props.children || props.text}</span>
</div>

Current api is not cool, because className="button__text" is more short and simple than block="button" elem="text"

Is it possible?

Old version on npm registry

Hi

What are the plans, when will you push the current version on github (0.3.0) to npm registry (0.2.1)?
I tried to install directly from github, but you did not push the build folder there.
I need the newer version, with newer rebem-classname, because I need to set the delimiters.

Thanks

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.