mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed navigation pruning when tabs + sections are active
This commit is contained in:
parent
1698fd8172
commit
292d563cb4
@ -53,20 +53,33 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% set tabs = "navigation.tabs" in features %}
|
||||
{% set sections = "navigation.sections" in features %}
|
||||
{% if tabs and level == 1 or sections and tabs >= level - 1 %}
|
||||
{% if "navigation.tabs" in features %}
|
||||
{% if level == 1 and nav_item.active %}
|
||||
{% set class = class ~ " md-nav__item--section" %}
|
||||
{% set is_section = true %}
|
||||
{% elif not nav_item.active and "navigation.prune" in features %}
|
||||
{% endif %}
|
||||
{% if "navigation.sections" in features %}
|
||||
{% if level == 2 and nav_item.parent.active %}
|
||||
{% set class = class ~ " md-nav__item--section" %}
|
||||
{% set is_section = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% elif "navigation.sections" in features %}
|
||||
{% if level == 1 %}
|
||||
{% set class = class ~ " md-nav__item--section" %}
|
||||
{% set is_section = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if "navigation.prune" in features %}
|
||||
{% if not is_section and not nav_item.active %}
|
||||
{% set class = class ~ " md-nav__item--pruned" %}
|
||||
{% set is_pruned = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<li class="{{ class }} md-nav__item--nested">
|
||||
{% if not is_pruned %}
|
||||
{% set checked = "checked" if nav_item.active %}
|
||||
{% set is_expanded = "navigation.expand" in features %}
|
||||
{% if is_expanded and not checked %}
|
||||
{% if "navigation.expand" in features and not checked %}
|
||||
{% set indeterminate = "md-toggle--indeterminate" %}
|
||||
{% endif %}
|
||||
<input class="md-nav__toggle md-toggle {{ indeterminate }}" type="checkbox" id="{{ path }}" {{ checked }}>
|
||||
|
@ -107,18 +107,44 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
<!-- Determine whether to render item as a section -->
|
||||
{% set tabs = "navigation.tabs" in features %}
|
||||
{% set sections = "navigation.sections" in features %}
|
||||
{% if tabs and level == 1 or sections and tabs >= level - 1 %}
|
||||
<!-- Navigation tabs -->
|
||||
{% if "navigation.tabs" in features %}
|
||||
|
||||
<!-- Render 1st level active item as section -->
|
||||
{% if level == 1 and nav_item.active %}
|
||||
{% set class = class ~ " md-nav__item--section" %}
|
||||
{% set is_section = true %}
|
||||
{% endif %}
|
||||
|
||||
<!-- Determine whether to prune inactive item -->
|
||||
{% elif not nav_item.active and "navigation.prune" in features %}
|
||||
<!-- Navigation tabs + sections -->
|
||||
{% if "navigation.sections" in features %}
|
||||
|
||||
<!-- Render 2nd level items with nested items as sections -->
|
||||
{% if level == 2 and nav_item.parent.active %}
|
||||
{% set class = class ~ " md-nav__item--section" %}
|
||||
{% set is_section = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<!-- Navigation sections -->
|
||||
{% elif "navigation.sections" in features %}
|
||||
|
||||
<!-- Render 1st level items with nested items as sections -->
|
||||
{% if level == 1 %}
|
||||
{% set class = class ~ " md-nav__item--section" %}
|
||||
{% set is_section = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<!-- Navigation pruning -->
|
||||
{% if "navigation.prune" in features %}
|
||||
|
||||
<!-- Prune item if it is not a section and not active -->
|
||||
{% if not is_section and not nav_item.active %}
|
||||
{% set class = class ~ " md-nav__item--pruned" %}
|
||||
{% set is_pruned = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<!-- Nested navigation item -->
|
||||
<li class="{{ class }} md-nav__item--nested">
|
||||
@ -126,8 +152,7 @@
|
||||
{% set checked = "checked" if nav_item.active %}
|
||||
|
||||
<!-- Determine checked and indeterminate state -->
|
||||
{% set is_expanded = "navigation.expand" in features %}
|
||||
{% if is_expanded and not checked %}
|
||||
{% if "navigation.expand" in features and not checked %}
|
||||
{% set indeterminate = "md-toggle--indeterminate" %}
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user