Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Yiliu/master/update mobile sidebar #204

Merged
Merged
1 change: 1 addition & 0 deletions exampleSite/config/_default/config.toml
Expand Up @@ -24,6 +24,7 @@ googleAnalytics = ""
table_classes = "table table-bordered"
hide_cfa_same_page = true
show_collapsible_menu = true
sidebar_layout = "default"

[Author]
name = "Christopher Guindon"
Expand Down
25 changes: 18 additions & 7 deletions exampleSite/config/_default/menus.en.toml
Expand Up @@ -253,43 +253,54 @@
url = "/translations"
weight = 3
parent = "home"
identifier = "translation-guide"

[[sidebar]]
name = "Translation Guide 1"
url = "/translations"
weight = 1
parent = "translation-guide"

[[sidebar]]
name = "Translation Guide 2"
url = "/translations"
weight = 1
parent = "translation-guide"

[[sidebar]]
name = "Third parent"
url = "/third-parent"
weight = 2
pre = "<i class=\"fa fa-github fa-fw\"></i>"
pre = "<i class=\"sidebar-menu-icon\" data-feather=\"github\"></i>"
identifier = "third-parent"

[[sidebar]]
name = "test children"
name = "Test Children"
url = "/third-parent/test-children"
weight = 1
parent = "third-parent"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"
identifier = "test-children"

[[sidebar]]
name = "test children 2"
name = "Test Children 2"
url = "/third-parent/test-children-2"
weight = 1
parent = "third-parent"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"
identifier = "test-children-2"

[[sidebar]]
name = "test children's children-1"
name = "Test Children Children 1"
url = "/third-parent/test-children/test-children-children"
weight = 1
parent = "test-children"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"

[[sidebar]]
name = "test children's children-2"
name = "Test Children Children 2"
url = "/third-parent/test-children/test-children-children-2"
weight = 2
parent = "test-children"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"

[[sidebar]]
name = "Membership"
Expand Down
8 changes: 4 additions & 4 deletions exampleSite/config/_default/menus.ru.toml
Expand Up @@ -244,30 +244,30 @@
identifier = "third-parent"

[[sidebar]]
name = "test children"
name = "Test Children"
url = "/third-parent/test-children"
weight = 1
parent = "third-parent"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"
identifier = "test-children"

[[sidebar]]
name = "test children 2"
name = "Test Children 2"
url = "/third-parent/test-children-2"
weight = 1
parent = "third-parent"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"
identifier = "test-children-2"

[[sidebar]]
name = "test children's children-1"
name = "Test Children's children-1"
url = "/third-parent/test-children/test-children-children"
weight = 1
parent = "test-children"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"

[[sidebar]]
name = "test children's children-2"
name = "Test Children's children-2"
url = "/third-parent/test-children/test-children-children-2"
weight = 2
parent = "test-children"
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/third-parent/_index.md
Expand Up @@ -4,6 +4,7 @@ headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
hide_sidebar: false
sidebar_layout: "sidebar_block"
---

Third Parent
2 changes: 1 addition & 1 deletion exampleSite/content/third-parent/test-children-2/_index.md
@@ -1,5 +1,5 @@
---
title: "Test Children 222"
title: "Test Children 2"
headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
Expand Down
@@ -1,5 +1,5 @@
---
title: "Test Children Children Two"
title: "Test Children Children 2"
headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
Expand Down
@@ -1,5 +1,5 @@
---
title: "Test Children Children One"
title: "Test Children Children 1"
headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
Expand Down
43 changes: 30 additions & 13 deletions layouts/partials/collapsible-menu.html
Expand Up @@ -21,38 +21,55 @@
{{ end }}
{{$currentSection := .Scratch.Get "currentSection" }}

<!--- Sidebar layout --->
{{ $sidebarLayout := .Page.Params.sidebar_layout | default .Site.Params.sidebar_layout | default "default" }}
{{ $classname := cond (eq $sidebarLayout "sidebar_block") "sidebar-block" "collapsible-menu" }}

<!----------------------- Collapisible start ------------------------------------>
{{ range .Site.Menus.sidebar }}
{{$parentItem := . }}
{{ if and (.HasChildren) (eq $currentSection $parentItem.Identifier) }}
<div class="collapsible-menu container hidden-lg hidden-md visible-sm visible-xs">
<div class="container collapsible-menu-item related-content">
<div class="{{ $classname }} margin-top-20 container hidden-lg hidden-md visible-sm visible-xs">
<div class="container padding-left-0 padding-right-0 {{ $classname }}-item related-content">
<a href="#sidebars-contents" data-toggle="collapse" aria-expanded="false" aria-controls="sidebars-contents">
<div class="col-xs-6"><i class="fa fa-plus fa-bars"></i></div>
<div class="col-xs-18 collapsible-menu-text">Related Content</div>
<div class="col-xs-18 {{ $classname }}-text">Related Content</div>
</a>
</div>
<div class="container collapse" id="sidebars-contents">
</div>
<div class="container collapse {{ if eq $classname "sidebar-block" }} padding-left-0 padding-right-0 {{ end }}" id="sidebars-contents">

