Skip to content

Commit 4a1a263

Browse files
committed
wip: nav info content
1 parent c6028ac commit 4a1a263

File tree

5 files changed

+88
-7
lines changed

5 files changed

+88
-7
lines changed

src/components/vertical-nav/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
import {headerNav} from "./header-nav.ts";
33
import {footerNav} from "./footer-nav.ts";
44
import {trackBreadcrumbs} from "./breadcrumbs-nav.ts";
5+
import {renderInfo} from "./info-nav.ts";
56
export * from "./header-nav.ts";
67
export * from "./breadcrumbs-nav.ts";
78
export * from "./footer-nav.ts";
89

910
//-----------------------------------------------------------------------
1011

11-
export function VerticalNav() {
12+
export function verticalNav() {
1213
const navBox = document.createElement("div");
1314
const navWrapper = document.createElement("div");
1415

@@ -19,6 +20,7 @@ export function VerticalNav() {
1920
navBox.appendChild(headerNav());
2021
navBox.appendChild(navWrapper);
2122
navWrapper.appendChild(trackBreadcrumbs());
23+
navWrapper.appendChild(renderInfo());
2224
navBox.appendChild(footerNav());
2325

2426
return navBox;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+

2+
3+
export function renderInfo() {
4+
const infoSection = document.createElement("div");
5+
6+
infoSection.id = "info-section";
7+
8+
return infoSection;
9+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
export type AboutProject = [
2+
release: string,
3+
platforms: string,
4+
developer: string
5+
]
6+
7+
export type RelatedLinks = [
8+
name: string,
9+
path: string,
10+
]
11+
12+
export function projectInfo(about: AboutProject, links: RelatedLinks[]) {
13+
const info = document.createElement("div");
14+
15+
if (about != null) {
16+
info.appendChild(sectionAboutTheGame(about));
17+
}
18+
19+
if (links != null) {
20+
info.appendChild(sectionRelatedLinks(links));
21+
}
22+
}
23+
24+
25+
function sectionAboutTheGame(about: AboutProject) {
26+
const [release, platforms, developer] = about;
27+
28+
const detailSection = document.createElement('div');
29+
const detailTitle = document.createElement("h4");
30+
const releaseDate = document.createElement("p");
31+
const platformAvailable = document.createElement("p");
32+
const developerNames = document.createElement("p");
33+
34+
detailSection.className = "detail-section";
35+
detailTitle.textContent = "About the Project"
36+
releaseDate.textContent = "<b>Release date: </b>" + release;
37+
platformAvailable.textContent = "<b>Platforms: </b" + platforms;
38+
developerNames.textContent = "<b>Developer: </b>" + developer;
39+
40+
detailSection.appendChild(detailTitle);
41+
detailSection.appendChild(releaseDate);
42+
detailSection.appendChild(platformAvailable);
43+
detailSection.appendChild(developerNames);
44+
45+
return detailSection;
46+
}
47+
48+
49+
function sectionRelatedLinks(relatedLinks: RelatedLinks[]) {
50+
const detailSection = document.createElement('div');
51+
const linkList = document.createElement('ul');
52+
53+
detailSection.className = "detail-section";
54+
detailSection.appendChild(linkList);
55+
56+
relatedLinks.forEach(relatedLink => {
57+
const [name, path] = relatedLink;
58+
const linkLine = document.createElement('li');
59+
const link = document.createElement("a");
60+
61+
link.href = path;
62+
link.target = "_blank";
63+
link.textContent = name;
64+
65+
linkList.appendChild(linkLine);
66+
linkLine.appendChild(link);
67+
})
68+
69+
return detailSection;
70+
}

src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import './views/home-view/styles.css';
22
import { ProjectPage } from "./content/projects/tank";
3-
import { VerticalNav } from "./components/vertical-nav";
3+
import { verticalNav } from "./components/vertical-nav";
44
import {createContentBase, renderContent} from "./views/utils";
55

66

77
function init() {
8-
createContentBase();
8+
const body = document.getElementsByTagName("body")[0];
9+
const contentPage = createContentBase();
910

10-
const contentPage = document.getElementById('content-page')
11-
const verticalNav = VerticalNav();
12-
13-
contentPage?.appendChild(verticalNav);
11+
body.appendChild(contentPage);
12+
contentPage.appendChild(verticalNav());
1413

1514
renderContent(ProjectPage);
1615
}

src/views/utils/view-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function createContentBase() {
1111
wrapper.id = 'wrapper';
1212

1313
page.appendChild(wrapper);
14+
return page;
1415
}
1516

1617
export function renderContent(contentFn: Function) {

0 commit comments

Comments
 (0)