UNPKG

3.42 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = void 0;
9
10var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectWithoutProperties"));
15
16var _react = _interopRequireDefault(require("react"));
17
18var _reactRouterDom = require("react-router-dom");
19
20var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
21
22var _styles = require("@material-ui/core/styles");
23
24var _propTypes = _interopRequireDefault(require("prop-types"));
25
26/* eslint-disable import/no-extraneous-dependencies */
27// flow-disable-next-line
28// flow-disable-next-line
29var styles = {
30 link: {
31 textDecoration: 'none',
32 color: '#ddd',
33 '&:hover': {
34 color: '#ccc'
35 }
36 },
37 container: {
38 textAlign: 'center'
39 },
40 icon: {
41 width: 100,
42 height: 100
43 }
44};
45
46var Inner = function Inner(_ref) {
47 var classes = _ref.classes,
48 label = _ref.label,
49 Icon = _ref.icon;
50 return _react.default.createElement("div", {
51 className: classes.container
52 }, _react.default.createElement(Icon, {
53 className: classes.icon
54 }), _react.default.createElement("br", null), _react.default.createElement(_Button.default, {
55 color: "primary",
56 variant: "raised"
57 }, label));
58};
59
60Inner.propTypes = {
61 classes: _propTypes.default.object.isRequired,
62 label: _propTypes.default.string.isRequired,
63 icon: _propTypes.default.func.isRequired
64};
65
66var HeroButtonJSX = function HeroButtonJSX(_ref2) {
67 var classes = _ref2.classes,
68 dest = _ref2.dest,
69 newTab = _ref2.newTab,
70 hardLink = _ref2.hardLink,
71 icon = _ref2.icon,
72 label = _ref2.label,
73 rest = (0, _objectWithoutProperties2.default)(_ref2, ["classes", "dest", "newTab", "hardLink", "icon", "label"]);
74
75 if (newTab || hardLink) {
76 var aProps = {
77 href: dest,
78 className: classes.link
79 };
80
81 if (newTab) {
82 aProps.target = '_blank';
83 }
84
85 return _react.default.createElement("a", (0, _extends2.default)({}, rest, aProps), _react.default.createElement(Inner, {
86 icon: icon,
87 label: label,
88 classes: classes
89 }));
90 }
91
92 return _react.default.createElement(_reactRouterDom.Link, (0, _extends2.default)({}, rest, {
93 to: dest,
94 className: classes.link
95 }), _react.default.createElement(Inner, {
96 icon: icon,
97 label: label,
98 classes: classes
99 }));
100};
101
102HeroButtonJSX.propTypes = (0, _defineProperty2.default)({
103 dest: function dest(props, propName, componentName) {
104 if (!Object.prototype.hasOwnProperty.call(props, propName)) {
105 throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value."));
106 }
107 },
108 hardLink: _propTypes.default.bool,
109 newTab: _propTypes.default.bool,
110 icon: _propTypes.default.func.isRequired,
111 label: _propTypes.default.string.isRequired,
112 classes: _propTypes.default.object.isRequired
113}, "label", _propTypes.default.string.isRequired);
114var HeroButton = (0, _styles.withStyles)(styles)(HeroButtonJSX);
115var _default = HeroButton;
116exports.default = _default;
\No newline at end of file