auto-component 0.0.32 → 0.0.34

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-component",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "main": "src/index.jsx",
5
5
  "peerDependencies": {
6
6
  "react": "^18.2.0",
@@ -1,22 +1,28 @@
1
- #content-creator {
2
- position: relative;
1
+ #auto-component {
3
2
  width: 100%;
4
3
  display: flex;
5
4
  flex-direction: column;
6
5
  align-items: center;
7
- margin: 40px 0;
8
6
  font-family: Arial, Helvetica, sans-serif
9
7
  }
10
- #content-creator div {
11
- width: 100%;
8
+ #auto-component-entry {
9
+ position: fixed;
10
+ bottom: 100px;
11
+ left: 50%;
12
+ transform: translateX(-50%);
13
+ width: 90%;
14
+ max-width: 700px;
12
15
  display: flex;
13
16
  flex-direction: row;
14
17
  justify-content: center;
15
18
  align-items: center;
16
-
19
+ padding: 0 20px;
20
+ background: #222;
21
+ border-radius: 10px;
22
+ border: 2px solid rgb(108, 108, 246);
17
23
  }
18
- #content-creator input {
19
- width: 60%;
24
+ #auto-component input {
25
+ width: 100%;
20
26
  height: 40px;
21
27
  border-radius: 5px;
22
28
  color: #444;
@@ -24,7 +30,7 @@
24
30
  border: 3px solid #ddd;
25
31
  padding-left: 10px;
26
32
  }
27
- #content-creator button {
33
+ #auto-component button {
28
34
  padding: 10px;
29
35
  margin: 20px;
30
36
  background: rgb(184, 230, 184);
@@ -32,29 +38,36 @@
32
38
  border-radius: 5px;
33
39
  box-shadow: 0px 0px 5px #fff;
34
40
  }
35
- #content-creator button:nth-child(3) {
41
+ #auto-component button:nth-child(3) {
36
42
  padding: 10px 20px;
37
43
  margin-left: 0px;
38
44
  margin-right: 0px;
39
45
  background: #db9d9d;
40
46
  }
41
- #content-creator button:hover {
47
+ #auto-component button:hover {
42
48
  background: green;
43
49
  color: #eee;
44
50
  }
45
- #content-creator button:nth-child(3):hover {
51
+ #auto-component button:nth-child(3):hover {
46
52
  background: #dc3c3c;
47
53
  }
48
- #content-creator div:nth-child(2) {
54
+ #auto-component-tabs {
55
+ position: fixed;
56
+ bottom: 68px;
57
+ left: 50%;
58
+ transform: translateX(-50%);
49
59
  display: flex;
50
- flex-direction: column;
60
+ flex-direction: row;
61
+ width: 100%;
62
+ max-width: 700px;
51
63
  }
52
64
  .tab {
65
+ width: 30%;
53
66
  margin: 0 10%;
54
67
  padding: 4px 0;
55
- background: #444;
56
- color: #aaa;
57
- border-radius: 5px 5px 0 0;
68
+ background: #c6c7d3;
69
+ color: #fff;
70
+ border-radius: 0 0 5px 5px;
58
71
  cursor: pointer;
59
72
  }
60
73
  .tab:hover {
@@ -62,17 +75,20 @@
62
75
  color: #eee;
63
76
  }
64
77
  .selected {
65
- background: #c6c7d3;
66
- color: #fff;
78
+ background: #444;
79
+ color: #aaa;
67
80
  font-size: 1.2rem;
68
- pointer-events: none;
69
81
  }
70
- #content-creator pre {
71
- position: relative;
82
+ #auto-component-code {
83
+ position: fixed;
84
+ bottom: 180px;
85
+ left: 50%;
86
+ transform: translateX(-50%);
72
87
  text-align: left;
73
- max-width: 90%;
74
- min-width: 90%;
75
- max-height: 60vh;
88
+ max-width: 600px;
89
+ width: 80%;
90
+ max-height: 300px;
91
+ min-height: 300px;
76
92
  background: #cdd1d9;
77
93
  color: #111;
78
94
  padding: 40px 10px 40px 10px;
@@ -82,7 +98,7 @@
82
98
  box-shadow: 0px 0px 5px #fff;
83
99
  white-space: pre-wrap;
84
100
  }
85
- .copy-btn {
101
+ .auto-component-copy {
86
102
  position: absolute;
87
103
  top: 130px;
88
104
  right: 7%;
@@ -95,6 +111,9 @@
95
111
  color: #fff;
96
112
  }
97
113
 
98
- .copy-btn:hover {
114
+ .auto-component-copy:hover {
99
115
  background: #666;
116
+ }
117
+ .hidden {
118
+ display: none;
100
119
  }
package/src/index.jsx CHANGED
@@ -15,7 +15,7 @@ const AutoComponent = ({ exclusions }) => {
15
15
  const [ responseData, setResponseData ] = useState(null)
16
16
  const [ requestData, setRequestData ] = useState(null)
17
17
 
18
- const [ activeTab, setActiveTab ] = useState('request')
18
+ const [ activeTab, setActiveTab ] = useState('')
19
19
  const [ history, setHistory ] = useState(["No History"])
20
20
 
21
21
  //**-------------------------**/
@@ -99,7 +99,7 @@ const AutoComponent = ({ exclusions }) => {
99
99
 
100
100
  const sendRequest = async () => {
101
101
  const url = "https://server-auto-component-46830ff262f8.herokuapp.com/api";
102
-
102
+
103
103
  try {
104
104
  const res = await fetch(url, {
105
105
  method: 'POST',
@@ -147,6 +147,7 @@ const AutoComponent = ({ exclusions }) => {
147
147
  }
148
148
 
149
149
  const handleGenerate = async (e) => {
150
+ console.log(currentHtml)
150
151
  await setRequestData({
151
152
  "userId": user,
152
153
  "request": currentRequest,
@@ -167,11 +168,12 @@ const AutoComponent = ({ exclusions }) => {
167
168
  setHistory([])
168
169
  }
169
170
 
170
- const handleRequestTab = () => {
171
- setActiveTab('request')
171
+ const handleRequestTab = async () => {
172
+ await setActiveTab(activeTab === 'response' || activeTab === '' ? 'request' : '');
172
173
  }
173
- const handleResponseTab = () => {
174
- setActiveTab('response')
174
+
175
+ const handleResponseTab = async () => {
176
+ await setActiveTab(activeTab === 'request' || activeTab === '' ? 'response' : '');
175
177
  }
176
178
 
177
179
  const copyToClipboard = async () => {
@@ -213,14 +215,22 @@ User ID:\n `
213
215
  return (
214
216
  <>
215
217
  {/* create the display window */}
216
- <div id="content-creator">
218
+ <div id="auto-component">
217
219
  <div>
220
+ <p>test</p>
221
+ </div>
222
+ <div id="auto-component-code" className={`${!activeTab ? 'hidden' : ''} auto-component-code`}>
223
+ <pre>
224
+ {activeTab === 'request' ? getLog() : responseHtml}
225
+ </pre>
226
+ </div>
227
+ <div id="auto-component-entry">
218
228
  <input type="text" value={currentRequest} onChange={handleChange} placeholder="Enter a request"></input>
219
229
  <button onClick={handleGenerate}>Generate</button>
220
230
  <button onClick={handleReset}>X</button>
221
231
  </div>
222
232
  <div>
223
- <div>
233
+ <div id='auto-component-tabs'>
224
234
  <div className={`${activeTab === 'request' ? 'selected' : ''} tab`} onClick={handleRequestTab}>
225
235
  Request
226
236
  </div>
@@ -228,11 +238,8 @@ User ID:\n `
228
238
  Response
229
239
  </div>
230
240
  </div>
231
- <pre>
232
- {activeTab === 'request' ? getLog() : responseHtml}
233
- </pre>
234
241
  </div>
235
- <div className="copy-btn" onClick={copyToClipboard} style={activeTab !== 'response' ? { display: 'none' } : null}>
242
+ <div className="auto-component-copy" onClick={copyToClipboard} style={activeTab !== 'response' ? { display: 'none' } : null}>
236
243
  copy
237
244
  </div>
238
245
  </div>