@@ -9,12 +9,7 @@ interface TreeNode {
99 children : TreeNode [ ] ;
1010}
1111
12- interface ModuleGroup {
13- module : string ;
14- roots : TreeNode [ ] ;
15- }
16-
17- function buildTree ( classesByKey : Map < string , SchemaClass > ) : ModuleGroup [ ] {
12+ function buildTree ( classesByKey : Map < string , SchemaClass > ) : TreeNode [ ] {
1813 const allNodes = new Map < string , TreeNode > ( ) ;
1914 const hasParentInTree = new Set < string > ( ) ;
2015
@@ -39,31 +34,24 @@ function buildTree(classesByKey: Map<string, SchemaClass>): ModuleGroup[] {
3934 }
4035 }
4136
42- const moduleRoots = new Map < string , TreeNode [ ] > ( ) ;
37+ const roots : TreeNode [ ] = [ ] ;
4338 for ( const [ key , node ] of allNodes ) {
4439 if ( ! hasParentInTree . has ( key ) ) {
45- let roots = moduleRoots . get ( node . cls . module ) ;
46- if ( ! roots ) {
47- roots = [ ] ;
48- moduleRoots . set ( node . cls . module , roots ) ;
49- }
5040 roots . push ( node ) ;
5141 }
5242 }
53-
54- const groups : ModuleGroup [ ] = [ ] ;
55- for ( const [ module , roots ] of moduleRoots ) {
56- roots . sort ( ( a , b ) => a . cls . name . localeCompare ( b . cls . name ) ) ;
57- groups . push ( { module, roots } ) ;
58- }
59- groups . sort ( ( a , b ) => a . module . localeCompare ( b . module ) ) ;
60- return groups ;
43+ roots . sort ( ( a , b ) => a . cls . name . localeCompare ( b . cls . name ) ) ;
44+ return roots ;
6145}
6246
6347const ClassLink = styled ( Link ) `
6448 text-decoration: none;
6549 color: var(--text);
6650 font-size: 14px;
51+ display: block;
52+ overflow: hidden;
53+ text-overflow: ellipsis;
54+ white-space: nowrap;
6755
6856 &:hover {
6957 color: var(--highlight);
@@ -72,7 +60,7 @@ const ClassLink = styled(Link)`
7260
7361const TreeList = styled . ul `
7462 margin: 0;
75- padding-left: 20px ;
63+ padding-left: 10px ;
7664 list-style: none;
7765` ;
7866
@@ -82,13 +70,21 @@ const RootList = styled.ul`
8270 list-style: none;
8371` ;
8472
73+ const TreeHeading = styled . h1 `
74+ margin: 0 0 8px;
75+ font-size: 18px;
76+ font-weight: 600;
77+ color: var(--text);
78+ ` ;
79+
8580const TreeContainer = styled . div `
8681 max-width: 560px;
8782 margin: 16px auto 0;
8883 padding: 16px 20px;
8984 background: var(--group);
9085 border: 1px solid var(--group-border);
9186 border-radius: 10px;
87+ overflow: hidden;
9288` ;
9389
9490function TreeNodeView ( { node, game } : { node : TreeNode ; game : string } ) {
@@ -127,24 +123,18 @@ export function ClassTree({ module }: { module?: string }) {
127123 return filtered ;
128124 } , [ classesByKey , module ] ) ;
129125
130- const groups = useMemo ( ( ) => buildTree ( filteredClassesByKey ) , [ filteredClassesByKey ] ) ;
126+ const roots = useMemo ( ( ) => buildTree ( filteredClassesByKey ) , [ filteredClassesByKey ] ) ;
131127
132128 return (
133129 < TreeContainer >
130+ < TreeHeading > { module } </ TreeHeading >
134131 < RootList >
135- { groups . map ( ( group ) => (
136- < li key = { group . module } >
137- < strong > { group . module } </ strong >
138- < TreeList >
139- { group . roots . map ( ( node ) => (
140- < TreeNodeView
141- key = { declarationKey ( node . cls . module , node . cls . name ) }
142- node = { node }
143- game = { game }
144- />
145- ) ) }
146- </ TreeList >
147- </ li >
132+ { roots . map ( ( node ) => (
133+ < TreeNodeView
134+ key = { declarationKey ( node . cls . module , node . cls . name ) }
135+ node = { node }
136+ game = { game }
137+ />
148138 ) ) }
149139 </ RootList >
150140 </ TreeContainer >
0 commit comments