Skip to content

Commit b1f7199

Browse files
authored
Merge pull request #544 from processing/feat/beta
Handle @beta in reference items
2 parents 85f0973 + a22dc9a commit b1f7199

File tree

8 files changed

+45
-8
lines changed

8 files changed

+45
-8
lines changed

src/components/ReferenceDirectoryWithFilter/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { ReferenceDocContentItem } from "@/src/content/types";
22
import { useMemo, useRef, useState } from "preact/hooks";
3-
import type { JSX } from "preact";
3+
import { type JSX } from "preact";
44
import { Icon } from "../Icon";
5+
import flask from "@src/content/ui/images/icons/flask.svg?raw";
56

67
type ReferenceDirectoryEntry = ReferenceDocContentItem & {
78
data: {
@@ -92,8 +93,15 @@ export const ReferenceDirectoryWithFilter = ({
9293
>
9394
<span
9495
class="text-body-mono group-hover:underline"
95-
dangerouslySetInnerHTML={{ __html: entry.data.title }}
96-
/>
96+
>
97+
{entry.data.beta && (
98+
<div
99+
className="inline-block mr-2 w-[16px] h-[16px] mb-[-2px]"
100+
dangerouslySetInnerHTML={{ __html: flask }}
101+
/>
102+
)}
103+
<span dangerouslySetInnerHTML={{ __html: entry.data.title }} />
104+
</span>
97105
<p
98106
class="mt-1 text-sm"
99107
id={`${entry.data.title}-description`}

src/content/reference/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const referenceSchema = z.object({
7070
itemtype: z.string().optional(),
7171
class: z.string().optional(),
7272
chainable: z.coerce.boolean().optional(),
73+
beta: z.coerce.boolean().optional(),
7374
return: returnSchema.optional(),
7475
example: z.array(exampleSchema).optional(),
7576
relatedContent: relatedContent().optional(),

src/content/ui/en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,6 @@ calloutTitles:
184184
"Try this!": "Try this!"
185185
Tip: Tip
186186
Note: Note
187+
experimentalApi:
188+
title: This API is experimental
189+
description: Its behavior may change in a future version of p5.js.

src/content/ui/images/icons/flask.svg

Lines changed: 3 additions & 0 deletions
Loading

src/layouts/ReferenceItemLayout.astro

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
} from "@/types/parsers.interface";
2020
import { setJumpToState } from "../globals/state";
2121
import { p5Version } from "../globals/p5-version";
22+
import flask from "@src/content/ui/images/icons/flask.svg?raw";
2223
2324
const { entry, relatedEntries } = Astro.props;
2425
const currentLocale = getCurrentLocale(Astro.url.pathname);
@@ -88,6 +89,18 @@ const seenParams: Record<string, true> = {};
8889
>
8990
<div class="content-grid mt-0 max-w-[770px]">
9091
<div class="col-span-9 xl:min-w-[1000px]">
92+
{entry.data.beta && (
93+
<div class="experimental">
94+
<h5>
95+
<div
96+
class="inline-block mr-2 w-[20px] h-[20px] mb-[-2px]"
97+
set:html={flask}
98+
/>
99+
{t('experimentalApi', 'title')}
100+
</h5>
101+
<p>{t('experimentalApi', 'description')}</p>
102+
</div>
103+
)}
91104
<div
92105
set:html={description}
93106
class="[&_a]:text-type-magenta-dark [&_a]:!decoration-type-magenta-dark mb-xl reference-item rendered-markdown"

src/scripts/builders/reference.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ const getMethodFrontmatter = (doc: ReferenceClassItemMethod) => {
293293
overloads,
294294
itemtype,
295295
chainable: doc.chainable === 1,
296+
beta: doc.beta ? !!doc.beta : undefined,
296297
};
297298
};
298299

styles/global.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pre.code-box,
291291
white-space: break-spaces;
292292
}
293293

294-
.callout {
294+
.callout, .experimental {
295295
padding: var(--spacing-sm);
296296
border-radius: 20px;
297297
background-color: var(--bg-magenta-20);
@@ -301,11 +301,15 @@ pre.code-box,
301301
.dark-theme & {
302302
color: var(--type-black);
303303
}
304+
305+
& h5 {
306+
font-weight: bold;
307+
margin-bottom: var(--spacing-sm);
308+
}
304309
}
305310

306-
.callout h5 {
307-
font-weight: bold;
308-
margin-bottom: var(--spacing-sm);
311+
.experimental {
312+
background-color: var(--bg-yellow);
309313
}
310314

311315
.callout.callout-note {

types/parsers.interface.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ interface Return {
9898
type: string;
9999
}
100100

101+
interface MaybeBeta {
102+
beta?: number;
103+
}
104+
101105
/* Represents a method within a class */
102-
export interface ReferenceClassItemMethod extends BaseClassItem, Chainable {
106+
export interface ReferenceClassItemMethod extends BaseClassItem, Chainable, MaybeBeta {
103107
params?: ReferenceParam[];
104108
return?: Return;
105109
example?: string[];

0 commit comments

Comments
 (0)