1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
8 |
|
9 | var _templateObject = _taggedTemplateLiteral(['\n font-size: 0.875em;\n display: inline-block;\n height: 2.5rem;\n padding: ', ';\n width: ', ';\n border: 0;\n border-radius: 3px;\n box-shadow: 0px 2px 0px 0px rgba(0,0,0,0.16);\n cursor: pointer;\n transition: background 0.2s ease-in, color 0.2s ease-in;\n font-family: ', ';\n\n ', '\n'], ['\n font-size: 0.875em;\n display: inline-block;\n height: 2.5rem;\n padding: ', ';\n width: ', ';\n border: 0;\n border-radius: 3px;\n box-shadow: 0px 2px 0px 0px rgba(0,0,0,0.16);\n cursor: pointer;\n transition: background 0.2s ease-in, color 0.2s ease-in;\n font-family: ', ';\n\n ', '\n']),
|
10 | _templateObject2 = _taggedTemplateLiteral(['\n height: 3.75em;\n font-size: 1em;\n width: ', ';\n '], ['\n height: 3.75em;\n font-size: 1em;\n width: ', ';\n ']),
|
11 | _templateObject3 = _taggedTemplateLiteral(['\n width: 100%;\n height: 100%;\n display: inline-flex;\n justify-content: ', ';\n align-items: center;\n\n > span {\n font-size: 1.25em;\n line-height: 1.25;\n }\n > span ~ .icon { margin-left: 1em }\n > .icon ~ span { margin-left: 1em }\n'], ['\n width: 100%;\n height: 100%;\n display: inline-flex;\n justify-content: ', ';\n align-items: center;\n\n > span {\n font-size: 1.25em;\n line-height: 1.25;\n }\n > span ~ .icon { margin-left: 1em }\n > .icon ~ span { margin-left: 1em }\n']);
|
12 |
|
13 | var _media = require('../library/media');
|
14 |
|
15 | var _media2 = _interopRequireDefault(_media);
|
16 |
|
17 | var _styledComponents = require('styled-components');
|
18 |
|
19 | var _styledComponents2 = _interopRequireDefault(_styledComponents);
|
20 |
|
21 | var _react = require('react');
|
22 |
|
23 | var _react2 = _interopRequireDefault(_react);
|
24 |
|
25 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26 |
|
27 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
28 |
|
29 | function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
30 |
|
31 | var StyledButton = _styledComponents2.default.button(_templateObject, function (props) {
|
32 | return props.square ? '0' : '0 1.5em';
|
33 | }, function (props) {
|
34 | return props.square ? '2.5rem' : 'auto';
|
35 | }, function (props) {
|
36 | return props.theme.font.header;
|
37 | }, _media2.default.medium(_templateObject2, function (props) {
|
38 | return props.square ? '3.75em' : 'auto';
|
39 | }));
|
40 |
|
41 | var Inner = _styledComponents2.default.span(_templateObject3, function (props) {
|
42 | return props.justify;
|
43 | });
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | var BaseButton = function BaseButton(_ref) {
|
52 | var children = _ref.children,
|
53 | justify = _ref.justify,
|
54 | square = _ref.square,
|
55 | other = _objectWithoutProperties(_ref, ['children', 'justify', 'square']);
|
56 |
|
57 | return _react2.default.createElement(
|
58 | StyledButton,
|
59 | _extends({ square: square }, other),
|
60 | _react2.default.createElement(
|
61 | Inner,
|
62 | { justify: justify },
|
63 | _react2.default.Children.map(children, function (Child) {
|
64 | return _react2.default.isValidElement(Child) ? (0, _react.cloneElement)(Child, { height: Child.props.height || '24' }) : _react2.default.createElement(
|
65 | 'span',
|
66 | null,
|
67 | Child
|
68 | );
|
69 | })
|
70 | )
|
71 | );
|
72 | };
|
73 |
|
74 | BaseButton.defaultProps = {
|
75 | justify: 'space-between'
|
76 | };
|
77 |
|
78 | BaseButton.propTypes = {
|
79 | square: _react.PropTypes.bool,
|
80 | justify: _react.PropTypes.string,
|
81 | children: _react.PropTypes.node.isRequired
|
82 | };
|
83 |
|
84 | exports.default = BaseButton; |
\ | No newline at end of file |