asciidoctor-tabs 1.0.0.alpha.7 → 1.0.0.alpha.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +30 -0
- data/README.adoc +28 -1
- data/data/css/tabs.css +33 -19
- data/data/js/tabs.js +18 -24
- data/lib/asciidoctor/tabs/block.rb +3 -1
- data/lib/asciidoctor/tabs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aeccc2d9238859443b65f67f884e6629f95ac3a11e1ef89ccaff2280ac27003
|
4
|
+
data.tar.gz: d88ba56fefb38744e27d059c53d61f25507b47b2a8958e34252fed4278c86215
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07a151ea4c94cb145e1bf673c0ceec2d96b6c75acc525a969bd304b8e59c4180057e1ee95d762c16f83c2845b76a2c91b6cf248835c97fa58043e1d8b5b58c3e
|
7
|
+
data.tar.gz: 6d8b2e56e0df595d0c5c05a357d5c5bfbd4de89e412c7d94a56d42aebf2bc9c1f875b8667089154c4c35d28ed931081d27270c9fdaba68a8d3a0e2ccc969a49e
|
data/CHANGELOG.adoc
CHANGED
@@ -4,6 +4,36 @@
|
|
4
4
|
This document provides a curated view of the changes to Asciidoctor Tabs per release.
|
5
5
|
For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
|
6
6
|
|
7
|
+
== 1.0.0-alpha.9 (2022-12-07) - @mojavelinux
|
8
|
+
|
9
|
+
=== Changed
|
10
|
+
|
11
|
+
* Assign `tab` role to each item in tab list
|
12
|
+
* Apply border and padding to tab pane element instead of its parent
|
13
|
+
* Remove fixed height on tab element; using padding instead
|
14
|
+
* Use more subtle color scheme for border and background colors on tabs
|
15
|
+
|
16
|
+
=== Fixed
|
17
|
+
|
18
|
+
* Configure overflow content in tab panel to scroll horizontally
|
19
|
+
* Set background on tabs properly so background does not bleed through
|
20
|
+
|
21
|
+
=== Details
|
22
|
+
|
23
|
+
{url-repo}/releases/tag/v1.0.0-alpha.9[git tag] | {url-repo}/compare/v1.0.0-alpha.8\...v1.0.0-alpha.9[full diff]
|
24
|
+
|
25
|
+
== 1.0.0-alpha.8 (2022-11-30) - @mojavelinux
|
26
|
+
|
27
|
+
=== Fixed
|
28
|
+
|
29
|
+
* Sync tab selection on hash change (#32)
|
30
|
+
* Lock position of content when synchronizing tab selection (#34)
|
31
|
+
* Remove bottom margin from last block in tab pane for the most common cases
|
32
|
+
|
33
|
+
=== Details
|
34
|
+
|
35
|
+
{url-repo}/releases/tag/v1.0.0-alpha.8[git tag] | {url-repo}/compare/v1.0.0-alpha.7\...v1.0.0-alpha.8[full diff]
|
36
|
+
|
7
37
|
== 1.0.0-alpha.7 (2022-11-28) - @mojavelinux
|
8
38
|
|
9
39
|
=== Added
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Asciidoctor Tabs
|
2
2
|
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
|
3
|
-
v1.0.0-alpha.
|
3
|
+
v1.0.0-alpha.9, 2022-12-07
|
4
4
|
:idprefix:
|
5
5
|
:idseparator: -
|
6
6
|
ifndef::env-github[:icons: font]
|
@@ -100,6 +100,33 @@ Tab B:: Just text.
|
|
100
100
|
======
|
101
101
|
----
|
102
102
|
|
103
|
+
== Tabs Sync
|
104
|
+
|
105
|
+
If you want to synchronize the tab selection across tabsets, set the `tabs-sync-option` on the document.
|
106
|
+
|
107
|
+
.document-with-tabs-sync.adoc
|
108
|
+
[,asciidoc]
|
109
|
+
----
|
110
|
+
:tabs-sync-option:
|
111
|
+
|
112
|
+
[tabs]
|
113
|
+
====
|
114
|
+
Tab A:: Contents of tab A in first tabset.
|
115
|
+
Tab B:: Contents of tab B in first tabset.
|
116
|
+
====
|
117
|
+
|
118
|
+
...
|
119
|
+
|
120
|
+
[tabs]
|
121
|
+
====
|
122
|
+
Tab A:: Contents of tab A in second tabset.
|
123
|
+
Tab B:: Contents of tab B in second tabset.
|
124
|
+
====
|
125
|
+
----
|
126
|
+
|
127
|
+
Alternately, you can set the `sync` option on each tabs block.
|
128
|
+
If you want to delist a tabs block from sync, set the `nosync` option on that block.
|
129
|
+
|
103
130
|
== Usage
|
104
131
|
|
105
132
|
=== CLI
|
data/data/css/tabs.css
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
/*! Asciidoctor Tabs | Copyright (c) 2018-present Dan Allen | MIT License */
|
2
|
+
.tabset {
|
3
|
+
margin-bottom: 1.25em;
|
4
|
+
}
|
5
|
+
|
2
6
|
.tabs > ul {
|
3
7
|
display: flex;
|
4
8
|
flex-wrap: wrap;
|
@@ -9,39 +13,36 @@
|
|
9
13
|
|
10
14
|
.tabs > ul li {
|
11
15
|
align-items: center;
|
12
|
-
|
13
|
-
border-bottom: 0;
|
16
|
+
background-color: #fff;
|
14
17
|
cursor: pointer;
|
15
18
|
display: flex;
|
16
19
|
font-weight: bold;
|
17
|
-
height:
|
18
|
-
|
19
|
-
margin-right: 0.25em;
|
20
|
-
padding: 0 1em;
|
20
|
+
line-height: 1.5;
|
21
|
+
padding: 0.25em 1em;
|
21
22
|
position: relative;
|
22
23
|
}
|
23
24
|
|
24
|
-
.tabs > ul li
|
25
|
-
margin
|
25
|
+
.tabs.ulist > ul li {
|
26
|
+
margin: 0;
|
26
27
|
}
|
27
28
|
|
28
|
-
.tabs > ul
|
29
|
-
|
29
|
+
.tabs > ul p {
|
30
|
+
line-height: inherit;
|
31
|
+
margin-bottom: 0;
|
30
32
|
}
|
31
33
|
|
32
|
-
.
|
33
|
-
margin-
|
34
|
+
.tabs.ulist > ul li + li {
|
35
|
+
margin-left: 0.25em;
|
34
36
|
}
|
35
37
|
|
36
38
|
.tabset.is-loading .tabs li:not(:first-child),
|
37
39
|
.tabset:not(.is-loading) .tabs li:not(.is-active) {
|
38
|
-
background-color:
|
39
|
-
color: white;
|
40
|
+
background-color: #f5f5f5;
|
40
41
|
}
|
41
42
|
|
42
43
|
.tabset.is-loading .tabs li:first-child::after,
|
43
|
-
.tabs li.is-active::after {
|
44
|
-
background-color:
|
44
|
+
.tabset:not(.is-loading) .tabs li.is-active::after {
|
45
|
+
background-color: inherit;
|
45
46
|
content: "";
|
46
47
|
display: block;
|
47
48
|
height: 3px; /* Chrome doesn't always paint the line accurately, so add a little extra */
|
@@ -51,11 +52,22 @@
|
|
51
52
|
right: 0;
|
52
53
|
}
|
53
54
|
|
54
|
-
.tabset
|
55
|
-
|
55
|
+
.tabset .tab-pane {
|
56
|
+
background-color: #fff;
|
57
|
+
display: flex;
|
58
|
+
overflow-x: auto;
|
56
59
|
padding: 1.25em;
|
57
60
|
}
|
58
61
|
|
62
|
+
.tabs > ul li,
|
63
|
+
.tabset .tab-pane {
|
64
|
+
border: 1px solid #dcdcdc;
|
65
|
+
}
|
66
|
+
|
67
|
+
.tabs > ul li {
|
68
|
+
border-bottom: 0;
|
69
|
+
}
|
70
|
+
|
59
71
|
.tabset.is-loading .tab-pane:not(:first-child),
|
60
72
|
.tabset:not(.is-loading) .tab-pane:not(.is-active) {
|
61
73
|
display: none;
|
@@ -65,6 +77,8 @@
|
|
65
77
|
margin-top: 0;
|
66
78
|
}
|
67
79
|
|
68
|
-
.tab-pane > :last-child
|
80
|
+
#content .tab-pane > :last-child,
|
81
|
+
#content .tab-pane > :last-child > :last-child,
|
82
|
+
#content .tab-pane > :last-child > :last-child > li:last-child > :last-child {
|
69
83
|
margin-bottom: 0;
|
70
84
|
}
|
data/data/js/tabs.js
CHANGED
@@ -7,11 +7,8 @@
|
|
7
7
|
|
8
8
|
function init (tabsets) {
|
9
9
|
if (!tabsets.length) return
|
10
|
-
var fragment = getFragment()
|
11
10
|
forEach.call(tabsets, function (tabset) {
|
12
11
|
var tabs = tabset.querySelectorAll('.tabs li')
|
13
|
-
if (!tabs.length) return tabset.classList.remove('is-loading')
|
14
|
-
var active, first, syncId
|
15
12
|
var syncIds = tabset.classList.contains('is-sync') ? {} : undefined
|
16
13
|
forEach.call(tabs, function (tab, idx) {
|
17
14
|
var id = tab.id
|
@@ -20,26 +17,22 @@
|
|
20
17
|
if (!anchor) return // invalid state
|
21
18
|
tab.id = id = anchor.parentNode.removeChild(anchor).id
|
22
19
|
}
|
23
|
-
tab.className = 'tab'
|
20
|
+
tab.className = idx ? 'tab' : 'tab is-active'
|
24
21
|
var pane = tabset.querySelector('.tab-pane[aria-labelledby~="' + id + '"]')
|
25
22
|
if (!pane) return // invalid state
|
23
|
+
if (!idx) pane.classList.add('is-active')
|
24
|
+
var onClick = activateTab
|
26
25
|
var instance = { tabset: tabset, tab: tab, pane: pane }
|
27
|
-
|
28
|
-
if (!active && fragment === id && (active = true)) {
|
29
|
-
tab.classList.add('is-active')
|
30
|
-
pane.classList.add('is-active')
|
31
|
-
}
|
26
|
+
var syncId
|
32
27
|
if (syncIds && !((syncId = tab.textContent.trim()) in syncIds)) {
|
33
28
|
syncIds[(tab.dataset.syncId = syncId)] = true
|
34
|
-
|
35
|
-
} else {
|
36
|
-
tab.addEventListener('click', activateTab.bind(instance))
|
29
|
+
onClick = activateTabSync
|
37
30
|
}
|
31
|
+
tab.addEventListener('click', onClick.bind(instance))
|
38
32
|
})
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
33
|
+
})
|
34
|
+
onHashChange()
|
35
|
+
forEach.call(tabsets, function (tabset) {
|
43
36
|
tabset.classList.remove('is-loading')
|
44
37
|
})
|
45
38
|
window.addEventListener('hashchange', onHashChange)
|
@@ -47,7 +40,7 @@
|
|
47
40
|
|
48
41
|
function activateTab (e) {
|
49
42
|
var tab = this.tab
|
50
|
-
var tabset = this.tabset || tab.closest('.tabset')
|
43
|
+
var tabset = this.tabset || (this.tabset = tab.closest('.tabset'))
|
51
44
|
var pane = this.pane || tabset.querySelector('.tab-pane[aria-labelledby~="' + tab.id + '"]')
|
52
45
|
forEach.call(tabset.querySelectorAll('.tabs li, .tab-pane'), function (el) {
|
53
46
|
el === tab || el === pane ? el.classList.add('is-active') : el.classList.remove('is-active')
|
@@ -61,20 +54,21 @@
|
|
61
54
|
|
62
55
|
function activateTabSync (e) {
|
63
56
|
activateTab.call(this, e)
|
57
|
+
var tabset = this.tabset
|
64
58
|
var thisTab = this.tab
|
59
|
+
var initialY = tabset.getBoundingClientRect().y
|
65
60
|
forEach.call(document.querySelectorAll('.tabs li'), function (tab) {
|
66
61
|
if (tab !== thisTab && tab.dataset.syncId === thisTab.dataset.syncId) activateTab.call({ tab: tab })
|
67
62
|
})
|
68
|
-
|
69
|
-
|
70
|
-
function getFragment (hash) {
|
71
|
-
return (hash = window.location.hash) && (~hash.indexOf('%') ? decodeURIComponent(hash.slice(1)) : hash.slice(1))
|
63
|
+
var shiftedBy = tabset.getBoundingClientRect().y - initialY
|
64
|
+
if (shiftedBy && (shiftedBy = Math.round(shiftedBy))) window.scrollBy({ top: shiftedBy, behavior: 'instant' })
|
72
65
|
}
|
73
66
|
|
74
67
|
function onHashChange () {
|
75
|
-
var id =
|
68
|
+
var id = window.location.hash.slice(1)
|
76
69
|
if (!id) return
|
77
|
-
var tab = document.getElementById(id)
|
78
|
-
if (tab && tab.classList.contains('tab'))
|
70
|
+
var tab = document.getElementById(~id.indexOf('%') ? decodeURIComponent(id) : id)
|
71
|
+
if (!(tab && tab.classList.contains('tab'))) return
|
72
|
+
tab.dataset.syncId ? activateTabSync.call({ tab: tab }) : activateTab.call({ tab: tab })
|
79
73
|
}
|
80
74
|
})()
|
@@ -23,7 +23,8 @@ module Asciidoctor
|
|
23
23
|
if (title = attrs['title'])
|
24
24
|
parent << (create_html_fragment parent, %(<div class="title">#{parent.apply_subs title}</div>))
|
25
25
|
end
|
26
|
-
|
26
|
+
tabs = create_list parent, :ulist
|
27
|
+
tabs.add_role 'tabs'
|
27
28
|
panes = {}
|
28
29
|
set_id_on_tab = (doc.backend == 'html5') || (list_item_supports_id? doc)
|
29
30
|
source_tabs.items.each do |labels, content|
|
@@ -32,6 +33,7 @@ module Asciidoctor
|
|
32
33
|
tab_id = generate_id tab.text, doc, tabs_id
|
33
34
|
tab_source_text = tab.instance_variable_get :@text
|
34
35
|
set_id_on_tab ? (tab.id = tab_id) : (tab.text = %([[#{tab_id}]]#{tab_source_text}))
|
36
|
+
tab.add_role 'tab'
|
35
37
|
(doc.register :refs, [tab_id, tab]).set_attr 'reftext', tab_source_text
|
36
38
|
tab_id
|
37
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-tabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|