27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
||
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||
|
import classNames from 'classnames';
|
||
|
import React from 'react';
|
||
|
import { useBootstrapPrefix } from './ThemeProvider';
|
||
|
var defaultProps = {
|
||
|
aspectRatio: '1by1'
|
||
|
};
|
||
|
var ResponsiveEmbed = React.forwardRef(function (_ref, ref) {
|
||
|
var bsPrefix = _ref.bsPrefix,
|
||
|
className = _ref.className,
|
||
|
children = _ref.children,
|
||
|
aspectRatio = _ref.aspectRatio,
|
||
|
props = _objectWithoutPropertiesLoose(_ref, ["bsPrefix", "className", "children", "aspectRatio"]);
|
||
|
|
||
|
var decoratedBsPrefix = useBootstrapPrefix(bsPrefix, 'embed-responsive');
|
||
|
var child = React.Children.only(children);
|
||
|
return React.createElement("div", _extends({
|
||
|
ref: ref
|
||
|
}, props, {
|
||
|
className: classNames(decoratedBsPrefix, className, aspectRatio && decoratedBsPrefix + "-" + aspectRatio)
|
||
|
}), React.cloneElement(child, {
|
||
|
className: classNames(child.props.className, decoratedBsPrefix + "-item")
|
||
|
}));
|
||
|
});
|
||
|
ResponsiveEmbed.defaultProps = defaultProps;
|
||
|
export default ResponsiveEmbed;
|