Skip to content

Commit f1d7d50

Browse files
fix: correct the tooltip for constructors
Also add a new translation key `constructorDescription` Resolves #20
1 parent ee3dae3 commit f1d7d50

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

src/components/ui/Tooltip.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type TooltipProps = {
77
| "element"
88
| "contextual"
99
// Section tooltips
10+
| "constructor"
1011
| "definitions"
1112
| "parameters"
1213
// Parameter tooltips
@@ -40,6 +41,13 @@ const tooltipContent: Record<
4041
bgColor: "bg-indigo-50",
4142
textColor: "text-indigo-700",
4243
},
44+
constructor: {
45+
label: <Translation translationKey="constructor" />,
46+
desc: <Translation translationKey="constructorDescription" />,
47+
isShowLabel: false,
48+
bgColor: "bg-gray-100",
49+
textColor: "text-gray-700",
50+
},
4351
definitions: {
4452
label: <Translation translationKey="definitions" />,
4553
desc: <Translation translationKey="definitionsDescription" />,

src/translation/en-US.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const translation: TranslationObject = {
1717
const map: Record<TooltipProps["kind"], string> = {
1818
element: "Element",
1919
contextual: "Contextual",
20+
constructor: "Constructor",
2021
definitions: "Definitions",
2122
parameters: "Parameters",
2223
variadic: "Variadic",
@@ -30,14 +31,6 @@ export const translation: TranslationObject = {
3031

3132
export const Translation: TranslationComponent = (props) => {
3233
switch (props.translationKey) {
33-
case "constructor":
34-
return <Fragment>Constructor</Fragment>;
35-
case "definitionsOf":
36-
return (
37-
<Fragment>
38-
Definitions of <code>{props.name}</code>
39-
</Fragment>
40-
);
4134
case "search":
4235
return <Fragment>Search</Fragment>;
4336
case "defaultValue":
@@ -117,6 +110,21 @@ export const Translation: TranslationComponent = (props) => {
117110
Context functions can only be used when the context is known.
118111
</Fragment>
119112
);
113+
case "constructor":
114+
return <Fragment>Constructor</Fragment>;
115+
case "constructorDescription":
116+
return (
117+
<Fragment>
118+
If a type has a constructor, you can call it like a function to create
119+
a new value of the type.
120+
</Fragment>
121+
);
122+
case "definitionsOf":
123+
return (
124+
<Fragment>
125+
Definitions of <code>{props.name}</code>
126+
</Fragment>
127+
);
120128
case "definitions":
121129
return <Fragment>Definitions</Fragment>;
122130
case "definitionsDescription":

src/translation/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type TranslationComponentKey =
3737
| "contextFunctionDescription"
3838
// Section tooltips
3939
| "constructor"
40+
| "constructorDescription"
4041
| "definitions" // See also `definitionsOf`
4142
| "definitionsDescription"
4243
| "parameters"

src/translation/ja-JP.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const translation: TranslationObject = {
2222
const map: Record<TooltipProps["kind"], string> = {
2323
element: "要素関数",
2424
contextual: "コンテキスト関数",
25+
constructor: "コンストラクタ",
2526
definitions: "定義",
2627
parameters: "引数",
2728
variadic: "可変長引数",
@@ -35,14 +36,6 @@ export const translation: TranslationObject = {
3536

3637
export const Translation: TranslationComponent = (props) => {
3738
switch (props.translationKey) {
38-
case "constructor":
39-
return <Fragment>コンストラクタ</Fragment>;
40-
case "definitionsOf":
41-
return (
42-
<Fragment>
43-
<code>{props.name}</code>の定義
44-
</Fragment>
45-
);
4639
case "search":
4740
return <Fragment>検索</Fragment>;
4841
case "defaultValue":
@@ -120,6 +113,21 @@ export const Translation: TranslationComponent = (props) => {
120113
コンテキスト関数は、コンテキストが既知の場合にのみ使用できます。
121114
</Fragment>
122115
);
116+
117+
case "constructor":
118+
return <Fragment>コンストラクタ</Fragment>;
119+
case "constructorDescription":
120+
return (
121+
<Fragment>
122+
型がコンストラクタを持っていれば、その型の新しい値を生成する関数のように呼び出すことができます。
123+
</Fragment>
124+
);
125+
case "definitionsOf":
126+
return (
127+
<Fragment>
128+
<code>{props.name}</code>の定義
129+
</Fragment>
130+
);
123131
case "definitions":
124132
return <Fragment>定義</Fragment>;
125133
case "definitionsDescription":

0 commit comments

Comments
 (0)