Skip to content

Commit 6007bae

Browse files
committed
fix sidebar height, gzip the jsons
1 parent 13a87eb commit 6007bae

File tree

10 files changed

+19
-14
lines changed

10 files changed

+19
-14
lines changed

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"scripts": {
55
"dev": "vite",
66
"build": "vite build",
7+
"preview": "vite preview",
78
"lint": "eslint .",
89
"test": "tsc --noEmit && npm run lint"
910
},

web/public/cs2.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

web/public/cs2.json.gz

480 KB
Binary file not shown.

web/public/deadlock.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

web/public/deadlock.json.gz

881 KB
Binary file not shown.

web/public/dota2.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

web/public/dota2.json.gz

1.05 MB
Binary file not shown.

web/src/components/layout/Sidebar.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ import { DeclarationsContext } from "~components/Docs/DeclarationsContext";
77
import { NAVBAR_HEIGHT } from "./constants";
88

99
const SidebarLink = styled(NavLink)`
10-
display: block;
10+
display: flex;
11+
align-items: center;
12+
gap: 4px;
1113
background: transparent;
1214
border-left: 2px solid transparent;
13-
padding: 4px 8px;
15+
padding: 0 8px;
16+
height: 28px;
1417
text-decoration: none;
1518
color: ${(props) => props.theme.text};
1619
overflow: hidden;
1720
text-overflow: ellipsis;
1821
white-space: nowrap;
1922
box-sizing: border-box;
2023
font-size: 14px;
21-
line-height: 20px;
2224
transition: background 0.1s, color 0.1s;
2325
2426
&:hover {
@@ -33,17 +35,13 @@ const SidebarLink = styled(NavLink)`
3335
}
3436
`;
3537

36-
const SidebarKindIcon = styled(KindIcon)`
37-
vertical-align: ${({ kind }) => (kind === "interface" ? "middle" : "baseline")};
38-
`;
39-
4038
export const SidebarElement: React.FC<{
4139
to: string;
4240
icon: IconKind;
4341
text: string;
4442
}> = React.memo(({ to, icon, text }) => (
4543
<SidebarLink to={to}>
46-
<SidebarKindIcon kind={icon} size="small" /> {text}
44+
<KindIcon kind={icon} size="small" /> {text}
4745
</SidebarLink>
4846
));
4947

web/src/pages/DeclarationsSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function groupByModule(declarations: Declaration[]): ModuleGroup[] {
3737

3838
const HEADER_HEIGHT = 28;
3939
const HEADER_GAP = 8;
40-
const ITEM_HEIGHT = 24;
40+
const ITEM_HEIGHT = 28;
4141

4242
export const DeclarationsSidebar = () => {
4343
const { declarations } = useContext(DeclarationsContext);

web/src/pages/data.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@ export async function loadGameSchemas(gameId: GameId): Promise<Declaration[]> {
2929
const cached = cache.get(gameId);
3030
if (cached) return cached;
3131

32-
const response = await fetch(`${import.meta.env.BASE_URL}${gameId}.json`);
32+
const response = await fetch(`${import.meta.env.BASE_URL}${gameId}.json.gz`);
3333
if (!response.ok) throw new Error(`Failed to load ${gameId} schemas: ${response.status}`);
34-
const data: SchemasJson = await response.json();
34+
35+
let data: SchemasJson;
36+
if (response.headers.get("Content-Type")?.includes("application/json")) {
37+
// Vite dev server: already decompressed via Content-Encoding
38+
data = await response.json();
39+
} else {
40+
// GitHub Pages / static hosting: raw gzip bytes
41+
const decompressed = response.body!.pipeThrough(new DecompressionStream("gzip"));
42+
data = await new Response(decompressed).json();
43+
}
3544

3645
const result = parseSchemas(data);
3746
cache.set(gameId, result);

0 commit comments

Comments
 (0)