Files
njump/templates/clients.html

84 lines
3.5 KiB
HTML

<aside
class="fixed sm:sticky w-full sm:w-auto transition-all duration-500 left-0 sm:left-auto top-auto sm:top-8 bottom-0 sm:bottom-auto self-start basis-3/12 mt-4 print:hidden"
_="on click
toggle .hidden on #open
toggle .hidden on #close
toggle .overflow-hidden on <body />
toggle .hidden on <.client:not(:first-child) />"
>
<div
class="text-sm text-center mb-4 absolute top-0 right-0 sm:relative w-9 sm:w-auto h-9 sm:h-auto"
>
<span class="hidden sm:block">Open in</span>
<span id="open" class="inline sm:hidden">
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
fill="currentColor"
viewBox="0 0 20 20"
class="w-1/2 h-1/2 block m-auto mt-[28%]"
>
<path
fill="#fafafa"
fill-rule="evenodd"
d="M3.808.355h2.85a2.85 2.85 0 0 1 2.85 2.85v2.85a2.85 2.85 0 0 1-2.85 2.85h-2.85a2.85 2.85 0 0 1-2.85-2.85v-2.85a2.85 2.85 0 0 1 2.85-2.85Zm2.85 6.65a.95.95 0 0 0 .95-.95v-2.85a.95.95 0 0 0-.95-.95h-2.85a.95.95 0 0 0-.95.95v2.85c0 .525.425.95.95.95h2.85Zm0 3.8h-2.85a2.85 2.85 0 0 0-2.85 2.85v2.85a2.85 2.85 0 0 0 2.85 2.85h2.85a2.85 2.85 0 0 0 2.85-2.85v-2.85a2.85 2.85 0 0 0-2.85-2.85Zm0 6.65a.95.95 0 0 0 .95-.95v-2.85a.95.95 0 0 0-.95-.95h-2.85a.95.95 0 0 0-.95.95v2.85c0 .525.425.95.95.95h2.85Zm10.45-6.65h-2.85a2.85 2.85 0 0 0-2.85 2.85v2.85a2.85 2.85 0 0 0 2.85 2.85h2.85a2.85 2.85 0 0 0 2.85-2.85v-2.85a2.85 2.85 0 0 0-2.85-2.85Zm0 6.65a.95.95 0 0 0 .95-.95v-2.85a.95.95 0 0 0-.95-.95h-2.85a.95.95 0 0 0-.95.95v2.85c0 .525.425.95.95.95h2.85Zm0-17.1h-2.85a2.85 2.85 0 0 0-2.85 2.85v2.85a2.85 2.85 0 0 0 2.85 2.85h2.85a2.85 2.85 0 0 0 2.85-2.85v-2.85a2.85 2.85 0 0 0-2.85-2.85Zm0 6.65a.95.95 0 0 0 .95-.95v-2.85a.95.95 0 0 0-.95-.95h-2.85a.95.95 0 0 0-.95.95v2.85c0 .525.425.95.95.95h2.85Z"
clip-rule="evenodd"
/>
</svg>
</span>
<span id="close" class="hidden sm:hidden">
<svg
xmlns="http://www.w3.org/2000/svg"
width="31"
height="16"
fill="currentColor"
viewBox="0 0 31 16"
class="w-1/2 h-1/2 block m-auto mt-[28%]"
>
<path
fill="#fafafa"
d="M30.207 3.016 16.744 14.983a1.496 1.496 0 0 1-1.974 0L1.307 3.016A1.496 1.496 0 0 1 3.28.772l12.476 11.085L28.233.772a1.496 1.496 0 1 1 1.974 2.244Z"
/>
</svg>
</span>
</div>
<div
_="on load
wait 50ms
get my children
get sortByCount(it) then repeat for c in it call me.appendChild(c) end
get first in me
then tell it
remove .hidden
add .rounded-t-lg .bg-strongpink .hover:bg-crimson to <a /> in you
remove .sm:rounded-lg
"
>
{{range .Clients}}
<div
class="client | hidden sm:mb-3 sm:flex items-center"
_="on load get localStorage['nj:{{.ID}}'] or 0 then set @count to it then set @title to `used ${it} times`
on click increment localStorage['nj:{{.ID}}']"
>
<a
class="block sm:inline basis-full text-left sm:text-center text-sm text-white bg-zinc-700 no-underline px-3 py-2 sm:py-1.5 sm:rounded-lg hover:bg-gray-700"
href="{{.URL}}"
>
<span class="inline text-white hidden basis-1/5 ml-1.5">Open in</span>
{{.Name}}
</a>
</div>
{{end}}
</div>
</aside>
<script>
function sortByCount(children) {
return Array.from(children).sort(
(a, b) =>
parseInt(b.getAttribute('count')) - parseInt(a.getAttribute('count'))
)
}
</script>