UNPKG

@winglet/style-utils

Version:

Comprehensive CSS and style management utilities including className manipulation, CSS compression, and universal style manager for TypeScript projects

30 lines (28 loc) 962 B
const cx = (...args) => { let index = 0, length = args.length, cursor, result = ''; for (; index < length; index++) { if ((cursor = args[index]) && (cursor = getSegment(cursor))) { result = result ? result + ' ' + cursor : cursor; } } return result; }; const getSegment = (input) => { let key, cursor, result = ''; if (typeof input === 'string' || typeof input === 'number') return result + input; else if (typeof input === 'object' && input) { if (Array.isArray(input)) { for (key = 0; key < input.length; key++) if ((cursor = input[key]) && (cursor = getSegment(cursor))) result = result ? result + ' ' + cursor : cursor; } else { for (cursor in input) if (input[cursor]) result = result ? result + ' ' + cursor : cursor; } } return result; }; export { cx };