Skip to content

Commit f8ee070

Browse files
authored
Styling Fix (#168)
* fix logic issue * add TOC active styling * apply copilot feedback * feedback
1 parent 5ca658a commit f8ee070

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

material-overrides/assets/stylesheets/polkadot.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,12 +1199,22 @@ input.md-search__input::placeholder {
11991199
color: var(--nav-fg-color);
12001200
font-size: 16px;
12011201
}
1202+
1203+
.md-nav--secondary .md-nav__link--active {
1204+
background: var(--nav-hover-bg-color);
1205+
border-radius: 6px;
1206+
}
12021207
}
12031208

12041209
@media screen and (min-width: 76.25em) {
12051210
.md-nav--secondary .md-nav__link {
12061211
margin-top: 0;
12071212
}
1213+
1214+
.md-nav--secondary .md-nav__link--active {
1215+
margin-left: -0.7em;
1216+
padding-left: 0.7em;
1217+
}
12081218
}
12091219

12101220
/** Nav styling on smaller screens **/

material-overrides/partials/nav-item.html

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
{% endif %}
3535
{% endfor %}
3636
{% endif %}
37+
{% set visible_children = [] %}
38+
{% for nav_item in nav_item.children %}
39+
{% if not indexes or nav_item != indexes | first %}
40+
{% set _ = visible_children.append({ 'idx': loop.index, 'node': nav_item }) %}
41+
{% endif %}
42+
{% endfor %}
3743
{% if not indexes %}
3844
<label class="md-nav__link" for="{{ path }}" id="{{ path }}_label" tabindex="0">
3945
{{ render_title_with_icon(nav_item.title, "twemoji nav-title") | safe }}
@@ -54,25 +60,28 @@
5460
{% endif %}
5561
</div>
5662
{% endif %}
57-
<nav class="md-nav" data-md-level="{{ level }}" aria-labelledby="{{ path }}_label" aria-expanded="{{ nav_item.active | tojson }}">
58-
<label class="md-nav__title" for="{{ path }}">
59-
<span class="md-nav__icon md-icon"></span>
60-
{{nav_item.title}}
61-
</label>
62-
<div class="nav-wrapper">
63-
{% if page %}
64-
{% if indexes[0] %}
65-
<ul class="md-nav__list {{ indexes[0].url.replace('/', '-') }}" data-md-scrollfix>
66-
{% endif %}
67-
{% endif %}
68-
{% for nav_item in nav_item.children %}
69-
{% if not indexes or nav_item != indexes | first %}
70-
{{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }}
71-
{% endif %}
72-
{% endfor %}
73-
</ul>
74-
</div>
75-
</nav>
63+
64+
{% if visible_children | length > 0 %}
65+
<nav class="md-nav"
66+
data-md-level="{{ level }}"
67+
aria-labelledby="{{ path }}_label"
68+
aria-expanded="{{ nav_item.active | tojson }}">
69+
70+
<label class="md-nav__title" for="{{ path }}">
71+
<span class="md-nav__icon md-icon"></span>
72+
{{ nav_item.title }}
73+
</label>
74+
75+
{% set indexes_class = indexes[0].url.replace('/', '-') if indexes and indexes[0] else '' %}
76+
<div class="nav-wrapper">
77+
<ul class="md-nav__list {{ indexes_class }}" data-md-scrollfix>
78+
{% for it in visible_children %}
79+
{{ render(it.node, path ~ "_" ~ it.idx, level + 1) }}
80+
{% endfor %}
81+
</ul>
82+
</div>
83+
</nav>
84+
{% endif %}
7685
</li>
7786
{% elif nav_item == page %}
7887
<li class="{{ class }}">

0 commit comments

Comments
 (0)