UNPKG

grommet

Version:

focus on the essential experience

49 lines (48 loc) 2.77 kB
"use strict"; exports.__esModule = true; exports.StyledText = void 0; var _styledComponents = _interopRequireWildcard(require("styled-components")); var _utils = require("../../utils"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } var sizeStyle = function sizeStyle(props) { var size = props.size || 'medium'; var data = props.theme.text[size]; if (data) { return (0, _styledComponents.css)(["font-size:", ";line-height:", ";"], data.size, data.height); } return (0, _styledComponents.css)(["font-size:", ";line-height:normal;"], size); }; var truncateStyle = "\n white-space: nowrap;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n"; var colorStyle = (0, _styledComponents.css)(["color:", ";"], function (props) { return (0, _utils.normalizeColor)(props.colorProp, props.theme); }); var weightStyle = (0, _styledComponents.css)(["font-weight:", ";"], function (props) { return props.weight; }); var wordBreakStyle = (0, _styledComponents.css)(["word-break:", ";"], function (props) { return props.wordBreak; }); var fontFamily = (0, _styledComponents.css)(["font-family:", ";"], function (props) { return props.theme.text.font.family; }); var StyledText = exports.StyledText = (0, _styledComponents["default"])('span').withConfig(_utils.styledComponentsConfig).withConfig({ displayName: "StyledText", componentId: "sc-1sadyjn-0" })(["", " ", " ", " ", " ", " ", " ", " ", " ", ""], _utils.genericStyles, function (props) { return sizeStyle(props); }, function (props) { return props.textAlign && _utils.textAlignStyle; }, function (props) { return props.truncate && truncateStyle; }, function (props) { return props.colorProp && colorStyle; }, function (props) { return props.weight && weightStyle; }, function (props) { return props.wordBreak && wordBreakStyle; }, function (props) { return props.theme.text.font && props.theme.text.font.family && fontFamily; }, function (props) { return props.theme.text && props.theme.text.extend; });