Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6be1576

Browse files
Create tabs on benchmakrs page with benchmakrs for each tab
1 parent1c503a5 commit6be1576

File tree

5 files changed

+141
-5
lines changed

5 files changed

+141
-5
lines changed

‎_includes/head.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<!-- google fonts -->
88
<linkdeferasynchref="https://fonts.googleapis.com/css?family=Fira+Sans|Sen:800&display=swap"rel="stylesheet">
99
<!-- stylesheet -->
10+
<linkdeferasyncrel="stylesheet"href="{{"/assets/tabs.css" | relative_url }}">
1011
<linkdeferasyncrel="stylesheet"href="{{"/assets/style.css" | relative_url }}">
1112
<linkdeferasyncrel="stylesheet"href="{{"/assets/media.css" | relative_url }}">
1213
<linkdeferasyncrel="stylesheet"href="{{"/assets/github.css" | relative_url }}">

‎_layouts/benchmarks.html‎

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,55 @@
2222
{{ content }}
2323
</div>
2424

25+
<!-- TODO clean up this code a bit -->
26+
27+
{% assign folders = "" | split: ", " %}
2528
{% for image in site.static_files %}
26-
{% if image.path contains 'benchmarks' %}
27-
<figure>
28-
<imgsrc="{{ site.baseurl }}{{ image.path }}"alt="image"width="30%"/>
29-
<figcaption>{{ image.name }}</figcaption>
30-
</figure>
29+
{% if image.path contains 'criterion/' %}
30+
{% assign imagepath = image.path | split: "/" %}
31+
{% for subpath in imagepath %}
32+
{% if forloop.index0 == 3 %}
33+
{% assign folders = folders | append: pathName %}
34+
{% endif %}
35+
{% endfor %}
3136
{% endif %}
3237
{% endfor %}
38+
{% assign folders = folders | uniq %}
39+
40+
<!-- {% assign folders = "" | split: ", " %}
41+
{% for folder in site.static_files %}
42+
{% if folder.path contains 'criterion/' %}
43+
{% assign temp = folder.path | split: 'criterion/' %}
44+
{% assign pathName = temp[1] | split: '/' | first %}
45+
{% assign pathName = pathName | split: ", " %}
46+
{% assign folders = folders | concat: pathName %}
47+
{% endif %}
48+
{% endfor%}
49+
{% assign folders = folders | uniq %} -->
50+
51+
<!-- TODO check if the folders list is empty, if so, display corresponding message -->
52+
<!-- TODO add text that explains the violin plots -->
53+
54+
<ulclass="tab"data-tab="benchmarks">
55+
{% for folder in folders %}
56+
<li{%ifforloop.index==1%}class="active"{%endif%}>
57+
<ahref="">{{ folder }}</a>
58+
</li>
59+
{% endfor%}
60+
</ul>
61+
<ulclass="tab-content"id="benchmarks">
62+
{% for folder in folders %}
63+
<li{%ifforloop.index==1%}class="active"{%endif%}>
64+
<br>
65+
{% for image in site.static_files %}
66+
{% if image.path contains folder %}
67+
<figure>
68+
<imgsrc="{{ site.baseurl }}{{ image.path }}"alt="image"width="50%"/>
69+
<figcaption>{{ image.name }}</figcaption>
70+
</figure>
71+
{% endif %}
72+
{% endfor%}
73+
</li>
74+
{% endfor%}
75+
</ul>
3376
</div>

‎_layouts/default.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
{%- include footer.html -%}
1717

18+
<scriptsrc="{{"/assets/js/tabs.js" | relative_url }}"></script>
1819
</body>
1920

2021
</html>

‎assets/js/tabs.js‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
constremoveActiveClasses=function(ulElement){
2+
constlis=ulElement.querySelectorAll('li');
3+
Array.prototype.forEach.call(lis,function(li){
4+
li.classList.remove('active');
5+
});
6+
}
7+
8+
constgetChildPosition=function(element){
9+
varparent=element.parentNode;
10+
vari=0;
11+
for(vari=0;i<parent.children.length;i++){
12+
if(parent.children[i]===element){
13+
returni;
14+
}
15+
}
16+
17+
thrownewError('No parent found');
18+
}
19+
20+
window.addEventListener('load',function(){
21+
consttabLinks=document.querySelectorAll('ul.tab li a');
22+
23+
Array.prototype.forEach.call(tabLinks,function(link){
24+
link.addEventListener('click',function(event){
25+
event.preventDefault();
26+
27+
liTab=link.parentNode;
28+
ulTab=liTab.parentNode;
29+
position=getChildPosition(liTab);
30+
if(liTab.className.includes('active')){
31+
return;
32+
}
33+
34+
removeActiveClasses(ulTab);
35+
tabContentId=ulTab.getAttribute('data-tab');
36+
tabContentElement=document.getElementById(tabContentId);
37+
removeActiveClasses(tabContentElement);
38+
39+
tabContentElement.querySelectorAll('li')[position].classList.add('active');
40+
liTab.classList.add('active');
41+
},false);
42+
});
43+
});

‎assets/tabs.css‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.tab {
2+
display: flex;
3+
flex-wrap: wrap;
4+
margin-left:-20px;
5+
padding:0;
6+
list-style: none;
7+
position: relative;
8+
}
9+
10+
.tab>* {
11+
flex: none;
12+
padding-left:20px;
13+
position: relative;
14+
}
15+
16+
.tab>*>a {
17+
display: block;
18+
text-align: center;
19+
padding:9px20px;
20+
color:#999;
21+
border-bottom:2px solid transparent;
22+
border-bottom-color: transparent;
23+
font-size:12px;
24+
text-transform: uppercase;
25+
transition: color.1s ease-in-out;
26+
line-height:20px;
27+
}
28+
29+
.tab> .active>a {
30+
color:#222;
31+
border-color:#1e87f0;
32+
}
33+
34+
.tablia {
35+
text-decoration: none;
36+
cursor: pointer;
37+
}
38+
39+
.tab-content{
40+
padding:0;
41+
}
42+
43+
.tab-contentli {
44+
display: none;
45+
}
46+
.tab-contentli.active {
47+
display: initial;
48+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp