auto-component 0.1.0 → 0.1.1

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.
@@ -56,7 +56,7 @@
56
56
  }
57
57
  #auto-component-tabs {
58
58
  position: fixed;
59
- bottom: 68px;
59
+ bottom: 70px;
60
60
  left: 50%;
61
61
  transform: translateX(-50%);
62
62
  display: flex;
@@ -70,7 +70,7 @@
70
70
  .tab {
71
71
  width: 30%;
72
72
  margin: 0 10%;
73
- padding: 4px 0;
73
+ padding: 6px 0;
74
74
  background: #c6c7d3 !important;
75
75
  color: #fff !important;
76
76
  border-radius: 0 0 5px 5px;
@@ -83,24 +83,24 @@
83
83
  .auto-component-selected {
84
84
  background: #444 !important;
85
85
  color: #aaa !important;
86
- font-size: 1.2rem;
86
+ font-weight: bold;
87
87
  }
88
88
  #auto-component-code-container {
89
89
  position: fixed;
90
90
  bottom: 180px;
91
91
  left: 50%;
92
92
  transform: translateX(-50%);
93
+ overflow: hidden;
93
94
  width: 80%;
94
95
  max-width: 900px;
95
- max-height: 300px;
96
- height: 300px;
96
+ max-height: 400px;
97
97
  }
98
98
 
99
99
  #auto-component-code {
100
- width: 100%;
100
+ margin: 0;
101
+ padding: 0;
101
102
  max-width: 900px;
102
103
  max-height: 300px;
103
- height: 300px;
104
104
  text-align: left;
105
105
  background: #cdd1d9;
106
106
  color: #111;
@@ -115,8 +115,8 @@
115
115
  }
116
116
  .auto-component-copy {
117
117
  position: absolute;
118
- top: 2px;
119
- right: 2px;
118
+ top: 0;
119
+ right: 0;
120
120
  display: flex;
121
121
  justify-content: center;
122
122
  align-items: center;
@@ -136,4 +136,57 @@
136
136
  }
137
137
  .auto-component-hidden {
138
138
  display: none;
139
- }
139
+ }
140
+
141
+ .placeholder-top-left {
142
+ position: relative;
143
+ top: 0;
144
+ left: 0;
145
+ padding: 10px;
146
+ }
147
+
148
+ .auto-component-placeholder {
149
+ display: flex;
150
+ flex-direction: column;
151
+ justify-content: space-between;
152
+ height: 100%;
153
+ width: 100%;
154
+ min-height: 150px;
155
+ background-size: 40px 40px;
156
+ background-image: repeating-linear-gradient(
157
+ 45deg, /* Change angle to horizontal */
158
+ rgba(255, 255, 255, 0.15) 0px,
159
+ rgba(76, 126, 97, 0.459) 1px,
160
+ transparent 3px,
161
+ transparent 14px
162
+ );
163
+ position: relative;
164
+ }
165
+
166
+ .auto-component-placeholder.animate {
167
+ animation: slide 1s linear infinite;
168
+ }
169
+
170
+ .loading-indicator {
171
+ border: 4px solid #f3f3f3; /* Light grey */
172
+ border-top: 4px solid #3498db; /* Blue */
173
+ border-radius: 50%;
174
+ width: 20px;
175
+ height: 20px;
176
+ animation: spin 2s linear infinite;
177
+ }
178
+
179
+ @keyframes spin {
180
+ 0% { transform: rotate(0deg); }
181
+ 100% { transform: rotate(360deg); }
182
+ }
183
+
184
+
185
+ @keyframes slide {
186
+ from {
187
+ background-position: -40px 0; /* Start moving from the left */
188
+ }
189
+ to {
190
+ background-position: 40px 0; /* Move to the right */
191
+ }
192
+ }
package/lib/index.js CHANGED
@@ -61,6 +61,10 @@ var AutoComponent = function AutoComponent() {
61
61
  _useState16 = _slicedToArray(_useState15, 2),
62
62
  history = _useState16[0],
63
63
  setHistory = _useState16[1];
64
+ var _useState17 = (0, _react.useState)(false),
65
+ _useState18 = _slicedToArray(_useState17, 2),
66
+ isRequesting = _useState18[0],
67
+ setIsRequesting = _useState18[1];
64
68
 
65
69
  //**-------------------------**/
66
70
  // ** HTML/CSS Formatting ** //
@@ -158,9 +162,10 @@ var AutoComponent = function AutoComponent() {
158
162
  return _regeneratorRuntime().wrap(function _callee$(_context) {
159
163
  while (1) switch (_context.prev = _context.next) {
160
164
  case 0:
165
+ setIsRequesting(true);
161
166
  url = "https://server-auto-component-46830ff262f8.herokuapp.com/api";
162
- _context.prev = 1;
163
- _context.next = 4;
167
+ _context.prev = 2;
168
+ _context.next = 5;
164
169
  return fetch(url, {
165
170
  method: 'POST',
166
171
  headers: {
@@ -168,31 +173,33 @@ var AutoComponent = function AutoComponent() {
168
173
  },
169
174
  body: JSON.stringify(requestData)
170
175
  });
171
- case 4:
176
+ case 5:
172
177
  res = _context.sent;
173
178
  if (!res.ok) {
174
- _context.next = 12;
179
+ _context.next = 13;
175
180
  break;
176
181
  }
177
- _context.next = 8;
182
+ _context.next = 9;
178
183
  return res.json();
179
- case 8:
184
+ case 9:
180
185
  jsonData = _context.sent;
181
186
  return _context.abrupt("return", jsonData);
182
- case 12:
183
- throw new Error("Invalid request!");
184
187
  case 13:
185
- _context.next = 18;
188
+ throw new Error("Invalid request!");
189
+ case 14:
190
+ _context.next = 19;
186
191
  break;
187
- case 15:
188
- _context.prev = 15;
189
- _context.t0 = _context["catch"](1);
192
+ case 16:
193
+ _context.prev = 16;
194
+ _context.t0 = _context["catch"](2);
190
195
  console.log(_context.t0.message);
191
- case 18:
196
+ case 19:
197
+ setIsRequesting(false);
198
+ case 20:
192
199
  case "end":
193
200
  return _context.stop();
194
201
  }
195
- }, _callee, null, [[1, 15]]);
202
+ }, _callee, null, [[2, 16]]);
196
203
  }));
