Skip to content

Commit ca28ead

Browse files
authored
Merge pull request #49 from couchbase/tabset-fixes
Tabset fixes bug fixes for more button
2 parents c27b1e8 + f34a201 commit ca28ead

File tree

5 files changed

+117
-66
lines changed

5 files changed

+117
-66
lines changed

src/css/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
html {
88
box-sizing: border-box;
99
text-size-adjust: 100%;
10+
scroll-behavior: smooth;
1011
}
1112

1213
html,

src/css/component-frame.css

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
.component-frame {
22
/* rgba(87, 160, 255, 1) */
33
background: var(--color-brand-gray6);
4-
padding: 12px 15px 12px 15px;
4+
/* padding: 12px 15px 12px 15px; */
55
display: flex;
6-
align-items: center;
6+
/* align-items: center; */
77
justify-content: center;
8+
position: relative;
9+
}
10+
11+
.frame-icon {
12+
padding: 12px 0 12px 15px;
813
}
914

1015
.frame-body {
1116
margin-left: var(--base-extra-small-space);
1217
position: relative;
18+
padding-top: 12px;
19+
padding-bottom: 12px;
20+
padding-right: 15px;
21+
line-height: 2;
22+
display: flex;
23+
align-items: center;
24+
flex-wrap: wrap;
1325
}
1426

