UNPKG

zss-engine

Version:

A CSS-in-JS transpiler engine for building zero-runtime stylesheets at build time.

26 lines (25 loc) 997 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.transpileAtomic = transpileAtomic; const helper_js_1 = require("./helper.js"); const shorthand_js_1 = require("./shorthand.js"); const ALL_LONGHANDS = new Set(Object.values(shorthand_js_1.SHORTHAND_PROPERTIES).flat()); function transpileAtomic(property, value, hash, pseudo) { if (typeof value === 'string' || typeof value === 'number') { const CSSProp = (0, helper_js_1.camelToKebabCase)(property); const applyValue = (0, helper_js_1.applyCssValue)(value, CSSProp); let selector = `.${hash}`; if (ALL_LONGHANDS.has(CSSProp)) { selector += ':not(#\\#)'; } if (pseudo) { selector += pseudo; } const atomicRule = `${selector} { ${CSSProp}: ${applyValue}; }`; if ((0, helper_js_1.isAtRule)(property)) { return `${property} { ${atomicRule} }`; } return atomicRule; } return ''; }