Skip to content

Commit 8dfc61a

Browse files
committed
feat: Typeテンプレートのスタイルを設定
1 parent 2d817a7 commit 8dfc61a

File tree

2 files changed

+30
-32
lines changed

2 files changed

+30
-32
lines changed

website/src/components/templates/TypeTemplate.tsx

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import type { FC } from "hono/jsx";
22
import BaseTemplate, { type BaseTemplateProps } from "./BaseTemplate";
33
import type { TypeBody, Page } from "../../types/model";
44
import { Tooltip, FunctionDisplay } from "../ui";
5-
import { type2class } from "../ui/type2class";
5+
import { TypeIcon } from "../ui/TypeIcon";
6+
import { type2href } from "../ui/type2href";
67

78
export type TypeTemplateProps = Omit<BaseTemplateProps, "page"> & {
89
page: Omit<Page, "body"> & {
@@ -28,19 +29,16 @@ export const TypeTemplate: FC<TypeTemplateProps> = ({
2829
nextPage={nextPage}
2930
>
3031
<h1 id="summary">
31-
<span class={`pill ${type2class(content.name)}`}>{content.name}</span>
32+
<TypeIcon type={content.name} isHeading={true} />
3233
</h1>
3334

3435
<div dangerouslySetInnerHTML={{ __html: content.details }} />
3536

3637
{content.constructor && (
3738
<>
38-
<h2 id="constructor">
39-
<Tooltip
40-
name="コンストラクタ"
41-
desc="If a type has a constructor, you can call it like a function to create a new value of the type."
42-
prefix="constructor"
43-
/>
39+
<h2 id="constructor" class="flex items-center gap-1">
40+
コンストラクタ
41+
<Tooltip kind="parameters" />
4442
</h2>
4543

4644
<FunctionDisplay
@@ -53,32 +51,22 @@ export const TypeTemplate: FC<TypeTemplateProps> = ({
5351

5452
{content.scope.length > 0 && (
5553
<>
56-
<h2 id="definitions">
57-
<Tooltip
58-
name="定義"
59-
desc="Functions and types and can have associated definitions. These are accessed by specifying the function or type, followed by a period, and then the definition's name."
60-
prefix="definitions"
61-
/>
54+
<h2 id="definitions" class="flex items-center gap-1">
55+
定義
56+
<Tooltip kind="definitions" />
6257
</h2>
6358

6459
{content.scope.map((method, index) => (
6560
<div>
66-
<h3 id={`definitions-${method.name}`} class="method-head">
67-
<code>{method.name}</code>
68-
<small>
69-
{method.element && (
70-
<Tooltip
71-
name="Element"
72-
desc="Element functions can be customized with <code>set</code> and <code>show</code> rules."
73-
/>
74-
)}
75-
{method.contextual && (
76-
<Tooltip
77-
name="Contextual"
78-
desc="Contextual functions can only be used when the context is known"
79-
/>
80-
)}
81-
</small>
61+
<h3
62+
id={`definitions-${method.name}`}
63+
class="method-head flex items-center gap-2 mb-3"
64+
>
65+
<code class="text-base font-medium">{method.name}</code>
66+
<div class="flex flex-wrap items-center gap-2">
67+
{method.element && <Tooltip kind="element" />}
68+
{method.contextual && <Tooltip kind="contextual" />}
69+
</div>
8270
</h3>
8371

8472
<FunctionDisplay

website/src/components/ui/TypeIcon.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FC } from "hono/jsx";
33
type TypeIconProps = {
44
type: string;
55
href?: string;
6+
isHeading?: boolean;
67
};
78

89
const getTypeStyles = (
@@ -51,9 +52,18 @@ const getTypeStyles = (
5152
);
5253
};
5354

54-
export const TypeIcon: FC<TypeIconProps> = ({ type, href }) => {
55+
export const TypeIcon: FC<TypeIconProps> = ({
56+
type,
57+
href,
58+
isHeading = false,
59+
}) => {
5560
const styles = getTypeStyles(type);
56-
const baseClasses = `pill ${styles.bgColor} ${styles.textColor} rounded-md px-1.5 py-0.5 text-sm font-mono whitespace-nowrap inline-flex items-center mx-0.5`;
61+
62+
const sizeClasses = isHeading
63+
? "text-3xl px-3 py-1.5"
64+
: "text-sm px-1.5 py-0.5";
65+
66+
const baseClasses = `pill ${styles.bgColor} ${styles.textColor} rounded-md ${sizeClasses} font-mono whitespace-nowrap inline-flex items-center mx-0.5`;
5767

5868
if (href) {
5969
return (

0 commit comments

Comments
 (0)