Skip to content
kevinkacePublic

About

Join CSS class names with test

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

50 Commits

Folders and files

Repository files navigation

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

About

Join CSS class names with test

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages