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 +1 -1
- package/src/auto-component.css +46 -27
- package/src/index.jsx +19 -12
package/package.json
CHANGED
package/src/auto-component.css
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
#
|
|
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
|
-
#
|
|
11
|
-
|
|
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
|
-
#
|
|
19
|
-
width:
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
47
|
+
#auto-component button:hover {
|
|
42
48
|
background: green;
|
|
43
49
|
color: #eee;
|
|
44
50
|
}
|
|
45
|
-
#
|
|
51
|
+
#auto-component button:nth-child(3):hover {
|
|
46
52
|
background: #dc3c3c;
|
|
47
53
|
}
|
|
48
|
-
#
|
|
54
|
+
#auto-component-tabs {
|
|
55
|
+
position: fixed;
|
|
56
|
+
bottom: 68px;
|
|
57
|
+
left: 50%;
|
|
58
|
+
transform: translateX(-50%);
|
|
49
59
|
display: flex;
|
|
50
|
-
flex-direction:
|
|
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: #
|
|
56
|
-
color: #
|
|
57
|
-
border-radius: 5px 5px
|
|
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: #
|
|
66
|
-
color: #
|
|
78
|
+
background: #444;
|
|
79
|
+
color: #aaa;
|
|
67
80
|
font-size: 1.2rem;
|
|
68
|
-
pointer-events: none;
|
|
69
81
|
}
|
|
70
|
-
#
|
|
71
|
-
position:
|
|
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:
|
|
74
|
-
|
|
75
|
-
max-height:
|
|
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
|
|
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
|
|
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('
|
|
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
|
-
|
|
174
|
-
|
|
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="
|
|
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
|
|
242
|
+
<div className="auto-component-copy" onClick={copyToClipboard} style={activeTab !== 'response' ? { display: 'none' } : null}>
|
|
236
243
|
copy
|
|
237
244
|
</div>
|
|
238
245
|
</div>
|