Skip to content

Commit c62bf21

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 #4674 Signed-off-by: Antoine Vandevenne (anv) <[email protected]>
1 parent 25e204a commit c62bf21

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
@@ -585,28 +585,42 @@ 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-
603-
.toctree-l1 {
606+
&:not(.o_toc_l1_to_l2) .toctree-l1 {
607+
@extend %toctree-custom-link;
604608
margin-bottom: 2rem;
609+
610+
> a {
611+
display: block;
612+
margin-top: $o-padding-m;
613+
margin-bottom: $o-margin-s;
614+
padding-bottom: $o-padding-xs;
615+
border-bottom: 1px solid $o-gray-border;
616+
@include font-size($h2-font-size);
617+
font-weight: $font-weight-bolder;
618+
}
605619
}
606620

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

612626
a[href="#"] {
@@ -615,6 +629,10 @@ main.container-fluid {
615629
pointer-events: none;
616630
cursor: default;
617631
}
632+
633+
.toctree-l3 > a {
634+
--o-link-fontweight: #{$font-weight-medium};
635+
}
618636
}
619637

620638
article.doc-body {

0 commit comments

Comments
 (0)