UNPKG

@mirrormedia/lilith-draft-renderer

Version:
76 lines (68 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BGVideoBlock = BGVideoBlock; var _react = _interopRequireDefault(require("react")); var _styledComponents = _interopRequireDefault(require("styled-components")); var _utils = require("../utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const BGVideoRenderWrapper = _styledComponents.default.div` position: relative; padding: 30px; width: 100%; ${({ textBlockAlign }) => { if (textBlockAlign === 'left') { return `padding-right: 50%;`; } else if (textBlockAlign === 'right') { return `padding-left: 50%;`; } else if (textBlockAlign === 'bottom') { return `padding-top: 50%;`; } }} `; const BGVideoRednerVideo = _styledComponents.default.video` position: absolute; width: 100%; height: 100%; top: 0; left: 0; z-index: -1; background-color: black; `; const BGVideoRenderBody = _styledComponents.default.div` background: rgba(0, 0, 0, 0.5); padding: 4px 20px; margin-bottom: 10px; `; function BGVideoBlock(props, contentLayout) { var _video$file; const { block, contentState } = props; const entityKey = block.getEntityAt(0); const entity = contentState.getEntity(entityKey); const { textBlockAlign, video, body } = entity.getData(); return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(BGVideoRenderWrapper, { textBlockAlign: textBlockAlign }, /*#__PURE__*/_react.default.createElement(BGVideoRednerVideo, { muted: true, autoPlay: true, loop: true }, /*#__PURE__*/_react.default.createElement("source", { src: video === null || video === void 0 ? void 0 : video.urlOriginal }), /*#__PURE__*/_react.default.createElement("source", { src: video === null || video === void 0 ? void 0 : (_video$file = video.file) === null || _video$file === void 0 ? void 0 : _video$file.url })), /*#__PURE__*/_react.default.createElement(BGVideoRenderBody, { dangerouslySetInnerHTML: { __html: contentLayout === 'amp' ? (0, _utils.convertEmbeddedToAmp)(body) : body } }))); }