click_extra.sphinx.tabs moduleΒΆ
Lay out a sphinx-design tab-set vertically, its labels down a left rail.
A tab-set with many tabs, like the install channels of a project, wraps its
labels into a strip that is hard to read. This module ships a stylesheet that
lays out a tab-set marked with VERTICAL_TABS_CLASS in two columns: the
labels stack down the left, and the selected pane fills the right. On a screen
narrower than NARROW_SCREEN, the tab-set falls back to the stock
horizontal layout.
sphinx-design keeps the radio inputs, their labels and the panes of a tab-set as flat siblings of one flex container, so a two-column grid on that container is enough: grid placement decouples the visual position of each sibling from its source order. The rules use the child combinator, so a tab-set nested inside a pane keeps the horizontal layout. The stylesheet is written into the build rather than packaged as a data file, and is inert on a project that does not load sphinx-design.
The class is deprecated: sphinx-design 0.8.0 lays out a tab-set the same way
with the :orientation: vertical option of tab-set, from
executablebooks/sphinx-design#304.
Each tab-set that carries the class gets a VERTICAL_TABS_WARNING, and
the class stops working in 11.0.0.
- click_extra.sphinx.tabs.VERTICAL_TABS_CLASS = 'tabs-vertical'ΒΆ
The class a
tab-settakes in its:class:option to lay out vertically.
- click_extra.sphinx.tabs.VERTICAL_TABS_WARNING = 'click_extra.tabs_vertical'ΒΆ
Type and subtype of the warning about a
VERTICAL_TABS_CLASStab-set.List it in
suppress_warningsto silence the warning.
- click_extra.sphinx.tabs.NARROW_SCREEN = '50em'ΒΆ
The screen width under which a vertical tab-set falls back to horizontal tabs.
- click_extra.sphinx.tabs.VERTICAL_TABS_CSS = ".sd-tab-set.tabs-vertical {\n display: grid;\n /* The pane's track is floored at zero: a bare `1fr` means `minmax(auto, 1fr)`,\n * whose floor grows to the widest line the pane cannot break, like a long URL\n * in a code block, and pushes the pane under the sidebar. */\n grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr);\n align-items: start;\n}\n\n/* No column gap: the marker of the active label then sits on the rule of the\n * pane, the way horizontal tabs merge an underline into an overline. */\n.sd-tab-set.tabs-vertical > label {\n grid-column: 1;\n text-align: left;\n padding-right: 1rem;\n border-bottom: none;\n border-right: 0.125rem solid transparent;\n}\n.sd-tab-set.tabs-vertical > input:checked + label {\n border-right-color: var(--sd-color-tabs-underline-active);\n}\n.sd-tab-set.tabs-vertical > .sd-tab-content {\n grid-column: 2;\n /* Span every row, or the height of the pane inflates the first row and\n * pushes the labels down the rail. `1 / -1` counts from the last explicit\n * row, and the grid declares none, so the span overshoots any tab count. */\n grid-row: 1 / span 99;\n align-self: stretch;\n padding: 0 0 0 1.5rem;\n /* sphinx-design rules a pane with two shadows, one above and one below. A\n * single hairline down the left edge replaces them. */\n box-shadow: -0.0625rem 0 var(--sd-color-tabs-overline);\n}\n\n/* Too narrow for two columns: restate the values of sphinx-design, since a\n * shorthand cannot fall back to the value of another stylesheet. */\n@media (max-width: 50em) {\n .sd-tab-set.tabs-vertical {\n display: flex;\n flex-wrap: wrap;\n }\n .sd-tab-set.tabs-vertical > label {\n padding: 1em 1.25em 0.5em;\n border-right: none;\n border-bottom: 0.125rem solid transparent;\n }\n .sd-tab-set.tabs-vertical > input:checked + label {\n border-bottom-color: var(--sd-color-tabs-underline-active);\n }\n .sd-tab-set.tabs-vertical > .sd-tab-content {\n align-self: auto;\n padding: 0.75rem 0;\n box-shadow:\n 0 -0.0625rem var(--sd-color-tabs-overline),\n 0 0.0625rem var(--sd-color-tabs-underline);\n }\n}\n"ΒΆ
Stylesheet laying out a tab-set marked with
VERTICAL_TABS_CLASS.
- click_extra.sphinx.tabs.STYLESHEET = 'click-extra-tabs.css'ΒΆ
File name of the stylesheet, served from the
_staticfolder.
- click_extra.sphinx.tabs.add_vertical_tabs(app)[source]ΒΆ
Write
VERTICAL_TABS_CSSinto the build and link it from each page.The file goes to the static folder of the extension (see
click_extra.sphinx.tables._write_static_file). Only an HTML builder serves it, so other builders skip it.- Return type:
- click_extra.sphinx.tabs.warn_vertical_tabs_class(app, doctree)[source]ΒΆ
Warn about each tab-set of
doctreemarked withVERTICAL_TABS_CLASS.sphinx-design gives the node of each
tab-setandtab-set-codethesd-tab-setclass, beside the classes of its:class:option.- Return type:
- click_extra.sphinx.tabs.setup(app)[source]ΒΆ
Register the vertical tab stylesheet and the deprecation warning on
app.Called from
click_extra.sphinx.setup()so projects only need to list"click_extra.sphinx"in theirextensions.- Return type: