@modern-kit/react
Version:
63 lines (54 loc) • 1.74 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { polymorphicForwardRef } from '../../utils/polymorphicForwardRef/index.mjs';
import { Slot } from '../Slot/index.mjs';
import classNames from 'classnames';
import 'react';
import '../../hooks/useMergeRefs/index.mjs';
import '../../utils/mergeRefs/index.mjs';
import '@modern-kit/utils';
function styleInject(css, ref) {
if ( ref === void 0 ) ref = {};
var insertAt = ref.insertAt;
if (typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
var css_248z = ".AspectRatio-modules_aspectRatioWrapper__x4FNF>*{display:block;width:100%}";
var styles = {"aspectRatioWrapper":"AspectRatio-modules_aspectRatioWrapper__x4FNF"};
styleInject(css_248z);
const AspectRatio = polymorphicForwardRef(
({ ratio, style, as = "div", asChild = false, ...props }, ref) => {
const AspectRatioWrapper = asChild ? Slot : as;
const slotStyle = {
aspectRatio: ratio,
...style
};
const className = asChild ? props.className : classNames(styles.aspectRatioWrapper, props.className);
return /* @__PURE__ */ jsx(
AspectRatioWrapper,
{
ref,
style: slotStyle,
className,
...props
}
);
}
);
export { AspectRatio };
//# sourceMappingURL=index.mjs.map