mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-08 22:17:26 +08:00
[O] Better clazz
This commit is contained in:
@@ -91,10 +91,13 @@ export const CHARTJS_OPT: ChartOptions<'line'> = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage: clazz({a: false, b: true}) -> "b"
|
||||
* Convert object keys to classes depending on their values
|
||||
*
|
||||
* @param obj HashMap<string, boolean>
|
||||
* @param obj Dictionary object {classname: truthy}
|
||||
* @param others Other classes to add
|
||||
*/
|
||||
export function clazz(obj: { [key: string]: boolean }) {
|
||||
return Object.keys(obj).filter(k => obj[k]).join(' ')
|
||||
export function clz(obj: any, others?: string) {
|
||||
let cls = Object.keys(obj).filter(key => obj[key]).join(' ')
|
||||
if (others) cls += ' ' + others
|
||||
return cls
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user