From 6aa25d2788b9d331cc356b3dd5117f1eb6c38625 Mon Sep 17 00:00:00 2001 From: Jay George Date: Fri, 23 Oct 2026 15:29:40 +0100 Subject: [PATCH] Optically centre badge text - Badge text (the text prop, plain text in the slot, and the labels before and after the value) trims to x-height and nudges down to sit between x-height and cap height, so lowercase and Capitalised labels both look centred - Each badge size gets a minimum height, so dark mode badges match light ones and badges can still grow - Bard and Replicator set badges, relationship badges and the asset editor's last-modified pill trim their own text elements; the set group chevron loses its 1px nudge - The header Search label and the array Close button use the same trim - Collection entry counts keep the cap trim, as they only show digits - Badge docs explain adding st-text-trim-optical-cap to custom slot content --- resources/css/core/utilities.css | 7 ++++ .../js/components/assets/Editor/Editor.vue | 1 + .../js/components/collections/Listing.vue | 8 ++-- .../components/fieldtypes/ArrayFieldtype.vue | 2 +- .../js/components/fieldtypes/bard/Set.vue | 6 +-- .../RelationshipIndexFieldtype.vue | 2 +- .../components/fieldtypes/replicator/Set.vue | 6 +-- .../js/components/global-header/Search.vue | 2 +- resources/js/components/ui/Badge.vue | 22 ++++++----- resources/js/stories/docs/Badge.mdx | 10 +++++ resources/js/tests/components/Badge.test.js | 38 +++++++++++++++++++ 11 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 resources/js/tests/components/Badge.test.js diff --git a/resources/css/core/utilities.css b/resources/css/core/utilities.css index a8b175638e0..7f7ceec9d78 100644 --- a/resources/css/core/utilities.css +++ b/resources/css/core/utilities.css @@ -99,6 +99,13 @@ @utility st-text-trim-ex-alphabetic { text-box: ex alphabetic; } +@utility st-text-trim-optical-cap { + /* =Jay. Trim to x-height, then nudge the text down so it sits between x-height and cap height, a touch nearer cap height. Lowercase and Capitalised labels both look centred in small, tight boxes like badges */ + @supports (text-box: ex alphabetic) { + text-box: ex alphabetic; + padding-top: calc((1cap - 1ex) * 3 / 4); + } +} @utility placeholder-xs { /* =Jay. The default of 1em on field inputs feels a bit clumsy/big */ diff --git a/resources/js/components/assets/Editor/Editor.vue b/resources/js/components/assets/Editor/Editor.vue index c3f84734429..dc2b6c51fb9 100644 --- a/resources/js/components/assets/Editor/Editor.vue +++ b/resources/js/components/assets/Editor/Editor.vue @@ -147,6 +147,7 @@