UNPKG

@guestbell/react-page-plugins

Version:

Plugins we use in GuestBell for working with amazing react-page package

36 lines 1.76 kB
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } import * as React from 'react'; import { ListTypes } from './listTypes'; var _getFirstColor = function getFirstColor(item) { var _children, _children2; return item !== null && item !== void 0 && (_children = item.children) !== null && _children !== void 0 && _children[0] ? _getFirstColor(item === null || item === void 0 ? void 0 : (_children2 = item.children) === null || _children2 === void 0 ? void 0 : _children2[0]) : item.color; }; export var List = function List(_ref) { var attributes = _ref.attributes, children = _ref.children, element = _ref.element; if (element.type === ListTypes.UL || element.type === ListTypes.OL || element.type === ListTypes.LI) { var color = _getFirstColor(element); var colorStyle = color ? "rgba(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ",").concat(color.a, ")") : 'inherit'; var style = { textAlign: element.alignment, '--marker-color': colorStyle }; switch (element.type) { case ListTypes.UL: return /*#__PURE__*/React.createElement("ul", _extends({}, attributes, { style: style }), children); case ListTypes.OL: return /*#__PURE__*/React.createElement("ol", _extends({}, attributes, { style: style }), children); case ListTypes.LI: return /*#__PURE__*/React.createElement("li", attributes, children); default: return null; } } return null; }; //# sourceMappingURL=List.js.map