cssjoiner

3.0.1 • Public • Published

cssJoiner

Node.js Package

Conditionally join CSS classes.

Examples

Simple joining 2 class names.

cssJoiner("button", "buttonPrimary");
// "button buttonPrimary"

Usually I'm using class names in an obj.

cssJoiner(css.btn, css.primary);
// "button buttonPrimary"

If a class name is actually an array, then the pattern is [test, trueClass, falseClass]

cssJoiner(css.btn, [ btnType === "primary", css.primary ])
// "button buttonPrimary" or "button"

cssJoiner(css.btn, [ btnType === "primary", css.primary, css.secondary ])
// "button buttonPrimary" or "button buttonSecondary"

An example with Mithril

const component = {
    view : (vnode) =>
        m("div", {
            class : cssJoiner(btnCss.btn, [ vnode.state.selected, css.selected ])
        })
};

Readme

Keywords

none

Package Sidebar

Install

npm i cssjoiner

Weekly Downloads

3

Version

3.0.1

License

ISC

Unpacked Size

6.95 kB

Total Files

8

Last publish

Collaborators

  • kevinkace