aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgUI
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2026-06-18 22:05:21 +0200
committerRuben Beltran del Rio <jj@r.bdr.sh>2026-06-18 22:06:01 +0200
commitcb91a73bfc845d74c3e4d1115bce5dfed10d456d (patch)
tree62d218c4ec13f742b5de10ff442f46d152716658 /Sources/NorgUI
parent3c391974907820c6385e90025faeab0d9c60bd06 (diff)
Make spacings configurable1.1.0
Diffstat (limited to 'Sources/NorgUI')
-rw-r--r--Sources/NorgUI/Theme/NorgTheme.swift16
-rw-r--r--Sources/NorgUI/Views/Blocks/HeadingView.swift2
-rw-r--r--Sources/NorgUI/Views/FlatBlocksView.swift2
-rw-r--r--Sources/NorgUI/Views/TreeNodesView.swift4
-rw-r--r--Sources/NorgUI/Views/VerbatimBlock.swift4
5 files changed, 23 insertions, 5 deletions
diff --git a/Sources/NorgUI/Theme/NorgTheme.swift b/Sources/NorgUI/Theme/NorgTheme.swift
index 47dd161..c788812 100644
--- a/Sources/NorgUI/Theme/NorgTheme.swift
+++ b/Sources/NorgUI/Theme/NorgTheme.swift
@@ -32,6 +32,14 @@ public struct NorgTheme: Sendable {
public var codeFont: Font
/// Horizontal indentation applied per nesting level.
public var indentWidth: CGFloat
+ /// Vertical spacing between the label and contents of a verbatim block.
+ public var verbatimLeadingSpace: CGFloat
+ /// Padding applied around the contents of a verbatim block.
+ public var verbatimPadding: CGFloat
+ /// Vertical spacing between sibling blocks and nodes.
+ public var blockSpacing: CGFloat
+ /// Padding applied above a heading.
+ public var headingTopPadding: CGFloat
/// Tint for a task's status symbol.
public var statusTint: @Sendable (TaskStatus) -> Color
/// SF Symbol name for a task's status symbol.
@@ -56,6 +64,10 @@ public struct NorgTheme: Sendable {
codeBackground: AnyShapeStyle,
codeFont: Font,
indentWidth: CGFloat,
+ verbatimLeadingSpace: CGFloat = 4,
+ verbatimPadding: CGFloat = 10,
+ blockSpacing: CGFloat = 10,
+ headingTopPadding: CGFloat = 4,
statusTint: @escaping @Sendable (TaskStatus) -> Color,
statusSymbol: @escaping @Sendable (TaskStatus) -> String,
statusLabel: @escaping @Sendable (TaskStatus) -> LocalizedStringResource = { $0.displayName }
@@ -74,6 +86,10 @@ public struct NorgTheme: Sendable {
self.codeBackground = codeBackground
self.codeFont = codeFont
self.indentWidth = indentWidth
+ self.verbatimLeadingSpace = verbatimLeadingSpace
+ self.verbatimPadding = verbatimPadding
+ self.blockSpacing = blockSpacing
+ self.headingTopPadding = headingTopPadding
self.statusTint = statusTint
self.statusSymbol = statusSymbol
self.statusLabel = statusLabel
diff --git a/Sources/NorgUI/Views/Blocks/HeadingView.swift b/Sources/NorgUI/Views/Blocks/HeadingView.swift
index 3b65134..800bc46 100644
--- a/Sources/NorgUI/Views/Blocks/HeadingView.swift
+++ b/Sources/NorgUI/Views/Blocks/HeadingView.swift
@@ -21,6 +21,6 @@ struct HeadingView: View {
.font(font)
}
}
- .padding(.top, 4)
+ .padding(.top, theme.headingTopPadding)
}
}
diff --git a/Sources/NorgUI/Views/FlatBlocksView.swift b/Sources/NorgUI/Views/FlatBlocksView.swift
index 185d08b..747edb6 100644
--- a/Sources/NorgUI/Views/FlatBlocksView.swift
+++ b/Sources/NorgUI/Views/FlatBlocksView.swift
@@ -10,7 +10,7 @@ struct FlatBlocksView: View {
var body: some View {
let ordinals = orderedOrdinals(blocks)
- VStack(alignment: .leading, spacing: 10) {
+ VStack(alignment: .leading, spacing: theme.blockSpacing) {
ForEach(Array(blocks.enumerated()), id: \.offset) { index, block in
row(block, ordinal: ordinals[index])
}
diff --git a/Sources/NorgUI/Views/TreeNodesView.swift b/Sources/NorgUI/Views/TreeNodesView.swift
index a509138..a6df972 100644
--- a/Sources/NorgUI/Views/TreeNodesView.swift
+++ b/Sources/NorgUI/Views/TreeNodesView.swift
@@ -5,9 +5,11 @@ struct TreeNodesView: View {
let nodes: [NorgNode]
let onSetStatus: (Int, TaskStatus) -> Void
+ @Environment(\.norgTheme) private var theme
+
var body: some View {
let siblingOrdinals = ordinals(forSiblings: nodes)
- VStack(alignment: .leading, spacing: 10) {
+ VStack(alignment: .leading, spacing: theme.blockSpacing) {
ForEach(Array(nodes.enumerated()), id: \.offset) { index, node in
NodeView(node: node, ordinal: siblingOrdinals[index], onSetStatus: onSetStatus)
.id(node.block.line)
diff --git a/Sources/NorgUI/Views/VerbatimBlock.swift b/Sources/NorgUI/Views/VerbatimBlock.swift
index 722c3f3..8f16ec0 100644
--- a/Sources/NorgUI/Views/VerbatimBlock.swift
+++ b/Sources/NorgUI/Views/VerbatimBlock.swift
@@ -7,7 +7,7 @@ struct VerbatimBlock: View {
let content: String
var body: some View {
- VStack(alignment: .leading, spacing: 4) {
+ VStack(alignment: .leading, spacing: theme.verbatimLeadingSpace) {
if let label, !label.isEmpty {
Text(label)
.font(.caption2)
@@ -17,7 +17,7 @@ struct VerbatimBlock: View {
.font(theme.codeFont)
.frame(maxWidth: .infinity, alignment: .leading)
}
- .padding(10)
+ .padding(theme.verbatimPadding)
.background(theme.codeBackground, in: RoundedRectangle(cornerRadius: 8))
}
}