Skip to content

Commit 4c2ba58

Browse files
Polish docs nav and homepage badges
After the rename PR introduced nested subsection groups in the left nav (the new topical grouping under Examples), the existing nav CSS was no longer sufficient. This commit: - Hides the redundant tab label inside the sidebar (the active tab name is already shown above the content via ``navigation.tabs``; Material was rendering it again as a ``.md-nav__title`` at the top of the level-1 nav). - Adds a 1px vertical guide line on sub-sections that have children, via a ``::before`` pseudo-element on the level-2 nav. Bottom-stops 5px short of the nav's lower edge. Excludes Getting Started (whose single ``index.md`` child got rolled up by ``navigation.indexes`` leaving its level-2 nav empty). - Shifts sub-section labels and their children's UL 10px LEFT to tighten the layout while leaving the guide line in place. - Adds a padding-left override on label-form and direct-link-form ``.md-nav__link`` items so they align horizontally with the container-form labels. Material renders Documentation sub-sections as ``<div class="md-nav__container"><a>``, which matches the base padding rule twice (once on the outer div, once on the inner a), giving the text 0.75rem of layered offset. Examples sub-sections (``<label>``) and Patterns pages (``<a>``) match the rule once, so without this override their text would sit 7.5px left of the Documentation equivalents. Also adds a Python-version shield to the docs homepage, mirroring the README's shield: img.shields.io/python/required- version-toml reads pyproject.toml's ``requires-python`` directly so the badge auto-updates if the floor moves. Verified across all three tabs via headless Chromium: all sub-section / top-level page text lands at 14.5px from the level-1 nav's left edge.
1 parent d8a9970 commit 4c2ba58

2 files changed

Lines changed: 101 additions & 4 deletions

File tree

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ buy-in from every node.
1111

