Skip to content

Commit 8d623f4

Browse files
committed
Changes after CR
1 parent db68e53 commit 8d623f4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

classes/header.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
309309
$cssparentid = '[data-tabid="' . $thissection->id . '"]';
310310
$cssid = '#onetabid-' . $thissection->id . '';
311311
$withunits = ['font-size', 'line-height', 'margin', 'padding', 'border-width', 'border-radius'];
312+
$childsbackgroundcolor = null;
312313
foreach ($orderedtabs as $type => $styles) {
313314
$important = false;
314315
switch ($type) {
@@ -376,6 +377,10 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
376377
// Capture background-color from any type that has it.
377378
if ($key === 'background-color') {
378379
$activebackgroundcolor = $value;
380+
// Also capture child background color for parent tab border rules.
381+
if ($type === 'childs') {
382+
$childsbackgroundcolor = $value;
383+
}
379384
}
380385

381386
if ($key == 'others') {
@@ -409,9 +414,35 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
409414
$onecss .= '.format_onetopic-tabs { ';
410415
$onecss .= 'border-bottom: none !important; ';
411416
$onecss .= '}';
417+
418+
// If this is a child tab (level 1) with its own background, override parent's child color.
419+
if (isset($formatoptions['level']) && $formatoptions['level'] == 1) {
420+
// Override parent's child background color rule with this child's specific color.
421+
$onecss .= '#tabs-tree-start#tabs-tree-start#tabs-tree-start:has(#onetabid-' . $thissection->id . ' a.nav-link.active) ';
422+
$onecss .= '.onetopic-tab-body > ul.format_onetopic-tabs { ';
423+
$onecss .= 'border-bottom: 2px solid ' . $activebackgroundcolor . ' !important; ';
424+
$onecss .= 'padding-bottom: 1px !important; ';
425+
$onecss .= '} ';
426+
}
412427
}
413428
}
414429

430+
// Add border for child tabs if parent defines childs background color.
431+
// Generate this CSS after processing all style types for this section.
432+
if (!empty($childsbackgroundcolor)) {
433+
// Target the second row tabs when a child is active.
434+
// Use multiple IDs and very specific path to maximize specificity beyond parent rule.
435+
$childrule = '#tabs-tree-start#tabs-tree-start:has(.onetopic-tab-body' . $cssparentid;
436+
$childrule .= ' .nav-item.subtopic a.nav-link.active) ';
437+
$childrule .= '.onetopic-tab-body' . $cssparentid . ' > ul.format_onetopic-tabs { ';
438+
$childrule .= 'border-bottom: 2px solid ' . $childsbackgroundcolor . ' !important; ';
439+
$childrule .= 'padding-bottom: 1px !important; ';
440+
$childrule .= '} ';
441+
442+
$onecss .= $childrule;
443+
}
444+
445+
415446
// Clean the CSS for html tags.
416447
$csstabstyles .= preg_replace('/<[^>]*>/', '', $onecss);
417448
}

0 commit comments

Comments
 (0)