Skip to content

[Docs Site] Amend SchemaRow styling #22630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions src/components/models/SchemaRow.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,22 @@
import { Type, MetaInfo } from "~/components";
import { type SchemaNode } from "@stoplight/json-schema-tree";

const { node, root } = Astro.props;
const { node } = Astro.props;
---

<li
class={`py-2 my-0! list-none! ${root ? "" : "border-l border-l-gray-200 dark:border-l-gray-500 pl-4"}`}
>
{
(
<code
class="mr-2 rounded-md bg-gray-100 pr-0! font-mono"
title={node.title}
>
{node.subpath[node.subpath.length - 1]}
{node.parent.fragment?.required?.includes(
node.subpath[node.subpath.length - 1],
) ? (
<span class="font-semibold text-red-500">*</span>
) : (
""
)}
</code>
)
}
<li>
<code title={node.title}>{node.subpath[node.subpath.length - 1]}</code>

{node.primaryType && <Type text={node.primaryType} />}

{node.combiners && node.combiners.includes("oneOf") && <Type text="one of" />}

{
node.parent.fragment?.required?.includes(
node.subpath[node.subpath.length - 1],
) && <MetaInfo text="required" />
}

{
node.annotations.default && (
<MetaInfo text={`default ${node.annotations.default}`} />
Expand All @@ -50,11 +39,11 @@ const { node, root } = Astro.props;
/>
)
}
<p class="mb-0!">{node.annotations.description}</p>
<p>{node.annotations.description}</p>

{
node.children && (
<ul class="m-0 ml-4 list-none! p-0">
<ul class="pl-6">
{node.children.map((node: SchemaNode) => (
<Astro.self node={node} />
))}
Expand Down
4 changes: 2 additions & 2 deletions src/components/models/SchemaViewer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const jsonSchemaTree = new SchemaTree(schema, {
jsonSchemaTree.populate();
---

<ul class="m-0 list-none p-0">
<ul class="pl-0">
{
(jsonSchemaTree.root.children[0] as RegularNode).children?.map(
(node: SchemaNode) => <SchemaRow node={node} root />,
(node: SchemaNode) => <SchemaRow node={node} />,
)
}
</ul>
Loading