@kuma-ui/system
Version:
🐻 Kuma UI is a utility-first, zero-runtime CSS-in-JS library that offers an outstanding developer experience and optimized performance.
47 lines (45 loc) • 1.82 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/responsive.ts
var responsive_exports = {};
__export(responsive_exports, {
applyResponsiveStyles: () => applyResponsiveStyles
});
module.exports = __toCommonJS(responsive_exports);
var import_sheet = require("@kuma-ui/sheet");
var applyResponsiveStyles = (cssProperty, cssValues, convertFn = (value) => value) => {
const { breakpoints } = import_sheet.theme.getUserTheme();
const media = {};
if (Array.isArray(cssValues)) {
const baseValue = convertFn(cssValues[0]);
cssValues.slice(1).map((value, index) => {
if (breakpoints) {
const breakpoint = Object.keys(breakpoints)[index];
const breakpointValue = breakpoints[breakpoint];
media[breakpointValue] = `${cssProperty}: ${convertFn(value)};`;
}
});
return { base: `${cssProperty}: ${baseValue};`, media };
}
return { base: `${cssProperty}: ${convertFn(cssValues)};`, media: {} };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
applyResponsiveStyles
});