fix: properly handle tabs overflow (#422)
Some checks failed
Deploy Hugo site to Pages / build (push) Has been cancelled
Deploy Hugo site to Pages / deploy (push) Has been cancelled

* fix: properly handle tabs overflow

* chore: rebuild css
This commit is contained in:
Xin
2024-07-10 01:11:51 +01:00
committed by GitHub
parent 56f6f19978
commit e3b582676e
5 changed files with 30 additions and 21 deletions

View File

@ -1,14 +1,14 @@
document.querySelectorAll('.tabs-toggle').forEach(function (button) {
document.querySelectorAll('.hextra-tabs-toggle').forEach(function (button) {
button.addEventListener('click', function (e) {
// set parent tabs to unselected
const tabs = Array.from(e.target.parentElement.querySelectorAll('.tabs-toggle'));
const tabs = Array.from(e.target.parentElement.querySelectorAll('.hextra-tabs-toggle'));
tabs.map(tab => tab.dataset.state = '');
// set current tab to selected
e.target.dataset.state = 'selected';
// set all panels to unselected
const panelsContainer = e.target.parentElement.nextElementSibling;
const panelsContainer = e.target.parentElement.parentElement.nextElementSibling;
Array.from(panelsContainer.children).forEach(function (panel) {
panel.dataset.state = '';
});