mirror of
https://github.com/twisterarmy/twister-react.git
synced 2025-01-13 16:37:58 +00:00
31 lines
730 B
JavaScript
Executable File
31 lines
730 B
JavaScript
Executable File
function classNames() {
|
|
var classes = '';
|
|
var arg;
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
arg = arguments[i];
|
|
if (!arg) {
|
|
continue;
|
|
}
|
|
|
|
if ('string' === typeof arg || 'number' === typeof arg) {
|
|
classes += ' ' + arg;
|
|
} else if (Object.prototype.toString.call(arg) === '[object Array]') {
|
|
classes += ' ' + classNames.apply(null, arg);
|
|
} else if ('object' === typeof arg) {
|
|
for (var key in arg) {
|
|
if (!arg.hasOwnProperty(key) || !arg[key]) {
|
|
continue;
|
|
}
|
|
classes += ' ' + key;
|
|
}
|
|
}
|
|
}
|
|
return classes.substr(1);
|
|
}
|
|
|
|
// safely export classNames in case the script is included directly on a page
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
module.exports = classNames;
|
|
}
|