3.0.1 • Published 1 year ago

cssjoiner v3.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
1 year ago

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 ])
        })
};
3.0.1

1 year ago

3.0.0

1 year ago

2.1.0

3 years ago

2.0.2

5 years ago

2.0.1

5 years ago