-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.js
173 lines (155 loc) · 5.44 KB
/
button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ButtonGroup = exports.OutlineButton = exports.DangerButton = exports.TertiaryButton = exports.SecondaryButton = exports.PrimaryButton = exports.DefaultButton = undefined;
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; };
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
require("./styles/button.css");
var _counter = require("./counter");
var _counter2 = _interopRequireDefault(_counter);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
var Button = function Button(_ref) {
var type = _ref.type,
text = _ref.text,
_ref$disabled = _ref.disabled,
disabled = _ref$disabled === undefined ? false : _ref$disabled,
count = _ref.count,
small = _ref.small,
_ref$groupItem = _ref.groupItem,
groupItem = _ref$groupItem === undefined ? false : _ref$groupItem,
rest = _objectWithoutProperties(_ref, ["type", "text", "disabled", "count", "small", "groupItem"]);
var smallClass = small ? "btn-sm" : "";
var disabledClass = disabled ? "disabled" : "";
var groupItemClass = groupItem ? "BtnGroup-item" : "";
return _react2.default.createElement(
"button",
_extends({
className: "btn " + type + " " + smallClass + " " + disabledClass + " " + groupItemClass
}, rest),
text,
!!count && _react2.default.createElement(_counter2.default, { count: count })
);
};
var DefaultButton = exports.DefaultButton = function DefaultButton(_ref2) {
var text = _ref2.text,
disabled = _ref2.disabled,
count = _ref2.count,
small = _ref2.small,
groupItem = _ref2.groupItem,
onClick = _ref2.onClick;
return _react2.default.createElement(Button, {
onClick: onClick,
text: text,
disabled: disabled,
count: count,
small: small,
groupItem: groupItem
});
};
var PrimaryButton = exports.PrimaryButton = function PrimaryButton(_ref3) {
var text = _ref3.text,
disabled = _ref3.disabled,
count = _ref3.count,
small = _ref3.small,
groupItem = _ref3.groupItem,
onClick = _ref3.onClick;
return _react2.default.createElement(Button, {
onClick: onClick,
text: text,
type: "btn-primary",
disabled: disabled,
count: count,
small: small,
groupItem: groupItem
});
};
var SecondaryButton = exports.SecondaryButton = function SecondaryButton(_ref4) {
var text = _ref4.text,
disabled = _ref4.disabled,
count = _ref4.count,
small = _ref4.small,
groupItem = _ref4.groupItem,
onClick = _ref4.onClick;
return _react2.default.createElement(Button, {
onClick: onClick,
text: text,
type: "btn-purple",
disabled: disabled,
count: count,
small: small,
groupItem: groupItem
});
};
var TertiaryButton = exports.TertiaryButton = function TertiaryButton(_ref5) {
var text = _ref5.text,
disabled = _ref5.disabled,
count = _ref5.count,
small = _ref5.small,
groupItem = _ref5.groupItem,
onClick = _ref5.onClick;
return _react2.default.createElement(Button, {
onClick: onClick,
text: text,
type: "btn-blue",
disabled: disabled,
count: count,
small: small,
groupItem: groupItem
});
};
var DangerButton = exports.DangerButton = function DangerButton(_ref6) {
var text = _ref6.text,
disabled = _ref6.disabled,
count = _ref6.count,
small = _ref6.small,
groupItem = _ref6.groupItem,
onClick = _ref6.onClick;
return _react2.default.createElement(Button, {
onClick: onClick,
text: text,
type: "btn-danger",
disabled: disabled,
count: count,
small: small,
groupItem: groupItem
});
};
var OutlineButton = exports.OutlineButton = function OutlineButton(_ref7) {
var text = _ref7.text,
disabled = _ref7.disabled,
count = _ref7.count,
small = _ref7.small,
groupItem = _ref7.groupItem,
onClick = _ref7.onClick;
return _react2.default.createElement(Button, {
onClick: onClick,
text: text,
type: "btn-outline",
disabled: disabled,
count: count,
small: small,
groupItem: groupItem
});
};
var ButtonGroup = exports.ButtonGroup = function ButtonGroup(_ref8) {
var children = _ref8.children;
return _react2.default.createElement(
"div",
{ className: "BtnGroup" },
_react2.default.Children.map(children, function (child) {
return _react2.default.cloneElement(child, { groupItem: true });
})
);
};
exports.default = {
Default: DefaultButton,
Primary: PrimaryButton,
Secondary: SecondaryButton,
Tertiary: TertiaryButton,
Danger: DangerButton,
Outline: OutlineButton,
Group: ButtonGroup
};