1212
[![PyPI](https://img.shields.io/pypi/v/openarmature.svg?color=blue)](https://pypi.org/project/openarmature/){target="_blank" rel="noopener"}
1313
[![spec](https://img.shields.io/badge/dynamic/toml?url=https://raw.githubusercontent.com/LunarCommand/openarmature-python/main/pyproject.toml&query=%24.tool.openarmature.spec_version&label=spec&color=9D4EDD)](https://github.com/LunarCommand/openarmature-spec){target="_blank" rel="noopener"}
14+
[![python](https://img.shields.io/python/required-version-toml?tomlFilePath=https://raw.githubusercontent.com/LunarCommand/openarmature-python/main/pyproject.toml&label=python&color=blue)](https://pypi.org/project/openarmature/){target="_blank" rel="noopener"}
1415

1516
[Get started](getting-started/index.md){ .md-button .md-button--primary }
1617
[View on GitHub](https://github.com/LunarCommand/openarmature-python){ .md-button target="_blank" rel="noopener" }

docs/stylesheets/extra.css

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,110 @@
200200
/* Indent nested nav items so section hierarchy reads at a glance.
201201
* Material's ``navigation.sections`` layout renders section labels
202202
* and their children flush-left at the same horizontal position;
203-
* fine for short sections but hard to scan when one runs long (the
204-
* Examples section has 11 entries). A small left-pad on the nested
205-
* links shows the hierarchy without altering typography. Scoped to
206-
* the primary nav so the right-hand TOC sidebar is untouched. */
203+
* a small left-pad on the nested links shows the hierarchy without
204+
* altering typography. Scoped to the primary nav so the right-hand
205+
* TOC sidebar is untouched. */
207206
.md-nav--primary .md-nav .md-nav__link {
208207
padding-left: 0.375rem;
209208
}
210209

210+
/* Hide the active tab's title inside the sidebar. The top tabs
211+
* (Documentation / Examples / Patterns) are shown above the
212+
* content via ``navigation.tabs``; Material also renders the
213+
* active tab's label as a ``.md-nav__title`` at the top of the
214+
* sidebar, which is redundant. The level-1 nav is the tab's
215+
* content; hiding its ``.md-nav__title`` drops the repeated
216+
* label cleanly. */
217+
.md-nav--primary .md-nav[data-md-level="1"] > .md-nav__title {
218+
display: none;
219+
}
220+
221+
/* Vertical guide line + extra indent next to the *children* of an
222+
* expandable sub-section group (Concepts / Model Providers /
223+
* Reference under Documentation; Foundations / Composition /
224+
* etc. under Examples). Material renders the section's toggle in
225+
* two different shapes:
226+
*
227+
* - ``<label class="md-nav__link">Composition</label>`` when the
228+
* section has no ``index.md`` of its own (Examples' topical
229+
* groups are like this).
230+
* - ``<div class="md-nav__link md-nav__container">`` when the
231+
* section has its own ``index.md`` (Documentation's Concepts /
232+
* Model Providers / Reference are like this, because
233+
* ``navigation.indexes`` wires the section's index page in via
234+
* a container that wraps both the index link and the toggle).
235+
*
236+
* Keying off either shape directly would also catch Getting Started
237+
* (which renders the container shape too, since ``navigation.indexes``
238+
* rolled its single ``index.md`` child up into the parent and left
239+
* the level-2 nav empty). Keying instead off "has at least one
240+
* direct child in the nested level-2 nav" cleanly skips Getting
241+
* Started (empty nested nav) while matching every real
242+
* multi-child sub-section in both tabs. Patterns' top-level pages
243+
* have no sub-section nesting at all, so no line is drawn there. */
244+
/* Position the children's nav and shift the children's UL 10px
245+
* LEFT, applied to ALL sub-sections under the level-1 nav so child
246+
* links align horizontally regardless of whether the parent
247+
* sub-section has the vertical guide line (which is itself scoped
248+
* separately to multi-child sub-sections only). */
249+
.md-nav--primary .md-nav[data-md-level="1"] > .md-nav__list > .md-nav__item > .md-nav {
250+
position: relative;
251+
margin-left: 0.25rem;
252+
}
253+
254+
.md-nav--primary .md-nav[data-md-level="1"] > .md-nav__list > .md-nav__item > .md-nav > .md-nav__list {
255+
margin-left: -0.625rem;
256+
}
257+
258+
/* Shift the sub-section label (the ``<label>`` or
259+
* ``<div class="md-nav__container">`` wrapper) 10px LEFT to
260+
* tighten the layout, while leaving the children's nav (with its
261+
* vertical guide line) in place. */
262+
.md-nav--primary .md-nav[data-md-level="1"] > .md-nav__list > .md-nav__item > .md-nav__link {
263+
margin-left: -0.625rem;
264+
}
265+
266+
/* Align label-form labels (Examples: Foundations, Composition,
267+
* etc.) and direct-link-form items (Patterns: Parameterized entry
268+
* point, Tool dispatch as node, etc.) with container-form labels
269+
* (Documentation: Concepts, Model Providers, Reference). The base
270+
* padding rule (.md-nav--primary .md-nav .md-nav__link
271+
* { padding-left: 0.375rem }) applies to ANY element with
272+
* .md-nav__link class. In Documentation, the section toggle is
273+
* rendered as <div class="md-nav__container"> wrapping
274+
* <a class="md-nav__link">, and the base rule applies to BOTH the
275+
* outer div AND the inner a, giving the text 0.75rem of layered
276+
* left offset. In Examples (<label class="md-nav__link">) and
277+
* Patterns (<a class="md-nav__link"> directly), the rule applies
278+
* once and the text only gets 0.375rem of offset; result is text
279+
* 7.5px left of the Documentation equivalent. This rule overrides
280+
* the single-application forms' padding to 0.75rem so all
281+
* sub-section / top-level page text lands at the same X column.
282+
* ``:not(.md-nav__container)`` excludes Documentation's div wrapper
283+
* so its layered offset stays intact. */
284+
.md-nav--primary .md-nav[data-md-level="1"] > .md-nav__list > .md-nav__item > .md-nav__link:not(.md-nav__container) {
285+
padding-left: 0.75rem;
286+
}
287+
288+
/* The vertical guide line, rendered as a ::before pseudo-element
289+
* (so it can stop 5px short of the nav's bottom edge via
290+
* ``top: 0; bottom: 5px``). Scoped to any sub-section whose nested
291+
* nav has at least one child (the ``:has(> .md-nav > .md-nav__list
292+
* > .md-nav__item)`` predicate); Getting Started's nested nav is
293+
* empty (single ``index.md`` child got rolled up into the parent
294+
* link via ``navigation.indexes``) so it doesn't match. A plain
295+
* border would always cover the full element height; the
296+
* pseudo-element gives us precise control over both ends. */
297+
.md-nav--primary .md-nav[data-md-level="1"] > .md-nav__list > .md-nav__item:has(> .md-nav > .md-nav__list > .md-nav__item) > .md-nav::before {
298+
content: "";
299+
position: absolute;
300+
left: 0;
301+
top: 0;
302+
bottom: 5px;
303+
width: 1px;
304+
background: var(--md-default-fg-color--lightest);
305+
}
306+
211307
[data-md-color-scheme="slate"] .md-header,
212308
[data-md-color-scheme="slate"] .md-footer-meta {
213309
background-color: var(--md-footer-bg-color);

0 commit comments

Comments
 (0)