Skip to content

Commit 8889e7b

Browse files
authored
Tabs tidy and shortcuts (#387)
* Fix indentation * Further simplify tabs CSS * Ignore tab contents in shortcuts * Remove tab paragraph wrapper * Further simplify tab styling; prevent total collapse of tabs * Fix highlight alignment; do not highlight top of selected tab * Fix selected tab hover
1 parent 05deadf commit 8889e7b

File tree

4 files changed

+42
-54
lines changed

4 files changed

+42
-54
lines changed

assets/js/shortcuts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ function remToPx(rem) {
8383
function setupShortcuts(shortcutDepth = 2) {
8484
shortcutDepth += 1; // to account for the page title
8585

86-
// Build a string like ".content-container h2, .content-container h3"
86+
// Build a class selector for each header type, and concatenate with commas
8787
let classes = "";
8888
for (let i = 2; i <= shortcutDepth; i++) {
8989
if (i != 2) {
9090
classes += ",";
9191
}
92-
classes += " .content-container h" + i;
92+
classes += " .content-container :not([role='tabpanel']) > h" + i;
9393
}
9494

9595
// Content Page Shortcuts

assets/theme-css/tabs.css

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,60 @@
1-
.tabs {
2-
display: block;
3-
padding-bottom: 1.5rem;
4-
}
51
.tabs :is(h1, h2, h3, h4, h5, h6) {
62
margin-top: 0.5rem;
73
}
84

5+
/* The tab list is the list of tab names */
96
[role="tablist"] {
10-
display: inline-block;
11-
min-width: 100%;
7+
display: flex;
8+
flex-flow: row wrap;
9+
margin-bottom: 0px;
10+
padding-bottom: 0px;
1211
}
1312

13+
/* The tab is the clickable element that selects between tabpanels (see below) */
1414
[role="tab"] {
15-
box-sizing: border-box;
16-
padding: 2px 2px 4px;
17-
background-color: var(--pst-color-background);
1815
border: none;
16+
padding: 0.75em 1.3em 0.9em;
17+
background-color: var(--pst-color-background);
18+
margin-bottom: 0;
1919
color: var(--pst-color-text);
20-
outline: none;
2120
font-weight: bold;
2221
max-width: 22%;
23-
overflow: hidden;
2422
text-align: left;
2523
cursor: pointer;
2624
font-size: 1rem;
2725
}
2826

29-
[role="tab"]:hover,
30-
[role="tab"][aria-selected="true"]:hover {
27+
[role="tab"]:hover {
3128
color: var(--pst-color-secondary);
32-
border-bottom-color: var(--pst-color-secondary);
33-
border-bottom-size: 2px;
34-
border-bottom-style: solid;
35-
border-top-color: var(--pst-color-secondary);
36-
border-top-size: 2px;
37-
border-top-style: solid;
29+
box-shadow:
30+
0 -0.125rem var(--pst-color-secondary),
31+
0 0.125rem var(--pst-color-secondary);
3832
}
3933

34+
/* Selected tab behavior */
4035
[role="tab"][aria-selected="true"] {
41-
border-bottom-color: var(--pst-color-primary);
42-
border-bottom-style: solid;
43-
border-bottom-size: 2px;
44-
border-top-color: transparent;
45-
border-top-style: solid;
46-
border-top-size: 2px;
4736
color: var(--pst-color-primary);
37+
box-shadow: 0 0.125rem var(--pst-color-primary);
4838
}
4939

50-
[role="tab"] span.focus {
51-
display: inline-block;
52-
margin: 2px;
53-
padding: 4px 6px;
40+
[role="tab"][aria-selected="true"]:hover {
41+
color: var(--pst-color-secondary);
42+
box-shadow:
43+
0 -0.125rem var(--pst-color-secondary),
44+
0 0.125rem var(--pst-color-secondary);
5445
}
5546

47+
/* The tab panel is in which the tab contents appear */
5648
[role="tabpanel"] {
57-
box-shadow:
58-
0 -0.0625rem var(--pst-color-text-muted),
59-
0 0.0625rem var(--pst-color-text-muted);
49+
border-top: 1px solid var(--pst-color-text-muted);
50+
border-bottom: 1px solid var(--pst-color-text-muted);
51+
margin-top: 1px;
52+
padding-top: 0.5rem;
53+
padding-bottom: 0.5rem;
6054
width: 100%;
6155
overflow: auto;
6256
}
6357

6458
[role="tabpanel"].is-hidden {
6559
display: none;
6660
}
67-
68-
[role="tabpanel"] p {
69-
margin: 0;
70-
}

layouts/partials/panel.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
{{- $tiles := index $panel "tiles" }}
55
<section class="panel">
66
<div class="container is-max-widescreen">
7-
<div class="panel-box-container">
8-
{{- range $tiles }}
9-
<div class="panel-box-content">
10-
<p>
11-
<div class="panel-box-action">
12-
<a href="{{ .url }}" class="panel-button">{{ .buttonText }}</a>
13-
</div>
14-
<div class="panel-box-text">{{ .text | markdownify }}</div>
15-
</p>
16-
</div>
17-
{{- end }}
18-
</div>
7+
<div class="panel-box-container">
8+
{{- range $tiles }}
9+
<div class="panel-box-content">
10+
<p>
11+
<div class="panel-box-action">
12+
<a href="{{ .url }}" class="panel-button">{{ .buttonText }}</a>
13+
</div>
14+
<div class="panel-box-text">{{ .text | markdownify }}</div>
15+
</p>
16+
</div>
17+
{{- end }}
1918
</div>
19+
</div>
2020
</section>

layouts/shortcodes/tabs.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
<div role="tablist" class="automatic">
77
{{- range $idx, $tab := .Scratch.Get "tabs" }}
88
<button id="{{ $groupId }}-tab-{{ $idx }}" type="button" role="tab" aria-selected="{{ cond (eq $idx 0) "true" "false" }}" aria-controls="{{ $groupId }}-tabpanel-{{ $idx }}">
9-
<span class="focus">{{ .name }}</span>
9+
{{ .name }}
1010
</button>
1111
{{- end }}
1212
</div>
1313
{{- range $idx, $tab := .Scratch.Get "tabs" }}
1414
<div id="{{ $groupId }}-tabpanel-{{ $idx }}" role="tabpanel" tabindex="0" aria-labelledby="${{ $groupId }}-tab-{{ $idx }}">
15-
<p>
16-
{{- .content | markdownify -}}
17-
</p>
15+
{{- .content | markdownify -}}
1816
</div>
1917
{{- end }}
2018
</div>

0 commit comments

Comments
 (0)