@makeen.io/material-ui-kit
Version:
Makeen UI components kit. Based on material-ui.
41 lines (15 loc) • 2.04 kB
JavaScript
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";function _templateObject() {var data = _taggedTemplateLiteral(["\n display: block;\n line-height: 0;\n\n .text {\n font-size: 13px;\n font-weight: normal;\n line-height: 1.23;\n color: #222b45;\n\n display: inline-block;\n }\n\n .read-more {\n display: inline-block;\n font-size: 12px;\n font-weight: 500;\n line-height: 1.33;\n color: #1998d5;\n\n margin: 0;\n\n white-space: nowrap;\n\n cursor: pointer;\n }\n"]);_templateObject = function _templateObject() {return data;};return data;}import React from "react";
import styled from "styled-components";
var TextWrapper = styled.div(_templateObject());
export default (function (_ref) {var _ref$text = _ref.text,text = _ref$text === void 0 ? "" : _ref$text,_ref$wrapClassName = _ref.wrapClassName,wrapClassName = _ref$wrapClassName === void 0 ? "" : _ref$wrapClassName,_ref$wrapTextClassNam = _ref.wrapTextClassName,wrapTextClassName = _ref$wrapTextClassNam === void 0 ? "" : _ref$wrapTextClassNam,_ref$showCharCount = _ref.showCharCount,showCharCount = _ref$showCharCount === void 0 ? 150 : _ref$showCharCount;var _React$useState =
React.useState(showCharCount),_React$useState2 = _slicedToArray(_React$useState, 2),charCount = _React$useState2[0],setCharCount = _React$useState2[1];
var showAll = function showAll() {
setCharCount(null);
};
return /*#__PURE__*/React.createElement(TextWrapper, { className: wrapClassName ? wrapClassName : "" }, /*#__PURE__*/
React.createElement("p", { className: "text ".concat(wrapTextClassName ? wrapTextClassName : "") },
text.slice(0, charCount ? charCount : text.length),
charCount && text.length > charCount ? "... " : "",
charCount && text.length > charCount && /*#__PURE__*/React.createElement("span", { className: "read-more", onClick: showAll }, "Read More")));
});
//# sourceMappingURL=index.js.map