Skip to content

Commit 69a0ebb

Browse files
Multiple resource tags (#197)
* Remove title, it blocks the tooltip on hover * Add additional tags on hover This adds a tool tip pop up that contains the additional tags on hover when there are more than 3 tags for a resource. --------- Co-authored-by: Simon (Darkside) Jackson <[email protected]>
1 parent b11a624 commit 69a0ebb

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

website/content/resources.njk

+24-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,29 @@ permalink: resources/{{ (category | slugify) if category !== "all" }}/
2626
<div id="resource-gallery" class="mg-item-grid mg-grid-2">
2727
{% for resource in resources %}
2828
{% if category in resource.tags or category === "all" %}
29-
<a class="mg-no-link hide-external-icon" href="{{ resource.url }}" title="{{ resource.title }}">
29+
<a class="mg-no-link hide-external-icon" href="{{ resource.url }}">
3030
<div class="mg-resource-container mg-box-shadow"
3131
style="background-image: url('{{ resource.cover }}');">
3232
<div class="transparent-overlay"></div>
3333
<div class="mg-resource-tags">
3434
{% for tag in resource.tags %}
35-
<div>{{ tag }}</div>
35+
{% if loop.index <= 3 %}
36+
<div>{{ tag }}</div>
37+
{% endif %}
3638
{% endfor %}
39+
40+
{% if resource.tags.length > 3 %}
41+
{% set additionalTags = '' %}
42+
{% for tag in resource.tags %}
43+
{% if loop.index0 >= 3 %}
44+
{% set additionalTags = additionalTags + tag + '<br/>' %}
45+
{% endif %}
46+
{% endfor %}
47+
<div data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="bottom" data-bs-title="{{ additionalTags }}">
48+
<div>+{{ resource.tags.length - 3 }}</div>
49+
</div>
50+
{% endif %}
51+
3752
</div>
3853
<div class="mg-resource-footer">
3954
<div class="mg-resource-title">{{ resource.title }}</div>
@@ -46,3 +61,10 @@ permalink: resources/{{ (category | slugify) if category !== "all" }}/
4661
</div>
4762
</section>
4863
{% endblock %}
64+
65+
{% block scripts %}
66+
<script type="text/javascript">
67+
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
68+
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
69+
</script>
70+
{% endblock %}

0 commit comments

Comments
 (0)