feat: Adds stacks, working on styles
This commit is contained in:
@@ -7,23 +7,21 @@ public struct Note<Label: TextNode, Content: TextNode>: TextNode {
|
||||
@usableFromInline
|
||||
let content: Content
|
||||
|
||||
@usableFromInline
|
||||
var separator: any TextNode = " "
|
||||
|
||||
@inlinable
|
||||
public init(
|
||||
separator: any TextNode = " ",
|
||||
@TextBuilder _ label: () -> Label,
|
||||
@TextBuilder content: () -> Content
|
||||
) {
|
||||
self.separator = separator
|
||||
self.label = label()
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public var body: some TextNode {
|
||||
Group(separator: separator, content: [label, content])
|
||||
HStack {
|
||||
label
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,28 +29,49 @@ public extension Note where Label == String {
|
||||
|
||||
@inlinable
|
||||
init(
|
||||
separator: any TextNode = " ",
|
||||
_ label: String = "NOTE:".yellow.bold,
|
||||
_ label: String = "NOTE:",
|
||||
@TextBuilder content: () -> Content
|
||||
) {
|
||||
self.separator = separator
|
||||
self.label = label
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
static func important(
|
||||
separator: any TextNode = " ",
|
||||
_ label: String = "IMPORTANT NOTE:".red.underline,
|
||||
_ label: String = "IMPORTANT NOTE:",
|
||||
@TextBuilder content: () -> Content
|
||||
) -> Self {
|
||||
self.init(separator: separator, label, content: content)
|
||||
self.init(label, content: content)
|
||||
}
|
||||
|
||||
static func seeAlso(
|
||||
separator: any TextNode = " ",
|
||||
_ label: String = "SEE ALSO:".yellow.bold,
|
||||
_ label: String = "SEE ALSO:",
|
||||
@TextBuilder content: () -> Content
|
||||
) -> Self {
|
||||
self.init(separator: separator, label, content: content)
|
||||
self.init(label, content: content)
|
||||
}
|
||||
}
|
||||
|
||||
public extension Note where Label == String, Content == String {
|
||||
|
||||
@inlinable
|
||||
init(
|
||||
_ label: String = "NOTE:",
|
||||
content: String
|
||||
) {
|
||||
self.init(label) { content }
|
||||
}
|
||||
|
||||
static func important(
|
||||
_ label: String = "IMPORTANT NOTE:",
|
||||
content: String
|
||||
) -> Self {
|
||||
self.init(label, content: content)
|
||||
}
|
||||
|
||||
static func seeAlso(
|
||||
_ label: String = "SEE ALSO:",
|
||||
content: String
|
||||
) -> Self {
|
||||
self.init(label, content: content)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user