0.0.1 • Published 3 years ago
strr v0.0.1
strr
Building a class name dynamically for an element may look ugly. This module keeps your code clean.
Installation
npm install strr
Usage
var strr = require('strr');
var btnClassName = 'btn';
// Instead of doing this...
btnClassName = btnClassName + ' huge pressed';
// Do this.
btnClassName = strr.append(btnClassName, 'huge', 'pressed'); // btnClassName => 'btn huge pressed'
// Also, you can do this to add a string only when it is needed.
var menuClassName = strr.append('menu', strr.useIf('dark', useDarkTheme()));
// Or this if you frequently find yourself using append and useIf together.
// If the condition is true, the result is 'container masthead dark large'.
// If false, then it's 'container masthead'.
var containerClassName = strr.appendIf(['container', 'masthead'], ['dark', 'large'], useDarkTheme());