#231, Allow open collapsed menu without changing page

soper-book
Alex Shpak 2020-09-14 22:45:31 +02:00
parent 4e34988b5d
commit 5cc3d6719c
6 changed files with 23 additions and 40 deletions

View File

@ -107,8 +107,10 @@ ul.pagination {
@include fixed; @include fixed;
} }
a { a,
label {
color: inherit; color: inherit;
cursor: pointer;
word-wrap: break-word; word-wrap: break-word;
} }
@ -116,13 +118,12 @@ ul.pagination {
color: var(--color-link); color: var(--color-link);
} }
a.collapsed { input.toggle + label + ul {
display: flex; display: none;
justify-content: space-between; }
&::after { input.toggle:checked + label + ul {
content: ""; display: block;
}
} }
} }

View File

@ -1,3 +1 @@
/* You can override SASS variables here. */ /* You can override SASS variables here. */
// @import "plugins/dark";

View File

@ -2,22 +2,3 @@
bookCollapseSection: true bookCollapseSection: true
weight: 20 weight: 20
--- ---
# Collapsed Level of Menu
## Cognita laeva illo fracta
Lorem markdownum pavent auras, surgit nunc cingentibus libet **Laomedonque que**
est. Pastor [An](http://est.org/ire.aspx) arbor filia foedat, ne [fugit
aliter](http://www.indiciumturbam.org/moramquid.php), per. Helicona illas et
callida neptem est *Oresitrophos* caput, dentibus est venit. Tenet reddite
[famuli](http://www.antro-et.net/) praesentem fortibus, quaeque vis foret si
frondes *gelidos* gravidae circumtulit [inpulit armenta
nativum](http://incurvasustulit.io/illi-virtute.html).
1. Te at cruciabere vides rubentis manebo
2. Maturuit in praetemptat ruborem ignara postquam habitasse
3. Subitarum supplevit quoque fontesque venabula spretis modo
4. Montis tot est mali quasque gravis
5. Quinquennem domus arsit ipse
6. Pellem turis pugnabant locavit

View File

@ -1 +1 @@
{"Target":"book.min.4194921b4c7ff04cd7c5b17f3ac51f141158e219fa9deb989de5e50f624ca88f.css","MediaType":"text/css","Data":{"Integrity":"sha256-QZSSG0x/8EzXxbF/OsUfFBFY4hn6neuYneXlD2JMqI8="}} {"Target":"book.min.891c5b58a7a694942d519238f3c4138504c9ad2e207c0fd6541f9cd4f8d6220a.css","MediaType":"text/css","Data":{"Integrity":"sha256-iRxbWKemlJQtUZI488QThQTJrS4gfA/WVB+c1PjWIgo="}}

View File

@ -8,11 +8,6 @@
{{ end }} {{ end }}
{{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}} {{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}}
{{ $self := eq .CurrentPage .Section }}
{{ $ancestor := .Section.IsAncestor .CurrentPage }}
{{ $collapsed := .Section.Params.bookCollapseSection }}
{{ if or $self $ancestor (not $collapsed) }}
<ul> <ul>
{{ range (where .Section.Pages "Params.bookhidden" "ne" true) }} {{ range (where .Section.Pages "Params.bookhidden" "ne" true) }}
{{ if .IsSection }} {{ if .IsSection }}
@ -27,14 +22,22 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
</ul> </ul>
{{ end }}
{{ end }} {{ end }}
{{ define "book-page-link" }}{{/* (dict "Page" .Page "CurrentPage" .CurrentPage) */}} {{ define "book-page-link" }}{{/* (dict "Page" .Page "CurrentPage" .CurrentPage) */}}
{{ if .Page.Content }} {{ $current := eq .CurrentPage .Page }}
<a href="{{ .Page.RelPermalink }}" class=" {{ $ancestor := .Page.IsAncestor .CurrentPage }}
{{- if and .Page.Params.bookCollapseSection .Page.IsSection }}collapsed {{ end }}
{{- if eq .CurrentPage .Page }}active{{ end }}"> {{ if .Page.Params.bookCollapseSection }}
<input type="checkbox" id="section-{{ md5 .Page }}" class="toggle" {{ if or $current $ancestor }}checked{{ end }} />
<label for="section-{{ md5 .Page }}" class="flex justify-between">
<a {{ if .Page.Content }}href="{{ .Page.Permalink }}"{{ end }} class="{{ if $current }}active{{ end }}">
{{- partial "docs/title" .Page -}}
</a>
<span></span>
</label>
{{ else if .Page.Content }}
<a href="{{ .Page.Permalink }}" class="{{ if $current }} active{{ end }}">
{{- partial "docs/title" .Page -}} {{- partial "docs/title" .Page -}}
</a> </a>
{{ else }} {{ else }}