Skip to content

Commit 38ac9df

Browse files
author
rakeshAlgo
committed
Desktop Tabs UI implementation with dropdown more button
1 parent 1dc01db commit 38ac9df

File tree

4 files changed

+136
-48
lines changed

4 files changed

+136
-48
lines changed

preview-src/index.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ Installation will vary based on your operation system.
6464
<li>
6565
<p><a id="tabset1_debian"></a>Debian</p>
6666
</li>
67+
<li>
68+
<p><a id="tabset1_test1"></a>Test1</p>
69+
</li>
70+
<li>
71+
<p><a id="tabset1_test2"></a>Test2</p>
72+
</li>
73+
<li>
74+
<p><a id="tabset1_test3"></a>Test3</p>
75+
</li>
76+
<li>
77+
<p><a id="tabset1_test4"></a>Test4</p>
78+
</li>
79+
<li>
80+
<p><a id="tabset1_test5"></a>Test5</p>
81+
</li>
6782
</ul>
6883
</div>
6984
<div class="content">
@@ -82,10 +97,36 @@ Installation will vary based on your operation system.
8297
<p>Content for Debian tab.</p>
8398
</div>
8499
</div>
100+
<div class="tab-pane" aria-labelledby="tabset1_test1">
101+
<div class="paragraph">
102+
<p>Content for test 1 tab.</p>
103+
</div>
104+
</div>
105+
<div class="tab-pane" aria-labelledby="tabset1_test2">
106+
<div class="paragraph">
107+
<p>Content for test 2 tab.</p>
108+
</div>
109+
</div>
110+
<div class="tab-pane" aria-labelledby="tabset1_test3">
111+
<div class="paragraph">
112+
<p>Content for test 3 tab.</p>
113+
</div>
114+
</div>
115+
<div class="tab-pane" aria-labelledby="tabset1_test4">
116+
<div class="paragraph">
117+
<p>Content for test 4 tab.</p>
118+
</div>
119+
</div>
120+
<div class="tab-pane" aria-labelledby="tabset1_test5">
121+
<div class="paragraph">
122+
<p>Content for test 5 tab.</p>
123+
</div>
124+
</div>
85125
</div>
86126
</div>
87127
++++
88128

129+
89130
== Admonition Blocks
90131

91132
Let's take a brief pause to look at some admonition blocks.

