Skip to content

Commit e9ed1ea

Browse files
julioestalandefreitas
authored andcommitted
docs(ui): tighter spacing in reference titles
Positive tracking keeps the outlines of neighbouring letters apart, and a small script wraps each "::" so the two colons sit together instead of reading as ": :".
1 parent eff13e8 commit e9ed1ea

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎docs/ui/src/css/doc.css‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ html {
189189
font-family: var(--monospace-font-family);
190190
font-weight: 700;
191191
font-style: italic;
192-
letter-spacing: -0.02em;
192+
/* Positive tracking so the 6px outlines of neighbouring letters don't run
193+
into each other. */
194+
letter-spacing: 0.02em;
193195
font-size: clamp(1.6rem, 1rem + 2.8vw, 3rem);
194196
line-height: 1.1;
195197
overflow-wrap: anywhere;
@@ -206,6 +208,14 @@ html {
206208
display: inline-block;
207209
}
208210

211+
/* "::" wrapped by 11-reference-title.js. Monospace colons sit in full-width
212+
cells; the negative tracking closes the gap between the two, and the margin
213+
gives back the space after the pair. */
214+
.mrdocs-reference .doc > h1.page .scope-sep {
215+
letter-spacing: -0.35em;
216+
margin-right: 0.3em;
217+
}
218+
209219
.doc > h2#name + .sectionbody {
210220
margin-top: 1rem;
211221
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
;(function () {
2+
'use strict'
3+
4+
// Menlo centres each colon in a full-width cell, so "::" in a reference
5+
// title reads as ": :". Wrap each "::" so doc.css can pull the pair together.
6+
var title = document.querySelector('.mrdocs-reference .doc > h1.page')
7+
if (!title) return
8+
var walker = document.createTreeWalker(title, window.NodeFilter.SHOW_TEXT)
9+
var nodes = []
10+
while (walker.nextNode()) nodes.push(walker.currentNode)
11+
nodes.forEach(function (node) {
12+
if (node.data.indexOf('::') < 0) return
13+
var fragment = document.createDocumentFragment()
14+
node.data.split(/(::)/).forEach(function (part) {
15+
if (!part) return
16+
if (part !== '::') return fragment.appendChild(document.createTextNode(part))
17+
var sep = document.createElement('span')
18+
sep.className = 'scope-sep'
19+
sep.textContent = part
20+
fragment.appendChild(sep)
21+
})
22+
node.parentNode.replaceChild(fragment, node)
23+
})
24+
})()

0 commit comments

Comments
 (0)