Esteves Enzo commited on
Commit
f803d8b
1 Parent(s): e97023d

need to rewrite a bit the logic of the body

Browse files
components/editor/sidebar.tsx CHANGED
@@ -26,65 +26,66 @@ export const EditorSidebar = ({
26
  }
27
  };
28
  return (
29
- <ul
30
  className={classNames(
31
- "min-w-[300px] transition-all duration-200 xl:max-w-sm w-2/3 xl:w-full bg-slate-900 border-r border-slate-700/40 xl:!h-full overflow-auto fixed top-[56px] xl:top-0 left-0 xl:relative z-10 -translate-x-full xl:!translate-x-0",
32
  {
33
  "translate-x-0 h-[calc(100%-56px)]": open,
34
  }
35
  )}
36
  >
37
- {API_COLLECTIONS.map((collection, c) => (
38
- <li key={collection.key} className="block w-full">
39
- <div
40
- className={classNames(
41
- "p-4 border-b border-slate-700/70 text-slate-400 cursor-pointer hover:bg-slate-700/30 flex items-center justify-between transition-all duration-200 select-none active:bg-indigo-600 active:text-slate-100",
42
- {
43
- "bg-indigo-600 !text-slate-100 hover:!bg-indigo-600 !border-indigo-500":
44
- collections.includes(collection.key),
45
- }
46
- )}
47
- onClick={() => handleSetActiveCollection(collection.key)}
48
- >
49
- <p className="font-semibold uppercase text-xs flex items-center justify-between">
50
- {collection.key} API
51
- </p>
52
- <TbChevronDown
53
  className={classNames(
54
- "text-slate-400 transition-all duration-200",
55
  {
56
- "transform rotate-180 !text-slate-100": collections.includes(
57
- collection.key
58
- ),
59
  }
60
  )}
61
- />
62
- </div>
63
- {collections.includes(collection.key) && (
64
- <div className="bg-slate-700/20 w-full p-3 border-b border-slate-700/70">
65
- <ul className="w-full">
66
- {collection.endpoints.map((end, e) => (
67
- <Link
68
- key={e}
69
- href={`/${collection.key}/${e}`}
70
- className={classNames(
71
- "text-slate-400 font-semibold text-xs flex items-center justify-start gap-2 rounded-md p-2.5 hover:bg-slate-600 hover:bg-opacity-10 cursor-pointer border-t border-b border-transparent select-none",
72
- {
73
- "bg-slate-600 bg-opacity-20 hover:!bg-opacity-20 !text-slate-200 border-b !border-b-slate-700/70 border-t !border-t-slate-800":
74
- pathname.includes(`/${collection.key}/${e}`),
75
- }
76
- )}
77
- >
78
- <Method method={end.method} />
79
- <p className="truncate">{end.path}</p>
80
- </Link>
81
- ))}
82
- </ul>
83
  </div>
84
- )}
85
- </li>
86
- ))}
87
- <div className="absolute bottom-0 xl:bottom-[56px] left-0 w-full">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  <a
89
  href="https://huggingface.co/spaces/enzostvs/hub-api-playground/discussions/1"
90
  target="_blank"
@@ -100,6 +101,6 @@ export const EditorSidebar = ({
100
  See HUB API documentation
101
  </a>
102
  </div>
103
- </ul>
104
  );
105
  };
 
26
  }
27
  };
