diff --git a/Sources/Slipstream/Documentation.docc/W3C/W3CViews.md b/Sources/Slipstream/Documentation.docc/W3C/W3CViews.md index 1362e7e..7868c16 100644 --- a/Sources/Slipstream/Documentation.docc/W3C/W3CViews.md +++ b/Sources/Slipstream/Documentation.docc/W3C/W3CViews.md @@ -33,8 +33,9 @@ The complete W3C HTML elements standard can be found [here](https://html.spec.wh ### Grouping content -- ``Div`` - ``Paragraph`` +- ``Divider`` +- ``Div`` ### Text-level semantics diff --git a/Sources/Slipstream/W3C/Elements/GroupingContent/Divider.swift b/Sources/Slipstream/W3C/Elements/GroupingContent/Divider.swift new file mode 100644 index 0000000..23321c0 --- /dev/null +++ b/Sources/Slipstream/W3C/Elements/GroupingContent/Divider.swift @@ -0,0 +1,32 @@ +import SwiftSoup + +/// A divider represents a paragraph-level thematic break, e.g., a +/// scene change in a story, or a transition to another topic within +/// a section of a reference book. +/// +/// ```swift +/// struct MySiteContent: View { +/// var body: some View { +/// Body { +/// Div { +/// Paragraph("Hello, world!") +/// Divider() +/// Paragraph("Let's make a website!") +/// } +/// } +/// } +/// } +/// ``` +/// +/// - SeeAlso: W3C [`hr`](https://html.spec.whatwg.org/multipage/grouping-content.html#the-hr-element) specification. +@available(iOS 17.0, macOS 14.0, *) +public struct Divider: View { + /// Creates a divider view. + public init() { + } + + @_documentation(visibility: private) + public func render(_ container: Element, environment: EnvironmentValues) throws { + _ = try container.appendElement("hr") + } +} diff --git a/Sources/Slipstream/W3C/Elements/Scripting/Script.swift b/Sources/Slipstream/W3C/Elements/Scripting/Script.swift index bbca777..73861c5 100644 --- a/Sources/Slipstream/W3C/Elements/Scripting/Script.swift +++ b/Sources/Slipstream/W3C/Elements/Scripting/Script.swift @@ -45,7 +45,6 @@ public struct Script: View { @_documentation(visibility: private) public func render(_ container: Element, environment: EnvironmentValues) throws { - switch storage { case .url(let url, let executionMode): guard let url else { diff --git a/Tests/SlipstreamTests/Sites/CatalogSiteTests.swift b/Tests/SlipstreamTests/Sites/CatalogSiteTests.swift index ef2f5f4..04bfb73 100644 --- a/Tests/SlipstreamTests/Sites/CatalogSiteTests.swift +++ b/Tests/SlipstreamTests/Sites/CatalogSiteTests.swift @@ -53,6 +53,8 @@ private struct CatalogSite: View { .textColor(.white) .display(.hidden) + Divider() + Heading(level: 2, "Generic heading 2") } .background(.black) @@ -107,6 +109,7 @@ struct CatalogSiteTests {

Heading 4

Heading 5
+

Generic heading 2

diff --git a/Tests/SlipstreamTests/W3C/DividerTests.swift b/Tests/SlipstreamTests/W3C/DividerTests.swift new file mode 100644 index 0000000..596f17b --- /dev/null +++ b/Tests/SlipstreamTests/W3C/DividerTests.swift @@ -0,0 +1,9 @@ +import Testing + +import Slipstream + +struct DividerTests { + @Test func divider() throws { + try #expect(renderHTML(Divider()) == "
") + } +}