1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _react = _interopRequireDefault(require("react"));
|
9 |
|
10 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
11 |
|
12 | var _withStyles = require("../helpers/withStyles");
|
13 |
|
14 | var _reactWithStyles = require("react-with-styles");
|
15 |
|
16 | var _Shimmer = _interopRequireDefault(require("./Shimmer"));
|
17 |
|
18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19 |
|
20 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
21 |
|
22 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
23 |
|
24 | var propTypes = _objectSpread({}, _reactWithStyles.withStylesPropTypes, {
|
25 | inline: _propTypes.default.bool,
|
26 | inverse: _propTypes.default.bool,
|
27 | loading: _propTypes.default.bool,
|
28 | level: _propTypes.default.oneOf([1, 2, 3]),
|
29 | light: _propTypes.default.bool,
|
30 | muted: _propTypes.default.bool,
|
31 | noBottomSpacing: _propTypes.default.bool,
|
32 | noSpacing: _propTypes.default.bool,
|
33 | noTopSpacing: _propTypes.default.bool,
|
34 | title: _propTypes.default.string,
|
35 | truncate: _propTypes.default.bool,
|
36 | shimmerWidth: _propTypes.default.string,
|
37 | children: _propTypes.default.any
|
38 | });
|
39 |
|
40 | var defaultProps = {
|
41 | level: 1
|
42 | };
|
43 |
|
44 | var Title = function Title(_ref) {
|
45 | var children = _ref.children,
|
46 | inline = _ref.inline,
|
47 | inverse = _ref.inverse,
|
48 | loading = _ref.loading,
|
49 | level = _ref.level,
|
50 | light = _ref.light,
|
51 | muted = _ref.muted,
|
52 | noBottomSpacing = _ref.noBottomSpacing,
|
53 | noSpacing = _ref.noSpacing,
|
54 | noTopSpacing = _ref.noTopSpacing,
|
55 | title = _ref.title,
|
56 | truncate = _ref.truncate,
|
57 | shimmerWidth = _ref.shimmerWidth,
|
58 | styles = _ref.styles;
|
59 |
|
60 | var content = function content() {
|
61 | switch (level) {
|
62 | case 1:
|
63 | return _react.default.createElement("h1", (0, _withStyles.css)(styles.title__header), children ? children : title);
|
64 |
|
65 | case 2:
|
66 | return _react.default.createElement("h2", (0, _withStyles.css)(styles.title__header), children ? children : title);
|
67 |
|
68 | case 3:
|
69 | return _react.default.createElement("h3", (0, _withStyles.css)(styles.title__header), children ? children : title);
|
70 |
|
71 | default:
|
72 | return _react.default.createElement("h1", (0, _withStyles.css)(styles.title__header), children ? children : title);
|
73 | }
|
74 | };
|
75 |
|
76 | return _react.default.createElement("div", (0, _withStyles.css)(styles.title, inline && styles.title_inline, inverse && styles.title_inverse, level === 1 && styles.title_level1, level === 2 && styles.title_level2, level === 3 && styles.title_level3, light && styles.title_light, muted && styles.title_muted, (noTopSpacing || noSpacing) && styles.title_noTopSpacing, (noBottomSpacing || noSpacing) && styles.title_noBottomSpacing, truncate && styles.title_truncate), loading ? _react.default.createElement(_Shimmer.default, {
|
77 | height: "1ex",
|
78 | width: shimmerWidth || '60%'
|
79 | }) : content());
|
80 | };
|
81 |
|
82 | Title.propTypes = propTypes;
|
83 | Title.defaultProps = defaultProps;
|
84 | var TitleWithStyles = (0, _withStyles.withStyles)(function (_ref2) {
|
85 | var units = _ref2.units,
|
86 | color = _ref2.color,
|
87 | weight = _ref2.weight,
|
88 | fontSize = _ref2.fontSize,
|
89 | lineHeight = _ref2.lineHeight,
|
90 | font = _ref2.font,
|
91 | breakpoint = _ref2.breakpoint;
|
92 | return {
|
93 | title: {
|
94 | wordWrap: 'break-word',
|
95 | letterSpacing: 'normal',
|
96 | fontFamily: font.default,
|
97 | color: color.grayDarker,
|
98 | fontWeight: weight.bold,
|
99 | lineHeight: lineHeight.short,
|
100 | margin: 0,
|
101 | paddingTop: units(0.5),
|
102 | paddingBottom: units(0.5),
|
103 | display: 'block'
|
104 | },
|
105 | title_inverse: {
|
106 | color: color.white
|
107 | },
|
108 | title_level1: _defineProperty({
|
109 | fontSize: fontSize.small.title1
|
110 | }, breakpoint.large, {
|
111 | fontSize: fontSize.large.title1
|
112 | }),
|
113 | title_level2: _defineProperty({
|
114 | fontSize: fontSize.small.title2
|
115 | }, breakpoint.large, {
|
116 | fontSize: fontSize.large.title2
|
117 | }),
|
118 | title_level3: _defineProperty({
|
119 | fontSize: fontSize.small.title3
|
120 | }, breakpoint.large, {
|
121 | fontSize: fontSize.large.title3
|
122 | }),
|
123 | title_light: {
|
124 | fontWeight: weight.light
|
125 | },
|
126 | title_muted: {
|
127 | color: color.blueGrayDark
|
128 | },
|
129 | title_noBottomSpacing: {
|
130 | paddingBottom: 0
|
131 | },
|
132 | title_noTopSpacing: {
|
133 | paddingTop: 0
|
134 | },
|
135 | title_truncate: {
|
136 | whiteSpace: 'nowrap',
|
137 | overflow: 'hidden',
|
138 | textOverflow: 'ellipsis'
|
139 | },
|
140 | title_inline: {
|
141 | display: 'inline-block'
|
142 | },
|
143 | title__header: {
|
144 | fontSize: '1em',
|
145 | lineHeight: 'inherit',
|
146 | fontWeight: 'inherit',
|
147 | color: 'inherit',
|
148 | margin: 0,
|
149 | padding: 0,
|
150 | display: 'flex',
|
151 | alignItems: 'center'
|
152 | }
|
153 | };
|
154 | })(Title);
|
155 | var _default = TitleWithStyles;
|
156 | exports.default = _default; |
\ | No newline at end of file |