Skip to content

Commit 5df3909

Browse files
committed
DataTag, CodeTabs
1 parent fa3583d commit 5df3909

File tree

14 files changed

+482
-711
lines changed

14 files changed

+482
-711
lines changed

package-lock.json

Lines changed: 399 additions & 610 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@
4141
"@babel/generator": "^7.27.3",
4242
"@babel/types": "^7.27.3",
4343
"@clack/prompts": "^0.10.1",
44+
"@heroicons/react": "^2.2.0",
4445
"@node-core/rehype-shiki": "^1.0.1-601b74e6d7dfc706eb99e854fc96120bea42f03a",
45-
"@node-core/ui-components": "^1.0.1-6cb8b0a0c75c24f5ccc84bb07a1ea9b4b810abd2",
46+
"@node-core/ui-components": "^1.0.1-79dc76991a4c35cbd47e62c12e8d3507e3d9a7c4",
4647
"@orama/orama": "^3.1.6",
4748
"@orama/plugin-data-persistence": "^3.1.6",
4849
"@orama/react-components": "^0.8.0",
49-
"@radix-ui/react-tabs": "^1.1.12",
5050
"@tailwindcss/postcss": "^4.1.8",
5151
"acorn": "^8.14.1",
5252
"commander": "^13.1.0",
5353
"dedent": "^1.6.0",
5454
"esbuild": "^0.25.5",
5555
"esbuild-style-plugin": "^1.6.3",
56-
"estree-to-babel": "^11.0.2",
56+
"estree-to-babel": "^11.0.3",
5757
"estree-util-value-to-estree": "^3.4.0",
5858
"estree-util-visit": "^2.0.0",
5959
"github-slugger": "^2.0.0",
@@ -62,7 +62,7 @@
6262
"hastscript": "^9.0.1",
6363
"html-minifier-terser": "^7.2.0",
6464
"mustache": "^4.2.0",
65-
"postcss": "^8.5.3",
65+
"postcss": "^8.5.4",
6666
"postcss-calc": "^10.1.1",
6767
"preact": "^10.26.8",
6868
"preact-render-to-string": "^6.5.13",

src/generators/jsx-ast/constants.mjs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ export const STABILITY_LEVELS = [
1111
'info', // (3) Legacy
1212
];
1313

14+
/**
15+
* UI classes for heading depths
16+
*/
17+
export const HEADER_SIZE_MAP = [
18+
undefined, // h0
19+
'lg', // h1
20+
'md', // h2
21+
'sm', // h3
22+
'sm', // h4
23+
];
24+
1425
/**
1526
* HTML tag to UI component mappings
1627
*/
@@ -26,19 +37,6 @@ export const TYPE_TRANSFORMS = {
2637
raw: 'text',
2738
};
2839

29-
/**
30-
* API type icon configurations
31-
*/
32-
export const API_ICONS = {
33-
event: { symbol: 'E', color: 'red' },
34-
method: { symbol: 'M', color: 'red' },
35-
property: { symbol: 'P', color: 'red' },
36-
class: { symbol: 'C', color: 'red' },
37-
module: { symbol: 'M', color: 'red' },
38-
classMethod: { symbol: 'S', color: 'red' },
39-
ctor: { symbol: 'C', color: 'red' },
40-
};
41-
4240
/**
4341
* API lifecycle change labels
4442
*/