197
204
  return function sendRequest() {
198
205
  return _ref.apply(this, arguments);
@@ -223,10 +230,14 @@ var AutoComponent = function AutoComponent() {
223
230
  _context2.t0 = _context2["catch"](0);
224
231
  console.log(_context2.t0);
225
232
  case 10:
233
+ _context2.prev = 10;
234
+ setIsRequesting(false); // Set isRequesting to false after processing response
235
+ return _context2.finish(10);
236
+ case 13:
226
237
  case "end":
227
238
  return _context2.stop();
228
239
  }
229
- }, _callee2, null, [[0, 7]]);
240
+ }, _callee2, null, [[0, 7, 10, 13]]);
230
241
  }));
231
242
  return function handleRequest() {
232
243
  return _ref2.apply(this, arguments);
@@ -249,8 +260,7 @@ var AutoComponent = function AutoComponent() {
249
260
  _context3.next = 2;
250
261
  return setRequestData({
251
262
  "userId": user,
252
- "request": currentRequest,
253
- "html": currentHtml
263
+ "request": currentRequest
254
264
  });
255
265
  case 2:
256
266
  setRequest('');
@@ -274,6 +284,7 @@ var AutoComponent = function AutoComponent() {
274
284
  setResponseData('');
275
285
  randomUser();
276
286
  setHistory([]);
287
+ setIsRequesting(false);
277
288
  };
278
289
  var handleRequestTab = /*#__PURE__*/function () {
279
290
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
@@ -341,7 +352,7 @@ var AutoComponent = function AutoComponent() {
341
352
  };
342
353
 
343
354
  // build request tab content
344
- var requestHTML = currentHtml ? getLog() && getLog().join('') + "Review the details below for accuracy and privacy concerns.\n\nIf the contents of an element should be excluded, add the 'exclude' class to the element.\n\nClick Generate to send a request and receive the auto component AI generated code.\n\nUser ID:\n" + user + "\n\nUser Request:\n" + currentRequest + "\n\nUser HTML:\n" + currentHtml : 'There was an error collecting your HTML. Ensure no top level elements are assigned the class "exclude"';
355
+ var requestHTML = currentHtml ? getLog() && getLog().join('') + "Click Generate to send a request and receive the auto component AI generated code.\n\nUser ID:\n" + user + "\n\nUser Request:\n" + currentRequest + "\n\nUser HTML:\n" + currentHtml : 'There was an error collecting your HTML. Ensure no top level elements are assigned the class "exclude"';
345
356
  var responseHtml = responseData ? responseData : 'No response has been generated';
346
357
  var handleKeyDown = function handleKeyDown(e) {
347
358
  if (e.key === 'Enter') {
@@ -356,9 +367,13 @@ var AutoComponent = function AutoComponent() {
356
367
 
357
368
  return /*#__PURE__*/_react["default"].createElement("div", {
358
369
  className: "auto-component exclude"
359
- }, /*#__PURE__*/_react["default"].createElement("div", null, responseData ? /*#__PURE__*/_react["default"].createElement(_reactJsxParser["default"], {
370
+ }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
371
+ className: "placeholder-top-left"
372
+ }, "auto-component"), /*#__PURE__*/_react["default"].createElement("hr", null), responseData ? /*#__PURE__*/_react["default"].createElement(_reactJsxParser["default"], {
360
373
  jsx: responseData
361
- }) : '- auto component will be added here -'), /*#__PURE__*/_react["default"].createElement("div", {
374
+ }) : /*#__PURE__*/_react["default"].createElement("div", {
375
+ className: "auto-component-placeholder ".concat(isRequesting ? 'animate' : '')
376
+ }), /*#__PURE__*/_react["default"].createElement("hr", null)), /*#__PURE__*/_react["default"].createElement("div", {
362
377
  id: "auto-component-ui"
363
378
  }, /*#__PURE__*/_react["default"].createElement("div", {
364
379
  id: "auto-component-code-container",
@@ -373,7 +388,9 @@ var AutoComponent = function AutoComponent() {
373
388
  } : null
374
389
  }, "copy")), /*#__PURE__*/_react["default"].createElement("div", {
375
390
  id: "auto-component-entry"
376
- }, /*#__PURE__*/_react["default"].createElement("input", {
391
+ }, isRequesting ? /*#__PURE__*/_react["default"].createElement("div", {
392
+ className: "loading-indicator"
393
+ }) : /*#__PURE__*/_react["default"].createElement("input", {
377
394
  type: "text",
378
395
  value: currentRequest,
379
396
  onChange: handleChange,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-component",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "lib/index.js",
5
5
  "peerDependencies": {
6
6
  "react": "^18.2.0",