Files
njump/templates/clients.html

84 lines
3.6 KiB
HTML

<aside
class="fixed bottom-0 left-0 top-auto mt-4 w-full basis-3/12 self-start transition-all duration-500 print:hidden sm:sticky sm:bottom-auto sm:left-auto sm:top-8 sm:w-auto"
_="on click
toggle .hidden on #open
toggle .hidden on #close
toggle .overflow-hidden on <body />
toggle .hidden on <.client:not(:first-child) />"
>
<div
class="absolute right-0 top-0 mb-4 h-10 w-10 text-center text-sm sm:relative sm:h-auto sm:w-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="m-auto mt-[28%] block h-1/2 w-1/2"
>
<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="m-auto mt-[28%] block h-1/2 w-1/2"
>
<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
"
>
{{range .Clients}}
<div
class="client | hidden items-center border-b border-zinc-800 bg-zinc-700 first-of-type:rounded-t-lg first-of-type:border-0 first-of-type:bg-strongpink hover:bg-zinc-800 sm:mb-3 sm:flex sm:rounded-lg sm:border-0 sm:first-of-type:rounded-lg"
_="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 basis-full px-3 py-3 text-left text-[17px] font-normal leading-4 text-white no-underline sm:inline sm:py-1.5 sm:py-1.5 sm:text-center sm:font-light"
href="{{.URL}}"
>
<span class="ml-1.5 inline basis-1/5 text-white sm:hidden"
>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>