style: improve code line number display and adjust top-0 to top-15 on paste header

This commit is contained in:
2026-03-27 20:21:33 -04:00
parent 4e02399d9f
commit 27093acadf
+23 -9
View File
@@ -118,7 +118,7 @@
const numbered = lines const numbered = lines
.map( .map(
(line, i) => (line, i) =>
`<div class="code-row"><span class="line-number" style="width:${digits}ch">${i + 1}</span><span class="code-line">${line}</span></div>` `<div class="code-row"><span class="line-number" style="--digits:${digits}">${i + 1}</span><span class="code-line">${line}</span></div>`
) )
.join(''); .join('');
return html.replace(code, numbered); return html.replace(code, numbered);
@@ -550,7 +550,7 @@
{#if data.paste} {#if data.paste}
<div class="mb-4 w-full text-center"> <div class="mb-4 w-full text-center">
<h1 <h1
class="mx-auto max-w-[90%] wrap-break-word min-w-0 text-3xl leading-tight font-bold sm:text-4xl" class="mx-auto max-w-[90%] min-w-0 text-3xl leading-tight font-bold wrap-break-word sm:text-4xl"
> >
{#if !editing} {#if !editing}
{data.paste.title || 'Untitled Paste'} {data.paste.title || 'Untitled Paste'}
@@ -709,7 +709,7 @@
</div> </div>
</div> </div>
<div <div
class="sticky top-0 z-10 flex flex-col items-center justify-between gap-2 rounded-t-md border-b border-neutral-700 bg-neutral-800 px-3 py-2 md:flex-row" class="sticky top-15 z-10 flex flex-col items-center justify-between gap-2 rounded-t-md border-b border-neutral-700 bg-neutral-800 px-3 py-2 md:flex-row"
> >
{#if !isBinary} {#if !isBinary}
<div class="flex items-center gap-2 text-sm text-neutral-300"> <div class="flex items-center gap-2 text-sm text-neutral-300">
@@ -968,6 +968,7 @@
<style> <style>
.hljs { .hljs {
background-color: var(--color-neutral-800) !important; background-color: var(--color-neutral-800) !important;
padding: 0 !important;
} }
.codeblock-with-lines { .codeblock-with-lines {
@@ -995,29 +996,42 @@
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
min-width: 0; min-width: 0;
padding: 0.1em 0; padding: 0;
border-radius: 0.15em;
} }
.code-row:hover { .code-row:hover {
background-color: rgba(255, 255, 255, 0.05); background-color: rgba(255, 255, 255, 0.05);
} }
.line-number { .line-number {
flex-shrink: 0; display: inline-flex;
align-self: stretch;
align-items: flex-start;
justify-content: flex-end;
flex: 0 0 calc(var(--digits, 1) * 1ch + 1.3em);
width: calc(var(--digits, 1) * 1ch + 1.3em);
box-sizing: border-box;
text-align: right; text-align: right;
color: #888; color: #888;
user-select: none; user-select: none;
margin-right: 1em; margin-right: 0;
font-family:
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
monospace;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
padding-top: 0.1em;
padding-bottom: 0.1em;
padding-right: 0.5em; padding-right: 0.5em;
padding-left: 0.25em; padding-left: 0.9em;
background: none; background: none;
border-right: 1px solid var(--color-neutral-700);
} }
.code-line { .code-line {
display: block; display: block;
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-word; word-break: break-word;
overflow-wrap: anywhere; overflow-wrap: anywhere;
padding-left: 0.25em; padding-top: 0.1em;
padding-bottom: 0.1em;
padding-left: 0.9em;
min-width: 0; min-width: 0;
} }