{{ range .Children }}

{{ if eq .HasChildren false }}
<div class="row collapsible-menu-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<div class="row {{ $classname }}-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 collapsible-menu-text">{{ .Name }}</div>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }} <!-- if eq .HasChildren false end -->

{{ if .HasChildren }}
<div class="row collapsible-menu-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<div class="row {{ $classname }}-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="#sub-children-{{ .Identifier }}" data-toggle="collapse" aria-expanded="false" aria-controls="sub-children{{ .Identifier }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 collapsible-menu-text">{{ .Name }}</div>
<div class="col-xs-18 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
<div class="row collapsible-menu-sub-items collapse" id="sub-children-{{ .Identifier }}">
<div class="row {{ $classname }}-sub-items {{ if eq $classname "sidebar-block" }} margin-bottom-20 {{ end }} collapse" id="sub-children-{{ .Identifier }}">
<!-- Check if current parent menu has children and has own url, we should add an entry to goto this parent -->
{{ if .URL }}
<div class="row {{ $classname }}-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }}

{{ range .Children }}
<div class="row collapsible-menu-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<div class="row {{ $classname }}-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 collapsible-menu-text">{{ .Name }}</div>
<div class="col-xs-18 col-xs-offset-6 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }} <!--Children's Children end-->
Expand All @@ -62,7 +79,7 @@
</div>
{{ end }} <!-- if .HasChildren end -->
{{ end }} <!-- range .Site.Menus.sidebar end -->
</div> <!-- div id="collapsible-menu" end -->
</div> <!-- div id="{{ $classname }}" end -->
<!-------------------- Collapisible end ----------------------------------------->

{{ end }} <!-- if or (eq $currentPage.Params.show_collapsible_menu true) (eq .Site.Params.show_collapsible_menu true) end-->
Expand Down
7 changes: 6 additions & 1 deletion layouts/partials/main_suffix.html
Expand Up @@ -12,9 +12,14 @@
-->

{{ if ne .Page.Params.hide_sidebar true }}
{{ $sidebarLayout := .Page.Params.sidebar_layout | default .Site.Params.sidebar_layout | default "default" }}
</div>
<div class="{{- .Params.main_sidebar_class | default .Site.Params.main_sidebar_class | default "col-md-6 padding-bottom-30"}}">
{{ partial "sidebar.html" . }}
{{ if eq $sidebarLayout "default" }}
{{ partial "sidebar.html" . }}
{{ else if eq $sidebarLayout "sidebar_block" }}
{{ partial "sidebar-block.html" . }}
{{ end }}
</div>
</div>
{{ end }}
Expand Down
54 changes: 54 additions & 0 deletions layouts/partials/sidebar-block.html
@@ -0,0 +1,54 @@
<!--
autumnfound marked this conversation as resolved.
Show resolved Hide resolved
Copyright (c) 2018 Eclipse Foundation, Inc.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.

Contributors:
Christopher Guindon <chris.guindon@eclipse-foundation.org>

SPDX-License-Identifier: EPL-2.0
-->

{{ if isset .Site.Menus "sidebar" }}
{{ $currentPage := . }}
{{ .Scratch.Set "currentSection" "home" }}
{{ if $currentPage.Section }}
{{ .Scratch.Set "currentSection" $currentPage.Section }}
{{ end }}
{{$currentSection := .Scratch.Get "currentSection" }}
{{ range .Site.Menus.sidebar }}
{{$parentItem := . }}
{{ if and (.HasChildren) (eq $currentSection $parentItem.Identifier) }}
<aside class="sidebar-block">
{{ range .Children }}
{{ if .HasChildren }}
<div class="row sidebar-block-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 sidebar-block-text">{{ .Name }}</div>
</a>
</div>
<div class="row sidebar-block-sub-items margin-bottom-20">
{{ range .Children }}
<div class="row sidebar-block-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 sidebar-block-text">{{ .Name }}</div>
</a>
</div>
{{ end }}
</div>
{{ else if or (eq $parentItem.Identifier $currentSection) (eq .Parent $currentSection) }}
<div class="row sidebar-block-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 sidebar-block-text">{{ .Name }}</div>
</a>
</div>
{{ end }}
{{ end }}
</aside>
{{ end }}
{{ end }}
{{ end }}
5 changes: 1 addition & 4 deletions layouts/partials/sidebar.html
@@ -1,13 +1,10 @@
<!--
Copyright (c) 2018 Eclipse Foundation, Inc.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.

Contributors:
Christopher Guindon <chris.guindon@eclipse-foundation.org>

SPDX-License-Identifier: EPL-2.0
-->

Expand Down Expand Up @@ -42,4 +39,4 @@
</aside>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.