From 84f4a44226db39290468bda6027ee5e83c7d9a22 Mon Sep 17 00:00:00 2001 From: alberto Date: Wed, 11 Mar 2020 15:43:57 +0100 Subject: [PATCH 1/4] feat(template js): add pregress line based on config --- template/src/index.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/template/src/index.js b/template/src/index.js index 1a65777..28d6f77 100644 --- a/template/src/index.js +++ b/template/src/index.js @@ -15,6 +15,7 @@ Get configuration parameters and initialize the web page; function init(config) { addEventListeners(config); setBorders(config.width, config.height); + addProgress(config); } /* @@ -67,3 +68,35 @@ function handleOnkeydown(event) { // No default } } + +/* + Add progress to each slide based on config +*/ + +function addProgress(config) { + if(!config.progress || config.progress === 'none') { + return; + } + + const articles = [...document.getElementsByTagName('article')]; + + if(config.progress === 'line') { + articles.forEach((article, index) => { + const line = document.createElement('div'); + line.classList.add("progress-line"); + article.appendChild(line); + + line.style.backgroundColor = 'var(--primary-color)'; + + line.style.height = '3px'; + line.style.position = 'absolute'; + + line.style.bottom = '0'; + line.style.left = '0'; + + const normIndex = index / (articles.length - 1); + + line.style.width = `${config.width * normIndex}px`; + }) + } + } From 9d9598257fc37ef8dcf56b916384f5403eec6a5b Mon Sep 17 00:00:00 2001 From: alberto Date: Wed, 11 Mar 2020 15:51:02 +0100 Subject: [PATCH 2/4] style: fix inden --- template/src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/src/index.js b/template/src/index.js index 28d6f77..5c76298 100644 --- a/template/src/index.js +++ b/template/src/index.js @@ -1,5 +1,5 @@ /* -Get configuration parameters and initialize the web page; + Get configuration parameters and initialize the web page; */ (async function () { @@ -99,4 +99,4 @@ function addProgress(config) { line.style.width = `${config.width * normIndex}px`; }) } - } +} From 3af958f7fc67db43dd8e2811ca2cb22c58a518d1 Mon Sep 17 00:00:00 2001 From: alberto Date: Wed, 11 Mar 2020 17:33:55 +0100 Subject: [PATCH 3/4] fix(template js): fix query selector for nested articles and primary color default --- template/src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/src/index.js b/template/src/index.js index 5c76298..bbbb2a1 100644 --- a/template/src/index.js +++ b/template/src/index.js @@ -78,7 +78,7 @@ function addProgress(config) { return; } - const articles = [...document.getElementsByTagName('article')]; + const articles = [...document.querySelectorAll()('main > article')]; if(config.progress === 'line') { articles.forEach((article, index) => { @@ -86,7 +86,7 @@ function addProgress(config) { line.classList.add("progress-line"); article.appendChild(line); - line.style.backgroundColor = 'var(--primary-color)'; + line.style.backgroundColor = 'var(--primary-color, #000)'; line.style.height = '3px'; line.style.position = 'absolute'; From e5db10fc21dd64c5064ecab5dccfc07ddb36fc44 Mon Sep 17 00:00:00 2001 From: alberto Date: Wed, 11 Mar 2020 17:34:25 +0100 Subject: [PATCH 4/4] improvement(template config): add default line progress --- template/onepunch.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/template/onepunch.json b/template/onepunch.json index adffe4f..34ad98a 100644 --- a/template/onepunch.json +++ b/template/onepunch.json @@ -1,4 +1,5 @@ { "width": 960, - "height": 600 + "height": 600, + "progress": "line" }