1
1
import './styles.css' ;
2
2
import { trackBreadcrumbs } from "./breadcrumbs-nav.ts" ;
3
+ import { EventBus } from "../../event-bus" ;
4
+ import { Events } from "../../consts/events" ;
5
+ import { handlers } from "../../consts/handlers" ;
3
6
4
7
import cdIcon from "/img/common/cd_icon_green.png" ;
5
8
import githubIcon from "./assets/github-icon.svg" ;
6
9
import linkedIcon from "./assets/linkedin-icon.svg" ;
7
10
import instagramIcon from "./assets/instagram-icon.svg" ;
11
+ import { TankInfo , TankView } from "../../content/projects/tank" ;
12
+ import { SpaceCompassInfo , SpaceCompassView } from "../../content/projects/space-compass" ;
13
+
14
+ const EVENT_BUS = new EventBus < Events > ( ) ;
15
+ EVENT_BUS . subscribe ( 'breadcrumb_button' , handlers . breadcrumb_button ) ;
8
16
9
17
const navTitle = "CD-BASH" ;
10
18
const githubProfile : string = "https://github.com/CD-BASH"
@@ -37,40 +45,41 @@ export function buildVerticalNav() {
37
45
navBox . appendChild ( header ( ) ) ;
38
46
navBox . appendChild ( navWrapper ) ;
39
47
navWrapper . appendChild ( trackBreadcrumbs ( ) ) ;
48
+ navBox . appendChild ( testButtons ( ) ) ;
40
49
navBox . appendChild ( footer ( ) ) ;
41
50
42
51
return navBox ;
43
52
}
44
53
45
54
export function renderNavInfo ( infoFn : Function ) {
46
- const wrapper = clearInfo ( ) ;
55
+ const navWrapper = clearInfo ( ) ;
47
56
const info = infoFn ( ) ;
48
57
49
- wrapper ?. appendChild ( info ) ;
58
+ navWrapper ?. appendChild ( info ) ;
50
59
}
51
60
52
61
//-----------------------------------------------------------------------
53
62
54
63
function header ( ) {
55
64
const container = document . createElement ( "div" ) ;
56
65
const topTriangle = document . createElement ( "div" ) ;
57
- const info = document . createElement ( "div" ) ;
66
+ const logo = document . createElement ( "div" ) ;
58
67
const icon = document . createElement ( "img" ) ;
59
68
const title = document . createElement ( "h5" ) ;
60
69
61
70
container . className = "header" ;
62
71
topTriangle . className = "top-triangle" ;
63
72
64
- info . className = "info" ;
73
+ logo . className = "info" ;
65
74
icon . className = "icon" ;
66
75
icon . src = cdIcon ;
67
76
68
77
title . textContent = navTitle ;
69
78
70
79
container . appendChild ( topTriangle ) ;
71
- container . appendChild ( info ) ;
72
- info . appendChild ( icon ) ;
73
- info . appendChild ( title ) ;
80
+ container . appendChild ( logo ) ;
81
+ logo . appendChild ( icon ) ;
82
+ logo . appendChild ( title ) ;
74
83
75
84
return container ;
76
85
}
@@ -112,7 +121,36 @@ function clearInfo() {
112
121
const cleanInfo = document . getElementById ( 'nav-wrapper' ) ;
113
122
cleanInfo ?. childNodes . forEach ( ( childNode ) => {
114
123
cleanInfo . removeChild ( childNode ) ;
124
+ console . log ( "hi" ) ;
115
125
} ) ;
116
126
127
+ console . log ( cleanInfo ) ;
128
+
117
129
return cleanInfo ;
130
+ }
131
+
132
+
133
+
134
+ function testButtons ( ) {
135
+ const buttonContainer = document . createElement ( "div" ) ;
136
+ const buttonA = document . createElement ( "button" ) ;
137
+ const buttonB = document . createElement ( "button" ) ;
138
+
139
+ buttonContainer . className = "button-container" ;
140
+
141
+ buttonA . id = "button-a" ;
142
+ buttonA . className = "button" ;
143
+ buttonA . textContent = "Button A" ;
144
+ buttonB . id = "button-b" ;
145
+ buttonB . className = "button" ;
146
+ buttonB . textContent = "Button B" ;
147
+
148
+
149
+ buttonA . addEventListener ( 'click' , ( ) => EVENT_BUS . dispatch ( 'breadcrumb_button' , { path : "Button A" , projectName : "TANK" , projectView : TankView , projectInfo : TankInfo } ) ) ;
150
+ buttonB . addEventListener ( 'click' , ( ) => EVENT_BUS . dispatch ( 'breadcrumb_button' , { path : "Button B" , projectName : "Space Compass" , projectView : SpaceCompassView , projectInfo : SpaceCompassInfo } ) ) ;
151
+
152
+ buttonContainer . appendChild ( buttonA ) ;
153
+ buttonContainer . appendChild ( buttonB ) ;
154
+
155
+ return buttonContainer ;
118
156
}
0 commit comments