-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
31 lines (24 loc) · 1.27 KB
/
App.js
File metadata and controls
31 lines (24 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import './app.scss';
import { DynamicPage } from './src/PageFlow.js';
import HtmlModule from './Modules/HtmlModule.js'; // Import HTML rendering example
import ClassModule from './Modules/ClassModule.js'; // Import Class/JS rendering example
// Global State
const state = {
counter: 1,
}
// Components to Render on each page load. Add RenderComponent functions to the Module Classes here.
// Each time the page is loaded these functions are called
let renderList = [() => {
document.querySelectorAll('a').forEach(link => {
link.addEventListener('click', (a) => {
a.preventDefault();
dynamicPage._makeRequest(link.href); // Make Request and Render
});
});
}];
renderList = [...renderList, HtmlModule({ val: state, parent: '.myParent2' }).RenderComponent]; // Works
renderList = [...renderList, ClassModule({ val: state, parent: '.myParent' }).RenderComponent];
// Define DynamicPage // Source = The HTML element to grab (OuterHTML) // target = The Placement
// DynamicPage needs to load after any specified data - should technically be the last Function loaded
const dynamicPage = new DynamicPage({source: 'DynamicPage', target: 'App'}, renderList);
dynamicPage._makeRequest('index.html'); // Make Request and Render index.html to the page