mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
tabs: allow codified tabs to be colored #550
This commit is contained in:
parent
0a3662be61
commit
cef256eb40
3 changed files with 16 additions and 9 deletions
|
@ -1951,8 +1951,11 @@ html[dir="rtl"] #sidebar ul.collapsible-menu > li > label > i.fa-chevron-right {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove margin if only a single code block is contained in the tab */
|
/* 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.code > .tab-content-text{
|
#body .tab-content.tab-panel-style.codify > .tab-content-text{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
#body .tab-content-text:has(> div.highlight:only-child){
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -411,7 +411,7 @@ article ul > li > input[type="checkbox"] {
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-panel-style.cstyle.transparent {
|
.tab-panel-style.cstyle.transparent {
|
||||||
--VARIABLE-BOX-color: var(--INTERNAL-BOX-NEUTRAL-color);
|
--VARIABLE-BOX-color: rgba( 134, 134, 134, .4 );
|
||||||
--VARIABLE-BOX-BG-color: transparent;
|
--VARIABLE-BOX-BG-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,18 +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.initial' ) ).filter( function( tabPanel ){
|
var codeTabPanels = Array.from( document.querySelectorAll( '.tab-content.tab-panel-style' ) ).filter( function( tabPanel ){
|
||||||
return tabPanel.querySelector( '.tab-content-text > div.highlight:only-child, .tab-content-text > pre.pre-code:only-child');
|
return tabPanel.querySelector( '.tab-content-text > div.highlight:only-child, .tab-content-text > pre.pre-code:only-child');
|
||||||
});
|
});
|
||||||
|
|
||||||
codeTabPanels.forEach( function( tabPanel ){
|
codeTabPanels.forEach( function( tabPanel ){
|
||||||
tabPanel.classList.remove( 'initial' );
|
|
||||||
tabPanel.classList.add( 'code' );
|
|
||||||
tabId = tabPanel.dataset.tabItem;
|
|
||||||
var p = tabPanel.parentNode.parentNode;
|
var p = tabPanel.parentNode.parentNode;
|
||||||
|
var tabId = tabPanel.dataset.tabItem;
|
||||||
var tabButton = p.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
|
var tabButton = p.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
|
||||||
|
if( tabPanel.classList.contains( 'initial' ) ){
|
||||||
tabButton.classList.remove( 'initial' );
|
tabButton.classList.remove( 'initial' );
|
||||||
tabButton.classList.add( 'code' );
|
tabButton.classList.add( 'code' );
|
||||||
|
tabPanel.classList.remove( 'initial' );
|
||||||
|
tabPanel.classList.add( 'code' );
|
||||||
|
}
|
||||||
|
// mark code blocks for FF without :has()
|
||||||
|
tabPanel.classList.add( 'codify' );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue