191 lines
5.7 KiB
JavaScript
191 lines
5.7 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.styles = void 0;
|
|
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
|
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
|
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
|
|
var _react = _interopRequireDefault(require("react"));
|
|
|
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
|
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
|
|
|
var _helpers = require("../utils/helpers");
|
|
|
|
var styles = function styles(theme) {
|
|
return {
|
|
root: {
|
|
display: 'block',
|
|
margin: 0
|
|
},
|
|
display4: theme.typography.display4,
|
|
display3: theme.typography.display3,
|
|
display2: theme.typography.display2,
|
|
display1: theme.typography.display1,
|
|
headline: theme.typography.headline,
|
|
title: theme.typography.title,
|
|
subheading: theme.typography.subheading,
|
|
body2: theme.typography.body2,
|
|
body1: theme.typography.body1,
|
|
caption: theme.typography.caption,
|
|
button: theme.typography.button,
|
|
alignLeft: {
|
|
textAlign: 'left'
|
|
},
|
|
alignCenter: {
|
|
textAlign: 'center'
|
|
},
|
|
alignRight: {
|
|
textAlign: 'right'
|
|
},
|
|
alignJustify: {
|
|
textAlign: 'justify'
|
|
},
|
|
noWrap: {
|
|
overflow: 'hidden',
|
|
textOverflow: 'ellipsis',
|
|
whiteSpace: 'nowrap'
|
|
},
|
|
gutterBottom: {
|
|
marginBottom: '0.35em'
|
|
},
|
|
paragraph: {
|
|
marginBottom: theme.spacing.unit * 2
|
|
},
|
|
colorInherit: {
|
|
color: 'inherit'
|
|
},
|
|
colorPrimary: {
|
|
color: theme.palette.primary.main
|
|
},
|
|
colorSecondary: {
|
|
color: theme.palette.secondary.main
|
|
},
|
|
colorTextSecondary: {
|
|
color: theme.palette.text.secondary
|
|
},
|
|
colorError: {
|
|
color: theme.palette.error.main
|
|
}
|
|
};
|
|
};
|
|
|
|
exports.styles = styles;
|
|
|
|
function Typography(props) {
|
|
var _classNames;
|
|
|
|
var align = props.align,
|
|
classes = props.classes,
|
|
classNameProp = props.className,
|
|
componentProp = props.component,
|
|
color = props.color,
|
|
gutterBottom = props.gutterBottom,
|
|
headlineMapping = props.headlineMapping,
|
|
noWrap = props.noWrap,
|
|
paragraph = props.paragraph,
|
|
variant = props.variant,
|
|
other = (0, _objectWithoutProperties2.default)(props, ["align", "classes", "className", "component", "color", "gutterBottom", "headlineMapping", "noWrap", "paragraph", "variant"]);
|
|
var className = (0, _classnames.default)(classes.root, classes[variant], (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes["color".concat((0, _helpers.capitalize)(color))], color !== 'default'), (0, _defineProperty2.default)(_classNames, classes.noWrap, noWrap), (0, _defineProperty2.default)(_classNames, classes.gutterBottom, gutterBottom), (0, _defineProperty2.default)(_classNames, classes.paragraph, paragraph), (0, _defineProperty2.default)(_classNames, classes["align".concat((0, _helpers.capitalize)(align))], align !== 'inherit'), _classNames), classNameProp);
|
|
var Component = componentProp || (paragraph ? 'p' : headlineMapping[variant]) || 'span';
|
|
return _react.default.createElement(Component, (0, _extends2.default)({
|
|
className: className
|
|
}, other));
|
|
}
|
|
|
|
Typography.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
/**
|
|
* Set the text-align on the component.
|
|
*/
|
|
align: _propTypes.default.oneOf(['inherit', 'left', 'center', 'right', 'justify']),
|
|
|
|
/**
|
|
* The content of the component.
|
|
*/
|
|
children: _propTypes.default.node,
|
|
|
|
/**
|
|
* Useful to extend the style applied to components.
|
|
*/
|
|
classes: _propTypes.default.object.isRequired,
|
|
|
|
/**
|
|
* @ignore
|
|
*/
|
|
className: _propTypes.default.string,
|
|
|
|
/**
|
|
* The color of the component. It supports those theme colors that make sense for this component.
|
|
*/
|
|
color: _propTypes.default.oneOf(['inherit', 'primary', 'textSecondary', 'secondary', 'error', 'default']),
|
|
|
|
/**
|
|
* The component used for the root node.
|
|
* Either a string to use a DOM element or a component.
|
|
* By default, it maps the variant to a good default headline component.
|
|
*/
|
|
component: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
|
|
/**
|
|
* If `true`, the text will have a bottom margin.
|
|
*/
|
|
gutterBottom: _propTypes.default.bool,
|
|
|
|
/**
|
|
* We are empirically mapping the variant property to a range of different DOM element types.
|
|
* For instance, h1 to h6. If you wish to change that mapping, you can provide your own.
|
|
* Alternatively, you can use the `component` property.
|
|
*/
|
|
headlineMapping: _propTypes.default.object,
|
|
|
|
/**
|
|
* If `true`, the text will not wrap, but instead will truncate with an ellipsis.
|
|
*/
|
|
noWrap: _propTypes.default.bool,
|
|
|
|
/**
|
|
* If `true`, the text will have a bottom margin.
|
|
*/
|
|
paragraph: _propTypes.default.bool,
|
|
|
|
/**
|
|
* Applies the theme typography styles.
|
|
*/
|
|
variant: _propTypes.default.oneOf(['display4', 'display3', 'display2', 'display1', 'headline', 'title', 'subheading', 'body2', 'body1', 'caption', 'button'])
|
|
} : {};
|
|
Typography.defaultProps = {
|
|
align: 'inherit',
|
|
color: 'default',
|
|
gutterBottom: false,
|
|
headlineMapping: {
|
|
display4: 'h1',
|
|
display3: 'h1',
|
|
display2: 'h1',
|
|
display1: 'h1',
|
|
headline: 'h1',
|
|
title: 'h2',
|
|
subheading: 'h3',
|
|
body2: 'aside',
|
|
body1: 'p'
|
|
},
|
|
noWrap: false,
|
|
paragraph: false,
|
|
variant: 'body1'
|
|
};
|
|
|
|
var _default = (0, _withStyles.default)(styles, {
|
|
name: 'MuiTypography'
|
|
})(Typography);
|
|
|
|
exports.default = _default; |