optimizely-oui
Version:
Optimizely's Component Library.
35 lines (25 loc) • 737 B
JavaScript
const generateComment = (description, isDeprecated) => {
const comments = [];
if (description) {
comments.push(`// ${description}`);
}
if (isDeprecated) {
comments.push("// @deprecated");
}
if (comments.length > 0) {
return `\n${comments.join("\n")}`;
}
return "";
};
const toSCSS = (memo, { id, value, description, deprecated }) => {
if (!id) {
throw new Error("An `id` must be provided.");
}
if (!value) {
throw new Error("A `value` must be provided.");
}
const formattedName = id;
const comment = generateComment(description, deprecated);
return `${memo}${comment}\n$${formattedName}: ${value};`;
};
module.exports = toSCSS;