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