feat: display maps list as a grid now (#2590)

![image](https://github.com/user-attachments/assets/db9eafd1-b4ea-48a1-a359-3e55d0011f4b)
This commit is contained in:
Yohan Boniface 2025-03-28 16:15:51 +01:00 committed by GitHub
commit ae8cbf39ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 67 additions and 41 deletions

View file

@ -84,6 +84,11 @@ hgroup {
hgroup > :not(:first-child):last-child { hgroup > :not(:first-child):last-child {
font-weight: normal; font-weight: normal;
} }
hgroup p,
hgroup button {
margin: 0;
}
/* /*
* List * List
@ -158,10 +163,23 @@ dt {
} }
.grid-container { .grid-container {
display: grid; display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr)); --grid-layout-gap: calc(var(--gutter) * 2);
--grid-column-count: 3;
--grid-item--min-width: 300px;
/**
* Calculated values.
*/
--gap-count: calc(var(--grid-column-count) - 1);
--total-gap-width: calc(var(--gap-count) * var(--grid-layout-gap));
--grid-item--max-width: calc((100% - var(--total-gap-width)) / var(--grid-column-count));
grid-template-columns: repeat(auto-fill, minmax(max(var(--grid-item--min-width), var(--grid-item--max-width)), 1fr));
grid-gap: var(--grid-layout-gap);
} }
.grid-container.by4 { .grid-container.by4 {
grid-template-columns: repeat(4, minmax(0, 1fr)); --grid-column-count: 4;
--grid-item--min-width: 60px;
} }
.grid-container > * { .grid-container > * {
text-align: center; text-align: center;

View file

@ -56,9 +56,9 @@ body.login header {
.map_fragment { .map_fragment {
width: 100%; width: 100%;
} }
.map_list .map_fragment, .map_fragment,
.demo_map .map_fragment { .demo_map .map_fragment {
height: 210px; height: var(--map-fragment-height);
} }
.map_list .legend { .map_list .legend {
padding-top: 7px; padding-top: 7px;
@ -164,6 +164,9 @@ h2.tabs a:hover {
color: #efefef; color: #efefef;
text-decoration: underline; text-decoration: underline;
} }
.more_button {
min-height: var(--map-fragment-height);
}
/* **************************** */ /* **************************** */

View file

@ -660,10 +660,6 @@ a.umap-control-caption,
.umap-caption .header i.icon { .umap-caption .header i.icon {
flex-shrink: 0; flex-shrink: 0;
} }
.umap-caption hgroup p,
.umap-caption hgroup button {
margin: 0;
}
.umap-browser .main-toolbox { .umap-browser .main-toolbox {
padding-left: 4px; /* Align with toolbox below */ padding-left: 4px; /* Align with toolbox below */
border-top: 1px solid var(--color-mediumGray); border-top: 1px solid var(--color-mediumGray);

View file

@ -45,6 +45,7 @@
--box-margin: 14px; --box-margin: 14px;
--text-margin: 7px; --text-margin: 7px;
--dialog-width: 40vw; --dialog-width: 40vw;
--map-fragment-height: 210px;
/* z-indexes (leaflet CSS sets the map at 400 by default) */ /* z-indexes (leaflet CSS sets the map at 400 by default) */
--zindex-alert: 500; --zindex-alert: 500;

View file

@ -13,7 +13,7 @@
</h2> </h2>
</div> </div>
<div class="wrapper"> <div class="wrapper">
<div class="map_list row"> <div class="row grid-container">
{% if maps %} {% if maps %}
{% include "umap/map_list.html" %} {% include "umap/map_list.html" %}
{% else %} {% else %}

View file

@ -13,7 +13,7 @@
</h2> </h2>
</div> </div>
<div class="wrapper"> <div class="wrapper">
<div class="map_list row"> <div class="grid-container row">
{% if maps %} {% if maps %}
{% include "umap/map_list.html" %} {% include "umap/map_list.html" %}
{% else %} {% else %}

View file

@ -43,22 +43,27 @@
<script type="text/javascript"> <script type="text/javascript">
window.addEventListener('DOMContentLoaded', event => { window.addEventListener('DOMContentLoaded', event => {
const server = new U.ServerRequest() const server = new U.ServerRequest()
const getMore = async function (e) { const getMore = async function (link) {
L.DomEvent.stop(e) const container = link.parentNode
const [{html}, response, error] = await server.get(this.href) container.removeChild(link)
const [{html}, response, error] = await server.get(link.href)
if (!error) { if (!error) {
const container = this.parentNode const template = document.createElement('template')
container.innerHTML = html template.innerHTML = html
const more = document.querySelector('.more_button') container.appendChild(template.content)
if (more) { listenForMore()
L.DomEvent.on(more, 'click', getMore, more)
}
} }
} }
const more = document.querySelector('.more_button') const listenForMore = () => {
if (more) { const more = document.querySelector('.more_button')
L.DomEvent.on(more, 'click', getMore, more) if (more) {
L.DomEvent.on(more, 'click', (e) => {
L.DomEvent.stop(e)
getMore(more)
})
}
} }
listenForMore()
}) })
</script> </script>
{% endblock bottom_js %} {% endblock bottom_js %}

View file

@ -20,11 +20,13 @@
{% endif %} {% endif %}
<div class="wrapper"> <div class="wrapper">
{% if maps %} {% if maps %}
<h2 class="section"> <div class="row">
{% blocktrans %}Get inspired, browse maps{% endblocktrans %} <h2 class="section">
</h2> {% blocktrans %}Get inspired, browse maps{% endblocktrans %}
<div class="map_list row"> </h2>
{% include "umap/map_list.html" %} <div class="grid-container">
{% include "umap/map_list.html" %}
</div>
</div> </div>
{% endif %} {% endif %}
</div> </div>

View file

@ -1,22 +1,19 @@
{% load umap_tags i18n %} {% load umap_tags i18n %}
{% for map_inst in maps %} {% for map_inst in maps %}
<hr /> <div>
<div class="col wide">
{% map_fragment map_inst prefix=prefix page=request.GET.p %} {% map_fragment map_inst prefix=prefix page=request.GET.p %}
<div class="legend"> <hgroup>
<a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a> <h3><a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a></h3>
{% with author=map_inst.get_author %} {% with author=map_inst.get_author %}
{% if author %} {% if author %}
<em>{% trans "by" %} <a href="{{ author.get_url }}">{{ author }}</a></em> <p>{% trans "by" %} <a href="{{ author.get_url }}">{{ author }}</a></p>
{% endif %} {% endif %}
{% endwith %} {% endwith %}
</div> </hgroup>
</div> </div>
{% endfor %} {% endfor %}
{% if maps.has_next %} {% if maps.has_next %}
<div class="col wide"> <a href="?{% paginate_querystring maps.next_page_number %}"
<a href="?{% paginate_querystring maps.next_page_number %}" class="button more_button neutral">{% trans "More" %}</a>
class="button more_button neutral">{% trans "More" %}</a>
</div>
{% endif %} {% endif %}

View file

@ -12,7 +12,7 @@
{% block maincontent %} {% block maincontent %}
{% include "umap/search_bar.html" %} {% include "umap/search_bar.html" %}
<div class="wrapper"> <div class="wrapper">
<div class="map_list row"> <div class="row">
{% if request.GET.q %} {% if request.GET.q %}
{% if maps %} {% if maps %}
<h2> <h2>
@ -22,7 +22,9 @@
{{ count }} maps found: {{ count }} maps found:
{% endblocktranslate %} {% endblocktranslate %}
</h2> </h2>
{% include "umap/map_list.html" with prefix="search_map" %} <div class="grid-container">
{% include "umap/map_list.html" with prefix="search_map" %}
</div>
{% else %} {% else %}
<h2> <h2>
{% trans "No map found." %} {% trans "No map found." %}
@ -32,7 +34,9 @@
<h2> <h2>
{% trans "Latest created maps" %} {% trans "Latest created maps" %}
</h2> </h2>
{% include "umap/map_list.html" with prefix="search_map" %} <div class="grid-container">
{% include "umap/map_list.html" with prefix="search_map" %}
</div>
{% endif %} {% endif %}
</div> </div>
</div> </div>

View file

@ -18,7 +18,7 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="map_list row"> <div class="grid-container row">
{% if maps %} {% if maps %}
{% include "umap/map_list.html" %} {% include "umap/map_list.html" %}
{% else %} {% else %}