28
  return (
29
+ <div
30
  className={classNames(
31
+ "min-w-[300px] transition-all flex flex-col items-start justify-between duration-200 xl:max-w-sm w-2/3 xl:w-full bg-slate-900 border-r border-slate-700/40 h-[calc(100%-56px)] overflow-auto fixed top-[56px] xl:top-0 left-0 xl:relative z-10 -translate-x-full xl:!translate-x-0",
32
  {
33
  "translate-x-0 h-[calc(100%-56px)]": open,
34
  }
35
  )}
36
  >
37
+ <ul className="w-full">
38
+ {API_COLLECTIONS.map((collection, c) => (
39
+ <li key={collection.key} className="block w-full">
40
+ <div
 
 
 
 
 
 
 
 
 
 
 
 
41
  className={classNames(
42
+ "p-4 border-b border-slate-700/70 text-slate-400 cursor-pointer hover:bg-slate-700/30 flex items-center justify-between transition-all duration-200 select-none active:bg-indigo-600 active:text-slate-100",
43
  {
44
+ "bg-indigo-600 !text-slate-100 hover:!bg-indigo-600 !border-indigo-500":
45
+ collections.includes(collection.key),
 
46
  }
47
  )}
48
+ onClick={() => handleSetActiveCollection(collection.key)}
49
+ >
50
+ <p className="font-semibold uppercase text-xs flex items-center justify-between">
51
+ {collection.key} API
52
+ </p>
53
+ <TbChevronDown
54
+ className={classNames(
55
+ "text-slate-400 transition-all duration-200",
56
+ {
57
+ "transform rotate-180 !text-slate-100":
58
+ collections.includes(collection.key),
59
+ }
60
+ )}
61
+ />
 
 
 
 
 
 
 
 
62
  </div>
63
+ {collections.includes(collection.key) && (
64
+ <div className="bg-slate-700/20 w-full p-3 border-b border-slate-700/70">
65
+ <ul className="w-full">
66
+ {collection.endpoints.map((end, e) => (
67
+ <Link
68
+ key={e}
69
+ href={`/${collection.key}/${e}`}
70
+ className={classNames(
71
+ "text-slate-400 font-semibold text-xs flex items-center justify-start gap-2 rounded-md p-2.5 hover:bg-slate-600 hover:bg-opacity-10 cursor-pointer border-t border-b border-transparent select-none",
72
+ {
73
+ "bg-slate-600 bg-opacity-20 hover:!bg-opacity-20 !text-slate-200 border-b !border-b-slate-700/70 border-t !border-t-slate-800":
74
+ pathname.includes(`/${collection.key}/${e}`),
75
+ }
76
+ )}
77
+ >
78
+ <Method method={end.method} />
79
+ <p className="truncate">{end.path}</p>
80
+ </Link>
81
+ ))}
82
+ </ul>
83
+ </div>
84
+ )}
85
+ </li>
86
+ ))}
87
+ </ul>
88
+ <div className="w-full">
89
  <a
90
  href="https://huggingface.co/spaces/enzostvs/hub-api-playground/discussions/1"
91
  target="_blank"
 
101
  See HUB API documentation
102
  </a>
103
  </div>
104
+ </div>
105
  );
106
  };
components/input/input.tsx CHANGED
@@ -37,7 +37,7 @@ export const TextInput: React.FC<Props> = ({
37
  value={value}
38
  placeholder={placeholder}
39
  onChange={handleInputChange}
40
- className="transition-all duration-200 w-full h-full px-4 py-4 bg-slate-950/50 rounded-lg outline-none text-slate-200 placeholder:text-slate-600 focus:ring-4 focus:ring-indigo-600 focus:ring-opacity-40 border border-slate-950/50 focus:border-indigo-500"
41
  />
42
  </div>
43
  );
 
37
  value={value}
38
  placeholder={placeholder}
39
  onChange={handleInputChange}
40
+ className="transition-all duration-200 truncate w-full h-full px-4 py-4 bg-slate-950/50 rounded-lg outline-none text-slate-200 placeholder:text-slate-600 focus:ring-4 focus:ring-indigo-600 focus:ring-opacity-40 border border-slate-950/50 focus:border-indigo-500"
41
  />
42
  </div>
43
  );
utils/datas/api_collections.ts CHANGED
@@ -144,29 +144,106 @@ export const API_COLLECTIONS: Array<ApiCollection> = [{
144
  path: '/api/whoami-v2',
145
  }],
146
  },
