Skip to content

Commit

Permalink
Merge pull request #42983 from rushatgabhane/help-fix-platform
Browse files Browse the repository at this point in the history
[HelpDot] choose a platform by default
  • Loading branch information
srikarparsi authored Jun 4, 2024
2 parents 87db18a + e76a05d commit 65ba672
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/_sass/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,8 @@ button {
}

#platform-tabs > .active {
color: var(--color-button-text);
background-color: var(--color-button-success-background);
color: var(--color-text);
background-color: var(--color-button-background);
}

.hidden {
Expand Down
46 changes: 28 additions & 18 deletions docs/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,30 @@ const tocbotOptions = {
scrollContainer: 'content-area',
};

function selectNewExpensify(newExpensifyTab, newExpensifyContent, expensifyClassicTab, expensifyClassicContent) {
newExpensifyTab.classList.add('active');
newExpensifyContent.classList.remove('hidden');

expensifyClassicTab.classList.remove('active');
expensifyClassicContent.classList.add('hidden');
window.tocbot.refresh({
...tocbotOptions,
contentSelector: '#new-expensify',
});
}

function selectExpensifyClassic(newExpensifyTab, newExpensifyContent, expensifyClassicTab, expensifyClassicContent) {
expensifyClassicTab.classList.add('active');
expensifyClassicContent.classList.remove('hidden');

newExpensifyTab.classList.remove('active');
newExpensifyContent.classList.add('hidden');
window.tocbot.refresh({
...tocbotOptions,
contentSelector: '#expensify-classic',
});
}

window.addEventListener('DOMContentLoaded', () => {
injectFooterCopywrite();

Expand All @@ -219,8 +243,10 @@ window.addEventListener('DOMContentLoaded', () => {
let contentSelector = '.article-toc-content';
if (expensifyClassicContent) {
contentSelector = '#expensify-classic';
selectExpensifyClassic(newExpensifyTab, newExpensifyContent, expensifyClassicTab, expensifyClassicContent);
} else if (newExpensifyContent) {
contentSelector = '#new-expensify';
selectNewExpensify(newExpensifyTab, newExpensifyContent, expensifyClassicTab, expensifyClassicContent);
}

if (window.tocbot) {
Expand All @@ -232,28 +258,12 @@ window.addEventListener('DOMContentLoaded', () => {

// eslint-disable-next-line es/no-optional-chaining
expensifyClassicTab?.addEventListener('click', () => {
expensifyClassicTab.classList.add('active');
expensifyClassicContent.classList.remove('hidden');

newExpensifyTab.classList.remove('active');
newExpensifyContent.classList.add('hidden');
window.tocbot.refresh({
...tocbotOptions,
contentSelector: '#expensify-classic',
});
selectExpensifyClassic(newExpensifyTab, newExpensifyContent, expensifyClassicTab, expensifyClassicContent);
});

// eslint-disable-next-line es/no-optional-chaining
newExpensifyTab?.addEventListener('click', () => {
newExpensifyTab.classList.add('active');
newExpensifyContent.classList.remove('hidden');

expensifyClassicTab.classList.remove('active');
expensifyClassicContent.classList.add('hidden');
window.tocbot.refresh({
...tocbotOptions,
contentSelector: '#new-expensify',
});
selectNewExpensify(newExpensifyTab, newExpensifyContent, expensifyClassicTab, expensifyClassicContent);
});

document.getElementById('header-button').addEventListener('click', toggleHeaderMenu);
Expand Down

0 comments on commit 65ba672

Please sign in to comment.