@wordpress/style-engine
Version:
A suite of parsers and compilers for WordPress styles.
82 lines (81 loc) • 1.94 kB
JavaScript
// packages/style-engine/src/styles/background/index.ts
import { generateRule, safeDecodeURI } from "../utils";
var backgroundImage = {
name: "backgroundImage",
generate: (style, options) => {
const _backgroundImage = style?.background?.backgroundImage;
if (typeof _backgroundImage === "object" && _backgroundImage?.url) {
return [
{
selector: options.selector,
key: "backgroundImage",
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
value: `url( '${encodeURI(
safeDecodeURI(_backgroundImage.url)
)}' )`
}
];
}
return generateRule(
style,
options,
["background", "backgroundImage"],
"backgroundImage"
);
}
};
var backgroundPosition = {
name: "backgroundPosition",
generate: (style, options) => {
return generateRule(
style,
options,
["background", "backgroundPosition"],
"backgroundPosition"
);
}
};
var backgroundRepeat = {
name: "backgroundRepeat",
generate: (style, options) => {
return generateRule(
style,
options,
["background", "backgroundRepeat"],
"backgroundRepeat"
);
}
};
var backgroundSize = {
name: "backgroundSize",
generate: (style, options) => {
return generateRule(
style,
options,
["background", "backgroundSize"],
"backgroundSize"
);
}
};
var backgroundAttachment = {
name: "backgroundAttachment",
generate: (style, options) => {
return generateRule(
style,
options,
["background", "backgroundAttachment"],
"backgroundAttachment"
);
}
};
var background_default = [
backgroundImage,
backgroundPosition,
backgroundRepeat,
backgroundSize,
backgroundAttachment
];
export {
background_default as default
};
//# sourceMappingURL=index.js.map