implement frontend utility functions for classes and styles
This commit is contained in:
parent
ff68a35505
commit
4b0277f950
|
@ -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(';');
|
||||||
|
}
|
Loading…
Reference in New Issue