UNPKG

@makeen.io/material-ui-kit

Version:
51 lines (48 loc) 2.15 kB
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";import _extends from "@babel/runtime/helpers/extends";function _templateObject() {var data = _taggedTemplateLiteral(["\n ", "\n"]);_templateObject = function _templateObject() {return data;};return data;}import React from "react"; import Typography from "@material-ui/core/Typography"; import { makeStyles } from "@material-ui/core/styles"; import styled from "styled-components"; import { default as theme } from "../../themes/default"; var paragraphOrSmallOrSpan = function paragraphOrSmallOrSpan(componentProps) { if (componentProps.gutterBottom || componentProps.paragraph || componentProps.align !== "inherit") { return "p"; } return typeof componentProps.variant === "string" && componentProps.variant.includes("small") ? "small" : "span"; }; var typography = theme.typography; var styles = _extends({ root: { fontFamily: typography.fontFamily } }, typography); var useStyles = makeStyles(styles); var TextComponent = function TextComponent(props) {var children = props.children,variant = props.variant,rest = _objectWithoutProperties(props, ["children", "variant"]); var classes = useStyles(props); var currentVariant; var currentClass; var component; switch (variant) { case "caption1": case "caption2": case "small1": case "small2": case "label": currentClass = "".concat(classes.root, " ").concat(classes[variant]); component = paragraphOrSmallOrSpan(props); currentVariant = "body1"; break; default: currentVariant = variant;} return /*#__PURE__*/React.createElement(Typography, _extends({ className: currentClass, component: component, variant: currentVariant }, rest), children); }; export default styled(function (props) { return /*#__PURE__*/React.createElement(TextComponent, _extends({}, props), props.children); })(_templateObject(), function (_ref) {var customStyle = _ref.customStyle;return customStyle ? customStyle() : "";}); //# sourceMappingURL=index.js.map