Skip to content

Commit a57d4ad

Browse files
feat: make available string values collapsible
Resolves #3
1 parent ddbabe0 commit a57d4ad

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

src/components/ui/FunctionParameters.tsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,32 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
6262
<HtmlContent html={param.details} />
6363
</div>
6464

65+
{param.default && (
66+
<p class="mt-3 text-sm">
67+
<span class="font-medium">
68+
<Translation translationKey="defaultValue" />
69+
</span>{" "}
70+
<span class="text-gray-700">
71+
<HtmlContent html={param.default} />
72+
</span>
73+
</p>
74+
)}
75+
76+
{/* Put all collapsible blocks after non-collapsible blocks. */}
77+
6578
{param.strings.length > 0 && (
66-
<div class="mt-3">
67-
<h5 class="text-sm font-medium text-gray-700 mb-2">
79+
<details
80+
class="my-4 folding-example group"
81+
// The list of strings can be very long. For example, `page.paper` has 100+ possibilities.
82+
open={param.strings.length <= 5}
83+
>
84+
<summary class="flex items-center gap-1 text-sm font-medium text-blue-600 cursor-pointer hover:text-blue-800">
85+
<div class="w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90">
86+
<ChevronRightIcon />
87+
</div>
6888
<Translation translationKey="stringValues" />
69-
</h5>
70-
<ul class="type-args space-y-2 pl-4">
89+
</summary>
90+
<ul class="type-args space-y-2">
7191
{param.strings.map((string) => (
7292
<li key={string.string}>
7393
<div class="break-box">
@@ -81,22 +101,11 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
81101
</li>
82102
))}
83103
</ul>
84-
</div>
85-
)}
86-
87-
{param.default && (
88-
<p class="mt-3 text-sm">
89-
<span class="font-medium">
90-
<Translation translationKey="defaultValue" />
91-
</span>{" "}
92-
<span class="text-gray-700">
93-
<HtmlContent html={param.default} />
94-
</span>
95-
</p>
104+
</details>
96105
)}
97106

98107
{param.example && (
99-
<details class="mt-4 folding-example group">
108+
<details class="my-4 folding-example group">
100109
<summary class="flex items-center gap-1 text-sm font-medium text-blue-600 cursor-pointer hover:text-blue-800">
101110
<div class="w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90">
102111
<ChevronRightIcon />

src/translation/en-US.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const Translation: TranslationComponent = (props) => {
5454
case "defaultValue":
5555
return <Fragment>Default value:</Fragment>;
5656
case "stringValues":
57-
return <Fragment>Available string values:</Fragment>;
57+
return <Fragment>Available string values</Fragment>;
5858
case "showExample":
5959
return <Fragment>Show example</Fragment>;
6060
case "tableOfContents":

src/translation/ja-JP.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const Translation: TranslationComponent = (props) => {
5959
case "defaultValue":
6060
return <Fragment>デフォルト値:</Fragment>;
6161
case "stringValues":
62-
return <Fragment>使用可能な文字列値</Fragment>;
62+
return <Fragment>使用可能な文字列値</Fragment>;
6363
case "showExample":
6464
return <Fragment>例を表示</Fragment>;
6565
case "tableOfContents":

0 commit comments

Comments
 (0)