index.ts 530 B

123456789101112131415
  1. // @ts-nocheck
  2. interface CSSProperties {
  3. [key: string]: string | number
  4. }
  5. /** converting camel-cased strings to be lowercase and link it with Separato */
  6. export function toLowercaseSeparator(key: string) {
  7. return key.replace(/([A-Z])/g, '-$1').toLowerCase();
  8. }
  9. export function getStyleStr(style: CSSProperties): string {
  10. return Object.keys(style).filter(key => style[key] !== undefined && style[key] !== null && style[key] !== '')
  11. .map((key: string) => `${toLowercaseSeparator(key)}: ${style[key]};`)
  12. .join(' ');
  13. }