Skip to content

Commit bebd143

Browse files
committed
Add circular label styling
1 parent a58b774 commit bebd143

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/_SchemaItem.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@
6767
background-color: transparent;
6868
}
6969

70+
.openapi-schema__circular {
71+
display: inline-flex;
72+
align-items: center;
73+
font-size: 10.5px;
74+
font-weight: bold;
75+
text-transform: uppercase;
76+
color: var(--openapi-circular);
77+
margin-left: 1%;
78+
background-color: transparent;
79+
}
80+
7081
.openapi-schema__strikethrough {
7182
text-decoration: line-through;
7283
}

packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ export default function SchemaItem(props: Props) {
9292
<span className="openapi-schema__nullable">nullable</span>
9393
));
9494

95+
const circularMatch =
96+
typeof schemaName === "string" && schemaName.startsWith("circular(")
97+
? schemaName.match(/^circular\\(([^)]*)\\)/)
98+
: null;
99+
100+
const renderCircular = guard(circularMatch, () => (
101+
<span className="openapi-schema__circular">
102+
{circularMatch ? `circular(${circularMatch[1]})` : "circular"}
103+
</span>
104+
));
105+
95106
const renderEnumDescriptions = guard(
96107
getEnumDescriptionMarkdown(enumDescriptions),
97108
(value) => {
@@ -206,6 +217,7 @@ export default function SchemaItem(props: Props) {
206217
{renderNullable}
207218
{renderRequired}
208219
{renderDeprecated}
220+
{renderCircular}
209221
</span>
210222
{renderSchemaDescription}
211223
{renderEnumDescriptions}

packages/docusaurus-theme-openapi-docs/src/theme/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
--openapi-required: var(--ifm-color-danger);
4747
--openapi-deprecated: var(--ifm-color-warning);
4848
--openapi-nullable: var(--ifm-color-info);
49+
--openapi-circular: var(--ifm-color-primary);
4950
--openapi-code-blue: var(--ifm-color-info);
5051
--openapi-code-red: var(--ifm-color-danger);
5152
--openapi-code-orange: var(--ifm-color-warning);

0 commit comments

Comments
 (0)