Skip to content

Commit 78c93cb

Browse files
refactor: <FunctionParameters> now accepts params instead of func
1 parent 45a382f commit 78c93cb

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/components/templates/FuncTemplate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const FuncTemplate: FC<FuncTemplateProps> = ({
7979
</div>
8080

8181
<div class="my-6">
82-
<FunctionParameters func={content} />
82+
<FunctionParameters params={content.params} />
8383
</div>
8484

8585
<ScopedDefinitions scope={content.scope} />

src/components/templates/GroupTemplate.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FC } from "hono/jsx";
22
import { Translation } from "../../translation/index.js";
3-
import type { Func, GroupBody, Page } from "../../types/model";
3+
import type { GroupBody, Page } from "../../types/model";
44
import { FunctionDisplay, FunctionParameters, Tooltip } from "../ui";
55
import { HtmlContent } from "../ui/HtmlContent";
66
import BaseTemplate, { type BaseTemplateProps } from "./BaseTemplate";
@@ -59,9 +59,9 @@ export const GroupTemplate: FC<GroupTemplateProps> = ({
5959
<h2 id="global-attributes">
6060
<Translation translationKey="globalAttributes" />
6161
</h2>
62-
{/* TODO: Correct the heading levels below */}
6362
<FunctionParameters
64-
func={{ params: content.global_attributes } as Func}
63+
params={content.global_attributes}
64+
globalAttributes={true}
6565
prefix="global-attributes"
6666
/>
6767
</>

src/components/ui/FunctionDisplay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const FunctionDisplay: FC<FunctionDisplayProps> = ({
6060
</div>
6161

6262
<div class="my-4">
63-
<FunctionParameters func={func} prefix={prefix} />
63+
<FunctionParameters params={func.params} prefix={prefix} />
6464
</div>
6565
</>
6666
);

src/components/ui/FunctionParameters.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { FC } from "hono/jsx";
22
import { basePath } from "../../metadata";
33
import { Translation } from "../../translation/";
4-
import type { Func } from "../../types/model";
4+
import type { Param } from "../../types/model";
55
import { normalizeDetailBlocks } from "../../utils/normalizeModel";
66
import { joinPath } from "../../utils/path";
77
import { ChevronRightIcon } from "../icons";
@@ -11,7 +11,9 @@ import { TypeIcon } from "./TypeIcon";
1111
import { buildParamId, type2href } from "./type2href";
1212

1313
type FunctionParametersProps = {
14-
func: Func;
14+
params: Param[];
15+
/** Whether these parameter are global attributes */
16+
globalAttributes?: boolean;
1517
/**
1618
* The prefix for IDs
1719
*
@@ -21,17 +23,19 @@ type FunctionParametersProps = {
2123
};
2224

2325
export const FunctionParameters: FC<FunctionParametersProps> = ({
24-
func,
26+
params,
27+
globalAttributes = false,
2528
prefix = undefined,
2629
}) => {
30+
const Heading = globalAttributes ? "h3" : "h4";
2731
return (
2832
<div class="space-y-6">
29-
{func.params.map((param, _index) => (
33+
{params.map((param, _index) => (
3034
<div
3135
key={param.name}
3236
class="bg-gray-50 rounded-md p-4 border border-gray-100"
3337
>
34-
<h4
38+
<Heading
3539
id={buildParamId(param.name, prefix)}
3640
class="flex flex-wrap items-center gap-2 mb-3"
3741
>
@@ -57,7 +61,7 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
5761
{param.variadic && <Tooltip kind="variadic" />}
5862
{param.settable && <Tooltip kind="settable" />}
5963
</div>
60-
</h4>
64+
</Heading>
6165

6266
{normalizeDetailBlocks(param).map((block) => {
6367
switch (block.kind) {

src/types/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export type Func = {
7979
} & WithDeprecation &
8080
WithDetailsBlocks;
8181

82-
type Param = {
82+
export type Param = {
8383
name: string;
8484
types: string[];
8585
strings: Str[];

0 commit comments

Comments
 (0)