git ssb

0+

Grey the earthling / gkn.me.uk



Commit 9e8c00eafa3d6d94f2b92037243fe07b6ba66aad

Reorder nearby links to prev, up, next

This order matches the typical reading order of
the intended visual appearance in a wide graphical display.

This makes it possible to achieve this grid layout
without targetting something other than the links' rel attributes
and without using :has() which has no browser support yet.

The linear order is less logical:
the middle item is a different category to the 2 around it.
Greg K Nicholson committed on 2/16/2018, 11:24:35 AM
Parent: 2a2b9271cfb5614e3cbf6c6b3ff2f4b127e8abe9

Files changed

themes/ran/static/style/ran.csschanged
themes/ran/templates/article.htmlchanged
themes/ran/templates/period_archives.htmlchanged
themes/ran/templates/tag.htmlchanged
themes/ran/static/style/ran.cssView
@@ -151,8 +151,15 @@
151151 display: block;
152152 margin-top: 1rem;
153153 }
154154
155 + nav.nearby li,
156 + nav.nearby ul {
157 + display: inline;
158 + margin: 0;
159 + padding: 0;
160 + }
161 +
155162 nav.nearby a {
156163 display: block;
157164 margin-top: 1rem;
158165 margin-right: 1rem;
@@ -176,16 +183,15 @@
176183 content: "← ";
177184 }
178185
179186 @media (min-width: 42rem) {
180- nav.nearby {
187 + nav.nearby ul {
181188 display: grid;
182189 grid-template-columns: 1fr 1fr 1fr;
183190 margin-right:0;
184191 }
185192
186193 nav.nearby a {
187- grid-row: 1/2;
188194 margin-top: 0;
189195 margin-right: 0;
190196 text-align: center;
191197 }
@@ -194,19 +200,16 @@
194200 width: 100%;
195201 }
196202
197203 nav.nearby a[rel="up"] {
198- grid-column: 2/3;
199204 text-align: center;
200205 }
201206
202207 nav.nearby a[rel="next"] {
203- grid-column: 3/4;
204208 text-align: right;
205209 }
206210
207211 nav.nearby a[rel="prev"] {
208- grid-column: 1/2;
209212 text-align: left;
210213 }
211214 }
212215
themes/ran/templates/article.htmlView
@@ -149,8 +149,16 @@
149149 </ul>
150150 {%- endif -%}
151151 <nav class="nearby">
152152 <ul>
153 + {%- if article.prev_article -%}
154 + <li>
155 + <a href="/{{- article.prev_article.url -}}" rel="prev">
156 + <span></span>
157 + {{- article.prev_article.title | trim -}}
158 + </a>
159 + </li>
160 + {%- endif -%}
153161 <li>
154162 <a href="/{{- article.date | strftime('%Y/%m/%d') -}}" rel="up">
155163 <span></span>
156164 {{- article.date | strftime(DATE_FORMAT_DAY) -}}
@@ -163,16 +171,8 @@
163171 {{- article.next_article.title | trim -}}
164172 </a>
165173 </li>
166174 {%- endif -%}
167- {%- if article.prev_article -%}
168- <li>
169- <a href="/{{- article.prev_article.url -}}" rel="prev">
170- <span></span>
171- {{- article.prev_article.title | trim -}}
172- </a>
173- </li>
174- {%- endif -%}
175175 </ul>
176176 </nav>
177177 {{- super() -}}
178178 {%- endblock -%}
themes/ran/templates/period_archives.htmlView
@@ -57,8 +57,52 @@
5757 {%- endblock -%}
5858 {%- block maincontent -%}
5959 <nav class="nearby">
6060 <ul>
61 + {%- for article in articles |
62 + selectattr("date", "lessthan",
63 + dates[ dates | length - 1].date) -%}
64 + {%- if loop.index == 1 -%}
65 + {%- if period | length == 1 -%}
66 + <li>
67 + <a href="/{{- article.date | strftime('%Y') -}}"
68 + rel="prev">
69 + <span></span>
70 + <time datetime="{{- article.date |
71 + strftime('%Y') -}}">
72 + {{- article.date |
73 + strftime(DATE_FORMAT_YEAR) -}}
74 + </time>
75 + </a>
76 + </li>
77 + {%- elif period | length == 2 -%}
78 + <li>
79 + <a href="/{{- article.date | strftime('%Y/%m') -}}"
80 + rel="prev">
81 + <span></span>
82 + <time datetime="{{- article.date |
83 + strftime('%Y-%m') -}}">
84 + {{- article.date |
85 + strftime(DATE_FORMAT_MONTH) -}}
86 + </time>
87 + </a>
88 + </li>
89 + {%- else -%}
90 + <li>
91 + <a href="/{{- article.date |
92 + strftime('%Y/%m/%d') -}}"
93 + rel="prev">
94 + <span></span>
95 + <time datetime="{{- article.date |
96 + strftime('%Y-%m-%d') -}}">
97 + {{- article.date |
98 + strftime(DATE_FORMAT_DAY) -}}
99 + </time>
100 + </a>
101 + </li>
102 + {%- endif -%}
103 + {%- endif -%}
104 + {%- endfor -%}
61105 {%- if period | length == 1 -%}
62106 <li>
63107 <a href="/entries" rel="up">
64108 <span></span>
@@ -129,52 +173,8 @@
129173 </li>
130174 {%- endif -%}
131175 {%- endif -%}
132176 {%- endfor -%}
133- {%- for article in articles |
134- selectattr("date", "lessthan",
135- dates[ dates | length - 1].date) -%}
136- {%- if loop.index == 1 -%}
137- {%- if period | length == 1 -%}
138- <li>
139- <a href="/{{- article.date | strftime('%Y') -}}"
140- rel="prev">
141- <span></span>
142- <time datetime="{{- article.date |
143- strftime('%Y') -}}">
144- {{- article.date |
145- strftime(DATE_FORMAT_YEAR) -}}
146- </time>
147- </a>
148- </li>
149- {%- elif period | length == 2 -%}
150- <li>
151- <a href="/{{- article.date | strftime('%Y/%m') -}}"
152- rel="prev">
153- <span></span>
154- <time datetime="{{- article.date |
155- strftime('%Y-%m') -}}">
156- {{- article.date |
157- strftime(DATE_FORMAT_MONTH) -}}
158- </time>
159- </a>
160- </li>
161- {%- else -%}
162- <li>
163- <a href="/{{- article.date |
164- strftime('%Y/%m/%d') -}}"
165- rel="prev">
166- <span></span>
167- <time datetime="{{- article.date |
168- strftime('%Y-%m-%d') -}}">
169- {{- article.date |
170- strftime(DATE_FORMAT_DAY) -}}
171- </time>
172- </a>
173- </li>
174- {%- endif -%}
175- {%- endif -%}
176- {%- endfor -%}
177177 </ul>
178178 </nav>
179179 {{- super() -}}
180180 {%- endblock -%}
themes/ran/templates/tag.htmlView
@@ -9,8 +9,20 @@
99 {% endblock %}
1010 {% block maincontent %}
1111 <nav class="nearby">
1212 <ul>
13 + {%- for othertag, otherarticles in tags | sort | reverse if
14 + othertag.slug < tag.slug and
15 + otherarticles | list | length > 1 -%}
16 + {%- if loop.index == 1 -%}
17 + <li>
18 + <a href="/entries/{{- othertag.slug -}}" rel="prev">
19 + <span></span>
20 + {{- othertag -}}
21 + </a>
22 + </li>
23 + {%- endif -%}
24 + {%- endfor -%}
1325 <li>
1426 <a href="/entries" rel="up">
1527 <span></span>
1628 {{- ARCHIVES_TITLE -}}
@@ -27,20 +39,8 @@
2739 </a>
2840 </li>
2941 {%- endif -%}
3042 {%- endfor -%}
31- {%- for othertag, otherarticles in tags | sort | reverse if
32- othertag.slug < tag.slug and
33- otherarticles | list | length > 1 -%}
34- {%- if loop.index == 1 -%}
35- <li>
36- <a href="/entries/{{- othertag.slug -}}" rel="prev">
37- <span></span>
38- {{- othertag -}}
39- </a>
40- </li>
41- {%- endif -%}
42- {%- endfor -%}
4343 </ul>
4444 </nav>
4545 {{- super() -}}
4646 {% endblock %}

Built with git-ssb-web