Skip to content

Commit 19e0c58

Browse files
committed
Update page navigation
There's not target on each button
1 parent a7f2213 commit 19e0c58

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

pages/tenfoot/index.pug

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extends ../components/tenfoot_layout
1+
extends ../../components/tenfoot_layout
22

33
block title
44
h2 Welcome
@@ -7,27 +7,27 @@ block title
77
block content
88
link(rel="stylesheet" href="/styles/menu10foot.scss")
99
section.menu10foot
10-
.menu10foot-card(tabindex="0" role="button" data-service="stregsystem")
10+
.menu10foot-card(tabindex="0" role="button" data-link="stregsystem")
1111
.menu10foot-icon 💵
1212
.menu10foot-title Stregsystem
1313
.menu10foot-description Browse our collection of wares
1414

15-
.menu10foot-card(tabindex="1" role="button" data-service="songbook")
15+
.menu10foot-card(tabindex="1" role="button" data-link="songbook")
1616
.menu10foot-icon 🎼
1717
.menu10foot-title Songbook
1818
.menu10foot-description Browse our collection of songs
1919

20-
.menu10foot-card(tabindex="2" role="button" data-service="events")
20+
.menu10foot-card(tabindex="2" role="button" data-link="events")
2121
.menu10foot-icon 📅
2222
.menu10foot-title Events
2323
.menu10foot-description List upcoming events
2424

25-
.menu10foot-card(tabindex="3" role="button" data-service="links")
25+
.menu10foot-card(tabindex="3" role="button" data-link="links")
2626
.menu10foot-icon 🌐
2727
.menu10foot-title Links
2828
.menu10foot-description Look at nice links
2929

30-
.menu10foot-card(tabindex="4" role="button" data-service="exit")
30+
.menu10foot-card(tabindex="4" role="button" data-link="//")
3131
.menu10foot-icon ➜]
3232
.menu10foot-title Exit
3333
.menu10foot-description Leave 10-foot display

scripts/tenfoot/menu.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export interface GotoPage {
99

1010
export class TenFootMenu {
1111
private cards: NodeListOf<HTMLElement>;
12-
private navigator: GotoPage;
12+
private nav: GotoPage;
1313
private currentIndex: number;
1414

1515
constructor(navigator: GotoPage, cardContainer: Element) {
16-
this.navigator = navigator;
16+
this.nav = navigator;
1717
this.cards = cardContainer.querySelectorAll<HTMLElement>('.menu10foot-card');
1818
this.currentIndex = 0;
1919
this.init();
@@ -60,21 +60,14 @@ export class TenFootMenu {
6060

6161
private setupClickHandlers(): void {
6262
this.cards.forEach((card: HTMLElement, index: number) => {
63-
card.addEventListener('click', () => {
64-
const service = card.dataset.service || '';
63+
card.addEventListener('click', async () => {
64+
const link = card.dataset.link || '';
6565
const titleElement = card.querySelector('.service-title');
6666
const title = titleElement?.textContent || '';
6767

68-
console.log(`Selected: ${title} (${service})`);
68+
console.log(`Selected: ${title} (${link})`);
6969

70-
// Dispatch custom event for handling navigation
71-
const event = new CustomEvent<ServiceSelected>('serviceSelected', {
72-
detail: { service }
73-
});
74-
document.dispatchEvent(event);
75-
76-
// Add your navigation logic here
77-
// navigator.navigateTo("links").then(r => console.log(r));
70+
await this.nav.navigateTo(link);
7871
});
7972

8073
card.addEventListener('focus', () => {

scripts/tenfoot/tenfoot-navigation.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,18 @@ class TenFootNavigator implements GotoPage {
5858
await this.LoadPage(page);
5959
}
6060

61-
async LoadPage(path: string) {
61+
async LoadPage(tenfoot_page: string) {
62+
// Special case of navigation
63+
if (tenfoot_page == "//"){
64+
window.location.href = "/";
65+
}else if (tenfoot_page == "/"){
66+
tenfoot_page = "index";
67+
}
68+
6269
const app = document.getElementsByTagName('section')[0]
6370

6471
try {
65-
const response = await fetch(`/${path}.html`);
72+
const response = await fetch(`/tenfoot/${tenfoot_page}.html`);
6673
const html = await response.text();
6774
app.innerHTML = html;
6875

0 commit comments

Comments
 (0)