1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6 |
|
7 | require('./slicedToArray-0711941d.js');
|
8 | require('./unsupportedIterableToArray-68db1d3b.js');
|
9 | var React = require('react');
|
10 | var React__default = _interopDefault(React);
|
11 | require('./_commonjsHelpers-72d386ba.js');
|
12 | var index = require('./index-b0606964.js');
|
13 | require('./defineProperty-0921a47c.js');
|
14 | require('./toConsumableArray-d8a4a2c3.js');
|
15 | var _styled = require('styled-components');
|
16 | var _styled__default = _interopDefault(_styled);
|
17 | require('./getPrototypeOf-2a661a20.js');
|
18 | require('./color.js');
|
19 | require('./components.js');
|
20 | require('./contains-component.js');
|
21 | require('./css.js');
|
22 | require('./dayjs.min-e07657bf.js');
|
23 | require('./date.js');
|
24 | require('./miscellaneous.js');
|
25 | require('./environment.js');
|
26 | require('./font.js');
|
27 | require('./math-f4029164.js');
|
28 | require('./characters.js');
|
29 | require('./format.js');
|
30 | require('./keycodes.js');
|
31 | require('./url.js');
|
32 | require('./web3.js');
|
33 | var constants = require('./constants.js');
|
34 | require('./breakpoints.js');
|
35 | require('./springs.js');
|
36 | var textStyles = require('./text-styles.js');
|
37 | require('./theme-dark.js');
|
38 | require('./theme-light.js');
|
39 | var Theme = require('./Theme.js');
|
40 | var _extends$1 = require('./extends-40571110.js');
|
41 | var objectWithoutProperties = require('./objectWithoutProperties-35db8ab0.js');
|
42 |
|
43 | function 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 |
|
79 | var _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 |
|
94 | var _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 |
|
105 | function 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();
|
116 |
|
117 | var modeStyles = React.useMemo(function () {
|
118 | var styles = getModeStyles(theme, mode);
|
119 | return styles;
|
120 | }, [mode, theme]);
|
121 | return 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 && React__default.createElement(_StyledH, {
|
128 | _css6: titleColor || modeStyles.titleColor,
|
129 | _css7: textStyles.textStyle('label2'),
|
130 | _css8: 1 * constants.GU
|
131 | }, title), children);
|
132 | }
|
133 |
|
134 | Info.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 | };
|
143 |
|
144 | function Warning(props) {
|
145 | return React__default.createElement(Info, _extends$1._extends({
|
146 | mode: "warning"
|
147 | }, props));
|
148 | }
|
149 |
|
150 | Info.Action = Info;
|
151 | Info.Permissions = Warning;
|
152 | Info.Alert = Warning;
|
153 |
|
154 | exports.default = Info;
|
155 |
|