Skip to content

Commit

Permalink
Merge pull request #4848 from jeradrutnam/master
Browse files Browse the repository at this point in the history
Update styling of tab content that has multiple elements or non-code element
  • Loading branch information
himeshsiriwardana authored Nov 11, 2024
2 parents 0c750b6 + c18b45c commit 3a015a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion en/theme/material/assets/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,13 @@
font-size: 14px;
font-style: italic;
color: var(--md-default-fg-color--light);
}
}

.tabbed-content.tab_with_no_code {
background: var(--md-default-fg-color--lightest);
padding: 0 20px 10px;
border-radius: 0 0 var(--md-code-block-radius) var(--md-code-block-radius);
}

/* Media query breakpoints
Expand Down
14 changes: 14 additions & 0 deletions en/theme/material/assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ dropdownLink.addEventListener('click', function(event) {
event.stopPropagation(); // Prevent the event from propagating to the document
dropdown.classList.toggle('open'); // Toggle the "open" class
});

// Add a class to tasb that has multiple child elements rather than a code block
document.querySelectorAll('.tabbed-content').forEach(tabbedContent => {
const tabbedBlocks = Array.from(tabbedContent.querySelectorAll('.tabbed-block'));

// Check if each .tabbed-block has more than 1 child or if its immediate child is not .highlight
const shouldAddClass = tabbedBlocks.some(tabbedBlock =>
tabbedBlock.children.length > 1 || !tabbedBlock.firstElementChild.classList.contains('highlight')
);

if (shouldAddClass) {
tabbedContent.classList.add('tab_with_no_code');
}
});

0 comments on commit 3a015a8

Please sign in to comment.