Skip to content

Commit 8111490

Browse files
hturanelithrar
authored andcommitted
Workers AI Model Page & Catalog Fixes (#17409)
* Implement empty state for model catalog * Clean up model schema design * Dark mode fixes for model empty state
1 parent e7b3090 commit 8111490

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

src/components/ModelCatalog.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ const ModelCatalog = ({ models }) => {
184184
</div>
185185
</div>
186186
<div className="flex md:w-3/4 w-full gap-[1%] items-stretch self-start flex-wrap !mt-0">
187+
{modelList.length === 0 && (
188+
<div className="border bg-gray-50 dark:bg-gray-800 dark:border-gray-500 rounded-md w-full flex-col flex align-middle justify-center text-center py-6">
189+
<span className="text-lg !font-bold">No models found</span>
190+
<p>
191+
Try a different search term, or broaden your search by removing
192+
filters.
193+
</p>
194+
</div>
195+
)}
187196
{modelList.map((model) => {
188197
const isBeta = model.model.properties.find(
189198
({ property_id, value }) =>

src/components/models/SchemaRow.astro

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,48 @@
11
---
2-
import { Type } from "~/components";
2+
import { Type, MetaInfo } from "~/components";
33
import { type SchemaNode } from "@stoplight/json-schema-tree";
44
5-
const { node } = Astro.props;
5+
const { node, root } = Astro.props;
66
---
77

8-
<li class="my-2 !list-none">
9-
<code class="mr-2 font-mono rounded-md bg-gray-100">
10-
{node.subpath[node.subpath.length - 1]}
11-
</code>
8+
<li
9+
class={`py-2 !my-0 !list-none ${root ? "" : "border-l border-l-gray-200 dark:border-l-gray-500 pl-4"}`}
10+
>
11+
{
12+
node.title ? (
13+
<span class="mr-2 font-bold">{node.title}</span>
14+
) : (
15+
<code class="mr-2 !pr-0 font-mono rounded-md bg-gray-100">
16+
{node.subpath[node.subpath.length - 1]}
17+
</code>
18+
)
19+
}
20+
1221
{node.primaryType && <Type text={node.primaryType} />}
22+
{node.combiners && node.combiners.includes("oneOf") && <Type text="one of" />}
1323

1424
{
1525
node.annotations.default && (
16-
<span class="text-xs mr-2">default {node.annotations.default}</span>
26+
<MetaInfo text={`default ${node.annotations.default}`} />
1727
)
1828
}
1929
{
2030
(node.validations.minLength !== undefined ||
2131
node.validations.minimum !== undefined) && (
22-
<span class="text-xs mr-2">
23-
min {node.validations.minLength || node.validations.minimum}
24-
</span>
32+
<MetaInfo
33+
text={`min ${node.validations.minLength || node.validations.minimum}`}
34+
/>
2535
)
2636
}
2737
{
2838
(node.validations.maxLength !== undefined ||
2939
node.validations.maximum !== undefined) && (
30-
<span class="text-xs">
31-
max {node.validations.maxLength || node.validations.maximum}
32-
</span>
40+
<MetaInfo
41+
text={`max ${node.validations.maxLength || node.validations.maximum}`}
42+
/>
3343
)
3444
}
35-
<p>{node.annotations.description}</p>
45+
<p class="!mb-0">{node.annotations.description}</p>
3646

3747
{
3848
node.children && (

src/components/models/SchemaViewer.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jsonSchemaTree.populate();
5656
<ul class="list-none m-0 p-0">
5757
{
5858
(jsonSchemaTree.root.children[0] as RegularNode).children?.map(
59-
(node: SchemaNode) => <SchemaRow node={node} />,
59+
(node: SchemaNode) => <SchemaRow node={node} root />,
6060
)
6161
}
6262
</ul>

0 commit comments

Comments
 (0)