mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
tabs: fix false codify detection if only contained in subtabs #550
This commit is contained in:
parent
efce383939
commit
5a2ffac7fc
2 changed files with 11 additions and 11 deletions
|
@ -1952,7 +1952,7 @@ html[dir="rtl"] #sidebar ul.collapsible-menu > li > label > i.fa-chevron-right {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove margin if only a single code block is contained in the tab (FF without :has using .codify style) */
|
/* remove margin if only a single code block is contained in the tab (FF without :has using .codify style) */
|
||||||
#body .tab-content.tab-panel-style.codify > .tab-content-text{
|
#body .tab-content.codify > .tab-content-text{
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
#body .tab-content-text:has(> div.highlight:only-child){
|
#body .tab-content-text:has(> div.highlight:only-child){
|
||||||
|
|
|
@ -67,22 +67,22 @@ function adjustContentWidth(){
|
||||||
|
|
||||||
function fixCodeTabs(){
|
function fixCodeTabs(){
|
||||||
/* if only a single code block is contained in the tab and no style was selected, treat it like style=code */
|
/* if only a single code block is contained in the tab and no style was selected, treat it like style=code */
|
||||||
var codeTabPanels = Array.from( document.querySelectorAll( '.tab-content.tab-panel-style' ) ).filter( function( tabPanel ){
|
var codeTabContents = Array.from( document.querySelectorAll( '.tab-content.tab-panel-style' ) ).filter( function( tabContent ){
|
||||||
return tabPanel.querySelector( '.tab-content-text > div.highlight:only-child, .tab-content-text > pre.pre-code:only-child');
|
return tabContent.querySelector( '*:scope > .tab-content-text > div.highlight:only-child, *:scope > .tab-content-text > pre.pre-code:only-child');
|
||||||
});
|
});
|
||||||
|
|
||||||
codeTabPanels.forEach( function( tabPanel ){
|
codeTabContents.forEach( function( tabContent ){
|
||||||
var p = tabPanel.parentNode.parentNode;
|
var tabId = tabContent.dataset.tabItem;
|
||||||
var tabId = tabPanel.dataset.tabItem;
|
var tabPanel = tabContent.parentNode.parentNode;
|
||||||
var tabButton = p.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
|
var tabButton = tabPanel.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
|
||||||
if( tabPanel.classList.contains( 'initial' ) ){
|
if( tabContent.classList.contains( 'initial' ) ){
|
||||||
tabButton.classList.remove( 'initial' );
|
tabButton.classList.remove( 'initial' );
|
||||||
tabButton.classList.add( 'code' );
|
tabButton.classList.add( 'code' );
|
||||||
tabPanel.classList.remove( 'initial' );
|
tabContent.classList.remove( 'initial' );
|
||||||
tabPanel.classList.add( 'code' );
|
tabContent.classList.add( 'code' );
|
||||||
}
|
}
|
||||||
// mark code blocks for FF without :has()
|
// mark code blocks for FF without :has()
|
||||||
tabPanel.classList.add( 'codify' );
|
tabContent.classList.add( 'codify' );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue