Skip to content

Commit 4e1d3e0

Browse files
teemingcclaude
andcommitted
Centre the copy icon on the capitals by hand
It was centred on the code trimmed to its capitals with text-box, which not every browser applies, leaving it centred on the whole line instead. It's now placed from IBM Plex Mono's metrics, and each drawing is centred in its own box. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ec914c8 commit 4e1d3e0

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎src/lib/Request.svelte‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@
180180
<code><span class="method">GET</span> {endpoint}</code>
181181
{/snippet}
182182

183-
<!-- The copy icon, or a tick once it's copied -->
183+
<!-- The copy icon, or a tick once it's copied, each drawing centred in its box -->
184184
{#snippet icons()}
185-
<svg class="icon" class:gone={copied} viewBox="0 0 16 16" aria-hidden="true">
185+
<svg class="icon" class:gone={copied} viewBox="0 -0.5 16 16" aria-hidden="true">
186186
<rect x="5.5" y="5.5" width="8" height="8" rx="1.5" />
187187
<path
188188
d="M10.5 3.5v-.5a1.5 1.5 0 0 0-1.5-1.5H4A1.5 1.5 0 0 0 2.5 3v5A1.5 1.5 0 0 0 4 9.5h.5"
189189
/>
190190
</svg>
191-
<svg class="icon" class:gone={!copied} viewBox="0 0 16 16" aria-hidden="true">
191+
<svg class="icon" class:gone={!copied} viewBox="0 0.375 16 16" aria-hidden="true">
192192
<path d="m3 8.5 3.25 3.25L13 5" />
193193
</svg>
194194
{/snippet}
@@ -283,7 +283,7 @@
283283
284284
.command {
285285
display: flex;
286-
align-items: center;
286+
align-items: flex-start;
287287
gap: 0.625rem;
288288
font-size: clamp(1.5rem, 2.3vw, 2rem);
289289
line-height: 1.2;
@@ -309,12 +309,9 @@
309309
position: absolute;
310310
}
311311
312-
/* Trimmed to the height of its capitals, so the icon beside it centres on the letters rather
313-
than on a line box with room for descenders */
314312
code {
315313
color: var(--ink);
316314
font: inherit;
317-
text-box: trim-both cap alphabetic;
318315
}
319316
320317
@media (max-width: 900px) {
@@ -352,6 +349,10 @@
352349
place-items: center;
353350
width: 1.75rem;
354351
height: 1.75rem;
352+
/* Centred on the capitals by hand, from IBM Plex Mono's metrics: an ascent of 1.02em
353+
and a descent of 0.27em in a 1.2em line put the baseline 0.975em down, and its
354+
capitals, 0.698em tall, are centred 0.626em down */
355+
margin-top: calc(0.626em - 0.875rem);
355356
border-radius: 0.375rem;
356357
background: none;
357358
color: var(--ink-soft);

0 commit comments

Comments
 (0)