1527
.frame-body .title {
16-
margin: 0;
28+
margin: 0 4px 0 0;
1729
font-size: var(--font-medium);
1830
line-height: 1.5rem;
1931
font-weight: var(--weight-semibold);
@@ -23,23 +35,25 @@
2335

2436
.component-frame .frame-link-dropdowns {
2537
display: inline-block;
38+
line-height: 1;
2639
}
2740

2841
.frame-body .frame-link {
2942
position: relative;
3043
}
3144

32-
.frame-body .frame-link-dropdowns:hover .frame-dropdown {
33-
display: block;
34-
}
35-
3645
.frame-dropdown {
3746
position: absolute;
3847
display: none;
39-
left: 56%;
40-
top: 0;
48+
left: auto;
49+
top: 100%;
4150
z-index: 1;
42-
padding: 47px 0 0;
51+
padding: 0;
52+
}
53+
54+
.component-frame .frame-dropdown.show,
55+
.component-frame .frame-body:hover .frame-dropdown {
56+
display: block;
4357
}
4458

4559
.frame-link-dropdowns .frame-link {
@@ -73,6 +87,7 @@
7387
width: 100%;
7488
color: var(--color-brand-primary);
7589
font-weight: var(--weight-semibold);
90+
line-height: var(--line-height-base);
7691
}
7792

7893
.frame-dropdown ul li a:hover,

src/css/doc.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ table.tableblock pre code.language-bash.hljs {
769769

770770
.doc .tabs.ulist {
771771
margin-top: 0;
772+
padding-left: 0;
772773
}
773774

774775
.doc .tabs ul {
@@ -999,6 +1000,10 @@ table.tableblock pre code.language-bash.hljs {
9991000
display: block;
10001001
}
10011002

1003+
.other-tab-box.desktop-hide {
1004+
display: none;
1005+
}
1006+
10021007
/* Media css */
10031008

10041009
@media screen and (max-width: 767px) {
@@ -1029,6 +1034,10 @@ table.tableblock pre code.language-bash.hljs {
10291034
font-size: var(--heading-h4-sm);
10301035
}
10311036

1037+
.other-tab-box.desktop-hide {
1038+
display: block;
1039+
}
1040+
10321041
.doc .admonitionblock td.content {
10331042
padding-left: 1rem;
10341043
}

src/css/landing-page.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@
124124
flex-wrap: wrap;
125125
}
126126

127+
.doc.landing-page-doc .other-info-list .box.ulist,
128+
.doc.landing-page-doc .other-info-list .box.olist {
129+
padding-left: 0;
130+
}
131+
127132
.doc.landing-page-doc .other-info-list .box {
128133
padding-right: 40px;
129134
}

src/js/05-tabset.js

Lines changed: 77 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,115 @@
11
var hash = window.location.hash
22
var queueData = []
33
var checkActiveClass
4-
var tabOnLargeScreen = 3 // Display tab on desktop
4+
var tabOnLargeScreen = 5 // Display tab on desktop
55
var tabOnSmallScreen = 1 // display tab on mobile view bewlow 768px screen
66
var smallBreak = 768 // Your small screen breakpoint in pixels
77
find('.doc .tabset').forEach(function (tabset) {
88
var active
99
var tabs = tabset.querySelector('.tabs')
1010
if (tabs) {
1111
var first
12-
find('li', tabs).forEach(function (tab, idx) {
13-
var id = (tab.querySelector('a[id]') || tab).id
14-
checkActiveClass = setTimeout(function () {
15-
var activeTabList = tab.classList.contains('is-active')
16-
if (activeTabList) {
17-
document.querySelector('.tabs').insertAdjacentHTML(
18-
'beforeend',
19-
/*eslint max-len: ["error", { "code": 180 }]*/
20-
'<div class="other-tab-box"><a href="#" class="dropddown-btn dropdown-btn-down">More... </a> <ul class="other-tablist" id="otherTabList"></ul></div>'
21-
)
22-
var dropdownBtn = document.querySelector('.dropdown-btn-down')
23-
var dropdownMenu = document.querySelector('.tabs .other-tablist')
24-
dropdownBtn.addEventListener('click', function (e) {
25-
e.preventDefault()
26-
if (dropdownMenu.style.display === 'block' || dropdownMenu.classList.contains('show')) {
27-
dropdownMenu.classList.remove('show')
28-
dropdownMenu.classList.add('hide')
29-
} else {
30-
dropdownMenu.classList.add('show')
31-
dropdownMenu.classList.remove('hide')
12+
find('ul', tabs).forEach(function (ulTabSet, id) {
13+
if (ulTabSet) {
14+
find('li', ulTabSet).forEach(function (tab, idx) {
15+
var id = (tab.querySelector('a[id]') || tab).id
16+
17+
if (window.innerWidth < smallBreak) {
18+
if (idx > tabOnSmallScreen - 1) {
19+
queueData.push(tab)
3220
}
33-
})
34-
}
35-
}, 100)
36-
if (window.innerWidth < smallBreak) {
37-
if (idx > tabOnSmallScreen - 1) {
38-
queueData.push(tab)
39-
}
40-
} else {
41-
if (idx > tabOnLargeScreen - 1) {
42-
queueData.push(tab)
43-
}
44-
}
21+
} else {
22+
if (idx > tabOnLargeScreen - 1) {
23+
queueData.push(tab)
24+
}
25+
}
26+
27+
checkActiveClass = setTimeout(function () {
28+
var activeTabList = tab.classList.contains('is-active')
4529

46-
if (!id) return
47-
var pane = getPane(id, tabset)
48-
if (!idx) first = { tab: tab, pane: pane }
49-
if (!active && hash === '#' + id && (active = true)) {
50-
tab.classList.add('is-active')
51-
if (pane) pane.classList.add('is-active')
52-
} else if (!idx) {
53-
tab.classList.remove('is-active')
54-
if (pane) pane.classList.remove('is-active')
30+
if (activeTabList) {
31+
if (queueData.length > 0) {
32+
if (window.innerWidth > smallBreak && (tab.parentNode.childElementCount > tabOnLargeScreen - 1)) {
33+
tab.parentNode.parentNode.insertAdjacentHTML(
34+
'beforeend',
35+
/*eslint max-len: ["error", { "code": 180 }]*/
36+
'<div class="other-tab-box"><a href="#" class="dropddown-btn dropdown-btn-down">More... </a> <ul class="other-tablist"></ul></div>'
37+
)
38+
} else {
39+
tab.parentNode.parentNode.insertAdjacentHTML(
40+
'beforeend',
41+
/*eslint max-len: ["error", { "code": 180 }]*/
42+
'<div class="other-tab-box desktop-hide"><a href="#" class="dropddown-btn dropdown-btn-down">More... </a> <ul class="other-tablist"></ul></div>'
43+
)
44+
}
45+
var dropdownBtn = tab.parentNode.parentNode.querySelector('.dropdown-btn-down')
46+
var dropdownMenu = tab.parentNode.parentNode.querySelector('.tabs .other-tablist')
47+
dropdownBtn.addEventListener('click', function (e) {
48+
console.log(e, 'enter')
49+
e.preventDefault()
50+
if (dropdownMenu.style.display === 'block' || dropdownMenu.classList.contains('show')) {
51+
dropdownMenu.classList.remove('show')
52+
dropdownMenu.classList.add('hide')
53+
} else {
54+
dropdownMenu.classList.add('show')
55+
dropdownMenu.classList.remove('hide')
56+
}
57+
})
58+
}
59+
}
60+
}, 40)
61+
62+
if (!id) return
63+
var pane = getPane(id, tabset)
64+
if (!idx) first = { tab: tab, pane: pane }
65+
if (!active && hash === '#' + id && (active = true)) {
66+
tab.classList.add('is-active')
67+
if (pane) pane.classList.add('is-active')
68+
} else if (!idx) {
69+
tab.classList.remove('is-active')
70+
if (pane) pane.classList.remove('is-active')
71+
}
72+
tab.addEventListener('click', activateTab.bind({ tabset: tabset, tab: tab, pane: pane }))
73+
})
5574
}
56-
tab.addEventListener('click', activateTab.bind({ tabset: tabset, tab: tab, pane: pane }))
5775
})
76+
5877
if (!active && first) {
5978
first.tab.classList.add('is-active')
6079
if (first.pane) first.pane.classList.add('is-active')
6180
}
6281
}
6382

64-
setTimeout(function () {
65-
var appendMoreTabList = document.getElementById('otherTabList')
66-
67-
queueData.forEach(function (tablist) {
68-
appendMoreTabList.appendChild(tablist)
69-
})
70-
}, 100)
7183
tabset.classList.remove('is-loading')
7284
clearTimeout(checkActiveClass, 20000)
7385
})
7486

87+
setTimeout(function () {
88+
if (queueData.length) {
89+
queueData.forEach(function (tablist) {
90+
tablist.parentNode.nextElementSibling.lastElementChild.appendChild(tablist)
91+
})
92+
}
93+
}, 200)
94+
// to activate tabset
7595
function activateTab (e) {
7696
e.preventDefault()
7797
var tab = this.tab
7898
var pane = this.pane
99+
// Moving element from dropdown into tabset list
79100
var tabMenu = document.querySelector('.tabs ul')
80-
var nodeTab = document.querySelector('.tabs > ul')
81-
var nodeDropdownTabNode = document.querySelector('.other-tablist')
101+
var nodeTab = tab.parentNode.parentNode.parentNode.querySelector('.tabs > ul')
102+
var nodeDropdownTabNode = tab.parentNode
82103
if (tab.parentNode.classList[0] === 'other-tablist') {
83104
nodeDropdownTabNode.appendChild(nodeTab.lastElementChild)
84105
nodeTab.appendChild(tab)
85106
nodeDropdownTabNode.classList.remove('show')
86107
}
87-
var activeTabList = tab.classList.contains('is-active')
88-
if (activeTabList) {
108+
var activeTabListItem = tab.classList.contains('is-active')
109+
if (activeTabListItem) {
89110
tabMenu.classList.remove('show')
90111
}
91-
112+
// for tab active pane
92113
find('.tabs li, .tab-pane', this.tabset).forEach(function (it) {
93114
it === tab || it === pane ? it.classList.add('is-active') : it.classList.remove('is-active')
94115
})
@@ -103,7 +124,7 @@ setTimeout(function () {
103124
e.preventDefault()
104125
})
105126
}
106-
}, 1000)
127+
}, 200)
107128

108129
function getPane (id, tabset) {
109130
return find('.tab-pane', tabset).find(function (it) {

0 commit comments

Comments
 (0)