Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Esteves Enzo
commited on
Commit
·
741554a
1
Parent(s):
d2a6779
replace contentEditable with an input sized
Browse files
components/editor/main/endpoint.tsx
CHANGED
@@ -4,6 +4,7 @@ import classNames from "classnames";
|
|
4 |
import { Method } from "@/components/method";
|
5 |
import { splitStringBracket } from "@/utils";
|
6 |
import { ApiRoute } from "@/utils/type";
|
|
|
7 |
|
8 |
export const Endpoint = ({
|
9 |
endpoint,
|
@@ -32,22 +33,15 @@ export const Endpoint = ({
|
|
32 |
<Method method={endpoint.method} />
|
33 |
<div className="flex items-center justify-start gap-1">
|
34 |
{path_formatted.map((p, i) => {
|
35 |
-
const isCustomizable = p.
|
36 |
-
return (
|
37 |
-
<
|
38 |
key={i}
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
contentEditable={isCustomizable}
|
45 |
-
onBlur={(e) => {
|
46 |
-
handleChange(e.currentTarget.textContent as string, i);
|
47 |
-
}}
|
48 |
-
>
|
49 |
-
{p}
|
50 |
-
</p>
|
51 |
);
|
52 |
})}
|
53 |
</div>
|
|
|
4 |
import { Method } from "@/components/method";
|
5 |
import { splitStringBracket } from "@/utils";
|
6 |
import { ApiRoute } from "@/utils/type";
|
7 |
+
import { Parameter } from "./parameter";
|
8 |
|
9 |
export const Endpoint = ({
|
10 |
endpoint,
|
|
|
33 |
<Method method={endpoint.method} />
|
34 |
<div className="flex items-center justify-start gap-1">
|
35 |
{path_formatted.map((p, i) => {
|
36 |
+
const isCustomizable = p.startsWith("{") && p.endsWith("}");
|
37 |
+
return isCustomizable ? (
|
38 |
+
<Parameter
|
39 |
key={i}
|
40 |
+
value={p}
|
41 |
+
onChange={(value) => handleChange(value, i)}
|
42 |
+
/>
|
43 |
+
) : (
|
44 |
+
<p className="text-slate-300">{p}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
);
|
46 |
})}
|
47 |
</div>
|
components/editor/main/parameter.tsx
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useMemo, useState } from "react";
|
2 |
+
import classNames from "classnames";
|
3 |
+
import { on } from "events";
|
4 |
+
|
5 |
+
interface Props {
|
6 |
+
value: string;
|
7 |
+
onChange: (value: string) => void;
|
8 |
+
}
|
9 |
+
export const Parameter: React.FC<Props> = ({ value, onChange }) => {
|
10 |
+
const [state, setState] = useState(value);
|
11 |
+
|
12 |
+
return (
|
13 |
+
<input
|
14 |
+
type="text"
|
15 |
+
className="bg-indigo-600 !text-white px-1.5 rounded-md outline-none bg-opacity-80 max-w-[80px] text-center truncate"
|
16 |
+
onBlur={() => onChange(state)}
|
17 |
+
value={state}
|
18 |
+
onChange={(e) => setState(e.target.value)}
|
19 |
+
/>
|
20 |
+
);
|
21 |
+
};
|
components/editor/main/request.tsx
CHANGED
@@ -16,8 +16,6 @@ export const Request = ({
|
|
16 |
Authorization: "hf_api_key",
|
17 |
});
|
18 |
|
19 |
-
console.log(headers);
|
20 |
-
|
21 |
return (
|
22 |
<div className="h-full bg-slate-900 px-4 xl:px-6 py-5">
|
23 |
{children}
|
|
|
16 |
Authorization: "hf_api_key",
|
17 |
});
|
18 |
|
|
|
|
|
19 |
return (
|
20 |
<div className="h-full bg-slate-900 px-4 xl:px-6 py-5">
|
21 |
{children}
|