Skip to content

feat: display maps list as a grid now #2590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions umap/static/umap/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ hgroup {
hgroup > :not(:first-child):last-child {
font-weight: normal;
}
hgroup p,
hgroup button {
margin: 0;
}


/*
* List
Expand Down Expand Up @@ -158,10 +163,23 @@ dt {
}
.grid-container {
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-template-columns: repeat(4, minmax(0, 1fr));
--grid-column-count: 4;
--grid-item--min-width: 60px;
}
.grid-container > * {
text-align: center;
Expand Down
7 changes: 5 additions & 2 deletions umap/static/umap/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ body.login header {
.map_fragment {
width: 100%;
}
.map_list .map_fragment,
.map_fragment,
.demo_map .map_fragment {
height: 210px;
height: var(--map-fragment-height);
}
.map_list .legend {
padding-top: 7px;
Expand Down Expand Up @@ -164,6 +164,9 @@ h2.tabs a:hover {
color: #efefef;
text-decoration: underline;
}
.more_button {
min-height: var(--map-fragment-height);
}


/* **************************** */
Expand Down
4 changes: 0 additions & 4 deletions umap/static/umap/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,6 @@ a.umap-control-caption,
.umap-caption .header i.icon {
flex-shrink: 0;
}
.umap-caption hgroup p,
.umap-caption hgroup button {
margin: 0;
}
.umap-browser .main-toolbox {
padding-left: 4px; /* Align with toolbox below */
border-top: 1px solid var(--color-mediumGray);
Expand Down
1 change: 1 addition & 0 deletions umap/static/umap/vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
--box-margin: 14px;
--text-margin: 7px;
--dialog-width: 40vw;
--map-fragment-height: 210px;

/* z-indexes (leaflet CSS sets the map at 400 by default) */
--zindex-alert: 500;
Expand Down
2 changes: 1 addition & 1 deletion umap/templates/auth/user_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2 class="section">
</h2>
</div>
<div class="wrapper">
<div class="map_list row">
<div class="row grid-container">
{% if maps %}
{% include "umap/map_list.html" %}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion umap/templates/auth/user_stars.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2 class="section">
</h2>
</div>
<div class="wrapper">
<div class="map_list row">
<div class="grid-container row">
{% if maps %}
{% include "umap/map_list.html" %}
{% else %}
Expand Down
29 changes: 17 additions & 12 deletions umap/templates/umap/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,27 @@
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', event => {
const server = new U.ServerRequest()
const getMore = async function (e) {
L.DomEvent.stop(e)
const [{html}, response, error] = await server.get(this.href)
const getMore = async function (link) {
const container = link.parentNode
container.removeChild(link)
const [{html}, response, error] = await server.get(link.href)
if (!error) {
const container = this.parentNode
container.innerHTML = html
const more = document.querySelector('.more_button')
if (more) {
L.DomEvent.on(more, 'click', getMore, more)
}
const template = document.createElement('template')
template.innerHTML = html
container.appendChild(template.content)
listenForMore()
}
}
const more = document.querySelector('.more_button')
if (more) {
L.DomEvent.on(more, 'click', getMore, more)
const listenForMore = () => {
const more = document.querySelector('.more_button')
if (more) {
L.DomEvent.on(more, 'click', (e) => {
L.DomEvent.stop(e)
getMore(more)
})
}
}
listenForMore()
})
</script>
{% endblock bottom_js %}
Expand Down
12 changes: 7 additions & 5 deletions umap/templates/umap/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ <h2 class="section">
{% endif %}
<div class="wrapper">
{% if maps %}
<h2 class="section">
{% blocktrans %}Get inspired, browse maps{% endblocktrans %}
</h2>
<div class="map_list row">
{% include "umap/map_list.html" %}
<div class="row">
<h2 class="section">
{% blocktrans %}Get inspired, browse maps{% endblocktrans %}
</h2>
<div class="grid-container">
{% include "umap/map_list.html" %}
</div>
</div>
{% endif %}
</div>
Expand Down
17 changes: 7 additions & 10 deletions umap/templates/umap/map_list.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{% load umap_tags i18n %}

{% for map_inst in maps %}
<hr />
<div class="col wide">
<div>
{% map_fragment map_inst prefix=prefix page=request.GET.p %}
<div class="legend">
<a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a>
<hgroup>
<h3><a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a></h3>
{% with author=map_inst.get_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 %}
{% endwith %}
</div>
</hgroup>
</div>
{% endfor %}
{% if maps.has_next %}
<div class="col wide">
<a href="?{% paginate_querystring maps.next_page_number %}"
class="button more_button neutral">{% trans "More" %}</a>
</div>
<a href="?{% paginate_querystring maps.next_page_number %}"
class="button more_button neutral">{% trans "More" %}</a>
{% endif %}
10 changes: 7 additions & 3 deletions umap/templates/umap/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% block maincontent %}
{% include "umap/search_bar.html" %}
<div class="wrapper">
<div class="map_list row">
<div class="row">
{% if request.GET.q %}
{% if maps %}
<h2>
Expand All @@ -22,7 +22,9 @@ <h2>
{{ count }} maps found:
{% endblocktranslate %}
</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 %}
<h2>
{% trans "No map found." %}
Expand All @@ -32,7 +34,9 @@ <h2>
<h2>
{% trans "Latest created maps" %}
</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 %}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion umap/templates/umap/team_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2 class="section">
{% endif %}
</div>
</div>
<div class="map_list row">
<div class="grid-container row">
{% if maps %}
{% include "umap/map_list.html" %}
{% else %}
Expand Down
Loading