mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-30 20:49:49 +02:00
Animate progress on the homescreen
This commit is contained in:
@@ -47,4 +47,5 @@ const { isUpcoming = false, isNew = false, text, url } = Astro.props;
|
|||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
<span data-progress class="z-10 bg-[#172a3a] absolute top-0 left-0 bottom-0 duration-300 transition-[width] w-0"></span>
|
||||||
</a>
|
</a>
|
||||||
|
@@ -37,21 +37,12 @@ async function renderProgress() {
|
|||||||
const totalDone = progress.done + progress.skipped;
|
const totalDone = progress.done + progress.skipped;
|
||||||
const percentageDone = (totalDone / progress.total) * 100;
|
const percentageDone = (totalDone / progress.total) * 100;
|
||||||
|
|
||||||
const progressBar = document.createElement('div');
|
const progressBar: HTMLElement = element.querySelector('[data-progress]')!;
|
||||||
progressBar.style.backgroundColor = 'rgb(23 42 58)';
|
|
||||||
progressBar.style.position = 'absolute';
|
|
||||||
progressBar.style.width = `${percentageDone}%`;
|
progressBar.style.width = `${percentageDone}%`;
|
||||||
progressBar.style.height = '100%';
|
|
||||||
progressBar.style.bottom = '0';
|
|
||||||
progressBar.style.left = '0';
|
|
||||||
progressBar.style.top = '0';
|
|
||||||
progressBar.style.zIndex = '1';
|
|
||||||
|
|
||||||
element.appendChild(progressBar);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// on DOM load
|
// on DOM load
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
window.setTimeout(renderProgress, 0);
|
window.setTimeout(renderProgress, 0);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user