improvements on the ui

This commit is contained in:
2026-11-25 07:14:49 +01:00
parent 3afdb6d67f
commit b7c72b9e16
249 changed files with 19702 additions and 17358 deletions
+7 -1
View File
@@ -1,6 +1,6 @@
import AppKit
/// IBM Plex Mono for the page, code, tables and bookmarks, IBM Plex Sans for the banner; the system fonts when Plex is missing.
/// IBM Plex Mono for the page, code, tables, bookmark lines and the bookmark index, IBM Plex Sans for the banner; the system fonts when Plex is missing.
public enum PlakFonts {
public static func body(_ size: CGFloat) -> NSFont {
FontRegistry.registerBundledFonts()
@@ -12,6 +12,12 @@ public enum PlakFonts {
return NSFont(name: "IBMPlexMono-Regular", size: size) ?? NSFont.monospacedSystemFont(ofSize: size, weight: .regular)
}
/// IBM Plex Mono Bold (700), the boldest bundled mono weight.
public static func monoBold(_ size: CGFloat) -> NSFont {
FontRegistry.registerBundledFonts()
return NSFont(name: "IBMPlexMono-Bold", size: size) ?? NSFont.monospacedSystemFont(ofSize: size, weight: .bold)
}
/// The height of one line of this font with no paragraph style.
static func naturalLineHeight(_ font: NSFont) -> CGFloat {
ceil(font.ascender - font.descender + font.leading)
+7 -19
View File
@@ -6,16 +6,14 @@ public enum Theme {
public static let paper = NSColor(hex: 0x101720)
/// Text, also on the save error banner.
public static let ink = NSColor(hex: 0xE4E7E6)
/// Bookmark labels, the bookmark index, `image missing`.
/// The bookmark index, `image missing`.
public static let inkMuted = NSColor(hex: 0x6C7783)
/// The caret, the drop caret and the frame of the selected table cell.
/// The caret, the drop caret, the frame of the selected table cell, bookmark lines and the hovered entry of the bookmark index.
public static let accent = NSColor(hex: 0xE8913A)
/// The tint behind selected text.
public static let selection = NSColor(hex: 0xE8913A, alpha: 0.22)
/// The grid lines of a table.
public static let rule = NSColor(hex: 0x3A424C)
/// The hairline from a bookmark to its label.
public static let bookmarkRule = NSColor(hex: 0x6C7783)
/// The background of the save error banner.
public static let panel = NSColor(hex: 0x18202B)
/// The tint behind a code block.
@@ -92,16 +90,12 @@ public enum PageMetrics {
public static let bookmarkIndexInset: CGFloat = 8
/// The bookmark index shows only the last bookmarks of the page.
public static let bookmarkIndexCount = 10
/// Room between the column, a bookmark rule and a bookmark label.
/// Half the room between the bookmark index and the column.
public static let bookmarkGap: CGFloat = 8
/// The rule right of a bookmark label.
public static let bookmarkTail: CGFloat = 16
/// The shortest rule between the column and a bookmark label.
public static let bookmarkRuleMinimum: CGFloat = 24
/// Below this side space bookmarks are always narrow.
public static let bookmarkSideMinimum: CGFloat = 160
/// A label longer than this many characters never keeps bookmarks narrow; it is cut off with an ellipsis instead.
public static let bookmarkLabelCharacters = 40
/// A bookmark line away from the caret is this much bigger than the page text.
public static let bookmarkLineGrowth: CGFloat = 2
/// The most room left of the column that the bookmark index takes when it has to push the column to the right.
public static let bookmarkIndexRoomMaximum: CGFloat = 160
/// The size of code and tables against the body size; the same as the page text.
public static let codeScale: CGFloat = 1
/// Room around the code inside a code block.
@@ -111,12 +105,6 @@ public enum PageMetrics {
public static let tableColumnMaximum: CGFloat = 240
public static let tableCellPadding = NSSize(width: 6, height: 3)
/// The side space from which bookmarks are wide: room for the widest label, at most `reasonableLabel`, with its rules.
public static func bookmarkWideSide(widestLabel: CGFloat, reasonableLabel: CGFloat) -> CGFloat {
let label = ceil(min(widestLabel, reasonableLabel))
return max(bookmarkGap + bookmarkRuleMinimum + bookmarkGap + label + bookmarkGap + bookmarkTail, bookmarkSideMinimum)
}
/// The width of about `characters` characters of body text.
public static func columnWidth(bodySize: CGFloat, characters: Int) -> CGFloat {
let sample = String(String(repeating: "the quick brown fox jumps over a lazy dog ", count: 4).prefix(characters))