All files / app/common/dom toCssRule.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11150x   271x 75x 289x 182x     75x    
import { assign, kebabCase, map, pickBy } from 'lodash';
 
export default function toCSSRule(selector: string, ...styles: Array<{ [key: string]: any } | undefined>): string {
    const mergedStyles = assign({}, ...styles);
    const props = map(pickBy(mergedStyles, value => typeof value === 'string'), (value, key) =>
        `${kebabCase(key)}: ${value};`
    ).join(' ');
 
    return `${selector} {${props}}`;
}