Skip to content

Commit a0af17d

Browse files
authored
♻️ REFACTOR: Reduce JS/CSS size and improve accessibility (#94)
Removes: * semantic-ui assets * unused 'sphinx_tabs_nowarn' sphinx option Changes: * tab structure to use tab roles * tab label colour, to increase contrast with background * assets are now copied across by sphinx rather than explicitly in the extension Adds: * tabindex atributes to allow users to focus and switch tabs using a keyboard (left and right arrows, and enter key to change) * ARIA labels for tabs and panels * ability to close tabs panel by clicking open tab * persistence of last selected group or code tab during the session (when session storage is permitted) * margin below images inside tab content
1 parent 05ddd2c commit a0af17d

28 files changed

+1232
-1593
lines changed

MANIFEST.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ include LICENSE
1515
include README.md
1616
include CHANGELOG.md
1717

18-
include sphinx_tabs/tabs.js
19-
include sphinx_tabs/tabs.css
20-
recursive-include sphinx_tabs/semantic-ui-2.4.1 *
18+
recursive-include sphinx_tabs *.css
19+
recursive-include sphinx_tabs *.js

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ Basic tabs can be coded as follows:
7373

7474
![Tabs](/images/tabs.gif)
7575

76+
The contents of each tab can be displayed by clicking on the tab that you wish to show. Clicking on the tab that is currently open will hide the tab's content, leaving only the tab set labels visible.
77+
78+
Alternatively, tab sets can be focused using :kbd:`Tab`. The :kbd:`Left Arrow` and :kbd:`Right Arrow` keys can then be used to navigate across the tab set and :kbd:`Enter` can be used to select a tab.
79+
7680
## Grouped Tabs
7781

78-
Tabs can be grouped, so that changing the current tab in one area changes the current tab in the
79-
another area. For example:
82+
Tabs can be grouped, so that changing the current tab in one tabset changes the current tab in all other tabsets containing a tab with a matching label.
83+
For example:
8084

8185
```rst
8286
.. tabs::
@@ -110,9 +114,12 @@ another area. For example:
110114

111115
![Group Tabs](/images/groupTabs.gif)
112116

117+
If permitted by the user's browser, the last selected group tab will be remembered when changing page. As such, if any tabsets on the next page contain a tab with the same label it will be selected.
118+
119+
113120
## Code Tabs
114121

115-
Grouped tabs containing code areas with syntax highlighting can be created as follows:
122+
Grouped tabs containing code with syntax highlighting can be created as follows:
116123

117124
```rst
118125
.. tabs::
@@ -152,9 +159,11 @@ Grouped tabs containing code areas with syntax highlighting can be created as fo
152159
END PROGRAM main
153160
```
154161

155-
Code tabs also support custom lexers (added via sphinx `conf.py`).
162+
![Code Tabs](/images/codeTabs.gif)
163+
164+
Code tabs also support custom lexers (added via sphinx `conf.py`). Pass the lexers alias as the first argument of `code-tab`.
156165

157-
By default, code tabs are labelled with the language name, though can be provided with custom labels like so:
166+
By default, code tabs are labelled with the language name, though a custom label can be provided as an optional second argument to the `code-tabs` directive:
158167

159168
```rst
160169
.. tabs::
@@ -172,8 +181,7 @@ By default, code tabs are labelled with the language name, though can be provide
172181
173182
```
174183

175-
176-
![Code Tabs](/images/codeTabs.gif)
184+
The tab label is used to group tabs, including `code-tabs`. As such, the same custom label should be used to group related tabs.
177185

178186
[github-ci]: https://github.com/executablebooks/sphinx-tabs/workflows/continuous-integration/badge.svg?branch=master
179187
[github-link]: https://github.com/executablebooks/sphinx-tabs

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project = "sphinx-tabs demo"
1+
project = "sphinx-tabs"
22
master_doc = "index"
33
source_suffix = ".rst"
44
extensions = ["sphinx_tabs.tabs"]

0 commit comments

Comments
 (0)