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 | var slicedToArray = require('./slicedToArray-ef426d0f.js');
|
8 | require('./unsupportedIterableToArray-8a00e599.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-7f36359f.js');
|
15 | var _styled = require('styled-components');
|
16 | var _styled__default = _interopDefault(_styled);
|
17 | require('./getPrototypeOf-e2d1e599.js');
|
18 | require('./color.js');
|
19 | require('./components.js');
|
20 | require('./contains-component.js');
|
21 | require('./css.js');
|
22 | require('./dayjs.min-aa59a48e.js');
|
23 | require('./date.js');
|
24 | require('./miscellaneous.js');
|
25 | require('./environment.js');
|
26 | require('./font.js');
|
27 | require('./math-ecfd5d91.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 | 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 | var index$1 = require('./index-ecc57c9f.js');
|
43 | require('./FocusVisible.js');
|
44 | var ButtonBase = require('./ButtonBase.js');
|
45 |
|
46 | var DEFAULT_WIDTH = 35 * constants.GU;
|
47 | var DEFAULT_HEIGHT = 40 * constants.GU;
|
48 |
|
49 | function dimension(insideCardLayout, value, defaultValue) {
|
50 | if (insideCardLayout) {
|
51 | return '100%';
|
52 | }
|
53 |
|
54 | if (typeof value === 'number') {
|
55 | value = "".concat(value, "px");
|
56 | }
|
57 |
|
58 | return value === undefined ? defaultValue : value;
|
59 | }
|
60 |
|
61 | var _StyledDiv = _styled__default("div").withConfig({
|
62 | displayName: "Card___StyledDiv",
|
63 | componentId: "sc-13r75gj-0"
|
64 | })(["position:relative;width:", ";height:", ";background:", ";border:1px solid ", ";border-radius:", "px;cursor:", ";display:flex;flex-direction:column;align-items:center;justify-content:center;", ""], function (p) {
|
65 | return p._css;
|
66 | }, function (p) {
|
67 | return p._css2;
|
68 | }, function (p) {
|
69 | return p._css3;
|
70 | }, function (p) {
|
71 | return p._css4;
|
72 | }, constants.RADIUS, function (p) {
|
73 | return p._css5;
|
74 | }, function (p) {
|
75 | return p._css6;
|
76 | });
|
77 |
|
78 | function Card(_ref) {
|
79 | var children = _ref.children,
|
80 | width = _ref.width,
|
81 | height = _ref.height,
|
82 | onClick = _ref.onClick,
|
83 | props = objectWithoutProperties._objectWithoutProperties(_ref, ["children", "width", "height", "onClick"]);
|
84 |
|
85 | var theme = Theme.useTheme();
|
86 |
|
87 | var _useInside = index$1.o('CardLayout'),
|
88 | _useInside2 = slicedToArray._slicedToArray(_useInside, 1),
|
89 | insideCardLayout = _useInside2[0];
|
90 |
|
91 | var interactive = Boolean(onClick);
|
92 | var interactiveProps = interactive ? {
|
93 | as: ButtonBase.default,
|
94 | element: 'div',
|
95 | focusRingRadius: constants.RADIUS,
|
96 | onClick: onClick
|
97 | } : {};
|
98 | var cssWidth = dimension(insideCardLayout, width, "".concat(DEFAULT_WIDTH, "px"));
|
99 | var cssHeight = dimension(insideCardLayout, height, "".concat(DEFAULT_HEIGHT, "px"));
|
100 | return React__default.createElement(_StyledDiv, _extends$1._extends({}, interactiveProps, props, {
|
101 | _css: cssWidth,
|
102 | _css2: cssHeight,
|
103 | _css3: theme.surface,
|
104 | _css4: theme.border,
|
105 | _css5: interactive ? 'pointer' : 'default',
|
106 | _css6: interactive && _styled.css(["border:0;box-shadow:0px 1px 3px rgba(0,0,0,0.15);transition-property:transform,box-shadow;transition-duration:50ms;transition-timing-function:ease-in-out;text-align:left;white-space:normal;&:active{transform:translateY(1px);box-shadow:0px 1px 3px rgba(0,0,0,0.08);}"])
|
107 | }), children);
|
108 | }
|
109 |
|
110 | Card.propTypes = {
|
111 | children: index.PropTypes.node,
|
112 | height: index.PropTypes.oneOfType([index.PropTypes.string, index.PropTypes.number]),
|
113 | width: index.PropTypes.oneOfType([index.PropTypes.string, index.PropTypes.number]),
|
114 | onClick: index.PropTypes.func
|
115 | };
|
116 |
|
117 | exports.default = Card;
|
118 |
|