147
- // {
148
- // key: 'collection',
149
- // endpoints: [{
150
- // method: 'POST',
151
- // path: '/api/collections',
152
- // }, {
153
- // method: 'GET',
154
- // path: '/api/collections/{namespace}/{slug}-{id}'
155
- // }, {
156
- // method: 'PATCH',
157
- // path: '/api/collections/{namespace}/{slug}-{id}'
158
- // }, {
159
- // method: 'DELETE',
160
- // path: '/api/collections/{namespace}/{slug}-{id}'
161
- // }, {
162
- // method: 'POST',
163
- // path: '/api/collections/{namespace}/{slug}-{id}/item'
164
- // }, {
165
- // method: 'PATCH',
166
- // path: '/api/collections/{namespace}/{slug}-{id}/items/{item_id}'
167
- // }, {
168
- // method: 'DELETE',
169
- // path: '/api/collections/{namespace}/{slug}-{id}/items/{item_id}'
170
- // }],
171
- // }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  ]
 
144
  path: '/api/whoami-v2',
145
  }],
146
  },
147
+ {
148
+ key: 'collection',
149
+ endpoints: [{
150
+ method: 'POST',
151
+ path: '/api/collections/create',
152
+ body: [{
153
+ label: "Title of collection",
154
+ key: "title",
155
+ required: true,
156
+ }, {
157
+ label: "Namespace",
158
+ key: "namespace",
159
+ required: true,
160
+ }, {
161
+ label: "Description of collection",
162
+ key: "description",
163
+ required: true,
164
+ }, {
165
+ label: "Type",
166
+ key: "item.type",
167
+ defaultValue: "model",
168
+ required: true,
169
+ }, {
170
+ label: "RepoId/PaperId",
171
+ key: "item.id",
172
+ required: true,
173
+ }, {
174
+ label: "Whether the repo is private",
175
+ required: true,
176
+ key: "private",
177
+ defaultValue: false,
178
+ }]
179
+ }, {
180
+ method: 'GET',
181
+ path: '/api/collections/{namespace}/{slug-id}',
182
+ }, {
183
+ method: 'PATCH',
184
+ path: '/api/collections/{namespace}/{slug-id}',
185
+ body: [{
186
+ label: "Title of collection",
187
+ key: "title",
188
+ required: true,
189
+ }, {
190
+ label: "Namespace",
191
+ key: "namespace",
192
+ required: true,
193
+ }, {
194
+ label: "Position",
195
+ required: true,
196
+ key: "position",
197
+ defaultValue: 0,
198
+ }, {
199
+ label: "Theme",
200
+ required: true,
201
+ key: "theme",
202
+ defaultValue: "green",
203
+ }, {
204
+ label: "Whether the repo is private",
205
+ required: true,
206
+ key: "private",
207
+ defaultValue: false,
208
+ }]
209
+ }, {
210
+ method: 'DELETE',
211
+ path: '/api/collections/{namespace}/{slug-id}',
212
+ }, {
213
+ method: 'POST',
214
+ path: '/api/collections/{namespace}/{slug-id}/item',
215
+ body: [{
216
+ label: "Type",
217
+ key: "item.type",
218
+ defaultValue: "model",
219
+ required: true,
220
+ }, {
221
+ label: "RepoId/PaperId",
222
+ key: "item.id",
223
+ required: true,
224
+ }, {
225
+ label: "Note",
226
+ key: "note",
227
+ defaultValue: "Here is the model I trained on ...",
228
+ required: true,
229
+ }]
230
+ }, {
231
+ method: 'PATCH',
232
+ path: '/api/collections/{namespace}/{slug-id}/item/{itemId}',
233
+ body: [{
234
+ label: "Position",
235
+ key: "position",
236
+ defaultValue: 0,
237
+ required: true,
238
+ }, {
239
+ label: "Note",
240
+ key: "note",
241
+ defaultValue: "Here is the model I trained on ...",
242
+ required: true,
243
+ }]
244
+ }, {
245
+ method: 'DELETE',
246
+ path: '/api/collections/{namespace}/{slug-id}/item/{itemId}',
247
+ }]
248
+ }
249
  ]