Skip to content

Commit cf198d4

Browse files
mano-odooAntoineVDV
authored andcommitted
[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-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 add a class to the toctree wrapper to replace the toctree-l1 style with a toctree-l2. task-3138525 task-3138563 part of task-3059178 closes #6504 X-original-commit: c62bf21 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
1 parent 1597ec0 commit cf198d4

File tree

10 files changed

+56
-19
lines changed

10 files changed

+56
-19
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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,25 @@
3434
// Make all external links open in a new tab by default.
3535
content.querySelectorAll('a.external').forEach(externalLink => {
3636
externalLink.setAttribute('target', '_blank');
37-
})
37+
});
38+
39+
let canAccessAllL1Toctrees = true; // Whether all direct children have a ref.
40+
const toctreeWrapper = document.querySelector('.toctree-wrapper');
41+
toctreeWrapper?.querySelectorAll('.toctree-l1').forEach(l1Toctree => {
42+
// Flag L2 toctrees that have L3 children.
43+
if (l1Toctree.querySelector('.toctree-l3')) {
44+
l1Toctree.querySelectorAll('.toctree-l2').forEach (l2Toctree => {
45+
l2Toctree.classList.add('o_toc_contains_l3');
46+
});
47+
}
48+
if (l1Toctree.querySelector('a').getAttribute('href') === '#') {
49+
canAccessAllL1Toctrees = false;
50+
}
51+
});
52+
if (canAccessAllL1Toctrees) {
53+
// Use the style of L2 toctrees on L1 toctrees.
54+
toctreeWrapper?.classList.add('o_toc_l1_to_l2');
55+
}
3856
});
3957

4058
})();

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: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -586,28 +586,42 @@ main.container-fluid {
586586
}
587587

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

594-
.toctree-l1 > a {
595-
display: block;
596-
margin-top: $o-padding-m;
597-
margin-bottom: $o-margin-s;
598-
padding-bottom: $o-padding-xs;
599-
border-bottom: 1px solid $o-gray-border;
600-
@include font-size($h2-font-size);
601-
font-weight: 600;
602-
}
603-
604-
.toctree-l1 {
607+
&:not(.o_toc_l1_to_l2) .toctree-l1 {
608+
@extend %toctree-custom-link;
605609
margin-bottom: 2rem;
610+
611+
> a {
612+
display: block;
613+
margin-top: $o-padding-m;
614+
margin-bottom: $o-margin-s;
615+
padding-bottom: $o-padding-xs;
616+
border-bottom: 1px solid $o-gray-border;
617+
@include font-size($h2-font-size);
618+
font-weight: $font-weight-bolder;
619+
}
606620
}
607621

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

613627
a[href="#"] {
@@ -616,6 +630,10 @@ main.container-fluid {
616630
pointer-events: none;
617631
cursor: default;
618632
}
633+
634+
.toctree-l3 > a {
635+
--o-link-fontweight: #{$font-weight-medium};
636+
}
619637
}
620638

621639
article.doc-body {

0 commit comments

Comments
 (0)