Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: board bios #120

Merged
merged 9 commits into from
Mar 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restyled by prettier (#119)
Co-authored-by: Restyled.io <commits@restyled.io>
restyled-io[bot] and restyled-commits authored Mar 19, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c3362c18da2c16d71ad1565fb94defdabe416ede
162 changes: 78 additions & 84 deletions src/wmcads/patterns/board-members/_example.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,104 @@
const boardMembersJS = () => {
// get all the 'trigger' elements on the page
const triggers = Array.from(document.querySelectorAll('[data-toggle="collapse"]'));

// listen to click events that occuor
// only on our triggers
window.addEventListener(
'click',
ev => {
const elm = ev.target;
if (triggers.includes(elm)) {
ev.preventDefault();
const selector = elm.getAttribute('data-target');
collapse(selector, 'toggle');
if (elm.getAttribute('aria-expanded') === 'false') {
elm.setAttribute('aria-expanded', 'true');
} else {
elm.setAttribute('aria-expanded', 'false');
// get all the 'trigger' elements on the page
const triggers = Array.from(document.querySelectorAll('[data-toggle="collapse"]'));

// listen to click events that occuor
// only on our triggers
window.addEventListener(
'click',
ev => {
const elm = ev.target;
if (triggers.includes(elm)) {
ev.preventDefault();
const selector = elm.getAttribute('data-target');
collapse(selector, 'toggle');
if (elm.getAttribute('aria-expanded') === 'false') {
elm.setAttribute('aria-expanded', 'true');
} else {
elm.setAttribute('aria-expanded', 'false');
}
}
}
},
false
);

// map commands to the classList methods
const fnmap = {
toggle: 'toggle',
show: 'add',
hide: 'remove'
};
const collapse = (selector, cmd) => {
const targets = Array.from(document.querySelectorAll(selector));
targets.forEach(target => {
target.classList[fnmap[cmd]]('show');
});
};
},
false
);

// map commands to the classList methods
const fnmap = {
toggle: 'toggle',
show: 'add',
hide: 'remove'
};
const collapse = (selector, cmd) => {
const targets = Array.from(document.querySelectorAll(selector));
targets.forEach(target => {
target.classList[fnmap[cmd]]('show');
});
};

const tabs = document.querySelectorAll('ul.wmcads-board-members-tab-labels > li');
const panelQuestions = document.querySelectorAll('.wmcads-board-members-panel-question');

const tabs = document.querySelectorAll('ul.wmcads-board-members-tab-labels > li');
const panelQuestions = document.querySelectorAll('.wmcads-board-members-panel-question');
const onTabClick = e => {
e.preventDefault();

const onTabClick = e => {
e.preventDefault();
tabs.forEach(tab => {
tab.classList.remove('active');
});

tabs.forEach(tab => {
tab.classList.remove('active');
});
const clickedTab = e.currentTarget;
clickedTab.classList.add('active');

const clickedTab = e.currentTarget;
clickedTab.classList.add('active');
const tabsPanel = document.querySelectorAll('.wmcads-board-members-single-panel');

const tabsPanel = document.querySelectorAll('.wmcads-board-members-single-panel');
tabsPanel.forEach(panel => {
panel.classList.remove('active');
});

tabsPanel.forEach(panel => {
panel.classList.remove('active');
});
const anchorRef = e.target;
const activePanelId = anchorRef.getAttribute('href');
const activePanel = document.querySelector(activePanelId);

const anchorRef = e.target;
const activePanelId = anchorRef.getAttribute('href');
const activePanel = document.querySelector(activePanelId);
activePanel.classList.add('active');
};

activePanel.classList.add('active');
};
const onQuestionClick = e => {
e.preventDefault();

const onQuestionClick = e => {
e.preventDefault();
tabs.forEach(tab => {
tab.classList.remove('active');
});

tabs.forEach(tab => {
tab.classList.remove('active');
});
tabs[1].classList.add('active');

tabs[1].classList.add('active');
const tabsPanel = document.querySelectorAll('.wmcads-board-members-single-panel');
const tab2 = document.querySelector('#tab-2');

const tabsPanel = document.querySelectorAll('.wmcads-board-members-single-panel');
const tab2 = document.querySelector('#tab-2');
tabsPanel.forEach(panel => {
panel.classList.remove('active');
});

tabsPanel.forEach(panel => {
panel.classList.remove('active');
});
tab2.classList.add('active');

tab2.classList.add('active');
const tabQuestion = document.querySelectorAll('.wmcads-board-members-panel-content');

const tabQuestion = document.querySelectorAll('.wmcads-board-members-panel-content');
tabQuestion.forEach(question => {
question.classList.remove('active');
});

tabQuestion.forEach(question => {
question.classList.remove('active');
});
const questionAnchor = e.target;
const activeQuestion = questionAnchor.getAttribute('href');
const AnswerPanel = document.querySelector(activeQuestion);

const questionAnchor = e.target;
const activeQuestion = questionAnchor.getAttribute('href');
const AnswerPanel = document.querySelector(activeQuestion);

AnswerPanel.classList.add('active');
};

for (const tab of tabs) {
tab.addEventListener('click', onTabClick);
}

for (const question of panelQuestions) {
question.addEventListener('click', onQuestionClick);
}
AnswerPanel.classList.add('active');
};

for (const tab of tabs) {
tab.addEventListener('click', onTabClick);
}

for (const question of panelQuestions) {
question.addEventListener('click', onQuestionClick);
}
};

export default boardMembersJS;