UNPKG

@miyagi/core

Version:

miyagi is a component development tool for JavaScript template engines.

36 lines (30 loc) 710 B
import { getCustomProperties } from "./helpers.js"; /** * @param {object} obj * @param {string} prefix * @returns {Array} */ export default function getSpacings(obj, prefix) { const spacings = []; getCustomProperties(obj, prefix).forEach(({ property, value, mq }) => { // filter out negative spacings if (property.startsWith(`--${prefix}-`) && !value.startsWith("-")) { spacings.push({ name: property.replace(`--${prefix}-`, ""), customProp: property, value, mq, }); } }); const deduped = {}; spacings.forEach((e) => { if (!deduped[e.name]) { deduped[e.name] = { customProp: e.customProp, value: e.value, }; } }); return Object.entries(deduped); }