Skip to content

Commit 671339c

Browse files
committed
fix class tree overflowing
1 parent 9990bc8 commit 671339c

3 files changed

Lines changed: 31 additions & 37 deletions

File tree

src/components/DeclarationsPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export default function DeclarationsPage({ context }: { context: DeclarationsCon
6666
const ContentColumn = styled.div`
6767
display: flex;
6868
flex-direction: column;
69+
min-width: 0;
6970
min-height: 0;
7071
padding-right: 32px;
7172

src/components/schema/ClassTree.tsx

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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

6347
const 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

7361
const 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+
8580
const 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

9490
function 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>

src/components/schema/ContentList.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ const InfoLink = styled.a`
9696
`;
9797

9898
const SearchFiltersBlock = styled(CardBlock)`
99+
dl {
100+
margin: 0;
101+
}
102+
99103
dt {
100104
font-weight: 600;
101105
color: var(--text);
@@ -283,7 +287,7 @@ export function ContentList() {
283287
</InfoBlock>
284288
<SearchFiltersBlock>
285289
<dl>
286-
<dt>Search by name</dt>
290+
<dt>Search by name, filters can be combined</dt>
287291
<dd>Type any text to match class, field, or enum names.</dd>
288292
{SEARCH_TAGS.map((t) => (
289293
<React.Fragment key={t.tag}>
@@ -295,7 +299,6 @@ export function ContentList() {
295299
</React.Fragment>
296300
))}
297301
</dl>
298-
Filters can be combined.
299302
</SearchFiltersBlock>
300303
{module ? <ClassTree module={module} /> : <ModuleList />}
301304
</>

0 commit comments

Comments
 (0)