Skip to content

Commit 14d44f5

Browse files
committed
Add link to github
1 parent f563576 commit 14d44f5

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

src/components/Docs/SchemaClass.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ReferencedBy } from "./ReferencedBy";
77
import { CrossGameRefs } from "./CrossGameRefs";
88
import { KindIcon } from "../KindIcon";
99
import { DeclarationsContext, declarationKey } from "./DeclarationsContext";
10+
import { getGame } from "../../games";
1011
import {
1112
matchesWords,
1213
matchesMetadataKeys,
@@ -105,6 +106,38 @@ export const ModuleBadge: React.FC<{ module: string }> = ({ module }) => {
105106
);
106107
};
107108

109+
const GitHubIcon = styled.a`
110+
display: inline-flex;
111+
align-items: center;
112+
color: var(--text-dim);
113+
margin-left: 4px;
114+
115+
&:hover {
116+
color: var(--highlight);
117+
}
118+
`;
119+
120+
export const GitHubFileLink: React.FC<{ module: string; name: string }> = ({ module, name }) => {
121+
const { game } = useContext(DeclarationsContext);
122+
const gameData = getGame(game);
123+
if (!gameData) return null;
124+
const fileName = name.replace(/:/g, "_");
125+
const url = `https://github.com/${gameData.repo}/blob/master/DumpSource2/schemas/${module}/${fileName}.h`;
126+
return (
127+
<GitHubIcon href={url} target="_blank" rel="noopener noreferrer" title="View on GitHub">
128+
<svg
129+
xmlns="http://www.w3.org/2000/svg"
130+
viewBox="0 0 16 16"
131+
width="16"
132+
height="16"
133+
fill="currentColor"
134+
>
135+
<path d="M6.766 11.695C4.703 11.437 3.25 9.904 3.25 7.92c0-.806.281-1.677.75-2.258-.203-.532-.172-1.662.062-2.129.626-.081 1.469.258 1.969.726.594-.194 1.219-.291 1.985-.291.765 0 1.39.097 1.953.274.484-.451 1.343-.79 1.969-.709.218.435.25 1.564.046 2.113.5.613.766 1.436.766 2.274 0 1.984-1.453 3.485-3.547 3.759.531.355.891 1.129.891 2.016v1.678c0 .484.39.758.859.564C13.781 14.824 16 11.905 16 8.291 16 3.726 12.406 0 7.984 0 3.562 0 0 3.726 0 8.291c0 3.581 2.203 6.55 5.172 7.663A.595.595 0 0 0 6 15.389v-1.291c-.219.097-.5.162-.75.162-1.031 0-1.641-.581-2.078-1.662-.172-.435-.36-.693-.719-.742-.187-.016-.25-.097-.25-.193 0-.194.313-.339.625-.339.453 0 .844.29 1.25.887.313.468.641.678 1.031.678.391 0 .641-.146 1-.516.266-.275.469-.517.657-.678Z"></path>
136+
</svg>
137+
</GitHubIcon>
138+
);
139+
};
140+
108141
export const SchemaClassView: React.FC<{
109142
declaration: api.SchemaClass;
110143
}> = ({ declaration }) => {
@@ -161,6 +194,7 @@ export const SchemaClassView: React.FC<{
161194
{declaration.name}
162195
</DeclarationNameLink>
163196
<ModuleBadge module={declaration.module} />
197+
<GitHubFileLink module={declaration.module} name={declaration.name} />
164198
</CommonGroupSignature>
165199
</DeclarationHeader>
166200
{(!collapseNonMatching ||

src/components/Docs/SchemaEnum.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { MetadataTags } from "./SchemaType";
88
import { formatHexOffset } from "./utils/format";
99
import { ReferencedBy } from "./ReferencedBy";
1010
import { CrossGameRefs } from "./CrossGameRefs";
11-
import { ModuleBadge } from "./SchemaClass";
11+
import { ModuleBadge, GitHubFileLink } from "./SchemaClass";
1212
import {
1313
matchesWords,
1414
matchesMetadataKeys,
@@ -96,6 +96,7 @@ export const SchemaEnumView: React.FC<{
9696
</DeclarationNameLink>
9797
<EnumTypeWrapper>: {declaration.alignment}</EnumTypeWrapper>
9898
<ModuleBadge module={declaration.module} />
99+
<GitHubFileLink module={declaration.module} name={declaration.name} />
99100
</CommonGroupSignature>
100101
</DeclarationHeader>
101102
{(!collapseNonMatching ||

src/games.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import React from "react";
22

33
export type GameId = "cs2" | "dota2" | "deadlock";
44

5-
export const GAMES: { id: GameId; name: string; icon: React.ReactNode }[] = [
5+
export const GAMES: { id: GameId; name: string; repo: string; icon: React.ReactNode }[] = [
66
{
77
id: "cs2",
88
name: "Counter-Strike 2",
9+
repo: "SteamTracking/GameTracking-CS2",
910

1011
icon: (
1112
<svg viewBox="0 0 32 32" width="24" height="24">
@@ -21,6 +22,7 @@ export const GAMES: { id: GameId; name: string; icon: React.ReactNode }[] = [
2122
{
2223
id: "dota2",
2324
name: "Dota 2",
25+
repo: "SteamTracking/GameTracking-Dota2",
2426

2527
icon: (
2628
<svg viewBox="0 0 32 32" width="24" height="24">
@@ -36,6 +38,7 @@ export const GAMES: { id: GameId; name: string; icon: React.ReactNode }[] = [
3638
{
3739
id: "deadlock",
3840
name: "Deadlock",
41+
repo: "SteamTracking/GameTracking-Deadlock",
3942

4043
icon: (
4144
<svg viewBox="0 0 32 32" width="24" height="24">

0 commit comments

Comments
 (0)