Skip to content

Commit a785f43

Browse files
committed
Add section headers to types
1 parent 988f2fa commit a785f43

File tree

1 file changed

+10
-11
lines changed
  • src/ui/screens/Docs/Doc/TypeDoc/Types

1 file changed

+10
-11
lines changed

src/ui/screens/Docs/Doc/TypeDoc/Types/index.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Markdown } from '~/ui/components/Markdown'
99
import { Missing } from '~/ui/components/Missing'
1010
import { createModal } from '~/ui/components/Modals'
1111
import { RichText } from '~/ui/components/RichText'
12+
import { SectionHeader } from '~/ui/components/SectionHeader'
1213
import { SourceLink } from '~/ui/components/SourceLink'
1314
import { TypeDocInterface } from '~/ui/components/TypeDocInterface'
1415
import { TypeDocType } from '~/ui/components/TypeDocType'
@@ -45,6 +46,7 @@ export const useTypesModal = createModal<TypesModalProps>(
4546
generateTypeUsage(type.name),
4647
[type]
4748
)
49+
const scope = type && typeIdStr(type.name, type.id)
4850

4951
return (
5052
<InlineTypeContext.Provider
@@ -117,27 +119,25 @@ export const useTypesModal = createModal<TypesModalProps>(
117119
usage={usage.usage}
118120
usageTabs={usage.usageTabs}
119121
header="h3"
120-
scope={typeIdStr(type.name, type.id)}
122+
scope={scope}
121123
/>
122124
)}
123125

124126
{type.type && (
125127
<section>
126-
<h3>Type</h3>
127-
128+
<SectionHeader header="Type" scope={scope} tag="h3" />
128129
<Code value={<TypeDocType type={type.type} />} />
129130
</section>
130131
)}
131132

132133
{type.typeParameters && (
133134
<section>
134-
<h3>Generics</h3>
135-
135+
<SectionHeader header="Generics" scope={scope} tag="h3" />
136136
<TypeDocInterface list={type.typeParameters} />
137137
</section>
138138
)}
139139

140-
<TypeContent type={type} />
140+
<TypeContent type={type} scope={scope} />
141141
</RichText>
142142

143143
<code>
@@ -159,17 +159,17 @@ export const useTypesModal = createModal<TypesModalProps>(
159159

160160
interface ContentProps {
161161
type: DeclarationReflection
162+
scope: string | undefined
162163
}
163164

164-
function TypeContent({ type }: ContentProps) {
165+
function TypeContent({ type, scope }: ContentProps) {
165166
switch (type.kindString) {
166167
case 'Interface':
167168
if (!type.children?.length) return null
168169

169170
return (
170171
<div>
171-
<h3>Interface</h3>
172-
172+
<SectionHeader header="Interface" scope={scope} tag="h3" />
173173
<TypeDocInterface list={type.children} />
174174
</div>
175175
)
@@ -179,8 +179,7 @@ function TypeContent({ type }: ContentProps) {
179179
<div>
180180
{type.default && (
181181
<div>
182-
<h3>Default type</h3>
183-
182+
<SectionHeader header="Default type" scope={scope} tag="h3" />
184183
<Code value={<TypeDocType type={type.default} />} />
185184
</div>
186185
)}

0 commit comments

Comments
 (0)