-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.njk
61 lines (50 loc) · 2.25 KB
/
macros.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{% macro sortableTableHeader(name, id, sortDirection, sortBy) %}
{% set upArrow %}
<svg class="inline-block h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
</svg>
{%endset%}
{% set downArrow %}
<svg class="inline-block h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path>
</svg>
{%endset%}
{% set sortingOnThisParam = id === sortBy %}
{% set linkParams = "?sortBy=" + id + "&sortDirection=asc" %}
{%set ariaSort = "none"%}
{%if sortingOnThisParam and sortDirection === "asc"%}
{% set linkParams = "?sortBy=" + id + "&sortDirection=desc" %}
{%set ariaSort = "ascending"%}
{%endif%}
{%if sortingOnThisParam and sortDirection === "desc"%}
{% set linkParams = "?sortBy=" + id + "&sortDirection=asc" %}
{%set ariaSort = "descending"%}
{%endif%}
<th class="py-2 pl-2" scope="col" aria-sort="{{ariaSort}}"><a href="/{{linkParams}}"> {{name}}
<span class="text-xs ml-1 whitespace-nowrap">
{% if sortDirection === "asc" and sortingOnThisParam %}
<div class="w-full">
{{upArrow | safe}}
</div>
{% elseif sortDirection === 'desc' and sortingOnThisParam %}
<div class="w-full">
{{downArrow | safe}}
</div>
{% elseif id !== sortBy %}
<div class="w-full">
{{upArrow | safe}}
{{downArrow | safe}}
</div>
{% endif %}
</span>
</a>
</th>
{% endmacro %}
{% macro tooltip(id, mainText, tooltipText) %}
<div aria-describedby="{{ id }}" class="group relative inline-block">
<span class="border-dotted border-b">{{ mainText }}</span>
<div role="tooltip" id="{{ id }}" class="invisible group-focus:visible group-hover:visible absolute -top-8 left-2/4 -translate-x-2/4 text-center z-30 py-0.5 px-2 bg-stone-800 text-white rounded-full after:content-[' '] after:absolute after:top-full after:left-2/4 after:-ml-[4px] after:border-4 after:border-transparent after:border-t-stone-800">
{{ tooltipText }}
</div>
</div>
{% endmacro %}