5bb488ccd0
release / release (push) Has been cancelled
build / test (push) Successful in 11m1s
build / cross-compile (amd64, linux) (push) Failing after 5m43s
build / cross-compile (arm64, darwin) (push) Failing after 5m23s
build / cross-compile (arm64, linux) (push) Failing after 5m23s
72 lines
2.9 KiB
Plaintext
72 lines
2.9 KiB
Plaintext
package ui
|
|
|
|
import "fmt"
|
|
|
|
templ Result(previewID, downloadID, fullHTML, filename string, sizeBytes int, lineCount int, elapsedMs int) {
|
|
<div id="result" class="mt-6">
|
|
<section class="overflow-hidden rounded-xl border border-border bg-background shadow-xs">
|
|
<div class="flex items-center gap-3 border-b border-border px-5 py-4">
|
|
<div class="grid size-8 shrink-0 place-items-center rounded-md bg-emerald-50 text-emerald-600">
|
|
@CheckIcon("size-4")
|
|
</div>
|
|
<div class="min-w-0 flex-1">
|
|
<div class="truncate text-sm font-medium text-foreground">Готово — { filename }</div>
|
|
<div class="text-xs text-muted-foreground font-mono">
|
|
{ formatResultMeta(sizeBytes, lineCount, elapsedMs) }
|
|
</div>
|
|
</div>
|
|
<span class="inline-flex items-center rounded-md border border-border bg-muted px-2 py-0.5 text-[11px] font-medium text-foreground font-mono">
|
|
standalone
|
|
</span>
|
|
</div>
|
|
<textarea id={ "result-html-" + previewID } class="sr-only" readonly>{ fullHTML }</textarea>
|
|
<a href={ "/preview/" + previewID } target="_blank" rel="noreferrer" class="sr-only">Открыть превью</a>
|
|
<iframe class="hidden" sandbox="" referrerpolicy="no-referrer" srcdoc={ fullHTML }></iframe>
|
|
<div class="flex flex-wrap items-center gap-2 px-5 py-5">
|
|
<a
|
|
href={ "/download/" + downloadID }
|
|
class="focus-ring inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3.5 text-sm font-medium text-primary-foreground transition hover:bg-primary/90"
|
|
>
|
|
@DownloadIcon("size-4")
|
|
<span>Скачать HTML</span>
|
|
</a>
|
|
<button
|
|
type="button"
|
|
class="focus-ring inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border bg-background px-3.5 text-sm font-medium text-foreground transition hover:bg-muted"
|
|
data-copy-target={ "result-html-" + previewID }
|
|
onclick="window.mdToHTMLCopyButton(this)"
|
|
>
|
|
@CopyIcon("size-4")
|
|
<span>Скопировать</span>
|
|
</button>
|
|
<a
|
|
href={ "/preview/" + previewID }
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
class="focus-ring inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border bg-background px-3.5 text-sm font-medium text-foreground transition hover:bg-muted"
|
|
>
|
|
@ExternalLinkIcon("size-4")
|
|
<span>Открыть в новой вкладке</span>
|
|
</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
}
|
|
|
|
templ Error(msg string) {
|
|
<div id="result" class="mt-6">
|
|
<div class="rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 shadow-xs">
|
|
{ msg }
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
func formatResultMeta(sizeBytes int, lineCount int, elapsedMs int) string {
|
|
kilobytes := float64(sizeBytes) / 1024
|
|
seconds := float64(elapsedMs) / 1000
|
|
if seconds < 0.1 {
|
|
seconds = 0.1
|
|
}
|
|
return fmt.Sprintf("%.1f KB · %d строки · сгенерирован %.1f сек назад", kilobytes, lineCount, seconds)
|
|
}
|