implement frontend utility functions for classes and styles

This commit is contained in:
Xymorot 2019-06-18 00:36:19 +02:00
parent ff68a35505
commit 4b0277f950
1 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,13 @@
export function c(input: Array<string | boolean> | object): string {
const array = Array.isArray(input)
? input.filter(el => typeof el === 'string')
: Object.keys(input).filter(key => !!input[key]);
return array.join(' ');
}
export function s(styles: object): string {
return Object.keys(styles)
.filter(key => !!styles[key])
.map(key => `${key}:${styles[key]}`)
.join(';');
}