20 lines
393 B
TypeScript
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
|
|
}
|