aboutsummaryrefslogtreecommitdiffstats
path: root/htdocs/src/js/app.js
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-10-24 18:56:45 +0200
committerArmand Philippot <git@armandphilippot.com>2021-10-24 18:56:45 +0200
commit52695360f9f6a51a808480986e91d74dab09d2e1 (patch)
tree9e0a3db86f58960cd16726997b4ffb8fbb60fa7e /htdocs/src/js/app.js
parent2afa7afed65d3a14c5f65c92d4f1a2345ca0ec1d (diff)
chore: print the projects list
Diffstat (limited to 'htdocs/src/js/app.js')
-rw-r--r--htdocs/src/js/app.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/htdocs/src/js/app.js b/htdocs/src/js/app.js
index 1b7bbc6..959bc56 100644
--- a/htdocs/src/js/app.js
+++ b/htdocs/src/js/app.js
@@ -1,6 +1,37 @@
+import projects from './config/projects';
import { isStyleJsExists } from './utilities/helpers';
/**
+ * Create a list item for a project.
+ * @param {Integer} id - The project id.
+ * @param {String} name - The project name.
+ * @returns {HTMLElement} The list item.
+ */
+function getProjectsNavItem(id, name) {
+ const item = document.createElement('li');
+ const link = document.createElement('a');
+ link.classList.add('nav__link', 'nav__link--app');
+ link.href = id;
+ link.id = id;
+ link.textContent = name;
+ item.classList.add('nav__item');
+ item.appendChild(link);
+ return item;
+}
+
+/**
+ * Print the list of available projects.
+ */
+function printProjectsNav() {
+ const ul = document.querySelector('.nav .nav__list');
+
+ projects.forEach((project) => {
+ const item = getProjectsNavItem(project.id, project.name);
+ ul.appendChild(item);
+ });
+}
+
+/**
* Add style.js script for development purposes.
*/
function loadWebpackStyles() {
@@ -17,6 +48,7 @@ function loadWebpackStyles() {
*/
function init() {
loadWebpackStyles();
+ printProjectsNav();
}
init();