@redocly/theme
Version:
Shared UI components lib
24 lines • 898 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseStyleString = parseStyleString;
function parseStyleString(styleString) {
return styleString
.split(';')
.filter((style) => style.trim().length)
.reduce((styleObj, style) => {
const colonIndex = style.indexOf(':');
if (colonIndex === -1)
return styleObj;
const key = style.substring(0, colonIndex).trim();
const value = style.substring(colonIndex + 1).trim();
if (key && value) {
const camelCaseKey = key.replace(/-[a-z]/g, (match) => {
return match[1].toUpperCase();
});
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
styleObj[camelCaseKey] = value;
}
return styleObj;
}, {});
}
//# sourceMappingURL=parse-style-string.js.map