UNPKG

1.51 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
4import classNames from 'classnames';
5import React from 'react';
6import { createBootstrapComponent } from './ThemeProvider';
7var defaultProps = {
8 aspectRatio: '1by1'
9};
10
11var ResponsiveEmbed =
12/*#__PURE__*/
13function (_React$Component) {
14 _inheritsLoose(ResponsiveEmbed, _React$Component);
15
16 function ResponsiveEmbed() {
17 return _React$Component.apply(this, arguments) || this;
18 }
19
20 var _proto = ResponsiveEmbed.prototype;
21
22 _proto.render = function render() {
23 var _this$props = this.props,
24 bsPrefix = _this$props.bsPrefix,
25 className = _this$props.className,
26 children = _this$props.children,
27 aspectRatio = _this$props.aspectRatio,
28 props = _objectWithoutPropertiesLoose(_this$props, ["bsPrefix", "className", "children", "aspectRatio"]);
29
30 var child = React.Children.only(children);
31 return React.createElement("div", _extends({}, props, {
32 className: classNames(bsPrefix, className, aspectRatio && bsPrefix + "-" + aspectRatio)
33 }), React.cloneElement(child, {
34 className: classNames(child.props.className, bsPrefix + "-item")
35 }));
36 };
37
38 return ResponsiveEmbed;
39}(React.Component);
40
41ResponsiveEmbed.defaultProps = defaultProps;
42export default createBootstrapComponent(ResponsiveEmbed, 'embed-responsive');
\No newline at end of file