src/css/doc.css

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -807,23 +807,30 @@ code.language-console.hljs.shell {
807807

808808
.doc .tabs li {
809809
align-items: center;
810-
border: 1px solid var(--color-brand-white);
811-
border-top: 3px solid var(--color-brand-white);
810+
/* border: 1px solid var(--color-brand-white);
811+
border-top: 3px solid var(--color-brand-white); */
812812
border-bottom: 0;
813813
cursor: pointer;
814814
display: flex;
815+
justify-content: center;
815816
font-weight: var(--weight-semibold);
816817
height: 2.5rem;
817818
line-height: 1;
818819
padding: 0;
819820
position: relative;
820-
margin-right: var(--base-space);
821+
margin-right: var(--base-large-space);
821822
}
822823

823824
.doc .tabs li + li {
824825
margin-top: 0;
825826
}
826827

828+
.doc .tabs li a {
829+
font-family: "Source Sans Pro", sans-serif;
830+
color: var(--color-brand-primary);
831+
font-weight: var(--weight-semibold);
832+
}
833+
827834
.doc .tabs li:last-child {
828835
margin-right: 0;
829836
}
@@ -883,7 +890,7 @@ code.language-console.hljs.shell {
883890
/* Media css */
884891

885892
@media screen and (min-width: 840px) {
886-
.active-tab-item-row,
893+
/* .active-tab-item-row, */
887894
.tabset .dropddown-btn {
888895
display: none;
889896
}
@@ -893,7 +900,7 @@ code.language-console.hljs.shell {
893900
}
894901
}
895902

896-
@media screen and (max-width: 840px) {
903+
@media screen and (min-width: 840px) {
897904
.tabset {
898905
position: relative;
899906
margin-top: 2rem;
@@ -903,12 +910,12 @@ code.language-console.hljs.shell {
903910
width: 100%;
904911
}
905912

906-
.active-tab-item-row {
913+
/* .active-tab-item-row {
907914
display: inline-block;
908915
max-width: 60%;
909-
}
916+
} */
910917

911-
.active-tab-item-row a {
918+
/* .active-tab-item-row a {
912919
align-items: center;
913920
color: var(--color-brand-gray1);
914921
border: 1px solid var(--color-border);
@@ -918,7 +925,6 @@ code.language-console.hljs.shell {
918925
font-weight: var(--weight-bold);
919926
min-height: 2.5rem;
920927
line-height: 1;
921-
/* margin-right: 0.25rem; */
922928
padding: 0 1.5rem 5px;
923929
position: relative;
924930
text-decoration: none;
@@ -929,26 +935,33 @@ code.language-console.hljs.shell {
929935
content: "";
930936
display: block;
931937
height: 3px;
932-
/* Chrome doesn't always paint the line accurately, so add a little extra */
933938
position: absolute;
934939
bottom: -1.5px;
935940
left: 0;
936941
right: 0;
937-
}
942+
} */
938943

939944
.ulist.tabs {
940945
margin: 0;
946+
947+
width: 100%;
948+
display: flex;
949+
}
950+
951+
.other-tab-box {
941952
position: relative;
953+
margin-left: var(--base-large-space);
942954
}
943955

944956
.doc .tabs .dropddown-btn {
945957
width: 100%;
946958
height: 100%;
947959
display: flex;
948960
align-items: center;
949-
color: #333;
950-
border-bottom: 1px solid var(--color-border);
951-
padding-left: 0.5rem;
961+
color: var(--color-brand-blue-secondary);
962+
font-family: "Source Sans Pro", sans-serif;
963+
font-weight: var(--weight-normal);
964+
/* border-bottom: 1px solid var(--color-border); */
952965
}
953966

954967
.doc .tabs .dropddown-btn .fas {
@@ -962,8 +975,9 @@ code.language-console.hljs.shell {
962975
text-decoration: none;
963976
}
964977

965-
.doc .tabs ul {
966-
box-shadow: 0 3px 10px -3px #ccc;
978+
.doc .tabs ul.other-tablist {
979+
box-shadow: 0px 3px 10px #0000000F;
980+
border: 1px solid var(--color-brand-gray8);
967981
margin: 0;
968982
position: absolute;
969983
left: 0;
@@ -974,11 +988,16 @@ code.language-console.hljs.shell {
974988
background-color: var(--color-brand-white);
975989
}
976990

977-
.doc .tabs ul p {
978-
color: var(--color-brand-gray1);
991+
.doc .tabs ul.other-tablist p {
992+
width: 100%;
993+
height: 100%;
994+
font-family: "Source Sans Pro", sans-serif;
995+
display: flex;
996+
justify-content: center;
997+
align-items: center;
979998
}
980999

981-
.doc .tabset:not(.is-loading) .tabs li:not(.is-active) {
1000+
/* .doc .tabset:not(.is-loading) .tabs li:not(.is-active) {
9821001
background: var(--color-brand-white);
9831002
min-height: 2.5rem;
9841003
height: auto;
@@ -987,21 +1006,32 @@ code.language-console.hljs.shell {
9871006
9881007
.doc .tabs li.is-active {
9891008
display: none;
990-
}
1009+
} */
9911010

992-
.doc .tabs li {
1011+
.doc .tabs ul.other-tablist li {
9931012
width: 100%;
9941013
flex-wrap: wrap;
9951014
margin-right: var(--base-space);
9961015
border-top: 0;
997-
border-bottom: 1px solid var(--color-border);
1016+
/* border-bottom: 1px solid var(--color-border); */
1017+
}
1018+
1019+
1020+
.doc .tabs ul.other-tablist li.is-active p,
1021+
.doc .tabs ul.other-tablist li p:hover {
1022+
background-color: var(--color-brand-gray7);
1023+
}
1024+
1025+
.doc .tabs ul.other-tablist li.is-active::before,
1026+
.doc .tabs ul.other-tablist li:hover::before {
1027+
content: none;
9981028
}
9991029

10001030
.doc .tabset > .content {
10011031
width: 100%;
10021032
}
10031033

1004-
.doc .tabs ul.show {
1034+
.doc .tabs ul.other-tablist.show {
10051035
display: block;
10061036
}
10071037
}

src/js/05-tabset.js

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,50 @@ var hash = window.location.hash
22
// var smallBreak = 768 // Your small screen breakpoint in pixels
33
find('.doc .tabset').forEach(function (tabset) {
44
var active
5+
var queueData = []
56
var checkActiveClass
67
var tabs = tabset.querySelector('.tabs')
78
if (tabs) {
89
var first
9-
var dropdownMenu = document.querySelector('.tabs ul')
1010
find('li', tabs).forEach(function (tab, idx) {
1111
var id = (tab.querySelector('a[id]') || tab).id
12+
// console.log(tab)
1213
checkActiveClass = setTimeout(function () {
1314
var activeTabList = tab.classList.contains('is-active')
1415
if (activeTabList) {
15-
document
16-
.querySelector('.tabs')
17-
.insertAdjacentHTML(
18-
'beforebegin',
19-
'<div class="active-tab-item-row"><a href="#" id="activeTabItem"></a><div>'
20-
)
2116
document
2217
.querySelector('.tabs')
2318
.insertAdjacentHTML(
2419
'beforeend',
25-
'<a href="#" class="dropddown-btn dropdown-btn-down">More <i class="fas fa-chevron-circle-down"></i></a>'
20+
// '<div class="other-tab-box"><a href="#" class="dropddown-btn dropdown-btn-down">More... <i class="fas fa-chevron-circle-down"></i></a> <ul class="other-tablist" id="otherTabList"></ul></div>'
21+
'<div class="other-tab-box"><a href="#" class="dropddown-btn dropdown-btn-down">More... </a> <ul class="other-tablist" id="otherTabList"></ul></div>'
2622
)
27-
document.getElementById('activeTabItem').innerText = tab.innerText
2823
var dropdownBtn = document.querySelector('.dropdown-btn-down')
24+
var dropdownMenu = document.querySelector('.tabs .other-tablist')
2925
dropdownBtn.addEventListener('click', function (e) {
3026
e.preventDefault()
3127
if (dropdownMenu.style.display === 'block' || dropdownMenu.classList.contains('show')) {
3228
dropdownMenu.classList.remove('show')
3329
dropdownMenu.classList.add('hide')
34-
this.querySelector('.fas').classList.add('fa-chevron-circle-down')
35-
this.querySelector('.fas').classList.remove('fa-chevron-circle-up')
3630
} else {
3731
dropdownMenu.classList.add('show')
3832
dropdownMenu.classList.remove('hide')
39-
this.querySelector('.fas').classList.add('fa-chevron-circle-up')
40-
this.querySelector('.fas').classList.remove('fa-chevron-circle-down')
4133
}
4234
})
4335
}
4436
}, 100)
4537

38+
if(idx > 3) {
39+
queueData.push(tab)
40+
}
41+
4642
if (!id) return
4743
var pane = getPane(id, tabset)
4844
if (!idx) first = { tab: tab, pane: pane }
4945
if (!active && hash === '#' + id && (active = true)) {
5046
tab.classList.add('is-active')
5147
if (pane) pane.classList.add('is-active')
48+
5249
} else if (!idx) {
5350
tab.classList.remove('is-active')
5451
if (pane) pane.classList.remove('is-active')
@@ -59,7 +56,18 @@ find('.doc .tabset').forEach(function (tabset) {
5956
first.tab.classList.add('is-active')
6057
if (first.pane) first.pane.classList.add('is-active')
6158
}
59+
6260
}
61+
62+
setTimeout(function () {
63+
var appendMoreTabList = document.getElementById('otherTabList')
64+
65+
queueData.forEach(function (tablist) {
66+
appendMoreTabList.appendChild(tablist)
67+
})
68+
69+
}, 100)
70+
6371
tabset.classList.remove('is-loading')
6472
clearTimeout(checkActiveClass, 20000)
6573
})
@@ -69,31 +77,40 @@ function activateTab (e) {
6977
var tab = this.tab
7078
var pane = this.pane
7179
var dropdownMenu = document.querySelector('.tabs ul')
72-
var dropdownBtnIcon = document.querySelector('.dropdown-btn-down .fas')
80+
// var dropdownBtnIcon = document.querySelector('.dropdown-btn-down .fas')
7381

74-
find('.tabs li, .tab-pane', this.tabset).forEach(function (it) {
75-
it === tab || it === pane ? it.classList.add('is-active') : it.classList.remove('is-active')
76-
var activeTabList = tab.classList.contains('is-active')
77-
if (activeTabList) {
78-
document.getElementById('activeTabItem').innerText = tab.innerText
82+
var nodeTab = document.querySelector('.tabs > ul')
83+
var nodeDropdownTabNode = document.querySelector('.other-tablist')
84+
85+
if( tab.parentNode.classList[0] == 'other-tablist') {
86+
nodeDropdownTabNode.appendChild(nodeTab.lastElementChild)
87+
nodeTab.appendChild(tab)
88+
}
89+
90+
var activeTabList = tab.classList.contains('is-active')
91+
// console.log(activeTabList, 127)
92+
if (activeTabList) {
7993
dropdownMenu.classList.remove('show')
80-
dropdownBtnIcon.classList.add('fa-chevron-circle-down')
81-
dropdownBtnIcon.classList.remove('fa-chevron-circle-up')
8294
}
95+
96+
find('.tabs li, .tab-pane', this.tabset).forEach(function (it) {
97+
it === tab || it === pane ? it.classList.add('is-active') : it.classList.remove('is-active')
8398
})
8499
}
85100

86101
function find (selector, from) {
87102
return Array.prototype.slice.call((from || document).querySelectorAll(selector))
88103
}
89104
setTimeout(function () {
90-
document.querySelector(' #activeTabItem').addEventListener('click', function (e) {
105+
document.querySelector(' .dropddown-btn').addEventListener('click', function (e) {
91106
e.preventDefault()
92107
})
93-
}, 3000)
108+
109+
}, 1000)
94110

95111
function getPane (id, tabset) {
96112
return find('.tab-pane', tabset).find(function (it) {
97113
return it.getAttribute('aria-labelledby') === id
98114
})
99115
}
116+

src/js/11-page-customize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
'use strict'
33
// for label edition/statuses
44
var $labels = $('.edition').find('a')
5-
console.log($labels.length)
5+
// console.log($labels.length)
66
for (var i = 0; i < $labels.length; i++) {
7-
console.log(i, 445, $labels[i])
7+
// console.log(i, 445, $labels[i])
88
if ($labels[i].text.toLocaleLowerCase().indexOf('community') !== -1) {
99
$labels[i].parentNode.classList.add('page-edition')
1010
}

0 commit comments

Comments
 (0)