8356
Wx
www-xonecas-io / files
www-xonecas-io / internal / site / templates / components.html
8.7 KB
1{{/* Components. Each takes its view type from view.go. */}} 2 3{{define "nav"}}{{/* dict "Here" section "Q" search "Filter" true on /projects, where the search filters the list */}} 4<header class="border-b-[1.5px] border-edge"><div class="flex flex-wrap items-center gap-x-6 gap-y-2 px-4 sm:px-8 py-3 max-w-[1440px] mx-auto"> 5 <a href="/" id="face" class="group relative flex items-center gap-2 font-bold text-xl"><img src="{{asset "/logo.svg"}}" alt="" width="32" height="32" class="rounded-[2px]">xonecas.io 6 <span id="quip" role="tooltip" class="pointer-events-none absolute left-0 top-full mt-2 z-10 hidden group-hover:block group-focus-visible:block w-max max-w-[18rem] rounded-[2px] bg-ink text-paper px-2 py-1 text-xs font-normal">Don't click!</span></a> 7 <nav class="flex gap-5 font-semibold"> 8 {{range $l := list "Overview" "Projects" "Activity"}}<a href="{{if eq $l "Overview"}}/{{else}}/{{lower $l}}/{{end}}" class="{{if eq $l $.Here}}underline underline-offset-[6px] decoration-[3px]{{else}}no-underline{{end}}">{{$l}}</a>{{end}} 9 </nav> 10 <button id="theme" type="button" title="Light or dark" aria-label="Switch between light and dark" class="ml-auto p-1 cursor-pointer hover:text-accent"><svg viewBox="0 0 16 16" width="20" height="20" aria-hidden="true"><circle cx="8" cy="8" r="6.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M8 1.5a6.5 6.5 0 0 1 0 13z" fill="currentColor"/></svg></button> 11 <form action="/projects/" class="search relative w-full sm:w-auto"><input id="q" name="q" {{with .Q}}value="{{.}}"{{end}} autocomplete="off" aria-label="Search projects" placeholder="Search projects" 12 {{if .Filter}}form="filters"{{else}}hx-get="/suggest" hx-trigger="input changed delay:150ms" hx-target="#suggest"{{end}} class="w-full sm:w-80 px-3 py-1.5 border-[1.5px] border-edge rounded-[2px] bg-card text-sm placeholder:text-soft"> 13 <div id="suggest" aria-label="Suggestions"></div></form> 14</div></header> 15{{end}} 16 17{{define "element"}}{{/* dict "El" Element "Size" xs|sm|lg */}} 18{{with .El}}<div class="bg-{{.Group}} text-tile-ink rounded-[2px] flex flex-col shrink-0 overflow-hidden {{if .Post}}outline-[2.5px] -outline-offset-[2.5px] outline-tile-ink{{end}} 19 {{if eq $.Size "xs"}}size-[30px] items-center justify-center{{else if eq $.Size "sm"}}size-12 px-1 py-0.5{{else}}size-[124px] px-2 py-1.5{{end}}" title="{{.Name}}"> 20 {{if ne $.Size "xs"}}<div class="flex justify-between {{if eq $.Size "lg"}}text-[13px]{{else}}text-[10px]{{end}}"><span>{{.Num}}</span><span>{{.Weight}}</span></div>{{end}} 21 <div class="font-bold leading-none {{if eq $.Size "xs"}}text-[15px]{{else if eq $.Size "sm"}}text-[19px]{{else}}text-[58px] mt-1{{end}}">{{.Sym}}</div> 22 {{if eq $.Size "lg"}}<div class="mt-auto text-[13px] truncate">{{.Name}}</div>{{end}} 23</div>{{end}} 24{{end}} 25 26{{define "tag"}}{{/* one of frontend, backend, small, big, pre-AI, post-AI */}} 27<span class="inline-flex items-center gap-1.5 border-[1.5px] border-edge rounded-[2px] px-2 py-px text-[13px] font-semibold whitespace-nowrap"> 28 <i class="inline-block rounded-[1px] {{if eq . "frontend"}}size-2.5 bg-fe outline outline-tile-ink{{else if eq . "backend"}}size-2.5 bg-be outline outline-tile-ink{{else if eq . "small"}}size-1.5 bg-ink{{else if eq . "big"}}size-3 bg-ink{{else if eq . "pre-AI"}}size-2.5 bg-none{{else}}size-2.5 bg-none outline-[2.5px] -outline-offset-[2.5px] outline-tile-ink{{end}}"></i>{{.}} 29</span> 30{{end}} 31 32{{define "topic"}}{{/* a specific tag, from the project's dependencies and docs: a tag without the marker */}} 33<span class="inline-flex items-center border-[1.5px] border-edge rounded-[2px] px-2 py-px text-[13px] whitespace-nowrap">{{.}}</span> 34{{end}} 35 36{{define "project-row"}} 37<div class="@container"><a href="/projects/{{.El.Name}}/" class="grid grid-cols-[48px_1fr] @3xl:grid-cols-[48px_minmax(0,2fr)_6rem_minmax(0,2fr)_4rem_minmax(0,1.6fr)] gap-x-4 gap-y-1 items-center py-2 border-b border-line no-underline"> 38 {{template "element" (dict "El" .El "Size" "sm")}} 39 <div class="min-w-0"><b class="block truncate">{{.El.Name}}</b><div class="text-sm text-soft truncate">{{or .Desc "No description"}}</div></div> 40 <span class="hidden @3xl:block text-sm text-soft">{{.Lang}}</span> 41 <div class="col-start-2 @3xl:col-start-auto relative h-3.5 bg-empty rounded-[2px]"><div class="absolute inset-y-0 min-w-1.5 rounded-[2px] bg-h{{.Heat}}" style="left:{{.From}}%;width:{{.Width}}%"></div></div> 42 <b class="hidden @3xl:block text-right">{{.El.Weight}}</b> 43 <div class="col-start-2 @3xl:col-start-auto flex flex-wrap gap-1">{{range .Tags}}{{template "tag" .}}{{end}} 44 {{range $i, $t := .Topics}}{{if lt $i 4}}{{template "topic" $t}}{{end}}{{end}}{{if gt (len .Topics) 4}}<span class="px-1 py-px text-[13px] text-soft">+{{len (slice .Topics 4)}}</span>{{end}}</div> 45</a></div> 46{{end}} 47 48{{define "file-tree"}}{{/* dict "Head" Commit "Entries" []TreeEntry */}} 49<div class="@container"><div class="border-[1.5px] border-edge rounded-[2px] bg-card text-[14.5px]"> 50 {{with .Head}}<div class="flex flex-wrap gap-x-3 px-4 py-2 bg-empty text-sm"><b>{{.Author}}</b><span class="min-w-0 flex-1 truncate">{{.Msg}}</span>{{if .Href}}<a href="{{.Href}}" class="font-mono text-accent no-underline hover:underline">{{.Hash}}</a>{{else}}<code class="font-mono text-accent">{{.Hash}}</code>{{end}}<span class="text-soft">{{.Date}}</span></div>{{end}} 51 {{range .Entries}}<div class="grid grid-cols-[1.25rem_minmax(0,1fr)_auto] @xl:grid-cols-[1.25rem_14rem_minmax(0,1fr)_6rem] gap-x-3 px-4 py-1.5 border-t border-line"> 52 <span class="text-accent">{{if .Dir}}▸{{else}}·{{end}}</span> 53 <a {{with .Href}}href="{{.}}"{{end}} class="truncate no-underline hover:underline {{if .Dir}}font-bold{{end}}">{{.Name}}{{if .Dir}}/{{end}}</a> 54 <span class="hidden @xl:block truncate text-soft">{{.Msg}}</span> 55 <span class="text-right text-sm text-soft">{{.Date}}</span> 56 </div>{{end}} 57</div></div> 58{{end}} 59 60{{define "code"}}{{/* dict "Name" file "Code" text */}} 61<figure class="m-0"> 62 {{with .Name}}<figcaption class="font-mono text-xs text-soft mb-1">{{.}}</figcaption>{{end}} 63 <pre class="bg-pre text-pre-fg rounded-[2px] px-4 py-3 overflow-x-auto [scrollbar-width:thin] [scrollbar-color:var(--color-soft)_transparent] font-mono text-[12.5px] leading-relaxed"><code>{{.Code}}</code></pre> 64</figure> 65{{end}} 66 67{{define "diff"}} 68<div class="border-[1.5px] border-edge rounded-[2px] bg-card overflow-hidden"> 69 <div class="flex gap-3 px-4 py-2 border-b-[1.5px] border-edge text-sm"><b class="font-mono min-w-0 truncate">{{.Path}}</b><span class="ml-auto text-h4 font-semibold">+{{.Adds}}</span><span class="text-accent font-semibold">−{{.Dels}}</span></div> 70 <div class="overflow-x-auto [scrollbar-width:thin] [scrollbar-color:var(--color-soft)_transparent] font-mono text-[12.5px] leading-relaxed"> 71 {{range .Lines}}{{if eq .Op "@"}}<div class="px-4 py-1 bg-empty text-soft whitespace-pre">{{.Text}}</div>{{else}}<div class="dl{{if eq .Op "+"}} add{{else if eq .Op "-"}} del{{end}}"><i>{{if .Old}}{{.Old}}{{end}}</i><i>{{if .New}}{{.New}}{{end}}</i><b>{{.Op}}</b><span>{{.Text}}</span></div>{{end}}{{end}} 72 {{with .Note}}<div class="px-4 py-2 font-sans text-sm text-soft italic">{{.}}</div>{{end}} 73 </div> 74</div> 75{{end}} 76 77{{define "commit-row"}} 78<div class="@container"><div class="grid grid-cols-[30px_minmax(0,1fr)_auto] @xl:grid-cols-[30px_12rem_5rem_minmax(0,1fr)_6rem] gap-x-3 gap-y-0.5 items-center py-1.5 border-b border-line text-[14.5px]"> 79 {{template "element" (dict "El" .El "Size" "xs")}} 80 <b class="truncate">{{.El.Name}}</b> 81 {{if .Href}}<a href="{{.Href}}" class="font-mono text-[12.5px] text-accent no-underline hover:underline">{{.Hash}}</a>{{else}}<code class="font-mono text-[12.5px] text-accent">{{.Hash}}</code>{{end}} 82 <span class="col-start-2 col-span-2 @xl:col-auto truncate">{{.Msg}}</span> 83 <span class="hidden @xl:block text-right text-sm text-soft">{{.Date}}</span> 84</div></div> 85{{end}} 86 87{{define "project-head"}}{{/* dict "Row" ProjectRow "Here" string: the subpage, after the project name */}} 88<header class="flex items-center gap-3 mb-5 min-w-0"> 89 {{template "element" (dict "El" .Row.El "Size" "sm")}} 90 <h1 class="text-2xl font-bold min-w-0 truncate"><a href="/projects/{{.Row.El.Name}}/" class="no-underline hover:underline">{{.Row.El.Name}}</a> <span class="text-soft font-semibold">/ {{.Here}}</span></h1> 91</header> 92{{end}} 93 94{{define "suggest"}}{{/* []Suggestion, for #suggest */}}{{range .}}<a href="{{.Href}}"><b>{{.Label}}</b><span>{{.Note}}</span></a>{{end}}{{end}} 95 96{{define "pager"}}{{/* []PagerItem */}}{{with .}}<nav class="pager" aria-label="Pages">{{range .}}{{if .Href}}<a href="{{.Href}}"{{if .Here}} aria-current="page"{{end}}{{with .Label}} aria-label="{{.}}"{{end}}>{{.Text}}</a>{{else}}<span{{with .Label}} aria-label="{{.}}"{{end}}>{{.Text}}</span>{{end}}{{end}}</nav>{{end}}{{end}}