All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.cjs.components.aspect-ratio.aspect-ratio.cjs Maven / Gradle / Ivy

Go to download

Responsive and accessible React UI components built with React and Emotion

The newest version!
"use strict";
"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var cx = require('../../utils/cx.cjs');
var walkObject = require('../../utils/walk-object.cjs');
var factory = require('../../styled-system/factory.cjs');

const AspectRatio = React.forwardRef(
  function AspectRatio2(props, ref) {
    const { ratio = 4 / 3, children, className, ...rest } = props;
    const child = React.Children.only(children);
    return /* @__PURE__ */ jsxRuntime.jsx(
      factory.chakra.div,
      {
        ref,
        position: "relative",
        className: cx.cx("chakra-aspect-ratio", className),
        _before: {
          height: 0,
          content: `""`,
          display: "block",
          paddingBottom: walkObject.mapObject(ratio, (r) => `${1 / r * 100}%`)
        },
        css: {
          "& > *:not(style)": {
            overflow: "hidden",
            position: "absolute",
            top: "0",
            right: "0",
            bottom: "0",
            left: "0",
            display: "flex",
            justifyContent: "center",
            alignItems: "center",
            width: "100%",
            height: "100%"
          },
          "& > img, & > video": {
            objectFit: "cover"
          },
          ...props.css
        },
        ...rest,
        children: child
      }
    );
  }
);

exports.AspectRatio = AspectRatio;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy