UNPKG

11.5 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _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
9var _templateObject = _taggedTemplateLiteral(['\n ', ' {\n text-decoration: none;\n display: block;\n text-align: center;\n cursor: pointer;\n border: none;\n height: 40px;\n padding: 0 14px;\n border-radius: 5px;\n -webkit-box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.15);\n -moz-box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.15);\n box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.15);\n font-size: 18px;\n line-height: 37px;\n -webkit-transition-property: background-color;\n -webkit-transition-duration: 0.2s;\n -webkit-transition-timing-function: linear;\n -moz-transition-property: background-color;\n -moz-transition-duration: 0.2s;\n -moz-transition-timing-function: linear;\n -ms-transition-property: background-color;\n -ms-transition-duration: 0.2s;\n -ms-transition-timing-function: linear;\n -o-transition-property: background-color;\n -o-transition-duration: 0.2s;\n -o-transition-timing-function: linear;\n transition-property: background-color;\n transition-duration: 0.2s;\n transition-timing-function: linear;\n background: #fafafa;\n color: #222;\n\n i {\n line-height: 37px;\n }\n &:active,\n &:active i {\n line-height: 40px;\n transform: translateY(2px);\n }\n ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' span {\n pointer-events: none;\n }\n &:hover {\n text-decoration: none;\n }\n &:focus {\n text-decoration: none;\n outline: none;\n }\n &:active {\n -webkit-box-shadow: none !important;\n -moz-box-shadow: none !important;\n box-shadow: none !important;\n }\n\n ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' &:disabled {\n background: #606263;\n color: #9ea1a3;\n }\n }\n'], ['\n ', ' {\n text-decoration: none;\n display: block;\n text-align: center;\n cursor: pointer;\n border: none;\n height: 40px;\n padding: 0 14px;\n border-radius: 5px;\n -webkit-box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.15);\n -moz-box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.15);\n box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.15);\n font-size: 18px;\n line-height: 37px;\n -webkit-transition-property: background-color;\n -webkit-transition-duration: 0.2s;\n -webkit-transition-timing-function: linear;\n -moz-transition-property: background-color;\n -moz-transition-duration: 0.2s;\n -moz-transition-timing-function: linear;\n -ms-transition-property: background-color;\n -ms-transition-duration: 0.2s;\n -ms-transition-timing-function: linear;\n -o-transition-property: background-color;\n -o-transition-duration: 0.2s;\n -o-transition-timing-function: linear;\n transition-property: background-color;\n transition-duration: 0.2s;\n transition-timing-function: linear;\n background: #fafafa;\n color: #222;\n\n i {\n line-height: 37px;\n }\n &:active,\n &:active i {\n line-height: 40px;\n transform: translateY(2px);\n }\n ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' span {\n pointer-events: none;\n }\n &:hover {\n text-decoration: none;\n }\n &:focus {\n text-decoration: none;\n outline: none;\n }\n &:active {\n -webkit-box-shadow: none !important;\n -moz-box-shadow: none !important;\n box-shadow: none !important;\n }\n\n ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' &:disabled {\n background: #606263;\n color: #9ea1a3;\n }\n }\n']);
10
11var _react = require('react');
12
13var _react2 = _interopRequireDefault(_react);
14
15var _propTypes = require('prop-types');
16
17var _propTypes2 = _interopRequireDefault(_propTypes);
18
19var _styledComponents = require('styled-components');
20
21var _styledComponents2 = _interopRequireDefault(_styledComponents);
22
23function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
25function _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; }
26
27function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } /* Buttons pen from https://codepen.io/valentin/pen/kahKl */
28
29
30var ButtonStyled = _styledComponents2.default.div(_templateObject, function (props) {
31 return props.buttonLink ? 'a' : 'button';
32}, function (props) {
33 return (props.primary || props.info || props.success || props.warning || props.danger || props.inverse) && '\n -webkit-box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.2);\n -moz-box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.2);\n box-shadow: inset 0 -3px 0 0 rgba(0, 0, 0, 0.2);\n ';
34}, function (props) {
35 return props.primary && '\n background: #0088cc;\n color: #fafafa;\n ';
36}, function (props) {
37 return props.primary && '\n &:hover,\n &:focus {\n background: #006da3;\n color: #fafafa;\n }\n ';
38}, function (props) {
39 return props.info && '\n background: #49afcd;\n color: #fafafa;\n ';
40}, function (props) {
41 return props.info && '\n &:hover,\n &:focus {\n background: #339bba;\n color: #fafafa;\n }\n ';
42}, function (props) {
43 return props.success && '\n background: #5bb75b;\n color: #fafafa;\n ';
44}, function (props) {
45 return props.success && '\n &:hover,\n &:focus {\n background: #47a247;\n color: #fafafa;\n }\n ';
46}, function (props) {
47 return props.warning && '\n background: #faa732;\n color: #fafafa;\n ';
48}, function (props) {
49 return props.warning && '\n &:hover,\n &:focus {\n background: #f9960a;\n color: #fafafa;\n }\n ';
50}, function (props) {
51 return props.danger && '\n background: #da4f49;\n color: #fafafa;\n ';
52}, function (props) {
53 return props.danger && '\n &:hover,\n &:focus {\n background: #d0312a;\n color: #fafafa;\n }\n ';
54}, function (props) {
55 return props.inverse && '\n background: #363636;\n color: #fafafa;\n ';
56}, function (props) {
57 return props.inverse && '\n &:hover,\n &:focus {\n background: #222222;\n color: #fafafa;\n }\n ';
58}, function (props) {
59 return props.small && '\n height: 30px;\n padding: 0 10px;\n border-radius: 4px;\n -webkit-box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, 0.15);\n -moz-box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, 0.15);\n box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 28px;\n i {\n line-height: 28px;\n }\n ';
60}, function (props) {
61 return props.small && '\n &:active,\n &:active i {\n line-height: 30px;\n }\n ';
62}, function (props) {
63 return props.small && (props.primary || props.info || props.success || props.warning || props.danger || props.inverse) && '\n -webkit-box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, 0.2);\n -moz-box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, 0.2);\n box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, 0.2);\n ';
64}, function (props) {
65 return props.large && '\n height: 50px;\n padding: 0 18px;\n border-radius: 6px;\n -webkit-box-shadow: inset 0 -4px 0 0 rgba(0, 0, 0, 0.15);\n -moz-box-shadow: inset 0 -4px 0 0 rgba(0, 0, 0, 0.15);\n box-shadow: inset 0 -4px 0 0 rgba(0, 0, 0, 0.15);\n font-size: 22px;\n line-height: 46px;\n i {\n line-height: 46px;\n }\n ';
66}, function (props) {
67 return props.large && '\n &:active,\n &:active i {\n line-height: 50px;\n }\n ';
68}, function (props) {
69 return props.large && (props.primary || props.info || props.success || props.warning || props.danger || props.inverse) && '\n -webkit-box-shadow: inset 0 -4px 0 0 rgba(0, 0, 0, 0.2);\n -moz-box-shadow: inset 0 -4px 0 0 rgba(0, 0, 0, 0.2);\n box-shadow: inset 0 -4px 0 0 rgba(0, 0, 0, 0.2);\n ';
70}, function (props) {
71 return props.xlarge && '\n height: 60px;\n padding: 0 22px;\n border-radius: 7px;\n -webkit-box-shadow: inset 0 -5px 0 0 rgba(0, 0, 0, 0.15);\n -moz-box-shadow: inset 0 -5px 0 0 rgba(0, 0, 0, 0.15);\n box-shadow: inset 0 -5px 0 0 rgba(0, 0, 0, 0.15);\n font-size: 26px;\n line-height: 55px;\n i {\n line-height: 55px;\n }\n ';
72}, function (props) {
73 return props.xlarge && '\n &:active,\n &:active i {\n line-height: 60px;\n }\n ';
74}, function (props) {
75 return props.xlarge && (props.primary || props.info || props.success || props.warning || props.danger || props.inverse) && '\n -webkit-box-shadow: inset 0 -5px 0 0 rgba(0, 0, 0, 0.2);\n -moz-box-shadow: inset 0 -5px 0 0 rgba(0, 0, 0, 0.2);\n box-shadow: inset 0 -5px 0 0 rgba(0, 0, 0, 0.2);\n ';
76}, function (props) {
77 return props.inline && '\n display: inline-block;\n vertical-align: middle;\n ';
78});
79
80var Button = function Button(_ref) {
81 var children = _ref.children,
82 primary = _ref.primary,
83 info = _ref.info,
84 success = _ref.success,
85 warning = _ref.warning,
86 danger = _ref.danger,
87 inverse = _ref.inverse,
88 inline = _ref.inline,
89 small = _ref.small,
90 large = _ref.large,
91 xlarge = _ref.xlarge,
92 buttonLink = _ref.buttonLink,
93 props = _objectWithoutProperties(_ref, ['children', 'primary', 'info', 'success', 'warning', 'danger', 'inverse', 'inline', 'small', 'large', 'xlarge', 'buttonLink']);
94
95 return _react2.default.createElement(
96 ButtonStyled,
97 {
98 primary: primary,
99 info: info,
100 success: success,
101 warning: warning,
102 danger: danger,
103 inverse: inverse,
104 inline: inline,
105 small: small,
106 large: large,
107 xlarge: xlarge,
108 buttonLink: buttonLink
109 },
110 buttonLink ? _react2.default.createElement(
111 'a',
112 _extends({ href: '#' }, props),
113 children
114 ) : _react2.default.createElement(
115 'button',
116 props,
117 children
118 )
119 );
120};
121
122Button.defaultProps = {
123 children: '',
124 primary: false,
125 info: false,
126 success: false,
127 warning: false,
128 danger: false,
129 inverse: false,
130 inline: false,
131 small: false,
132 large: false,
133 xlarge: false,
134 buttonLink: false
135};
136
137Button.propTypes = {
138 children: _propTypes2.default.node.isRequired,
139 primary: _propTypes2.default.bool,
140 info: _propTypes2.default.bool,
141 success: _propTypes2.default.bool,
142 warning: _propTypes2.default.bool,
143 danger: _propTypes2.default.bool,
144 inverse: _propTypes2.default.bool,
145 inline: _propTypes2.default.bool,
146 small: _propTypes2.default.bool,
147 large: _propTypes2.default.bool,
148 xlarge: _propTypes2.default.bool,
149 buttonLink: _propTypes2.default.bool
150};
151
152exports.default = Button;
\No newline at end of file