UNPKG

4.75 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7require('./slicedToArray-0711941d.js');
8require('./unsupportedIterableToArray-68db1d3b.js');
9var React = require('react');
10var React__default = _interopDefault(React);
11require('./_commonjsHelpers-72d386ba.js');
12var index = require('./index-b0606964.js');
13require('./defineProperty-0921a47c.js');
14require('./toConsumableArray-d8a4a2c3.js');
15var _styled = require('styled-components');
16var _styled__default = _interopDefault(_styled);
17require('./getPrototypeOf-2a661a20.js');
18require('./color.js');
19require('./components.js');
20require('./contains-component.js');
21require('./css.js');
22require('./dayjs.min-e07657bf.js');
23require('./date.js');
24require('./miscellaneous.js');
25require('./environment.js');
26require('./font.js');
27require('./math-f4029164.js');
28require('./characters.js');
29require('./format.js');
30require('./keycodes.js');
31require('./url.js');
32require('./web3.js');
33var constants = require('./constants.js');
34require('./breakpoints.js');
35require('./springs.js');
36var textStyles = require('./text-styles.js');
37require('./theme-dark.js');
38require('./theme-light.js');
39var Theme = require('./Theme.js');
40var _extends$1 = require('./extends-40571110.js');
41var objectWithoutProperties = require('./objectWithoutProperties-35db8ab0.js');
42
43function getModeStyles(theme, mode) {
44 if (mode === 'warning') {
45 return {
46 background: theme.warningSurface,
47 borderColor: theme.warning,
48 color: theme.warningSurfaceContent,
49 titleColor: theme.warningSurfaceContent
50 };
51 }
52
53 if (mode === 'error') {
54 return {
55 background: theme.negativeSurface,
56 borderColor: theme.negative,
57 color: theme.negativeSurfaceContent,
58 titleColor: theme.negativeSurfaceContent
59 };
60 }
61
62 if (mode === 'description') {
63 return {
64 background: theme.infoSurface,
65 borderColor: theme.info,
66 color: theme.surfaceContent,
67 titleColor: theme.surfaceContentSecondary
68 };
69 }
70
71 return {
72 background: theme.infoSurface,
73 borderColor: theme.info,
74 color: theme.infoSurfaceContent,
75 titleColor: theme.infoSurfaceContent
76 };
77}
78
79var _StyledSection = _styled__default("section").withConfig({
80 displayName: "Info___StyledSection",
81 componentId: "sc-1kgnlbm-0"
82})(["color:", ";background:", ";border-left:2px solid ", ";padding:", "px;border-radius:", "px;word-wrap:break-word;", ";"], function (p) {
83 return p._css;
84}, function (p) {
85 return p._css2;
86}, function (p) {
87 return p._css3;
88}, function (p) {
89 return p._css4;
90}, constants.RADIUS, function (p) {
91 return p._css5;
92});
93
94var _StyledH = _styled__default("h1").withConfig({
95 displayName: "Info___StyledH",
96 componentId: "sc-1kgnlbm-1"
97})(["display:flex;align-items:center;color:", ";", ";margin-bottom:", "px;"], function (p) {
98 return p._css6;
99}, function (p) {
100 return p._css7;
101}, function (p) {
102 return p._css8;
103});
104
105function Info(_ref) {
106 var children = _ref.children,
107 mode = _ref.mode,
108 color = _ref.color,
109 titleColor = _ref.titleColor,
110 background = _ref.background,
111 borderColor = _ref.borderColor,
112 title = _ref.title,
113 props = objectWithoutProperties._objectWithoutProperties(_ref, ["children", "mode", "color", "titleColor", "background", "borderColor", "title"]);
114
115 var theme = Theme.useTheme(); // Get styles from the current mode
116
117 var modeStyles = React.useMemo(function () {
118 var styles = getModeStyles(theme, mode);
119 return styles;
120 }, [mode, theme]);
121 return /*#__PURE__*/React__default.createElement(_StyledSection, _extends$1._extends({}, props, {
122 _css: color || modeStyles.color,
123 _css2: background || modeStyles.background,
124 _css3: borderColor || modeStyles.borderColor,
125 _css4: 2 * constants.GU,
126 _css5: textStyles.textStyle('body3')
127 }), title && /*#__PURE__*/React__default.createElement(_StyledH, {
128 _css6: titleColor || modeStyles.titleColor,
129 _css7: textStyles.textStyle('label2'),
130 _css8: 1 * constants.GU
131 }, title), children);
132}
133
134Info.propTypes = {
135 children: index.PropTypes.node,
136 title: index.PropTypes.node,
137 mode: index.PropTypes.oneOf(['info', 'description', 'warning', 'error']),
138 color: index.PropTypes.string,
139 titleColor: index.PropTypes.string,
140 background: index.PropTypes.string,
141 borderColor: index.PropTypes.string
142}; // Backward compatibility
143
144function Warning(props) {
145 return /*#__PURE__*/React__default.createElement(Info, _extends$1._extends({
146 mode: "warning"
147 }, props));
148}
149
150Info.Action = Info;
151Info.Permissions = Warning;
152Info.Alert = Warning;
153
154exports.default = Info;
155//# sourceMappingURL=Info.js.map