0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-12 00:08:59 +01:00
Bootstrap/site/layouts/partials/docs-sidebar.html
Patrick H. Lauke 5ec6400bd0
Docs: change sidebar collapse controls to actual button elements (#31098)
apart from the visual styling, there's probably no good reason why these shouldn't be `<button>` elements, semantically

the buttons still look a shade too button-like, despite using `.btn-light`. the last remnant of button styling can probably be suppressed further, *or* this makes the case for expanding the core button styles to have one that looks completely non-button and non-link like (for cases where an additional style/hint was given already, or it's clear from context that something's an actionable button or link)

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
2020-11-18 20:20:05 +02:00

46 lines
2.0 KiB
HTML

<nav class="collapse bd-links" id="bd-docs-nav" aria-label="Docs navigation">
{{- $url := split .Permalink "/" -}}
{{- $page_slug := index $url (sub (len $url) 2) -}}
<ul class="list-unstyled mb-0 py-3 pt-md-1">
{{- range $group := .Site.Data.sidebar -}}
{{- $link := $group.title -}}
{{- $link_slug := $link | urlize -}}
{{- if $group.pages -}}
{{- $link = index $group.pages 0 -}}
{{- $link_slug = $link.title | urlize -}}
{{- end -}}
{{- $group_slug := $group.title | urlize -}}
{{- $is_active_group := eq $.Page.Params.group $group_slug }}
<li class="mb-1{{ if $is_active_group }} active{{ end }}">
<button class="btn d-inline-flex align-items-center rounded{{ if not $is_active_group }} collapsed{{ end }}" data-bs-toggle="collapse" data-bs-target="#{{ $group_slug }}-collapse" aria-expanded="{{ $is_active_group }}"{{ if $is_active_group }} aria-current="true"{{ end }}>
{{ $group.title }}
</button>
{{- if $group.pages }}
<div class="collapse{{ if $is_active_group }} show{{ end }}" id="{{ $group_slug }}-collapse">
<ul class="list-unstyled fw-normal pb-1 small">
{{- range $doc := $group.pages -}}
{{- $doc_slug := $doc.title | urlize -}}
{{- $is_active := and $is_active_group (eq $page_slug $doc_slug) -}}
{{- $href := printf "/docs/%s/%s/%s/" $.Site.Params.docs_version $group_slug $doc_slug }}
<li><a href="{{ $href }}" class="d-inline-flex align-items-center rounded{{ if $is_active }} active{{ end }}"{{ if $is_active }} aria-current="page"{{ end }}>{{ $doc.title }}</a></li>
{{- end }}
</ul>
</div>
{{- end }}
</li>
{{- end }}
<li class="my-3 mx-4 border-top"></li>
<li{{ if eq $page_slug "migration" }} class="active"{{ end }}>
<a href="/docs/{{ $.Site.Params.docs_version }}/migration/" class="d-inline-flex align-items-center rounded">
Migration
</a>
</li>
</ul>
</nav>