diff --git a/src/_includes/toc-and-content.html b/src/_includes/toc-and-content.html deleted file mode 100644 index d753d6a6..00000000 --- a/src/_includes/toc-and-content.html +++ /dev/null @@ -1,50 +0,0 @@ -
-
-
-

Table of contents

- -
- {% for item in include.toc_data %} -

{{ item.title }}

- - {% endfor %} -
-
- -
-
-
-
- {% for item in include.toc_data %} -

{{ item.title }}

- {% for subsection_item in item.subsection_items %} -

{{ subsection_item.title }}

- {% for paragraph in subsection_item.paragraphs %} {% if paragraph.title %} -

{{ paragraph.title }}

- {% endif %} -

{{ paragraph.text }}

- {% if paragraph.html %} {% include {{paragraph.html}} %}{% endif %} {% endfor %} {% endfor %} {% endfor %} -
-
diff --git a/src/_layouts/sidebar-toc.html b/src/_layouts/sidebar-toc.html index cda37c65..dc182823 100644 --- a/src/_layouts/sidebar-toc.html +++ b/src/_layouts/sidebar-toc.html @@ -9,9 +9,9 @@ {{ preface }}
-
-
-
+
+
+

Table of contents

-
- {% include toc.html html=real_content class="list-unstyled.table-of-contents" submenu_class="list-unstyled" h_max=3 %} +
+ {% include toc.html html=real_content class="table-of-contents" h_max=3 %} +
+
+ {% include toc.html html=real_content class="dropdown-menu table-of-contents w-100" anchor_class="dropdown-item" h_max=3 %}
diff --git a/src/_sass/components/_toc-and-content.scss b/src/_sass/components/_toc-and-content.scss index 72d9949d..8a64ef40 100644 --- a/src/_sass/components/_toc-and-content.scss +++ b/src/_sass/components/_toc-and-content.scss @@ -1,12 +1,154 @@ +.toc { + .toc-container { + ul { + list-style: none; + margin: 0; + padding: 0; + + li { + padding: 12px 0; + margin: 0; + } + } + + a { + text-decoration: none !important; + border: none; + font-weight: 500; + } + } +} + +.content-container { + h2:first-child { + margin-top: calc(8rem / 16); + } + h2 { + margin-top: calc(56rem / 16); + margin-bottom: calc(48rem / 16); + } + h3 { + margin-top: calc(56rem / 16); + margin-bottom: calc(24rem / 16); + } +} + +@include media-breakpoint-up(md) { + #toc-and-content { + div :target::before { + // see: https://stackoverflow.com/questions/4086107/fixed-page-header-overlaps-in-page-anchors + display: block; + content: ""; + height: 1px !important; + margin: -1px 0 0 !important; + } + } + + .toc { + .toc-container { + position: sticky; + position: -webkit-sticky; + top: 0; + + .h4 { + font-family: var(--bs-body-font-family) !important; + padding: 12px 0; + margin: 0; + } + } + } +} + +@include media-breakpoint-down(md) { + #toc-and-content { + div :target::before { + // this ensures clicking an anchor tag takes you to the right spot + display: block; // without this code, the fixed header blocks the anchor tag from showing up + content: ""; // see: https://stackoverflow.com/questions/4086107/fixed-page-header-overlaps-in-page-anchors + height: 68px !important; + margin: -68px 0 0 !important; + } + } + + .toc { + padding: 0; + position: -webkit-sticky; + position: sticky; + z-index: 1020; + top: 0; + + .toc-container { + .toggle-menu { + width: 100%; + background: white; + color: $primary; + border-top: 1px solid #d7d7d7; + border-left: none; + border-right: none; + border-bottom: 1px solid #d7d7d7; + text-align: left; + height: 64px; + padding-left: 16px; + + &.show { + border-bottom: 1px solid #ffffff; + } + + &::after { + position: absolute; + content: ""; + border: solid $primary; + border-width: 0 3px 3px 0; + display: inline-block; + padding: 3px; + top: calc(50% - 6px); + right: 20px; + transform: rotate(45deg); + transition: transform 0.3s ease-in-out; + } + + &.show::after { + transform: rotate(225deg); + } + } + } + } + + .table-of-contents { + border-bottom: 1px solid #d7d7d7; + border-top: 1px solid #ffffff; + + & > li > a { + padding-bottom: 0; + padding-top: 0; + } + } +} + .table-of-contents { - & > li > a { - color: #000; - font-family: var(--bs-body-font-family) !important; - font-weight: 700; + line-height: 1.2; + margin: 0; + padding: 0; + + & > li { + padding: 0 !important; + + & > a { + color: #000; + font-family: var(--bs-body-font-family) !important; + font-weight: 700 !important; + } + } + + & > li > ul { + li a { + color: $primary; + white-space: break-spaces; + } } li { - margin: 1.25rem 0; + margin: 1.25rem; } ul { @@ -14,4 +156,16 @@ font-weight: 500 !important; } } + + & > li > a { + display: inline-block; + padding-bottom: 12px; + padding-top: 12px; + width: 100% + } + + ul .dropdown-item { + padding-bottom: 0; + padding-top: 0; + } }