restores Helder in all its glory

This commit is contained in:
2026-09-28 11:34:49 +02:00
parent c2b38b853c
commit 1d29d0952d
280 changed files with 29205 additions and 7 deletions
@@ -0,0 +1,38 @@
import SwiftUI
/// The 1pt `raised` divider. Use it for every border between panels, rows and bars.
public struct Hairline: View {
var axis: Axis
/// `.horizontal` draws a line across (a row divider); `.vertical` draws a column divider.
public init(_ axis: Axis = .horizontal) {
self.axis = axis
}
public var body: some View {
Rectangle()
.fill(Palette.raised)
.frame(width: axis == .vertical ? Metrics.hairline : nil,
height: axis == .horizontal ? Metrics.hairline : nil)
}
}
extension View {
/// Draws a hairline along one edge without changing the layout.
public func hairline(_ edge: Edge) -> some View {
overlay(alignment: edge.alignment) {
Hairline(edge == .top || edge == .bottom ? .horizontal : .vertical)
}
}
}
extension Edge {
fileprivate var alignment: Alignment {
switch self {
case .top: .top
case .bottom: .bottom
case .leading: .leading
case .trailing: .trailing
}
}
}