@quintoandar-tokko/button 1.2.371

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/lib/index.js +251 -0
  3. package/package.json +24 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 One Loop
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/index.js ADDED
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ButtonIcon = exports.Button = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _badge = require("@quintoandar-tokko/badge");
9
+ var _box = require("@quintoandar-tokko/box");
10
+ var _checkbox = require("@quintoandar-tokko/checkbox");
11
+ var _icons = require("@quintoandar-tokko/icons");
12
+ var _image = require("@quintoandar-tokko/image");
13
+ var _theme = _interopRequireDefault(require("@quintoandar-tokko/theme"));
14
+ require("@quintoandar-tokko/fonts");
15
+ var _excluded = ["variant"],
16
+ _excluded2 = ["icon", "variant", "text", "badgeValue", "badgeVariant", "maxWidth", "srcImage", "userImage", "hasCheckbox", "active", "isCollapsible", "disabled", "holdPress", "hover", "filled", "isExpanded", "widthImage", "heightImage", "setExpand", "testForAction"];
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
18
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
19
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
20
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
21
+ var Button = exports.Button = function Button(_ref) {
22
+ var variant = _ref.variant,
23
+ props = _objectWithoutProperties(_ref, _excluded);
24
+ return /*#__PURE__*/_react["default"].createElement(_box.Box, {
25
+ sx: {
26
+ position: 'relative'
27
+ }
28
+ }, /*#__PURE__*/_react["default"].createElement(_box.Box, _extends({
29
+ as: "button",
30
+ tx: "buttons",
31
+ type: "button",
32
+ variant: variant
33
+ }, props, {
34
+ __css: {
35
+ appearance: 'none',
36
+ display: 'flex',
37
+ lineHeight: 'inherit',
38
+ fontFamily: 'Nunito Sans',
39
+ textAlign: 'center',
40
+ textDecoration: 'none',
41
+ cursor: 'pointer',
42
+ outline: 'none',
43
+ border: 0,
44
+ flexDirection: 'row',
45
+ alignItems: 'center',
46
+ whiteSpace: 'nowrap',
47
+ justifyContent: 'center',
48
+ fontWeight: 'bold',
49
+ borderRadius: '12px'
50
+ }
51
+ })));
52
+ };
53
+ var ButtonIcon = exports.ButtonIcon = function ButtonIcon(_ref2) {
54
+ var icon = _ref2.icon,
55
+ variant = _ref2.variant,
56
+ text = _ref2.text,
57
+ _ref2$badgeValue = _ref2.badgeValue,
58
+ badgeValue = _ref2$badgeValue === void 0 ? 0 : _ref2$badgeValue,
59
+ _ref2$badgeVariant = _ref2.badgeVariant,
60
+ badgeVariant = _ref2$badgeVariant === void 0 ? ['badgeNormal', 'primary'] : _ref2$badgeVariant,
61
+ maxWidth = _ref2.maxWidth,
62
+ srcImage = _ref2.srcImage,
63
+ userImage = _ref2.userImage,
64
+ hasCheckbox = _ref2.hasCheckbox,
65
+ active = _ref2.active,
66
+ isCollapsible = _ref2.isCollapsible,
67
+ disabled = _ref2.disabled,
68
+ holdPress = _ref2.holdPress,
69
+ hover = _ref2.hover,
70
+ filled = _ref2.filled,
71
+ isExpanded = _ref2.isExpanded,
72
+ widthImage = _ref2.widthImage,
73
+ heightImage = _ref2.heightImage,
74
+ setExpand = _ref2.setExpand,
75
+ testForAction = _ref2.testForAction,
76
+ props = _objectWithoutProperties(_ref2, _excluded2);
77
+ var colorValue;
78
+ var colorValueIcon;
79
+ var fontSize;
80
+ var fontWeight;
81
+ var fontSizeIcon;
82
+ if (Array.isArray(variant)) {
83
+ var indexes = variant.map(function (v) {
84
+ return Object.keys(_theme["default"].buttons).indexOf(v);
85
+ });
86
+ indexes.map(function (index) {
87
+ var variantValues = Object.values(_theme["default"].buttons)[index];
88
+ if (variantValues[':focus'] !== undefined && active) {
89
+ colorValue = variantValues[':focus'].color;
90
+ fontWeight = variantValues[':focus'].fontWeight;
91
+ if (variantValues.colorIcon !== undefined) {
92
+ colorValueIcon = variantValues[':focus'].colorIcon;
93
+ }
94
+ }
95
+ if (colorValue === undefined && variantValues.color !== undefined) {
96
+ colorValue = variantValues.color;
97
+ }
98
+ if (colorValueIcon === undefined && variantValues.colorIcon !== undefined) {
99
+ colorValueIcon = variantValues.colorIcon;
100
+ }
101
+ if (fontWeight === undefined && variantValues.fontWeight !== undefined) {
102
+ fontWeight = variantValues.fontWeight;
103
+ }
104
+ if (fontSize === undefined && variantValues.fontSize !== undefined) {
105
+ fontSize = variantValues.fontSize;
106
+ }
107
+ if (filled && colorValueIcon === undefined) {
108
+ colorValueIcon = variantValues.colorFilled;
109
+ }
110
+ if (fontSizeIcon === undefined) {
111
+ fontSizeIcon = variantValues.fontSizeIcon;
112
+ }
113
+ return colorValue;
114
+ });
115
+ } else {
116
+ var index = Object.keys(_theme["default"].buttons).indexOf(variant);
117
+ var variantValues = Object.values(_theme["default"].buttons)[index];
118
+ if (variantValues !== undefined) {
119
+ colorValue = variantValues.color;
120
+ colorValueIcon = variantValues.colorIcon || (filled && colorValueIcon === undefined ? variantValues.colorFilled : variantValues.color);
121
+ fontSize = variantValues.fontSize;
122
+ fontWeight = variantValues.fontWeight;
123
+ if (hover) {
124
+ colorValue = variantValues[':hover'].color;
125
+ colorValueIcon = variantValues[':hover'].colorIcon;
126
+ fontWeight = variantValues[':hover'].fontWeight;
127
+ } else if (active) {
128
+ colorValue = variantValues[':focus'].color;
129
+ colorValueIcon = variantValues[':focus'].colorIcon;
130
+ fontWeight = variantValues[':focus'].fontWeight;
131
+ }
132
+ if (fontSizeIcon === undefined) {
133
+ fontSizeIcon = variantValues.fontSizeIcon;
134
+ }
135
+ }
136
+ }
137
+ if (badgeValue > 99) {
138
+ badgeValue = '+99';
139
+ }
140
+ if (testForAction) {
141
+ console.log('It has a boolean testForAction.');
142
+ }
143
+ return /*#__PURE__*/_react["default"].createElement(_box.Box, {
144
+ sx: maxWidth ? {
145
+ position: 'relative',
146
+ width: '100%'
147
+ } : {
148
+ position: 'relative'
149
+ }
150
+ }, /*#__PURE__*/_react["default"].createElement(_box.Box, _extends({
151
+ as: "button",
152
+ tx: "buttons",
153
+ type: "button",
154
+ variant: variant
155
+ }, props, {
156
+ __css: {
157
+ appearance: 'none',
158
+ display: 'flex',
159
+ lineHeight: 'inherit',
160
+ fontFamily: 'Nunito Sans',
161
+ fontWeight: fontWeight || 'bold',
162
+ textAlign: 'center',
163
+ textDecoration: 'none',
164
+ cursor: 'pointer',
165
+ outline: 'none',
166
+ border: 0,
167
+ flexDirection: 'row',
168
+ justifyContent: !maxWidth && 'center',
169
+ width: maxWidth && '100%',
170
+ alignItems: 'center',
171
+ whiteSpace: 'nowrap',
172
+ position: 'relative'
173
+ }
174
+ }), hasCheckbox && active && /*#__PURE__*/_react["default"].createElement(_checkbox.Checkbox, {
175
+ defaultChecked: true,
176
+ disabled: disabled
177
+ }), hasCheckbox && !active && /*#__PURE__*/_react["default"].createElement(_checkbox.Checkbox, {
178
+ defaultChecked: false,
179
+ disabled: disabled
180
+ }), icon && /*#__PURE__*/_react["default"].createElement(_icons.Icon, {
181
+ icon: icon,
182
+ fontSize: fontSizeIcon || fontSize,
183
+ style: holdPress && {
184
+ color: colorValueIcon || colorValue
185
+ }
186
+ }), !userImage && srcImage && /*#__PURE__*/_react["default"].createElement(_image.Image, {
187
+ src: srcImage,
188
+ style: {
189
+ width: widthImage,
190
+ height: heightImage
191
+ }
192
+ }), userImage && srcImage && /*#__PURE__*/_react["default"].createElement(_image.Image, {
193
+ src: srcImage,
194
+ variant: "avatar"
195
+ }), userImage && !srcImage && /*#__PURE__*/_react["default"].createElement("span", {
196
+ className: "icon-contactos",
197
+ style: {
198
+ fontSize: '24px'
199
+ }
200
+ }), text && !holdPress && /*#__PURE__*/_react["default"].createElement("span", null, text), text && holdPress && /*#__PURE__*/_react["default"].createElement("span", {
201
+ style: colorValue && {
202
+ color: colorValue,
203
+ fontWeight: fontWeight
204
+ }
205
+ }, text), isCollapsible && setExpand === undefined && /*#__PURE__*/_react["default"].createElement("span", {
206
+ className: "icon-dropdown",
207
+ style: {
208
+ position: 'absolute',
209
+ right: '10px',
210
+ color: '#798B97',
211
+ fontSize: '14px',
212
+ transform: isExpanded ? 'rotate(-180deg)' : 'rotate(0deg)',
213
+ transition: 'all 0.5s',
214
+ paddingTop: '4px'
215
+ }
216
+ }), isCollapsible && setExpand !== undefined && /*#__PURE__*/_react["default"].createElement("span", {
217
+ className: "icon-dropdown",
218
+ onClick: function onClick(event) {
219
+ event.preventDefault();
220
+ setExpand();
221
+ event.stopPropagation();
222
+ event.nativeEvent.stopImmediatePropagation();
223
+ },
224
+ style: {
225
+ position: 'absolute',
226
+ right: '10px',
227
+ color: '#798B97',
228
+ fontSize: '14px',
229
+ transform: isExpanded ? 'rotate(-180deg)' : 'rotate(0deg)',
230
+ transition: 'all 0.5s',
231
+ paddingTop: '4px',
232
+ paddingLeft: '1px',
233
+ paddingRight: '1px'
234
+ }
235
+ }), badgeValue !== 0 && !text && /*#__PURE__*/_react["default"].createElement(_badge.Badge, {
236
+ variant: badgeVariant,
237
+ isNotButton: true,
238
+ style: {
239
+ position: 'absolute',
240
+ top: '2px',
241
+ left: '16px'
242
+ }
243
+ }, badgeValue), badgeValue !== 0 && text && /*#__PURE__*/_react["default"].createElement(_badge.Badge, {
244
+ variant: badgeVariant,
245
+ isNotButton: true,
246
+ style: {
247
+ position: 'absolute',
248
+ right: isCollapsible ? '30px' : '10px'
249
+ }
250
+ }, badgeValue)));
251
+ };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@quintoandar-tokko/button",
3
+ "version": "1.2.371",
4
+ "main": "lib/index.js",
5
+ "module": "src/index.js",
6
+ "files": [
7
+ "lib"
8
+ ],
9
+ "dependencies": {
10
+ "@quintoandar-tokko/box": "^1.2.286",
11
+ "@quintoandar-tokko/fonts": "^1.0.135",
12
+ "styled-components": "5.3.5",
13
+ "styled-system": "5.1.5"
14
+ },
15
+ "peerDependencies": {
16
+ "react": "^16.8.0",
17
+ "react-dom": "^16.8.0",
18
+ "styled-components": "^5.3.5"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "gitHead": "d33e426a17c29e62c8ea591ae6afa96300d55ad9"
24
+ }