src/generators/jsx-ast/utils/buildContent.mjs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { sortChanges } from '../../../utils/generators.mjs';
1212
import createQueries from '../../../utils/queries/index.mjs';
1313
import { JSX_IMPORTS } from '../../web/constants.mjs';
1414
import {
15-
API_ICONS,
1615
STABILITY_LEVELS,
16+
HEADER_SIZE_MAP,
1717
LIFECYCLE_LABELS,
1818
INTERNATIONALIZABLE,
1919
} from '../constants.mjs';
@@ -104,15 +104,22 @@ const transformStabilityNode = ({ data }, index, parent) => {
104104
const transformHeadingNode = (entry, node, index, parent) => {
105105
const { data, children } = node;
106106
const headerChildren = [
107-
createElement(`h${data.depth + 1}`, [
108-
createElement(`a#${data.slug}`, { href: `#${data.slug}` }, children),
109-
]),
107+
createElement(
108+
`h${data.depth + 1}`,
109+
{
110+
style: 'display: flex; align-items: center; gap: 8px;',
111+
},
112+
[createElement(`a#${data.slug}`, { href: `#${data.slug}` }, children)]
113+
),
110114
];
111115

112116
// Add type icon if available
113-
if (data.type in API_ICONS) {
114-
headerChildren.unshift(
115-
createJSXElement(JSX_IMPORTS.DataTag.name, API_ICONS[data.type])
117+
if (data.type && data.type !== 'misc') {
118+
headerChildren[0].children.unshift(
119+
createJSXElement(JSX_IMPORTS.DataTag.name, {
120+
kind: data.type,
121+
size: HEADER_SIZE_MAP[data.depth],
122+
})
116123
);
117124
}
118125

src/generators/web/client/components/CodeBox.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useState } from 'react';
22
import BaseCodeBox from '@node-core/ui-components/Common/BaseCodeBox';
3-
import { staticData } from '../utilities.mjs';
3+
import { STATIC_DATA } from '../constants.mjs';
44

5-
const languageDisplayNameMap = new Map(staticData.shikiDisplayNameMap);
5+
const languageDisplayNameMap = new Map(STATIC_DATA.shikiDisplayNameMap);
66

77
/**
88
* Get the display name of a language

src/generators/web/client/components/CodeTabs.jsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/generators/web/client/components/DataTag.jsx

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
import MetaBar from '@node-core/ui-components/Containers/MetaBar';
2-
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub.tsx';
2+
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
3+
import { CodeBracketIcon, DocumentIcon } from '@heroicons/react/24/outline';
34

4-
export default ({ headings, addedIn, readingTime, viewAs, editThisPage }) => {
5-
return (
6-
<MetaBar
7-
heading="Table of Contents"
8-
headings={{ items: headings }}
9-
items={{
10-
'Added In': addedIn,
11-
'Reading Time': readingTime,
12-
'View As': viewAs.map(([title, path]) => <a href={path}>{title}</a>),
13-
Contribute: (
14-
<>
15-
<GitHubIcon className="fill-neutral-700 dark:fill-neutral-100" />
16-
<a href={editThisPage}>Edit this page</a>
17-
</>
18-
),
19-
}}
20-
/>
21-
);
5+
const iconMap = {
6+
JSON: CodeBracketIcon,
7+
MD: DocumentIcon,
228
};
9+
10+
export default ({ headings, addedIn, readingTime, viewAs, editThisPage }) => (
11+
<MetaBar
12+
heading="Table of Contents"
13+
headings={{ items: headings }}
14+
items={{
15+
'Added In': addedIn,
16+
'Reading Time': readingTime,
17+
'View As': (
18+
<ol>
19+
{viewAs.map(([title, path]) => {
20+
const Icon = iconMap[title];
21+
return (
22+
<ol key={title}>
23+
<a href={path}>
24+
{Icon && <Icon className="inline w-4 h-4 mr-1" />}
25+
{title}
26+
</a>
27+
</ol>
28+
);
29+
})}
30+
</ol>
31+
),
32+
Contribute: (
33+
<>
34+
<GitHubIcon className="fill-neutral-700 dark:fill-neutral-100" />
35+
<a href={editThisPage}>Edit this page</a>
36+
</>
37+
),
38+
}}
39+
/>
40+
);

src/generators/web/client/components/SearchBox/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const MDXSearchBox = () => {
2020
setClient(db);
2121

2222
// Then fetch and load the data
23-
const response = await fetch('/orama-db.json');
23+
const response = await fetch('orama-db.json');
2424
if (response.ok) {
2525
load(db, await response.json());
2626
}
@@ -35,6 +35,7 @@ const MDXSearchBox = () => {
3535
return (
3636
<>
3737
<OramaSearchButton
38+
aria-disabled={!client || isLoading}
3839
style={{ flexGrow: 1 }}
3940
colorScheme={colorScheme}
4041
themeConfig={themeConfig}
@@ -43,6 +44,7 @@ const MDXSearchBox = () => {
4344
Search documentation
4445
</OramaSearchButton>
4546
<OramaSearchBox
47+
aria-disabled={!client || isLoading}
4648
disableChat={true}
4749
linksTarget="_self"
4850
clientInstance={client}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-undef
2+
export const STATIC_DATA = __STATIC_DATA__;

0 commit comments

Comments
 (0)