Skip to content

Commit d720879

Browse files
LucidDanthibaudcolashelenb
authored
Make template docs the default tab, and change the order of tabs (#272)
* Modify the tabs for the pattern so that the default tab is the "docs" tab Also change the order of display of tabs so the template docs is the first tab - this reads more naturally, and makes more sense visually to have the left-hand tab be default. * Display a default text when no docs is available Shows "No template doc available" if there is no .md file or the file is empty. --------- Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com> Co-authored-by: Helen Chapman <helen.chapman@torchbox.com>
1 parent 7b0bdb3 commit d720879

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Changed
6+
7+
- Swap position of template "docs" and "source" tabs, and make the "docs" tab the default ([#259](https://github.com/torchbox/django-pattern-library/issues/259))
8+
59
### Removed
610

711
- Drop support for Python 3.9

pattern_library/templates/pattern_library/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,29 @@ <h4 class="heading heading--iframe-size js-iframe-size">
2525
<div class="tabbed-content">
2626
<ul class="tabbed-content__list">
2727
<li class="tabbed-content__heading tabbed-content__heading--active">
28-
<a href="#tab-1">Template source</a>
28+
<a href="#tab-1">Template docs</a>
2929
</li>
30+
3031
<li class="tabbed-content__heading">
3132
<a href="#tab-2">Template config</a>
3233
</li>
3334

3435
<li class="tabbed-content__heading">
35-
<a href="#tab-3">Template docs</a>
36+
<a href="#tab-3">Template source</a>
3637
</li>
3738
</ul>
3839

3940
<div class="tabbed-content__tabs">
4041
<div id="tab-1" class="tabbed-content__item tabbed-content__item--active">
41-
<pre><code class="code django">{{ pattern_source }}</code></pre>
42+
{% if pattern_markdown %}<div class="md">{{ pattern_markdown|safe }}</div>{% else %}<div class="md">No template doc available.</div>{% endif %}
4243
</div>
4344

4445
<div id="tab-2" class="tabbed-content__item">
4546
<pre><code class="code yaml">{{ pattern_config }}</code></pre>
4647
</div>
4748

4849
<div id="tab-3" class="tabbed-content__item">
49-
<div class="md">{{ pattern_markdown|safe }}</div>
50+
<pre><code class="code django">{{ pattern_source }}</code></pre>
5051
</div>
5152
</div>
5253
</div>

0 commit comments

Comments
 (0)