brf/client/shared/utils/merge_styles.ts
2025-12-13 21:12:08 +01:00

20 lines
393 B
TypeScript

import cn from 'classnames'
export default function mergeStyles(styles: Record<string, string>[]) {
const props = new Set<string>()
for (const style of styles) {
for (const prop of Object.keys(style)) {
props.add(prop)
}
}
const obj: Record<string, string> = {}
for (const prop of props) {
obj[prop] = cn(styles.map((style) => style[prop]))
}
return obj
}