Skip to content

Commit a5255c8

Browse files
barinalileo
authored andcommitted
Added ability to toggle the list view (vercel#276)
1 parent b35865f commit a5255c8

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

assets/styles.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ main {
1010
max-width: 920px;
1111
}
1212

13+
header {
14+
display: flex;
15+
justify-content: space-between;
16+
}
17+
18+
#toggle {
19+
display: none;
20+
cursor: pointer;
21+
}
22+
23+
#toggle:before {
24+
display: inline-block;
25+
content: url("data:image/svg+xml; utf8, <svg height='24px' version='1.1' viewBox='0 0 24 24' width='24px' xmlns='http://www.w3.org/2000/svg'><g fill='none' fill-rule='evenodd' stroke='none' stroke-width='1'><g transform='translate(-431.000000, -479.000000)'><g transform='translate(215.000000, 119.000000)'/><path d='M432,480 L432,486 L438,486 L438,480 L432,480 Z M440,480 L440,486 L446,486 L446,480 L440,480 Z M448,480 L448,486 L454,486 L454,480 L448,480 Z M449,481 L449,485 L453,485 L453,481 L449,481 Z M441,481 L441,485 L445,485 L445,481 L441,481 Z M433,481 L433,485 L437,485 L437,481 L433,481 Z M432,488 L432,494 L438,494 L438,488 L432,488 Z M440,488 L440,494 L446,494 L446,488 L440,488 Z M448,488 L448,494 L454,494 L454,488 L448,488 Z M449,489 L449,493 L453,493 L453,489 L449,489 Z M441,489 L441,493 L445,493 L445,489 L441,489 Z M433,489 L433,493 L437,493 L437,489 L433,489 Z M432,496 L432,502 L438,502 L438,496 L432,496 Z M440,496 L440,502 L446,502 L446,496 L440,496 Z M448,496 L448,502 L454,502 L454,496 L448,496 Z M449,497 L449,501 L453,501 L453,497 L449,497 Z M441,497 L441,501 L445,501 L445,497 L441,497 Z M433,497 L433,501 L437,501 L437,497 L433,497 Z' fill='#000000'/></g></g></svg>");
26+
}
27+
28+
#toggle.single-column:before {
29+
content: url("data:image/svg+xml; utf8, <svg height='24px' viewBox='0 0 24 24' width='24px' xmlns='http://www.w3.org/2000/svg'><g fill='none' fill-rule='evenodd' id='miu' stroke='none' stroke-width='1'><g transform='translate(-359.000000, -479.000000)'><g transform='translate(215.000000, 119.000000)'/><path d='M360.577138,485 C360.258394,485 360,485.221932 360,485.5 C360,485.776142 360.262396,486 360.577138,486 L381.422862,486 C381.741606,486 382,485.778068 382,485.5 C382,485.223858 381.737604,485 381.422862,485 L360.577138,485 L360.577138,485 Z M360.577138,490 C360.258394,490 360,490.221932 360,490.5 C360,490.776142 360.262396,491 360.577138,491 L381.422862,491 C381.741606,491 382,490.778068 382,490.5 C382,490.223858 381.737604,490 381.422862,490 L360.577138,490 L360.577138,490 Z M360.577138,495 C360.258394,495 360,495.221932 360,495.5 C360,495.776142 360.262396,496 360.577138,496 L381.422862,496 C381.741606,496 382,495.778068 382,495.5 C382,495.223858 381.737604,495 381.422862,495 L360.577138,495 L360.577138,495 Z' fill='#000000'/></g></g></svg>");
30+
}
31+
1332
a {
1433
color: #1A00F2;
1534
text-decoration: none;
@@ -47,6 +66,10 @@ ul {
4766
padding: 20px 0 0 0;
4867
}
4968

69+
ul.single-column {
70+
flex-direction: column;
71+
}
72+
5073
ul li {
5174
list-style: none;
5275
padding: 10px 0;
@@ -94,6 +117,10 @@ ul a[class='']::before {
94117
}
95118

96119
@media (min-width: 768px) {
120+
#toggle {
121+
display: inline-block;
122+
}
123+
97124
ul {
98125
display: flex;
99126
flex-wrap: wrap;
@@ -103,6 +130,10 @@ ul a[class='']::before {
103130
width: 230px;
104131
padding-right: 20px;
105132
}
133+
134+
ul.single-column li {
135+
width: auto;
136+
}
106137
}
107138

108139
@media (min-width: 992px) {

views/index.hbs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111

1212
<body>
1313
<main>
14-
<h1>
15-
<i>Index of&nbsp;</i>
14+
<header>
15+
<h1>
16+
<i>Index of&nbsp;</i>
1617

17-
{{#each paths}}
18-
<a href="/{{url}}">{{name}}</a>
19-
{{/each}}
20-
</h1>
18+
{{#each paths}}
19+
<a href="/{{url}}">{{name}}</a>
20+
{{/each}}
21+
</h1>
22+
23+
<a class="single-column" id="toggle" title="click to toggle the view"></a>
24+
</header>
2125

22-
<ul>
26+
<ul id="files">
2327
{{#each files}}
2428
<li>
2529
<a href="/{{relative}}" title="{{title}}" class="{{ext}}">{{base}}</a>
@@ -28,5 +32,14 @@
2832
{{/each}}
2933
</ul>
3034
</main>
35+
36+
<script type="text/javascript">
37+
(function() {
38+
toggle.addEventListener('click', function() {
39+
files.classList.toggle('single-column');
40+
toggle.classList.toggle('single-column');
41+
});
42+
})();
43+
</script>
3144
</body>
3245
</html>

0 commit comments

Comments
 (0)