@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
38 lines (36 loc) • 1.16 kB
JavaScript
import { utils_exports } from "../../utils/index.js";
import { tokenToVar } from "./utils.js";
//#region src/core/css/at-rule.ts
const generateAtRule = (identifier) => (values, { system }) => {
if (!(0, utils_exports.isArray)(values)) return values;
return values.reduce((prev, { type, name, css, h, height, maxH, maxHeight, maxW, maxWidth, minH, minHeight, minW, minWidth, prefersColorMode, query, w, width,...rest }) => {
width ??= w;
minWidth ??= minW;
maxWidth ??= maxW;
height ??= h;
minHeight ??= minH;
maxHeight ??= maxH;
if (!query) {
const resolvedRest = (0, utils_exports.filterUndefined)({
height,
maxHeight,
maxWidth,
minHeight,
minWidth,
prefersColorScheme: prefersColorMode,
width,
...rest
});
query = Object.entries(resolvedRest).map(([key, value]) => {
value = tokenToVar(system)("sizes", value);
return `(${(0, utils_exports.toKebabCase)(key)}: ${value})`;
}).join(" and ");
}
const condition = `@${identifier} ${type ?? name ?? ""} ${query}`;
prev[condition] = css;
return prev;
}, {});
};
//#endregion
export { generateAtRule };
//# sourceMappingURL=at-rule.js.map