Skip to content

Commit ab9efb4

Browse files
committed
[IMP] odoo_theme: toctrees-l1,l2 design improvement
Issue 1: ======== The toctrees in the documentation are visually inconsistent because of the content. Sometimes we have titles that are also links and visually collides with the rest of the toc making it hard to read. This applies to toctree-l1 and toctree-l2. Fix 1: ======== When we have a link and title toctree-l1 or toctree-l2 in a list containing other nested toc, we apply another styling displaying it with the same color as a title, but with an icon and hover behavior indicating that it is a link. (This commit also changes the direction of the i-link icon to make it standard). Issue 2: ======== When we have only have toctree-l1 links without nested toc the toctree is uselessly taking a lot of space. Fix: 2 ======== In these scenario we replace the toctree-l1 class with toctree-l2 to make them appear as a discreet list. task-3138525 task-3138563 part of task-3059178
1 parent 7510b4b commit ab9efb4

File tree

10 files changed

+65
-17
lines changed

10 files changed

+65
-17
lines changed
-64 Bytes
Binary file not shown.

extensions/odoo_theme/static/fonts/icomoon.svg

Lines changed: 1 addition & 1 deletion
Loading
-64 Bytes
Binary file not shown.
-64 Bytes
Binary file not shown.
380 Bytes
Binary file not shown.

extensions/odoo_theme/static/js/layout.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@
3535
content.querySelectorAll('a.external').forEach(externalLink => {
3636
externalLink.setAttribute('target', '_blank');
3737
})
38+
39+
// Add extra classes to allow more control on the design of the toctrees
40+
const tocTreeWrapperEl = document.querySelector('.toctree-wrapper');
41+
let tocFirstLevelOnly = true;
42+
let tocFirstLevelAreLinks = true;
43+
44+
// Add a class to all toctree-l1 if there is a 2nd level toctree inside.
45+
tocTreeWrapperEl?.querySelectorAll('.toctree-l1').forEach(tocl1 => {
46+
if (tocl1.querySelector('.toctree-l2')) {
47+
tocl1.classList.add('o_toc_contains_l2');
48+
tocFirstLevelOnly = false;
49+
}
50+
// Same logic is applied for tocl2 if there is a 3rd level inside their parent l1
51+
if (tocl1.querySelector('.toctree-l3')) {
52+
tocl1.querySelectorAll('.toctree-l2').forEach (tocl2 => {
53+
tocl2.classList.add('o_toc_contains_l3');
54+
});
55+
}
56+
tocl1.querySelector('a').getAttribute('href') == '#' ? tocFirstLevelAreLinks = false : '';
57+
});
58+
// Swap tocl1 for tocl2 if they are only links without nested toc
59+
if (tocFirstLevelAreLinks && tocFirstLevelOnly) {
60+
tocTreeWrapperEl?.querySelectorAll('.toctree-l1').forEach(tocl1 => {
61+
tocl1.classList.replace('toctree-l1', 'toctree-l2');
62+
});
63+
}
3864
});
3965

4066
})();

extensions/odoo_theme/static/scss/_typography.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ b, strong{
3939
}
4040

4141
a {
42-
font-weight: $font-weight-bold;
42+
font-weight: var(--o-link-fontweight, #{$font-weight-bold});
4343
}

extensions/odoo_theme/static/scss/bootstrap_overridden.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ $h6-font-size: $font-size-base !default;
4949
$font-weight-lighter: 200;
5050
$font-weight-light: 300;
5151
$font-weight-normal: 400;
52+
$font-weight-medium: 500;
5253
$font-weight-bold: 600;
5354
$font-weight-bolder: 700;
5455

extensions/odoo_theme/static/scss/bootstrap_scss/_reboot.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ sup { top: -.5em; }
259259
// Links
260260

261261
a {
262-
color: $link-color;
262+
color: var(--o-link-color, #{$link-color});
263263
text-decoration: $link-decoration;
264264

265265
&:hover {
266-
color: $link-hover-color;
266+
color: var(--o-link-hover-color, #{$link-hover-color});
267267
text-decoration: $link-hover-decoration;
268268
}
269269
}

extensions/odoo_theme/static/style.scss

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -585,28 +585,45 @@ main.container-fluid {
585585
}
586586

587587
.toctree-wrapper {
588+
%toctree-custom-link {
589+
> a:not([href="#"]){
590+
--o-link-color: #{$o-gray-color};
591+
--o-link-hover-color: #{$primary};
592+
593+
&:after {
594+
content: ' #{$i-link}';
595+
@include o-inline-icon(auto, baseline, 0.7em, $font-weight-bold);
596+
color: $primary;
597+
}
598+
}
599+
}
600+
588601
> ul, .toctree-l1 > ul {
589602
padding-left: 0;
590603
list-style: none;
591604
}
592605

593-
.toctree-l1 > a {
594-
display: block;
595-
margin-top: $o-padding-m;
596-
margin-bottom: $o-margin-s;
597-
padding-bottom: $o-padding-xs;
598-
border-bottom: 1px solid $o-gray-border;
599-
@include font-size($h2-font-size);
600-
font-weight: 600;
601-
}
602-
603606
.toctree-l1 {
604607
margin-bottom: 2rem;
608+
609+
> a {
610+
display: block;
611+
margin-top: $o-padding-m;
612+
margin-bottom: $o-margin-s;
613+
padding-bottom: $o-padding-xs;
614+
border-bottom: 1px solid $o-gray-border;
615+
@include font-size($h2-font-size);
616+
font-weight: $font-weight-bolder;
617+
}
618+
619+
&.o_toc_contains_l2 {
620+
@extend %toctree-custom-link;
621+
}
605622
}
606623

607-
.toctree-l2 > a[href="#"] {
608-
margin-top: 0.7rem;
609-
display: inline-block;
624+
.toctree-l2.o_toc_contains_l3 {
625+
margin-top: map-get($spacers, 3);
626+
@extend %toctree-custom-link;
610627
}
611628

612629
a[href="#"] {
@@ -615,6 +632,10 @@ main.container-fluid {
615632
pointer-events: none;
616633
cursor: default;
617634
}
635+
636+
.toctree-l3 > a {
637+
--o-link-fontweight: #{$font-weight-medium};
638+
}
618639
}
619640

620641
article.doc-body {

0 commit comments

Comments
 (0)