Skip to content

Commit c759c40

Browse files
committed
add ability to toggle layout
1 parent 2c65e64 commit c759c40

File tree

4 files changed

+107
-29
lines changed

4 files changed

+107
-29
lines changed

index.html

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,47 @@
1515
<section class='main-content'>
1616
<div class='tierlist'>
1717
</div>
18-
<div class='bottom-container'>
19-
<div class='buttons-container'>
20-
<div class='button'>
21-
<label for='load-img-input'>
22-
<img src='plus.png' title='Add images'/>
23-
</label>
24-
<input id='load-img-input' type='file' accept='image/*' multiple/>
25-
</div>
26-
<div class='button'>
27-
<label for='reset-list-input'>
28-
<img src='reset.png' title='Reset list'>
29-
</label>
30-
<input id='reset-list-input' type='button' />
31-
</div>
32-
<div class='button'>
33-
<label for='export-input'>
34-
<img src='export.png' title='Export'>
35-
</label>
36-
<input id='export-input' type='button' />
37-
</div>
38-
<div class='button'>
39-
<label for='import-input'>
40-
<img src='import.png' title='Import'/>
41-
</label>
42-
<input id='import-input' type='file' accept='.json' multiple/>
18+
<div class='toggleable-container'>
19+
<div class='bottom-container'>
20+
<div class='buttons-container'>
21+
<div class='button'>
22+
<label for='load-img-input'>
23+
<img src='plus.png' title='Add images'/>
24+
</label>
25+
<input id='load-img-input' type='file' accept='image/*' multiple/>
26+
</div>
27+
<div class='button'>
28+
<label for='reset-list-input'>
29+
<img src='reset.png' title='Reset list'>
30+
</label>
31+
<input id='reset-list-input' type='button' />
32+
</div>
33+
<div class='button'>
34+
<label for='export-input'>
35+
<img src='export.png' title='Export'>
36+
</label>
37+
<input id='export-input' type='button' />
38+
</div>
39+
<div class='button'>
40+
<label for='import-input'>
41+
<img src='import.png' title='Import'/>
42+
</label>
43+
<input id='import-input' type='file' accept='.json' multiple/>
44+
</div>
4345
</div>
46+
<section class='images'></section>
4447
</div>
45-
<section class='images'></section>
48+
<p class='hint'>Hint: you can paste an image into this page to have it show up in the image list.</p>
4649
</div>
47-
<p class='hint'>Hint: you can paste an image into this page to have it show up in the image list.</p>
4850
</section>
49-
<img id='trash' src='trash_bin.png' title='Delete image (drag it over here)'></img>
51+
<div class="top-container">
52+
<img id='trash' src='trash_bin.png' title='Delete image (drag it over here)'></img>
53+
<div class='button'>
54+
<label for='toggle-layout'>
55+
<img src='toggle_layout.png' title='Toggle Layout'/>
56+
</label>
57+
<input id='toggle-layout' type='button'/>
58+
</div>
59+
</div>
5060
</body>
5161
</html>

tiers.css

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ body {
3434
flex-flow: column;
3535
}
3636

37+
.main-content.vertical {
38+
flex-flow: row !important;
39+
}
40+
41+
.vertical .tierlist {
42+
width: 80%;
43+
}
44+
45+
.toggleable-container {
46+
display: flex;
47+
flex-flow: column;
48+
flex-grow: 1;
49+
}
50+
3751
.tierlist span {
3852
min-width: 100px;
3953
min-height: 100px;
@@ -134,6 +148,13 @@ img.draggable.dragged, .button:active {
134148
flex-flow: row;
135149
align-items: center;
136150
margin-top: 15px;
151+
flex-grow: 1;
152+
}
153+
154+
.vertical .bottom-container {
155+
flex-flow: column !important;
156+
margin-left: 15px;
157+
margin-top: 0px !important;
137158
}
138159

139160
.bottom-container input {
@@ -171,18 +192,42 @@ img.draggable.dragged, .button:active {
171192
width: 270px;
172193
}
173194

195+
.vertical .buttons-container {
196+
justify-content: center;
197+
}
198+
174199
.gh-link {
175200
position: absolute;
176201
top: 5px;
177202
color: #ccc;
178203
text-decoration: none;
179204
}
180205

181-
#trash {
206+
.top-container {
182207
position: absolute;
183208
top: 5px;
184209
right: 5px;
185210
height: 60px;
211+
display: flex;
212+
flex-flow: row;
213+
}
214+
215+
.top-container * {
216+
height: 100%;
217+
overflow: hidden;
218+
margin: 0;
219+
padding-left: 5px;
220+
padding-right: 5px;
221+
border: 0;
222+
}
223+
224+
.top-container input {
225+
border: 0;
226+
padding: 0;
227+
display: none;
228+
}
229+
230+
#trash {
186231
opacity: 0.4;
187232
}
188233

@@ -194,4 +239,5 @@ img.draggable.dragged, .button:active {
194239
font-style: italic;
195240
font-size: small;
196241
color: #ccc;
242+
padding: 0px 10px;
197243
}

tiers.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ let unique_id = 0;
3131

3232
let unsaved_changes = false;
3333

34+
const LAYOUT_HORIZONTAL = 0;
35+
const LAYOUT_VERTICAL = 1;
36+
let cur_layout = LAYOUT_HORIZONTAL;
37+
3438
// Contains [[header, input, label]]
3539
let all_headers = [];
3640
let headers_orig_min_width;
@@ -145,6 +149,7 @@ window.addEventListener('load', () => {
145149
});
146150

147151
bind_trash_events();
152+
bind_toggle_layout_events();
148153

149154
window.addEventListener('beforeunload', (evt) => {
150155
if (!unsaved_changes) return null;
@@ -458,3 +463,20 @@ function bind_trash_events() {
458463
}
459464
});
460465
}
466+
467+
function bind_toggle_layout_events() {
468+
let toggle = document.getElementById('toggle-layout');
469+
toggle.addEventListener('click', () => {
470+
set_layout((cur_layout + 1) % 2);
471+
});
472+
}
473+
474+
function set_layout(layout) {
475+
let main = document.getElementsByClassName("main-content")[0];
476+
if (layout === LAYOUT_VERTICAL) {
477+
main.classList.add("vertical");
478+
} else {
479+
main.classList.remove("vertical");
480+
}
481+
cur_layout = layout;
482+
}

toggle_layout.png

9.65 KB
Loading

0 commit comments

Comments
 (0)