Skip to content

Commit 2a0dff9

Browse files
author
SPRINX0\prochazka
committed
better UX in table
1 parent 4e014b4 commit 2a0dff9

File tree

2 files changed

+76
-40
lines changed

2 files changed

+76
-40
lines changed

layouts/_default/home.html

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,79 @@
11
<h1>Image Gallery</h1>
22

3-
<h2>Stable</h2>
4-
{{ partial "images-table.html" "img" }}
3+
{{ $stableFiles := readDir "static/img" }}
4+
{{ $devFiles := readDir "static/img-dev" }}
5+
{{ $names := slice }}
56

6-
<h2>DEV</h2>
7-
{{ partial "images-table.html" "img-dev" }}
7+
{{ range $stableFiles }}
8+
{{ if hasSuffix .Name "-dark.png" }}
9+
{{ $names = $names | append (substr .Name 0 -9) }}
10+
{{ end }}
11+
{{ end }}
12+
13+
{{ range $devFiles }}
14+
{{ if hasSuffix .Name "-dark.png" }}
15+
{{ $baseName := substr .Name 0 -9 }}
16+
{{ if not (in $names $baseName) }}
17+
{{ $names = $names | append $baseName }}
18+
{{ end }}
19+
{{ end }}
20+
{{ end }}
21+
22+
<table width="100%">
23+
<thead>
24+
<tr>
25+
<th>Base Name</th>
26+
<th>Dark STABLE</th>
27+
<th>Dark DEV</th>
28+
<th>Light Stable</th>
29+
<th>Light DEV</th>
30+
</tr>
31+
</thead>
32+
<tbody>
33+
{{ range $name := $names }}
34+
<tr>
35+
<td>{{ $name }}</td>
36+
<td>
37+
{{ $stableDark := printf "static/img/%s-dark.png" $name }}
38+
{{ if fileExists $stableDark }}
39+
<a href="img/{{ $name }}-dark.png">
40+
<img src="img/{{ $name }}-dark.png" alt="{{ $name }} dark stable" width="200px" />
41+
</a>
42+
{{ else }}
43+
-
44+
{{ end }}
45+
</td>
46+
<td>
47+
{{ $devDark := printf "static/img-dev/%s-dark.png" $name }}
48+
{{ if fileExists $devDark }}
49+
<a href="img-dev/{{ $name }}-dark.png">
50+
<img src="img-dev/{{ $name }}-dark.png" alt="{{ $name }} dark dev" width="200px" />
51+
</a>
52+
{{ else }}
53+
-
54+
{{ end }}
55+
</td>
56+
<td>
57+
{{ $stableLight := printf "static/img/%s-light.png" $name }}
58+
{{ if fileExists $stableLight }}
59+
<a href="img/{{ $name }}-light.png">
60+
<img src="img/{{ $name }}-light.png" alt="{{ $name }} light stable" width="200px" />
61+
</a>
62+
{{ else }}
63+
-
64+
{{ end }}
65+
</td>
66+
<td>
67+
{{ $devLight := printf "static/img-dev/%s-light.png" $name }}
68+
{{ if fileExists $devLight }}
69+
<a href="img-dev/{{ $name }}-light.png">
70+
<img src="img-dev/{{ $name }}-light.png" alt="{{ $name }} light dev" width="200px" />
71+
</a>
72+
{{ else }}
73+
-
74+
{{ end }}
75+
</td>
76+
</tr>
77+
{{ end }}
78+
</tbody>
79+
</table>

layouts/partials/images-table.html

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)