Last active: 7 months ago
Build css module className
/**
* clsx
*/
export function cn(...rest: string[]) {
return rest.join(' ');
}
/**
* 构建 cn 函数
*
* Usage:
*
* ```ts
* import styles from 'index.module.less';
* const cn = buildCN(styles);
* <div className={cn('left', 'align-center')}>
* ```
*/
export function buildCN(module: typeof import('*.less')) {
return (...rest: string[]) => {
return cn(rest.map<string>((className) => module[className]).join(' '));
};
}