cssjoiner
v3.0.1
Published
Conditionally join CSS classes.
Downloads
4
Readme
cssJoiner
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 ])
})
};