diff --git a/Sources/WebUI/Core/HTML/Attribute.swift b/Sources/WebUI/Core/Markup/Attribute.swift similarity index 88% rename from Sources/WebUI/Core/HTML/Attribute.swift rename to Sources/WebUI/Core/Markup/Attribute.swift index 9c05bb11..440b1306 100644 --- a/Sources/WebUI/Core/HTML/Attribute.swift +++ b/Sources/WebUI/Core/Markup/Attribute.swift @@ -1,5 +1,5 @@ public enum Attribute { - /// Builds an HTML attribute string if the value exists. + /// Builds a markup attribute string if the value exists. /// /// - Parameters: /// - name: Attribute name (e.g., "id", "class", "src"). @@ -10,7 +10,7 @@ public enum Attribute { return "\(name)=\"\(value)\"" } - /// Builds a boolean HTML attribute if enabled. + /// Builds a boolean markup attribute if enabled. /// /// - Parameters: /// - name: Attribute name (e.g., "disabled", "checked", "required"). @@ -20,7 +20,7 @@ public enum Attribute { enabled == true ? name : nil } - /// Builds an HTML attribute string from a typed enum value. + /// Builds a markup attribute string from a typed enum value. /// /// - Parameters: /// - name: Attribute name (e.g., "type", "role"). diff --git a/Sources/WebUI/Core/HTML/AttributeBuilder.swift b/Sources/WebUI/Core/Markup/AttributeBuilder.swift similarity index 57% rename from Sources/WebUI/Core/HTML/AttributeBuilder.swift rename to Sources/WebUI/Core/Markup/AttributeBuilder.swift index 6d3b1607..812d221d 100644 --- a/Sources/WebUI/Core/HTML/AttributeBuilder.swift +++ b/Sources/WebUI/Core/Markup/AttributeBuilder.swift @@ -1,27 +1,27 @@ import Foundation -/// Utility for building HTML attributes +/// Utility for building markup attributes /// -/// The `AttributeBuilder` provides helper methods for generating HTML +/// The `AttributeBuilder` provides helper methods for generating markup /// attribute strings in a consistent way across all elements. public enum AttributeBuilder { - /// Builds a collection of HTML attributes from common parameters + /// Builds a collection of markup attributes from common parameters /// /// - Parameters: - /// - id: Optional unique identifier for the HTML element - /// - classes: Optional array of CSS class names + /// - id: Optional unique identifier for the markup element + /// - classes: Optional array of stylesheet class names /// - role: Optional ARIA role for accessibility /// - label: Optional ARIA label for accessibility /// - data: Optional dictionary of data attributes /// - additional: Optional array of additional attribute strings - /// - Returns: Array of attribute strings for use in HTML tags + /// - Returns: Array of attribute strings for use in markup tags public static func buildAttributes( - id: String? = nil, - classes: [String]? = nil, - role: AriaRole? = nil, - label: String? = nil, - data: [String: String]? = nil, - additional: [String] = [] + identifier id: String? = nil, + styleSheetClasses classes: [String]? = nil, + ariaRole role: AriaRole? = nil, + ariaLabel label: String? = nil, + dataAttributes data: [String: String]? = nil, + additionalAttributes additional: [String] = [] ) -> [String] { var attributes: [String] = [] @@ -54,17 +54,48 @@ public enum AttributeBuilder { attributes.append(contentsOf: additional) return attributes } + + /// Builds a collection of markup attributes from common parameters (backward compatibility) + /// + /// This overload maintains backward compatibility with existing code. + /// Consider using the version with clearer parameter labels for new code. + /// + /// - Parameters: + /// - id: Optional unique identifier for the markup element + /// - classes: Optional array of stylesheet class names + /// - role: Optional ARIA role for accessibility + /// - label: Optional ARIA label for accessibility + /// - data: Optional dictionary of data attributes + /// - additional: Optional array of additional attribute strings + /// - Returns: Array of attribute strings for use in markup tags + public static func buildAttributes( + id: String? = nil, + classes: [String]? = nil, + role: AriaRole? = nil, + label: String? = nil, + data: [String: String]? = nil, + additional: [String] = [] + ) -> [String] { + return buildAttributes( + identifier: id, + styleSheetClasses: classes, + ariaRole: role, + ariaLabel: label, + dataAttributes: data, + additionalAttributes: additional + ) + } - /// Renders a complete HTML tag with attributes and content + /// Renders a complete markup tag with attributes and content /// /// - Parameters: - /// - tag: The HTML tag name + /// - tag: The markup tag name /// - attributes: Array of attribute strings /// - content: Optional content to include between opening and closing tags /// - isSelfClosing: Whether this is a self-closing tag /// - noClosingTag: Whether this should be rendered without a self-close and without a seperate close - /// - Returns: Complete HTML tag as a string - public static func renderTag( + /// - Returns: Complete markup tag as a string + public static func buildMarkupTag( _ tag: String, attributes: [String], content: String = "", diff --git a/Sources/WebUI/Core/HTML/HTML.swift b/Sources/WebUI/Core/Markup/Markup.swift similarity index 64% rename from Sources/WebUI/Core/HTML/HTML.swift rename to Sources/WebUI/Core/Markup/Markup.swift index ee655dc5..ae37883a 100644 --- a/Sources/WebUI/Core/HTML/HTML.swift +++ b/Sources/WebUI/Core/Markup/Markup.swift @@ -1,13 +1,13 @@ import Foundation -/// Represents an HTML component or element. +/// Represents a markup component or element. /// -/// The `HTML` protocol is the foundation for all HTML elements in WebUI. It +/// The `Markup` protocol is the foundation for all markup elements in WebUI. It /// defines how components describe their structure and content. /// -/// Elements conforming to HTML can be composed together to create complex +/// Elements conforming to Markup can be composed together to create complex /// layouts while maintaining a declarative syntax. The protocol handles both -/// primitive HTML string content and composite element structures. +/// primitive markup string content and composite element structures. /// /// ## Example /// ```swift @@ -15,7 +15,7 @@ import Foundation /// var title: String /// var content: String /// -/// var body: some HTML { +/// var body: some Markup { /// Stack { /// Heading(.title) { title } /// Text { content } @@ -26,42 +26,42 @@ import Foundation /// } /// } /// ``` -public protocol HTML { - /// The type of HTML content this component produces. - associatedtype Body: HTML +public protocol Markup { + /// The type of markup content this component produces. + associatedtype Body: Markup - /// The content and structure of this HTML component. + /// The content and structure of this markup component. /// /// The `body` property defines the component's layout and content /// hierarchy. This pattern mirrors SwiftUI's declarative syntax, making /// the code more intuitive and maintainable. /// - /// - Returns: A composition of HTML elements that make up this component. + /// - Returns: A composition of markup elements that make up this component. var body: Body { get } - /// Renders the HTML component to its string representation. + /// Renders the markup component to its string representation. /// - /// This method converts the HTML component into its final HTML string representation - /// for output to files or HTTP responses. + /// This method converts the markup component into its final markup string representation + /// for output to files or responses. /// - /// - Returns: The rendered HTML string. + /// - Returns: The rendered markup string. func render() -> String } -/// A type-erased HTML component. +/// A type-erased markup component. /// -/// `AnyHTML` wraps any HTML-conforming type, allowing for type erasure in +/// `AnyMarkup` wraps any Markup-conforming type, allowing for type erasure in /// heterogeneous collections or when specific type information isn't needed. -public struct AnyHTML: HTML { - private let wrapped: any HTML +public struct AnyMarkup: Markup { + private let wrapped: any Markup private let renderClosure: () -> String - public init(_ html: T) { - self.wrapped = html - self.renderClosure = { html.render() } + public init(_ markup: T) { + self.wrapped = markup + self.renderClosure = { markup.render() } } - public var body: AnyHTML { + public var body: AnyMarkup { self } @@ -70,13 +70,13 @@ public struct AnyHTML: HTML { } } -/// Primitive HTML string content. +/// Primitive markup string content. /// -/// Used internally to represent raw HTML string content within the HTML hierarchy. -public struct HTMLString: HTML { +/// Used internally to represent raw markup string content within the markup hierarchy. +public struct MarkupString: Markup { let content: String - public var body: HTMLString { + public var body: MarkupString { self } @@ -89,27 +89,27 @@ public struct HTMLString: HTML { } } -// String extension that conforms to HTML is in Utilities/String.swift +// String extension that conforms to Markup is in Utilities/String.swift // MARK: - Default Implementations -extension HTML { +extension Markup { /// Default render implementation that delegates to the body. public func render() -> String { body.render() } - /// Adds CSS classes to an HTML element + /// Adds stylesheet classes to a markup element /// - /// - Parameter classes: The CSS classes to add - /// - Returns: A container with the HTML content and additional classes - public func addingClasses(_ classes: [String]) -> some HTML { - HTMLClassContainer(content: self, classes: classes) + /// - Parameter classes: The stylesheet classes to add + /// - Returns: A container with the markup content and additional classes + public func addingClasses(_ classes: [String]) -> some Markup { + MarkupClassContainer(content: self, classes: classes) } } -/// A container that adds CSS classes to HTML content -public struct HTMLClassContainer: HTML { +/// A container that adds stylesheet classes to markup content +public struct MarkupClassContainer: Markup { private let content: Content private let classes: [String] @@ -118,8 +118,8 @@ public struct HTMLClassContainer: HTML { self.classes = classes } - public var body: HTMLString { - HTMLString(content: renderWithClasses()) + public var body: MarkupString { + MarkupString(content: renderWithClasses()) } private func renderWithClasses() -> String { @@ -131,7 +131,7 @@ public struct HTMLClassContainer: HTML { return renderedContent } - // Check if content starts with an HTML tag + // Check if content starts with a markup tag guard let tagRange = renderedContent.range( of: "<[^>]+>", options: .regularExpression) diff --git a/Sources/WebUI/Core/HTML/HTMLBuilder.swift b/Sources/WebUI/Core/Markup/MarkupBuilder.swift similarity index 56% rename from Sources/WebUI/Core/HTML/HTMLBuilder.swift rename to Sources/WebUI/Core/Markup/MarkupBuilder.swift index 9cd77ed9..cd180bfd 100644 --- a/Sources/WebUI/Core/HTML/HTMLBuilder.swift +++ b/Sources/WebUI/Core/Markup/MarkupBuilder.swift @@ -1,17 +1,17 @@ -/// Enables declarative construction of HTML content using Swift's result builder feature. +/// Enables declarative construction of markup content using Swift's result builder feature. /// -/// `HTMLBuilder` provides a domain-specific language (DSL) for creating HTML structures +/// `MarkupBuilder` provides a domain-specific language (DSL) for creating markup structures /// with a SwiftUI-like syntax. It transforms Swift code written in a declarative style -/// into a collection of HTML elements, allowing for intuitive, hierarchical composition +/// into a collection of markup elements, allowing for intuitive, hierarchical composition /// of web content. /// -/// This result builder pattern simplifies the creation of complex HTML structures by handling +/// This result builder pattern simplifies the creation of complex markup structures by handling /// the combination of elements, conditional logic, and loops in a natural, Swift-native way. /// /// - Example: /// ```swift -/// @HTMLBuilder -/// func createContent() -> [any HTML] { +/// @MarkupBuilder +/// func createContent() -> [any Markup] { /// Heading(.one) { "Welcome" } /// Text { "This is a paragraph" } /// if isLoggedIn { @@ -22,15 +22,15 @@ /// } /// ``` @resultBuilder -public struct HTMLBuilder { - /// Combines multiple HTML component arrays into a single array. +public struct MarkupBuilder { + /// Combines multiple markup component arrays into a single array. /// - /// This method joins multiple variadic HTML component lists into a single flat array, - /// which is essential for building nested HTML structures from multiple blocks of content. + /// This method joins multiple variadic markup component lists into a single flat array, + /// which is essential for building nested markup structures from multiple blocks of content. /// /// - Parameters: - /// - components: Variadic arrays of HTML components, each representing a block of content. - /// - Returns: A flattened array of all provided HTML components. + /// - components: Variadic arrays of markup components, each representing a block of content. + /// - Returns: A flattened array of all provided markup components. /// /// - Example: /// ```swift @@ -40,35 +40,35 @@ public struct HTMLBuilder { /// // [Button, Link] /// // Into: [Heading, Text, Image, Button, Link] /// ``` - public static func buildBlock(_ components: [any HTML]...) -> [any HTML] { + public static func buildBlock(_ components: [any Markup]...) -> [any Markup] { components.joined().map { $0 } } - /// Wraps a single HTML entity in an array. + /// Wraps a single markup entity in an array. /// - /// This method converts an individual HTML expression (like a Heading or Text element) + /// This method converts an individual markup expression (like a Heading or Text element) /// into a component array, which is the standard format for all builder operations. /// /// - Parameters: - /// - expression: The HTML entity to include in the result. - /// - Returns: An array containing the single HTML entity. + /// - expression: The markup entity to include in the result. + /// - Returns: An array containing the single markup entity. /// /// - Example: /// ```swift /// // Converts: Text { "Hello" } /// // Into: [Text { "Hello" }] /// ``` - public static func buildExpression(_ expression: any HTML) -> [any HTML] { + public static func buildExpression(_ expression: any Markup) -> [any Markup] { [expression] } - /// Handles optional HTML components in conditional statements. + /// Handles optional markup components in conditional statements. /// /// This method processes the optional result of an `if` statement that doesn't have an `else` clause, /// returning the components if present, or an empty array if nil. /// /// - Parameters: - /// - component: An optional array of HTML components from the conditional. + /// - component: An optional array of markup components from the conditional. /// - Returns: The components or an empty array if nil. /// /// - Example: @@ -79,17 +79,17 @@ public struct HTMLBuilder { /// } /// // Returns [Heading] if showWelcome is true, or [] if false /// ``` - public static func buildOptional(_ component: [any HTML]?) -> [any HTML] { + public static func buildOptional(_ component: [any Markup]?) -> [any Markup] { component ?? [] } - /// Resolves the true branch of a conditional HTML structure. + /// Resolves the true branch of a conditional markup structure. /// /// This method handles the first (true) branch of an if-else statement in the builder, /// returning components that should be included when the condition is true. /// /// - Parameters: - /// - component: The HTML components from the true branch of the condition. + /// - component: The markup components from the true branch of the condition. /// - Returns: The components from the first branch, unchanged. /// /// - Example: @@ -101,17 +101,17 @@ public struct HTMLBuilder { /// Text { "Login required" } /// } /// ``` - public static func buildEither(first component: [any HTML]) -> [any HTML] { + public static func buildEither(first component: [any Markup]) -> [any Markup] { component } - /// Resolves the false branch of a conditional HTML structure. + /// Resolves the false branch of a conditional markup structure. /// /// This method handles the second (false) branch of an if-else statement in the builder, /// returning components that should be included when the condition is false. /// /// - Parameters: - /// - component: The HTML components from the false branch of the condition. + /// - component: The markup components from the false branch of the condition. /// - Returns: The components from the second branch, unchanged. /// /// - Example: @@ -123,19 +123,19 @@ public struct HTMLBuilder { /// Text { "Login required" } /// } /// ``` - public static func buildEither(second component: [any HTML]) -> [any HTML] { + public static func buildEither(second component: [any Markup]) -> [any Markup] { component } - /// Flattens an array of HTML component arrays from loop structures. + /// Flattens an array of markup component arrays from loop structures. /// /// This method converts a nested array from a `for` loop or other iterable context /// into a single flat array of components. It's essential for building lists and - /// other repeating structures in the HTML. + /// other repeating structures in the markup. /// /// - Parameters: - /// - components: An array of HTML component arrays, each from one iteration of the loop. - /// - Returns: A flattened array of all HTML components from all iterations. + /// - components: An array of markup component arrays, each from one iteration of the loop. + /// - Returns: A flattened array of all markup components from all iterations. /// /// - Example: /// ```swift @@ -145,22 +145,22 @@ public struct HTMLBuilder { /// } /// // Converts [[Item1], [Item2], [Item3]] into [Item1, Item2, Item3] /// ``` - public static func buildArray(_ components: [[any HTML]]) -> [any HTML] { + public static func buildArray(_ components: [[any Markup]]) -> [any Markup] { components.flatMap { $0 } } } -/// Type alias for a closure that builds HTML content using the HTML builder DSL. +/// Type alias for a closure that builds markup content using the markup builder DSL. /// /// This type is commonly used as a parameter type for component initializers, -/// allowing them to accept content-building closures with the HTMLBuilder syntax. +/// allowing them to accept content-building closures with the MarkupBuilder syntax. /// /// - Example: /// ```swift -/// func makeSection(content: HTMLContentBuilder) -> Element { +/// func makeSection(content: MarkupContentBuilder) -> Element { /// return Section { /// content() /// } /// } /// ``` -public typealias HTMLContentBuilder = () -> [any HTML] +public typealias MarkupContentBuilder = () -> [any Markup] diff --git a/Sources/WebUI/Core/Metadata/Metadata.swift b/Sources/WebUI/Core/Metadata/Metadata.swift index 5bf9f8a7..cec3b8e8 100644 --- a/Sources/WebUI/Core/Metadata/Metadata.swift +++ b/Sources/WebUI/Core/Metadata/Metadata.swift @@ -259,7 +259,7 @@ public struct Metadata { } // Structured Data if let structuredData = structuredData { - let jsonString = structuredData.toJSON() + let jsonString = structuredData.convertToJsonString() if !jsonString.isEmpty { baseTags.append( "" diff --git a/Sources/WebUI/Core/Protocols/Document.swift b/Sources/WebUI/Core/Protocols/Document.swift index 1b27c7db..bf93f0be 100644 --- a/Sources/WebUI/Core/Protocols/Document.swift +++ b/Sources/WebUI/Core/Protocols/Document.swift @@ -14,14 +14,14 @@ import Foundation /// Metadata(from: Portfolio.metadata, title: "Home") /// } /// -/// var body: some HTML { +/// var body: some Markup { /// Card(title: "Hello, world") /// } /// } /// ``` public protocol Document { - /// The type of HTML content this document produces. - associatedtype Body: HTML + /// The type of markup content this document produces. + associatedtype Body: Markup /// The metadata configuration for this document. /// @@ -31,7 +31,7 @@ public protocol Document { /// The main content of the document. /// - /// This property returns the HTML content that will be rendered as the + /// This property returns the markup content that will be rendered as the /// body of the page. var body: Body { get } @@ -51,7 +51,7 @@ public protocol Document { /// Optional theme configuration specific to this document. var theme: Theme? { get } - /// Optional custom HTML to append to this document's head section. + /// Optional custom markup to append to this document's head section. var head: String? { get } } diff --git a/Sources/WebUI/Core/Protocols/Element.swift b/Sources/WebUI/Core/Protocols/Element.swift index 9c4c663a..251177f2 100644 --- a/Sources/WebUI/Core/Protocols/Element.swift +++ b/Sources/WebUI/Core/Protocols/Element.swift @@ -1,8 +1,8 @@ import Foundation -/// A protocol for building reusable HTML components with a SwiftUI-like pattern. +/// A protocol for building reusable markup components with a SwiftUI-like pattern. /// -/// The `Element` protocol extends `HTML` to provide a body property that +/// The `Element` protocol extends `Markup` to provide a body property that /// follows the SwiftUI pattern for building declarative user interfaces. /// Elements define their content through the `body` property, making it easy /// to compose complex layouts from simple, reusable components. @@ -11,20 +11,20 @@ import Foundation /// ```swift /// struct Card: Element { /// var title: String -/// var body: some HTML { +/// var body: some Markup { /// Stack { /// Text { title } /// } /// } /// } /// ``` -public protocol Element: HTML { +public protocol Element: Markup { /// The content and structure of this element. /// /// The `body` property defines the element's layout and content hierarchy. /// This pattern mirrors SwiftUI's declarative syntax, making the code more /// intuitive and maintainable. /// - /// - Returns: A composition of HTML elements that make up this component. + /// - Returns: A composition of markup elements that make up this component. var body: Body { get } } diff --git a/Sources/WebUI/Core/Protocols/Website.swift b/Sources/WebUI/Core/Protocols/Website.swift index 37b5bbc3..6f1b3ccf 100644 --- a/Sources/WebUI/Core/Protocols/Website.swift +++ b/Sources/WebUI/Core/Protocols/Website.swift @@ -46,17 +46,17 @@ public protocol Website { /// Optional custom HTML to append to all document head sections. var head: String? { get } - /// Base URL of the website for sitemap generation. - var baseURL: String? { get } + /// Base web address of the website for sitemap generation. + var baseWebAddress: String? { get } /// Custom sitemap entries to include in the sitemap.xml. var sitemapEntries: [SitemapEntry]? { get } /// Controls whether to generate a sitemap.xml file. - var generateSitemap: Bool { get } + var shouldGenerateSitemap: Bool { get } /// Controls whether to generate a robots.txt file. - var generateRobotsTxt: Bool { get } + var shouldGenerateRobotsTxt: Bool { get } /// Optional custom rules to include in robots.txt file. var robotsRules: [RobotsRule]? { get } @@ -77,17 +77,17 @@ extension Website { /// Default head implementation returns nil. public var head: String? { nil } - /// Default baseURL implementation returns nil. - public var baseURL: String? { nil } + /// Default base web address implementation returns nil. + public var baseWebAddress: String? { nil } /// Default sitemapEntries implementation returns nil. public var sitemapEntries: [SitemapEntry]? { nil } - /// Default generateSitemap implementation returns true if baseURL is provided. - public var generateSitemap: Bool { baseURL != nil } + /// Default sitemap generation implementation returns true if base web address is provided. + public var shouldGenerateSitemap: Bool { baseWebAddress != nil } - /// Default generateRobotsTxt implementation returns true if baseURL is provided. - public var generateRobotsTxt: Bool { baseURL != nil } + /// Default robots.txt generation implementation returns true if base web address is provided. + public var shouldGenerateRobotsTxt: Bool { baseWebAddress != nil } /// Default robotsRules implementation returns nil. public var robotsRules: [RobotsRule]? { nil } @@ -142,12 +142,12 @@ extension Website { } // Generate sitemap if enabled - if generateSitemap, let baseURL = baseURL { - try generateSitemapXML(in: outputDirectory, baseURL: baseURL) + if shouldGenerateSitemap, let baseWebAddress = baseWebAddress { + try generateSitemapXML(in: outputDirectory, baseWebAddress: baseWebAddress) } // Generate robots.txt if enabled - if generateRobotsTxt { + if shouldGenerateRobotsTxt { try generateRobotsTxt(in: outputDirectory) } } @@ -186,11 +186,11 @@ extension Website { } } - private func generateSitemapXML(in directory: URL, baseURL: String) throws { + private func generateSitemapXML(in directory: URL, baseWebAddress: String) throws { var entries = try routes.compactMap { route -> SitemapEntry? in guard let path = route.path else { return nil } return SitemapEntry( - url: "\(baseURL)/\(path).html", + url: "\(baseWebAddress)/\(path).html", lastModified: route.metadata.date, changeFrequency: .monthly, priority: 0.5 @@ -234,8 +234,8 @@ extension Website { private func generateRobotsTxt(in directory: URL) throws { // Use the dedicated Robots.generateTxt method let robotsTxt = Robots.generateTxt( - baseURL: baseURL, - generateSitemap: generateSitemap, + baseWebAddress: baseWebAddress, + shouldGenerateSitemap: shouldGenerateSitemap, robotsRules: robotsRules ) diff --git a/Sources/WebUI/Core/Robots/Robots.swift b/Sources/WebUI/Core/Robots/Robots.swift index 2d1a4646..8ec5fbbe 100644 --- a/Sources/WebUI/Core/Robots/Robots.swift +++ b/Sources/WebUI/Core/Robots/Robots.swift @@ -14,16 +14,16 @@ public struct Robots { /// one exists. /// /// - Parameters: - /// - baseURL: The optional base URL of the website (e.g., "https://example.com"). - /// - generateSitemap: Whether a sitemap is being generated for this website. + /// - baseWebAddress: The optional base web address of the website (e.g., "https://example.com"). + /// - shouldGenerateSitemap: Whether a sitemap is being generated for this website. /// - robotsRules: Custom rules to include in the robots.txt file. /// - Returns: A string containing the content of the robots.txt file. /// /// - Example: /// ```swift /// let content = Robots.generateTxt( - /// baseURL: "https://example.com", - /// generateSitemap: true, + /// baseWebAddress: "https://example.com", + /// shouldGenerateSitemap: true, /// robotsRules: [.allowAll()] /// ) /// ``` @@ -31,8 +31,8 @@ public struct Robots { /// - Note: If custom rules are provided, they will be included in the file. /// Otherwise, a default permissive robots.txt will be generated. public static func generateTxt( - baseURL: String? = nil, - generateSitemap: Bool = false, + baseWebAddress: String? = nil, + shouldGenerateSitemap: Bool = false, robotsRules: [RobotsRule]? = nil ) -> String { var contentComponents: [String] = [] @@ -48,8 +48,8 @@ public struct Robots { } // Add sitemap reference if applicable - if generateSitemap, let baseURL = baseURL { - contentComponents.append("Sitemap: \(baseURL)/sitemap.xml") + if shouldGenerateSitemap, let baseWebAddress = baseWebAddress { + contentComponents.append("Sitemap: \(baseWebAddress)/sitemap.xml") } return contentComponents.joined(separator: "\n") diff --git a/Sources/WebUI/Core/Sitemap/Sitemap.swift b/Sources/WebUI/Core/Sitemap/Sitemap.swift index 1d7da8ed..dce22547 100644 --- a/Sources/WebUI/Core/Sitemap/Sitemap.swift +++ b/Sources/WebUI/Core/Sitemap/Sitemap.swift @@ -18,15 +18,15 @@ public struct Sitemap { /// follows the Sitemap protocol specification from sitemaps.org. /// /// - Parameters: - /// - baseURL: The base URL of the website (e.g., "https://example.com"). + /// - baseWebAddress: The base web address of the website (e.g., "https://example.com"). /// - routes: The document routes in the website. /// - customEntries: Additional sitemap entries to include. - /// - Returns: A string containing the XML content of the sitemap. + /// - Returns: A string containing the extensible markup language content of the sitemap. /// /// - Example: /// ```swift - /// let sitemapXML = Sitemap.generateXML( - /// baseURL: "https://example.com", + /// let sitemapMarkup = Sitemap.generateExtensibleMarkupLanguageDocument( + /// baseWebAddress: "https://example.com", /// routes: website.routes, /// customEntries: additionalEntries /// ) @@ -34,8 +34,8 @@ public struct Sitemap { /// /// - Note: If any route has a `metadata.date` value, it will be used as the lastmod date /// in the sitemap. Priority is set based on the path depth (home page gets 1.0). - public static func generateXML( - baseURL: String, + public static func generateExtensibleMarkupLanguageDocument( + baseWebAddress: String, routes: [any Document], customEntries: [SitemapEntry]? = nil ) -> String { @@ -49,7 +49,7 @@ public struct Sitemap { // Add entries for all routes for route in routes { let path = route.path ?? "index" - let url = "\(baseURL)/\(path == "index" ? "" : "\(path).html")" + let url = "\(baseWebAddress)/\(path == "index" ? "" : "\(path).html")" var urlComponents = [" ", " \(url)"] @@ -115,10 +115,10 @@ public struct Sitemap { return xmlComponents.joined(separator: "\n") } - /// Validates if a URL is properly formatted for inclusion in a sitemap. + /// Validates if a web address is properly formatted for inclusion in a sitemap. /// - /// - Parameter url: The URL to validate. - /// - Returns: True if the URL is valid for a sitemap, false otherwise. + /// - Parameter url: The web address to validate. + /// - Returns: True if the web address is valid for a sitemap, false otherwise. public static func isValidURL(_ url: String) -> Bool { guard let url = URL(string: url) else { return false @@ -126,4 +126,25 @@ public struct Sitemap { return url.scheme != nil && url.host != nil } + + /// Backward compatibility method for generating XML sitemap content. + /// + /// - Deprecated: Use `generateExtensibleMarkupLanguageDocument(baseWebAddress:routes:customEntries:)` instead. + /// - Parameters: + /// - baseURL: The base URL of the website. + /// - routes: The document routes in the website. + /// - customEntries: Additional sitemap entries to include. + /// - Returns: A string containing the XML content of the sitemap. + @available(*, deprecated, message: "Use generateExtensibleMarkupLanguageDocument(baseWebAddress:routes:customEntries:) instead") + public static func generateXML( + baseURL: String, + routes: [any Document], + customEntries: [SitemapEntry]? = nil + ) -> String { + return generateExtensibleMarkupLanguageDocument( + baseWebAddress: baseURL, + routes: routes, + customEntries: customEntries + ) + } } diff --git a/Sources/WebUI/Core/Sitemap/SitemapEntry.swift b/Sources/WebUI/Core/Sitemap/SitemapEntry.swift index 77f09a26..c613e39e 100644 --- a/Sources/WebUI/Core/Sitemap/SitemapEntry.swift +++ b/Sources/WebUI/Core/Sitemap/SitemapEntry.swift @@ -75,19 +75,19 @@ public struct SitemapEntry: Equatable, Hashable { /// Creates a homepage sitemap entry with recommended settings. /// /// - Parameters: - /// - baseURL: The base URL of the website. + /// - baseWebAddress: The base web address of the website. /// - lastModified: The date when the homepage was last modified. /// - Returns: A sitemap entry configured for a homepage. /// /// - Example: /// ```swift - /// let homepage = SitemapEntry.homepage(baseURL: "https://example.com") + /// let homepage = SitemapEntry.homepage(baseWebAddress: "https://example.com") /// ``` - public static func homepage(baseURL: String, lastModified: Date? = nil) + public static func homepage(baseWebAddress: String, lastModified: Date? = nil) -> SitemapEntry { SitemapEntry( - url: baseURL, + url: baseWebAddress, lastModified: lastModified, changeFrequency: .weekly, priority: 1.0 diff --git a/Sources/WebUI/Core/StructuredData/ArticleSchema.swift b/Sources/WebUI/Core/StructuredData/ArticleSchema.swift index bddfe995..df788a3e 100644 --- a/Sources/WebUI/Core/StructuredData/ArticleSchema.swift +++ b/Sources/WebUI/Core/StructuredData/ArticleSchema.swift @@ -11,7 +11,7 @@ extension StructuredData { /// - datePublished: The date the article was published. /// - dateModified: The date the article was last modified. /// - description: A short description of the article content. - /// - url: The URL of the article. + /// - webAddress: The web address of the article. /// - Returns: A structured data object for an article. /// /// - Example: @@ -61,7 +61,7 @@ extension StructuredData { datePublished: Date, dateModified: Date? = nil, description: String? = nil, - url: String? = nil + webAddress: String? = nil ) -> StructuredData { var data: [String: Any] = [ "headline": headline, @@ -81,7 +81,7 @@ extension StructuredData { || publisherData.type == .person { // Extract the raw data from the structured data object - let publisherDict = publisherData.getData() + let publisherDict = publisherData.retrieveStructuredDataDictionary() var typeDict = publisherDict typeDict["@type"] = publisherData.type.rawValue data["publisher"] = typeDict @@ -98,8 +98,8 @@ extension StructuredData { data["description"] = description } - if let url = url { - data["url"] = url + if let webAddress = webAddress { + data["url"] = webAddress } return StructuredData(type: .article, data: data) diff --git a/Sources/WebUI/Core/StructuredData/OrganizationSchema.swift b/Sources/WebUI/Core/StructuredData/OrganizationSchema.swift index db0a67e1..eff1db97 100644 --- a/Sources/WebUI/Core/StructuredData/OrganizationSchema.swift +++ b/Sources/WebUI/Core/StructuredData/OrganizationSchema.swift @@ -6,7 +6,7 @@ extension StructuredData { /// - Parameters: /// - name: The name of the organization. /// - logo: The URL to the organization's logo. - /// - url: The URL of the organization's website. + /// - webAddress: The web address of the organization's website. /// - contactPoint: Optional contact information. /// - sameAs: Optional array of URLs that also represent the entity. /// - Returns: A structured data object for an organization. @@ -16,21 +16,21 @@ extension StructuredData { /// let orgData = StructuredData.organization( /// name: "WebUI Technologies", /// logo: "https://example.com/logo.png", - /// url: "https://example.com", + /// webAddress: "https://example.com", /// sameAs: ["https://twitter.com/webui", "https://github.com/webui"] /// ) /// ``` public static func organization( name: String, logo: String, - url: String, + webAddress: String, contactPoint: [String: Any]? = nil, sameAs: [String]? = nil ) -> StructuredData { var data: [String: Any] = [ "name": name, "logo": logo, - "url": url, + "url": webAddress, ] if let contactPoint = contactPoint { diff --git a/Sources/WebUI/Core/StructuredData/PersonSchema.swift b/Sources/WebUI/Core/StructuredData/PersonSchema.swift index c92d6744..926d957e 100644 --- a/Sources/WebUI/Core/StructuredData/PersonSchema.swift +++ b/Sources/WebUI/Core/StructuredData/PersonSchema.swift @@ -11,7 +11,7 @@ extension StructuredData { /// - jobTitle: The person's job title. /// - email: The person's email address. /// - telephone: The person's telephone number. - /// - url: The URL of the person's website or profile. + /// - webAddress: The web address of the person's website or profile. /// - address: Optional address information. /// - birthDate: The person's date of birth. /// - sameAs: Optional array of URLs that also represent the person (social profiles). @@ -24,7 +24,7 @@ extension StructuredData { /// givenName: "Jane", /// familyName: "Doe", /// jobTitle: "Software Engineer", - /// url: "https://janedoe.com", + /// webAddress: "https://janedoe.com", /// sameAs: ["https://twitter.com/janedoe", "https://github.com/janedoe"] /// ) /// ``` @@ -36,7 +36,7 @@ extension StructuredData { jobTitle: String? = nil, email: String? = nil, telephone: String? = nil, - url: String? = nil, + webAddress: String? = nil, address: [String: Any]? = nil, birthDate: Date? = nil, sameAs: [String]? = nil @@ -69,8 +69,8 @@ extension StructuredData { data["telephone"] = telephone } - if let url = url { - data["url"] = url + if let webAddress = webAddress { + data["url"] = webAddress } if let address = address { diff --git a/Sources/WebUI/Core/StructuredData/StructuredData.swift b/Sources/WebUI/Core/StructuredData/StructuredData.swift index f8f5ea42..725ec285 100644 --- a/Sources/WebUI/Core/StructuredData/StructuredData.swift +++ b/Sources/WebUI/Core/StructuredData/StructuredData.swift @@ -14,7 +14,7 @@ public struct StructuredData { /// Returns a copy of the raw data dictionary. /// /// - Returns: A dictionary containing the structured data properties. - public func getData() -> [String: Any] { + public func retrieveStructuredDataDictionary() -> [String: Any] { data } @@ -53,7 +53,7 @@ public struct StructuredData { /// Converts the structured data to a JSON string. /// /// - Returns: A JSON string representation of the structured data, or an empty string if serialization fails. - public func toJSON() -> String { + public func convertToJsonString() -> String { var jsonObject: [String: Any] = [ "@context": "https://schema.org", "@type": type.rawValue, @@ -75,4 +75,24 @@ public struct StructuredData { return "" } + + // MARK: - Backward Compatibility + + /// Backward compatibility alias for `retrieveStructuredDataDictionary()`. + /// + /// - Deprecated: Use `retrieveStructuredDataDictionary()` instead. + /// - Returns: A dictionary containing the structured data properties. + @available(*, deprecated, message: "Use retrieveStructuredDataDictionary() instead") + public func getData() -> [String: Any] { + return retrieveStructuredDataDictionary() + } + + /// Backward compatibility alias for `convertToJsonString()`. + /// + /// - Deprecated: Use `convertToJsonString()` instead. + /// - Returns: A JSON string representation of the structured data. + @available(*, deprecated, message: "Use convertToJsonString() instead") + public func toJSON() -> String { + return convertToJsonString() + } } diff --git a/Sources/WebUI/Core/Theme.swift b/Sources/WebUI/Core/Theme.swift index 2c661d17..1bcb9865 100644 --- a/Sources/WebUI/Core/Theme.swift +++ b/Sources/WebUI/Core/Theme.swift @@ -201,7 +201,7 @@ public struct Theme { func appendVariables(prefix: String, from dict: [String: String]) { for (key, value) in dict { - css += " --\(prefix)-\(key.sanitizedForCSS()): \(value);\n" + css += " --\(prefix)-\(key.sanitizedForStyleSheet()): \(value);\n" propertyCount += 1 } } @@ -228,7 +228,7 @@ public struct Theme { for (category, values) in custom { css += "\n /* \(category.capitalized) */\n" appendVariables( - prefix: category.sanitizedForCSS(), from: values) + prefix: category.sanitizedForStyleSheet(), from: values) } } diff --git a/Sources/WebUI/Elements/Base/Body.swift b/Sources/WebUI/Elements/Base/Body.swift index ffe04c78..95319e56 100644 --- a/Sources/WebUI/Elements/Base/Body.swift +++ b/Sources/WebUI/Elements/Base/Body.swift @@ -17,13 +17,13 @@ public struct BodyWrapper: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML div element for generic content grouping. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for styling and scripting. - /// - classes: An array of CSS classnames for styling the div container. + /// - classes: An array of stylesheet classnames for styling the div container. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element's purpose for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the container. @@ -43,7 +43,7 @@ public struct BodyWrapper: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -53,11 +53,11 @@ public struct BodyWrapper: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -67,6 +67,6 @@ public struct BodyWrapper: Element { ) let content = contentBuilder().map { $0.render() }.joined().render() - return AttributeBuilder.renderTag("body", attributes: attributes, content: content) + return AttributeBuilder.buildMarkupTag("body", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Base/Script/Script.swift b/Sources/WebUI/Elements/Base/Script/Script.swift index 2279f19c..93e67493 100644 --- a/Sources/WebUI/Elements/Base/Script/Script.swift +++ b/Sources/WebUI/Elements/Base/Script/Script.swift @@ -24,11 +24,11 @@ public struct Script: Element { self.content = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let attribute, let attributeAttr = Attribute.bool(attribute.rawValue, true) @@ -42,7 +42,7 @@ public struct Script: Element { additional: additional ) - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "script", attributes: attributes, content: content()) } } diff --git a/Sources/WebUI/Elements/Base/Style.swift b/Sources/WebUI/Elements/Base/Style.swift index e304676f..7c5b18ca 100644 --- a/Sources/WebUI/Elements/Base/Style.swift +++ b/Sources/WebUI/Elements/Base/Style.swift @@ -26,13 +26,13 @@ public struct Style: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML style element. /// /// - Parameters: /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames for the style element itself. + /// - classes: An array of stylesheet classnames for the style element itself. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data. @@ -51,7 +51,7 @@ public struct Style: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -61,11 +61,11 @@ public struct Style: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -75,7 +75,7 @@ public struct Style: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "style", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Interactive/Button/Button.swift b/Sources/WebUI/Elements/Interactive/Button/Button.swift index db4a6a87..b3da1b5d 100644 --- a/Sources/WebUI/Elements/Interactive/Button/Button.swift +++ b/Sources/WebUI/Elements/Interactive/Button/Button.swift @@ -13,7 +13,7 @@ public struct Button: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML button with string title. /// @@ -25,7 +25,7 @@ public struct Button: Element { /// - autofocus: When true, automatically focuses the button when the page loads, optional. /// - onClick: JavaScript function to execute when the button is clicked, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the button. + /// - classes: An array of stylesheet classnames for styling the button. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when button text isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the button. @@ -70,7 +70,7 @@ public struct Button: Element { /// - autofocus: When true, automatically focuses the button when the page loads, optional. /// - onClick: JavaScript function to execute when the button is clicked, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the button. + /// - classes: An array of stylesheet classnames for styling the button. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when button text isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the button. @@ -118,7 +118,7 @@ public struct Button: Element { /// - autofocus: When true, automatically focuses the button when the page loads, optional. /// - onClick: JavaScript function to execute when the button is clicked, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the button. + /// - classes: An array of stylesheet classnames for styling the button. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when button text isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the button. @@ -142,7 +142,7 @@ public struct Button: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.type = type self.autofocus = autofocus @@ -155,11 +155,11 @@ public struct Button: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let type, let typeAttr = Attribute.typed("type", type) { additional.append(typeAttr) @@ -179,7 +179,7 @@ public struct Button: Element { additional: additional ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "button", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Interactive/Form/Form.swift b/Sources/WebUI/Elements/Interactive/Form/Form.swift index db4bc5d8..0de2e869 100644 --- a/Sources/WebUI/Elements/Interactive/Form/Form.swift +++ b/Sources/WebUI/Elements/Interactive/Form/Form.swift @@ -30,7 +30,7 @@ public struct Form: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML form element. /// @@ -38,7 +38,7 @@ public struct Form: Element { /// - action: Optional URL where form data will be submitted. If nil, the form submits to the current page. /// - method: HTTP method for submission (GET or POST), defaults to `.post`. /// - id: Unique identifier for the HTML element, useful for JavaScript interactions. - /// - classes: An array of CSS classnames for styling the form. + /// - classes: An array of stylesheet classnames for styling the form. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the form. @@ -64,7 +64,7 @@ public struct Form: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.action = action self.method = method @@ -76,11 +76,11 @@ public struct Form: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let action, let actionAttr = Attribute.string("action", action) { additional.append(actionAttr) @@ -97,7 +97,7 @@ public struct Form: Element { additional: additional ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "form", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Interactive/Form/Input/Input.swift b/Sources/WebUI/Elements/Interactive/Form/Input/Input.swift index 376a9ee2..cfc8baf9 100644 --- a/Sources/WebUI/Elements/Interactive/Form/Input/Input.swift +++ b/Sources/WebUI/Elements/Interactive/Form/Input/Input.swift @@ -38,11 +38,11 @@ public struct Input: Element { /// - required: When true, the input must be filled before form submission, optional. /// - checked: For checkbox inputs, indicates if initially checked, optional. /// - id: Unique identifier for the HTML element, useful for labels and JavaScript. - /// - classes: An array of CSS classnames for styling the input. + /// - classes: An array of stylesheet classnames for styling the input. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data. - /// - on: String? = nil, + /// - eventHandler: JavaScript event handler code, optional. /// /// ## Example /// ```swift @@ -71,7 +71,7 @@ public struct Input: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - on: String? = nil + eventHandler on: String? = nil ) { self.name = name self.type = type @@ -88,11 +88,11 @@ public struct Input: Element { self.on = on } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -126,7 +126,7 @@ public struct Input: Element { if let on = on { attributes.append(on) } - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "input", attributes: attributes, isSelfClosing: true) } } diff --git a/Sources/WebUI/Elements/Interactive/Form/Input/Label.swift b/Sources/WebUI/Elements/Interactive/Form/Input/Label.swift index 8bb97e65..c9c01611 100644 --- a/Sources/WebUI/Elements/Interactive/Form/Input/Label.swift +++ b/Sources/WebUI/Elements/Interactive/Form/Input/Label.swift @@ -22,14 +22,14 @@ public struct Label: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML label element associated with a form control. /// /// - Parameters: /// - for: ID of the associated input element. This creates a programmatic connection between the label and the form control. /// - id: Unique identifier for the HTML element itself. - /// - classes: An array of CSS classnames for styling the label. + /// - classes: An array of stylesheet classnames for styling the label. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the label. @@ -48,7 +48,7 @@ public struct Label: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.forAttribute = `for` self.id = id @@ -59,11 +59,11 @@ public struct Label: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let forAttr = Attribute.string("for", forAttribute) { additional.append(forAttr) @@ -77,7 +77,7 @@ public struct Label: Element { additional: additional ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "label", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Interactive/Form/TextArea.swift b/Sources/WebUI/Elements/Interactive/Form/TextArea.swift index 798e4755..6d5856de 100644 --- a/Sources/WebUI/Elements/Interactive/Form/TextArea.swift +++ b/Sources/WebUI/Elements/Interactive/Form/TextArea.swift @@ -34,7 +34,7 @@ public struct TextArea: Element { /// - autofocus: When true, automatically focuses this element when the page loads, optional. /// - required: When true, indicates the textarea must be filled before form submission, optional. /// - id: Unique identifier for the HTML element, useful for labels and script interaction. - /// - classes: An array of CSS classnames for styling the textarea. + /// - classes: An array of stylesheet classnames for styling the textarea. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the textarea. @@ -76,11 +76,11 @@ public struct TextArea: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let nameAttr = Attribute.string("name", name) { additional.append(nameAttr) @@ -108,7 +108,7 @@ public struct TextArea: Element { additional: additional ) let content = value ?? "" - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "textarea", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Interactive/Progress.swift b/Sources/WebUI/Elements/Interactive/Progress.swift index 399ef68c..e29997b2 100644 --- a/Sources/WebUI/Elements/Interactive/Progress.swift +++ b/Sources/WebUI/Elements/Interactive/Progress.swift @@ -26,7 +26,7 @@ public struct Progress: Element { /// - value: Current progress value between 0 and max, optional. When omitted, the progress bar shows an indeterminate state. /// - max: Maximum progress value (100% completion point), optional. Defaults to 100 when omitted. /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames for styling the progress bar. + /// - classes: An array of stylesheet classnames for styling the progress bar. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers (e.g., "Download progress"). /// - data: Dictionary of `data-*` attributes for storing element-relevant data. @@ -57,11 +57,11 @@ public struct Progress: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let value, let valueAttr = Attribute.string("value", "\(value)") { additional.append(valueAttr) @@ -77,6 +77,6 @@ public struct Progress: Element { data: data, additional: additional ) - return AttributeBuilder.renderTag("progress", attributes: attributes) + return AttributeBuilder.buildMarkupTag("progress", attributes: attributes) } } diff --git a/Sources/WebUI/Elements/Media/Audio/Audio.swift b/Sources/WebUI/Elements/Media/Audio/Audio.swift index 6c25b30a..ea63f0de 100644 --- a/Sources/WebUI/Elements/Media/Audio/Audio.swift +++ b/Sources/WebUI/Elements/Media/Audio/Audio.swift @@ -34,7 +34,7 @@ public struct Audio: Element { /// - autoplay: Automatically starts playback if true, optional. /// - loop: Repeats audio playback if true, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the audio player. + /// - classes: An array of stylesheet classnames for styling the audio player. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the audio player. @@ -73,11 +73,11 @@ public struct Audio: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -104,10 +104,10 @@ public struct Audio: Element { { sourceAttributes.append(typeAttr) } - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "source", attributes: sourceAttributes, hasNoClosingTag: true) }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "audio", attributes: attributes, content: diff --git a/Sources/WebUI/Elements/Media/Image/Figure.swift b/Sources/WebUI/Elements/Media/Image/Figure.swift index 54df9211..049fcf91 100644 --- a/Sources/WebUI/Elements/Media/Image/Figure.swift +++ b/Sources/WebUI/Elements/Media/Image/Figure.swift @@ -31,7 +31,7 @@ public struct Figure: Element { /// - description: Text for the figcaption and alt text for accessibility. /// - size: Picture size dimensions, optional. /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames. + /// - classes: An array of stylesheet classnames. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element. /// - data: Dictionary of `data-*` attributes for element relevant storing data. @@ -70,11 +70,11 @@ public struct Figure: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -84,9 +84,9 @@ public struct Figure: Element { ) let pictureElement = renderPictureElement() - let figcaptionElement = AttributeBuilder.renderTag( + let figcaptionElement = AttributeBuilder.buildMarkupTag( "figcaption", attributes: [], content: description) - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "figure", attributes: attributes, content: pictureElement + figcaptionElement) } @@ -103,7 +103,7 @@ public struct Figure: Element { if let srcsetAttr = Attribute.string("srcset", source.src) { sourceAttributes.append(srcsetAttr) } - content += AttributeBuilder.renderTag( + content += AttributeBuilder.buildMarkupTag( "source", attributes: sourceAttributes, hasNoClosingTag: true @@ -131,9 +131,9 @@ public struct Figure: Element { } } - content += AttributeBuilder.renderTag( + content += AttributeBuilder.buildMarkupTag( "img", attributes: imgAttributes, isSelfClosing: true) - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "picture", attributes: [], content: content) } } diff --git a/Sources/WebUI/Elements/Media/Image/Image.swift b/Sources/WebUI/Elements/Media/Image/Image.swift index b3044db1..4fe5057d 100644 --- a/Sources/WebUI/Elements/Media/Image/Image.swift +++ b/Sources/WebUI/Elements/Media/Image/Image.swift @@ -34,7 +34,7 @@ public struct Image: Element { /// - type: The MIME type of the image, optional. /// - size: The size of the image in pixels, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the image. + /// - classes: An array of stylesheet classnames for styling the image. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when alt text isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the image. @@ -60,11 +60,11 @@ public struct Image: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -93,7 +93,7 @@ public struct Image: Element { attributes.append(heightAttr) } } - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "img", attributes: attributes, isSelfClosing: true) } } diff --git a/Sources/WebUI/Elements/Media/Image/Picture.swift b/Sources/WebUI/Elements/Media/Image/Picture.swift index cab82cde..fa4ed8e9 100644 --- a/Sources/WebUI/Elements/Media/Image/Picture.swift +++ b/Sources/WebUI/Elements/Media/Image/Picture.swift @@ -28,7 +28,7 @@ public struct Picture: Element { /// - description: Alt text for accessibility. /// - size: Picture size dimensions, optional. /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames. + /// - classes: An array of stylesheet classnames. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element. /// - data: Dictionary of `data-*` attributes for element relevant storing data. @@ -64,11 +64,11 @@ public struct Picture: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -90,7 +90,7 @@ public struct Picture: Element { if let srcsetAttr = Attribute.string("srcset", source.src) { sourceAttributes.append(srcsetAttr) } - content += AttributeBuilder.renderTag( + content += AttributeBuilder.buildMarkupTag( "source", attributes: sourceAttributes, isSelfClosing: true @@ -109,7 +109,7 @@ public struct Picture: Element { data: data ).render() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "picture", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Media/SystemImage.swift b/Sources/WebUI/Elements/Media/SystemImage.swift index 4558b9ba..8ac3ee4d 100644 --- a/Sources/WebUI/Elements/Media/SystemImage.swift +++ b/Sources/WebUI/Elements/Media/SystemImage.swift @@ -24,7 +24,7 @@ public struct SystemImage: Element { /// - Parameters: /// - name: The name of the system image/icon. /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames for styling the icon. + /// - classes: An array of stylesheet classnames for styling the icon. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the icon for accessibility. /// - data: Dictionary of `data-*` attributes for storing custom data. @@ -44,11 +44,11 @@ public struct SystemImage: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { // Combine base icon classes with custom classes var allClasses = ["system-image", "icon-\(name.replacingOccurrences(of: ".", with: "-"))"] if let classes = classes { @@ -63,9 +63,9 @@ public struct SystemImage: Element { data: data ) - // Render as a span with CSS classes for icon fonts/CSS icons + // Render as a span with stylesheet classes for icon fonts/CSS icons // This allows flexibility for different icon systems (Font Awesome, Feather, etc.) - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "span", attributes: attributes, content: "" ) } diff --git a/Sources/WebUI/Elements/Media/Video/Video.swift b/Sources/WebUI/Elements/Media/Video/Video.swift index 347d085b..d5dc6461 100644 --- a/Sources/WebUI/Elements/Media/Video/Video.swift +++ b/Sources/WebUI/Elements/Media/Video/Video.swift @@ -37,7 +37,7 @@ public struct Video: Element { /// - loop: Repeats video playback if true, optional. /// - size: Video size dimensions, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the video player. + /// - classes: An array of stylesheet classnames for styling the video player. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the video player. @@ -80,11 +80,11 @@ public struct Video: Element { self.data = data } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -121,10 +121,10 @@ public struct Video: Element { { sourceAttributes.append(typeAttr) } - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "source", attributes: sourceAttributes, hasNoClosingTag: true) }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "video", attributes: attributes, content: diff --git a/Sources/WebUI/Elements/Structure/Layout/Article.swift b/Sources/WebUI/Elements/Structure/Layout/Article.swift index 42de27b9..7680adea 100644 --- a/Sources/WebUI/Elements/Structure/Layout/Article.swift +++ b/Sources/WebUI/Elements/Structure/Layout/Article.swift @@ -20,13 +20,13 @@ public struct Article: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML article element for self-contained content. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for linking and scripting. - /// - classes: An array of CSS classnames for styling the article. + /// - classes: An array of stylesheet classnames for styling the article. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the article. @@ -45,7 +45,7 @@ public struct Article: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -55,11 +55,11 @@ public struct Article: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -69,7 +69,7 @@ public struct Article: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "article", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/Layout/Aside.swift b/Sources/WebUI/Elements/Structure/Layout/Aside.swift index d80cc18b..9f7b74cf 100644 --- a/Sources/WebUI/Elements/Structure/Layout/Aside.swift +++ b/Sources/WebUI/Elements/Structure/Layout/Aside.swift @@ -23,13 +23,13 @@ public struct Aside: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML aside element. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for styling and scripting. - /// - classes: An array of CSS classnames for styling the aside container. + /// - classes: An array of stylesheet classnames for styling the aside container. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element's purpose (e.g., "Related Content"). /// - data: Dictionary of `data-*` attributes for storing custom data related to the aside. @@ -48,7 +48,7 @@ public struct Aside: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -58,11 +58,11 @@ public struct Aside: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -72,7 +72,7 @@ public struct Aside: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "aside", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/Layout/Footer.swift b/Sources/WebUI/Elements/Structure/Layout/Footer.swift index 1d54f5da..0c840ca6 100644 --- a/Sources/WebUI/Elements/Structure/Layout/Footer.swift +++ b/Sources/WebUI/Elements/Structure/Layout/Footer.swift @@ -20,13 +20,13 @@ public struct Footer: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML footer element. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for styling and scripting. - /// - classes: An array of CSS classnames for styling the footer. + /// - classes: An array of stylesheet classnames for styling the footer. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element's purpose (e.g., "Page Footer"). /// - data: Dictionary of `data-*` attributes for storing custom data related to the footer. @@ -48,7 +48,7 @@ public struct Footer: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -58,11 +58,11 @@ public struct Footer: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -72,7 +72,7 @@ public struct Footer: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "footer", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/Layout/Header.swift b/Sources/WebUI/Elements/Structure/Layout/Header.swift index f2cf313c..a562d2e8 100644 --- a/Sources/WebUI/Elements/Structure/Layout/Header.swift +++ b/Sources/WebUI/Elements/Structure/Layout/Header.swift @@ -22,13 +22,13 @@ public struct Header: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML header element. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for styling and scripting. - /// - classes: An array of CSS classnames for styling the header. + /// - classes: An array of stylesheet classnames for styling the header. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the header. @@ -46,7 +46,7 @@ public struct Header: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -56,11 +56,11 @@ public struct Header: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -70,7 +70,7 @@ public struct Header: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "header", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/Layout/MainElement.swift b/Sources/WebUI/Elements/Structure/Layout/MainElement.swift index d646bf81..00506745 100644 --- a/Sources/WebUI/Elements/Structure/Layout/MainElement.swift +++ b/Sources/WebUI/Elements/Structure/Layout/MainElement.swift @@ -21,13 +21,13 @@ public struct Main: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML main element. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for styling and scripting. - /// - classes: An array of CSS classnames for styling the main content area. + /// - classes: An array of stylesheet classnames for styling the main content area. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element's purpose (e.g., "Main Content"). /// - data: Dictionary of `data-*` attributes for storing custom data related to the main content. @@ -48,7 +48,7 @@ public struct Main: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -58,11 +58,11 @@ public struct Main: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -72,7 +72,7 @@ public struct Main: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "main", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/Layout/Navigation.swift b/Sources/WebUI/Elements/Structure/Layout/Navigation.swift index 3b0876f4..ccb9b4d4 100644 --- a/Sources/WebUI/Elements/Structure/Layout/Navigation.swift +++ b/Sources/WebUI/Elements/Structure/Layout/Navigation.swift @@ -20,13 +20,13 @@ public struct Navigation: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML navigation element. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for styling and scripting. - /// - classes: An array of CSS classnames for styling the navigation container. + /// - classes: An array of stylesheet classnames for styling the navigation container. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element's purpose (e.g., "Main Navigation"). /// - data: Dictionary of `data-*` attributes for storing custom data related to navigation. @@ -45,7 +45,7 @@ public struct Navigation: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -55,11 +55,11 @@ public struct Navigation: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -69,7 +69,7 @@ public struct Navigation: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "nav", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/Layout/Section.swift b/Sources/WebUI/Elements/Structure/Layout/Section.swift index 28c3207a..92ef2713 100644 --- a/Sources/WebUI/Elements/Structure/Layout/Section.swift +++ b/Sources/WebUI/Elements/Structure/Layout/Section.swift @@ -21,13 +21,13 @@ public struct Section: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML section element for thematic content grouping. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for navigation and linking. - /// - classes: An array of CSS classnames for styling the section. + /// - classes: An array of stylesheet classnames for styling the section. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element's purpose for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the section. @@ -46,7 +46,7 @@ public struct Section: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -56,11 +56,11 @@ public struct Section: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -70,7 +70,7 @@ public struct Section: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "section", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/List/Item.swift b/Sources/WebUI/Elements/Structure/List/Item.swift index 435207e1..88356193 100644 --- a/Sources/WebUI/Elements/Structure/List/Item.swift +++ b/Sources/WebUI/Elements/Structure/List/Item.swift @@ -1,7 +1,7 @@ /// Generates an HTML list item element (`
  • `). /// /// `Item` elements should be used as children of a `List` element to represent -/// individual entries in a list. Each item can contain any HTML content. +/// individual entries in a list. Each item can contain any markup content. /// /// ## Example /// ```swift @@ -17,13 +17,13 @@ public struct Item: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML list item element. /// /// - Parameters: /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames for styling the list item. + /// - classes: An array of stylesheet classnames for styling the list item. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data. @@ -41,7 +41,7 @@ public struct Item: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -51,11 +51,11 @@ public struct Item: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -65,7 +65,7 @@ public struct Item: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "li", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/List/List.swift b/Sources/WebUI/Elements/Structure/List/List.swift index f9d3f1ac..7fe82d40 100644 --- a/Sources/WebUI/Elements/Structure/List/List.swift +++ b/Sources/WebUI/Elements/Structure/List/List.swift @@ -22,7 +22,7 @@ public struct List: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML list element (`
      ` or `
        `). /// @@ -30,7 +30,7 @@ public struct List: Element { /// - type: List type (ordered or unordered), defaults to unordered. /// - style: List style (disc, circle, or square), defaults to none. /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames for styling the list. + /// - classes: An array of stylesheet classnames for styling the list. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data. @@ -51,7 +51,7 @@ public struct List: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.type = type self.style = style @@ -63,11 +63,11 @@ public struct List: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let combinedClasses = (classes ?? []) + (style != .none ? ["list-\(style.rawValue)"] : []) @@ -81,7 +81,7 @@ public struct List: Element { let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( type.rawValue, attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Structure/Stack.swift b/Sources/WebUI/Elements/Structure/Stack.swift index 9923270c..6969b4bd 100644 --- a/Sources/WebUI/Elements/Structure/Stack.swift +++ b/Sources/WebUI/Elements/Structure/Stack.swift @@ -26,13 +26,13 @@ public struct Stack: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML div element for generic content grouping. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for styling and scripting. - /// - classes: An array of CSS classnames for styling the div container. + /// - classes: An array of stylesheet classnames for styling the div container. /// - role: ARIA role of the element for accessibility and screen readers. /// - label: ARIA label to describe the element's purpose for screen readers. /// - data: Dictionary of `data-*` attributes for storing custom data related to the container. @@ -52,7 +52,7 @@ public struct Stack: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -62,11 +62,11 @@ public struct Stack: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -76,7 +76,7 @@ public struct Stack: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "div", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Abbreviation.swift b/Sources/WebUI/Elements/Text/Abbreviation.swift index a8bc5473..873b73d1 100644 --- a/Sources/WebUI/Elements/Text/Abbreviation.swift +++ b/Sources/WebUI/Elements/Text/Abbreviation.swift @@ -19,14 +19,14 @@ public struct Abbreviation: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML abbreviation element. /// /// - Parameters: /// - title: The full term or explanation of the abbreviation. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the abbreviation. + /// - classes: An array of stylesheet classnames for styling the abbreviation. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the abbreviation. @@ -48,7 +48,7 @@ public struct Abbreviation: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.fullTitle = title self.id = id @@ -59,11 +59,11 @@ public struct Abbreviation: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let titleAttr = Attribute.string("title", fullTitle) { additional.append(titleAttr) @@ -77,7 +77,7 @@ public struct Abbreviation: Element { additional: additional ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "abbr", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Code.swift b/Sources/WebUI/Elements/Text/Code.swift index c35a4bd8..08d447e3 100644 --- a/Sources/WebUI/Elements/Text/Code.swift +++ b/Sources/WebUI/Elements/Text/Code.swift @@ -10,7 +10,7 @@ public struct Code: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML code element with string content. /// @@ -19,7 +19,7 @@ public struct Code: Element { /// - Parameters: /// - content: The code snippet to display. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the code element. + /// - classes: An array of stylesheet classnames for styling the code element. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the code element. @@ -49,7 +49,7 @@ public struct Code: Element { /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the code element. + /// - classes: An array of stylesheet classnames for styling the code element. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the code element. @@ -68,7 +68,7 @@ public struct Code: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -78,11 +78,11 @@ public struct Code: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -91,7 +91,7 @@ public struct Code: Element { data: data ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "code", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Emphasis.swift b/Sources/WebUI/Elements/Text/Emphasis.swift index 9f7740a6..eeb68ec4 100644 --- a/Sources/WebUI/Elements/Text/Emphasis.swift +++ b/Sources/WebUI/Elements/Text/Emphasis.swift @@ -1,6 +1,6 @@ import Foundation -/// Creates HTML emphasis elements for highlighting important text. +/// Creates markup emphasis elements for highlighting important text. /// /// Represents emphasized text with semantic importance, typically displayed in italics. /// Emphasis elements are used to draw attention to text within another body of text @@ -11,16 +11,16 @@ public struct Emphasis: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder - /// Creates a new HTML emphasis element with string content. + /// Creates a new markup emphasis element with string content. /// /// This is the preferred SwiftUI-like initializer for creating emphasized text. /// /// - Parameters: /// - content: The text content to be emphasized. - /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the emphasized text. + /// - id: Unique identifier for the markup element, useful for JavaScript interaction and styling. + /// - classes: An array of stylesheet classnames for styling the emphasized text. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the element. @@ -46,11 +46,11 @@ public struct Emphasis: Element { self.contentBuilder = { [content] } } - /// Creates a new HTML emphasis element using HTMLBuilder closure syntax. + /// Creates a new markup emphasis element using MarkupBuilder closure syntax. /// /// - Parameters: - /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the emphasized text. + /// - id: Unique identifier for the markup element, useful for JavaScript interaction and styling. + /// - classes: An array of stylesheet classnames for styling the emphasized text. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the element. @@ -69,7 +69,7 @@ public struct Emphasis: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -79,11 +79,11 @@ public struct Emphasis: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -93,7 +93,7 @@ public struct Emphasis: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "em", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Heading/Heading.swift b/Sources/WebUI/Elements/Text/Heading/Heading.swift index cbe437c4..cd7c73bb 100644 --- a/Sources/WebUI/Elements/Text/Heading/Heading.swift +++ b/Sources/WebUI/Elements/Text/Heading/Heading.swift @@ -12,7 +12,7 @@ public struct Heading: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML heading element with string title. /// @@ -22,7 +22,7 @@ public struct Heading: Element { /// - level: Heading level (.largeTitle, .title, .headline, .subheadline, .body, or .footnote). /// - title: The heading text content. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the heading. + /// - classes: An array of stylesheet classnames for styling the heading. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the heading. @@ -56,7 +56,7 @@ public struct Heading: Element { /// - Parameters: /// - level: Heading level (.largeTitle, .title, .headline, .subheadline, .body, or .footnote). /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the heading. + /// - classes: An array of stylesheet classnames for styling the heading. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the heading. @@ -76,7 +76,7 @@ public struct Heading: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.level = level self.id = id @@ -87,11 +87,11 @@ public struct Heading: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -101,7 +101,7 @@ public struct Heading: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( level.rawValue, attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Link.swift b/Sources/WebUI/Elements/Text/Link.swift index 519ec1b5..cfb735c9 100644 --- a/Sources/WebUI/Elements/Text/Link.swift +++ b/Sources/WebUI/Elements/Text/Link.swift @@ -13,7 +13,7 @@ public struct Link: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML anchor link with string title. /// @@ -24,7 +24,7 @@ public struct Link: Element { /// - destination: URL or path the link points to. /// - newTab: Opens in a new tab if true, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the link. + /// - classes: An array of stylesheet classnames for styling the link. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when link text isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the link. @@ -64,7 +64,7 @@ public struct Link: Element { /// - to: URL or path the link points to. /// - newTab: Opens in a new tab if true, optional. /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the link. + /// - classes: An array of stylesheet classnames for styling the link. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when link text isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the link. @@ -84,7 +84,7 @@ public struct Link: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.destination = destination self.newTab = newTab @@ -96,11 +96,11 @@ public struct Link: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -116,7 +116,7 @@ public struct Link: Element { attributes.append("rel=\"noreferrer\"") } let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "a", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Preformatted.swift b/Sources/WebUI/Elements/Text/Preformatted.swift index 52e3580b..63cdb77f 100644 --- a/Sources/WebUI/Elements/Text/Preformatted.swift +++ b/Sources/WebUI/Elements/Text/Preformatted.swift @@ -23,13 +23,13 @@ public struct Preformatted: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML preformatted element. /// /// - Parameters: /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the preformatted text. + /// - classes: An array of stylesheet classnames for styling the preformatted text. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the element. @@ -55,7 +55,7 @@ public struct Preformatted: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -65,11 +65,11 @@ public struct Preformatted: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -78,7 +78,7 @@ public struct Preformatted: Element { data: data ) let content = HTMLEscaper.escapeContent(contentBuilder().map { $0.render() }.joined()) - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "pre", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Strong.swift b/Sources/WebUI/Elements/Text/Strong.swift index dbcef7c4..adf020b0 100644 --- a/Sources/WebUI/Elements/Text/Strong.swift +++ b/Sources/WebUI/Elements/Text/Strong.swift @@ -1,6 +1,6 @@ import Foundation -/// Creates HTML strong emphasis elements. +/// Creates markup strong emphasis elements. /// /// Represents text with strong emphasis or importance, typically displayed in bold by browsers. /// The `` element indicates content with high importance, seriousness, or urgency. @@ -17,16 +17,16 @@ public struct Strong: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder - /// Creates a new HTML strong element with string content. + /// Creates a new markup strong element with string content. /// /// This is the preferred SwiftUI-like initializer for creating strongly emphasized text. /// /// - Parameters: /// - content: The text content to be strongly emphasized. - /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the emphasized text. + /// - id: Unique identifier for the markup element, useful for JavaScript interaction and styling. + /// - classes: An array of stylesheet classnames for styling the emphasized text. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the element. @@ -52,11 +52,11 @@ public struct Strong: Element { self.contentBuilder = { [content] } } - /// Creates a new HTML strong element using HTMLBuilder closure syntax. + /// Creates a new markup strong element using MarkupBuilder closure syntax. /// /// - Parameters: - /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the emphasized text. + /// - id: Unique identifier for the markup element, useful for JavaScript interaction and styling. + /// - classes: An array of stylesheet classnames for styling the emphasized text. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the element. @@ -77,7 +77,7 @@ public struct Strong: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.id = id self.classes = classes @@ -87,11 +87,11 @@ public struct Strong: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let attributes = AttributeBuilder.buildAttributes( id: id, classes: classes, @@ -101,7 +101,7 @@ public struct Strong: Element { ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "strong", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Elements/Text/Text.swift b/Sources/WebUI/Elements/Text/Text.swift index c9867f83..eb59973c 100644 --- a/Sources/WebUI/Elements/Text/Text.swift +++ b/Sources/WebUI/Elements/Text/Text.swift @@ -1,6 +1,6 @@ import Foundation -/// Generates HTML text elements as `

        ` or `` based on content. +/// Generates markup text elements as `

        ` or `` based on content. /// /// Paragraphs are for long form content with multiple sentences and /// a `` tag is used for a single sentence of text and grouping inline content. @@ -10,7 +10,7 @@ public struct Text: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new text element with string content. /// @@ -19,8 +19,8 @@ public struct Text: Element { /// /// - Parameters: /// - content: The text content to display. - /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames. + /// - id: Unique identifier for the markup element. + /// - classes: An array of stylesheet classnames. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element. /// - data: Dictionary of `data-*` attributes for element relevant storing data. @@ -46,13 +46,13 @@ public struct Text: Element { self.contentBuilder = { [content] } } - /// Creates a new text element using HTMLBuilder closure syntax. + /// Creates a new text element using MarkupBuilder closure syntax. /// /// Uses `

        ` for multiple sentences, `` for one or fewer. /// /// - Parameters: - /// - id: Unique identifier for the HTML element. - /// - classes: An array of CSS classnames. + /// - id: Unique identifier for the markup element. + /// - classes: An array of stylesheet classnames. /// - role: ARIA role of the element for accessibility. /// - label: ARIA label to describe the element. /// - data: Dictionary of `data-*` attributes for element relevant storing data. @@ -68,7 +68,7 @@ public struct Text: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder + @MarkupBuilder content: @escaping MarkupContentBuilder ) { self.id = id self.classes = classes @@ -78,11 +78,11 @@ public struct Text: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { let renderedContent = contentBuilder().map { $0.render() }.joined() let sentenceCount = renderedContent.components( separatedBy: CharacterSet(charactersIn: ".!?") diff --git a/Sources/WebUI/Elements/Text/Time.swift b/Sources/WebUI/Elements/Text/Time.swift index 67632a2e..adada6b5 100644 --- a/Sources/WebUI/Elements/Text/Time.swift +++ b/Sources/WebUI/Elements/Text/Time.swift @@ -20,14 +20,14 @@ public struct Time: Element { private let role: AriaRole? private let label: String? private let data: [String: String]? - private let contentBuilder: HTMLContentBuilder + private let contentBuilder: MarkupContentBuilder /// Creates a new HTML time element. /// /// - Parameters: /// - datetime: The machine-readable timestamp in a valid format (ISO 8601 recommended). /// - id: Unique identifier for the HTML element, useful for JavaScript interaction and styling. - /// - classes: An array of CSS classnames for styling the time element. + /// - classes: An array of stylesheet classnames for styling the time element. /// - role: ARIA role of the element for accessibility, enhancing screen reader interpretation. /// - label: ARIA label to describe the element for accessibility when context isn't sufficient. /// - data: Dictionary of `data-*` attributes for storing custom data relevant to the time element. @@ -49,7 +49,7 @@ public struct Time: Element { role: AriaRole? = nil, label: String? = nil, data: [String: String]? = nil, - @HTMLBuilder content: @escaping HTMLContentBuilder = { [] } + @MarkupBuilder content: @escaping MarkupContentBuilder = { [] } ) { self.datetime = datetime self.id = id @@ -60,11 +60,11 @@ public struct Time: Element { self.contentBuilder = content } - public var body: some HTML { - HTMLString(content: renderTag()) + public var body: some Markup { + MarkupString(content: buildMarkupTag()) } - private func renderTag() -> String { + private func buildMarkupTag() -> String { var additional: [String] = [] if let datetimeAttr = Attribute.string("datetime", datetime) { additional.append(datetimeAttr) @@ -78,7 +78,7 @@ public struct Time: Element { additional: additional ) let content = contentBuilder().map { $0.render() }.joined() - return AttributeBuilder.renderTag( + return AttributeBuilder.buildMarkupTag( "time", attributes: attributes, content: content) } } diff --git a/Sources/WebUI/Styles/Color/BackgroundStyleOperation.swift b/Sources/WebUI/Styles/Color/BackgroundStyleOperation.swift index 353ced69..d844d124 100644 --- a/Sources/WebUI/Styles/Color/BackgroundStyleOperation.swift +++ b/Sources/WebUI/Styles/Color/BackgroundStyleOperation.swift @@ -29,10 +29,10 @@ public struct BackgroundStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the background style and returns the appropriate CSS classes + /// Applies the background style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for background styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { ["bg-\(params.color.rawValue)"] } @@ -45,7 +45,7 @@ public struct BackgroundStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide background styling -extension HTML { +extension Markup { /// Applies background color to the element. /// /// Adds a background color class based on the provided color and optional modifiers. @@ -70,7 +70,7 @@ extension HTML { public func background( color: Color, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = BackgroundStyleOperation.Parameters(color: color) return BackgroundStyleOperation.shared.applyTo( diff --git a/Sources/WebUI/Styles/Effects/Border/BorderRadiusStyleOperation.swift b/Sources/WebUI/Styles/Effects/Border/BorderRadiusStyleOperation.swift index e4354c0d..5b68d851 100644 --- a/Sources/WebUI/Styles/Effects/Border/BorderRadiusStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/Border/BorderRadiusStyleOperation.swift @@ -38,10 +38,10 @@ public struct BorderRadiusStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the border radius style and returns the appropriate CSS classes + /// Applies the border radius style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for border radius styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] let size = params.size @@ -65,7 +65,7 @@ public struct BorderRadiusStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide border radius styling -extension HTML { +extension Markup { /// Applies border radius styling to the element. /// /// - Parameters: @@ -87,7 +87,7 @@ extension HTML { _ size: RadiusSize? = .md, _ sides: RadiusSide..., on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = BorderRadiusStyleOperation.Parameters( size: size, sides: sides diff --git a/Sources/WebUI/Styles/Effects/Border/BorderStyleOperation.swift b/Sources/WebUI/Styles/Effects/Border/BorderStyleOperation.swift index 4260abfb..460df0ba 100644 --- a/Sources/WebUI/Styles/Effects/Border/BorderStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/Border/BorderStyleOperation.swift @@ -52,10 +52,10 @@ public struct BorderStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the border style and returns the appropriate CSS classes + /// Applies the border style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for border styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] let width = params.width @@ -100,7 +100,7 @@ public struct BorderStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide border styling -extension HTML { +extension Markup { /// Applies border styling to the element with specified attributes. /// /// Adds borders with custom width, style, and color to specified edges of an element. @@ -125,7 +125,7 @@ extension HTML { style: BorderStyle? = nil, color: Color? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = BorderStyleOperation.Parameters( width: width, edges: edges, diff --git a/Sources/WebUI/Styles/Effects/Border/EdgeInsets.swift b/Sources/WebUI/Styles/Effects/Border/EdgeInsets.swift index 173be3f2..552efa5b 100644 --- a/Sources/WebUI/Styles/Effects/Border/EdgeInsets.swift +++ b/Sources/WebUI/Styles/Effects/Border/EdgeInsets.swift @@ -64,13 +64,13 @@ public struct EdgeInsets: Sendable, Equatable { // MARK: - Margin and Padding Style API -extension HTML { +extension Markup { /// Applies margin styling to the element using edge insets. /// /// - Parameters: /// - insets: The edge insets to apply as margins. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated margin classes. + /// - Returns: Markup with updated margin classes. /// /// ## Example /// ```swift @@ -79,7 +79,7 @@ extension HTML { public func margins( _ insets: EdgeInsets, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let classes = EdgeInsets.marginClasses(from: insets) let newClasses = StyleUtilities.combineClasses(classes, withModifiers: modifiers) return StyleModifier(content: self, classes: newClasses) @@ -90,7 +90,7 @@ extension HTML { /// - Parameters: /// - insets: The edge insets to apply as padding. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated padding classes. + /// - Returns: Markup with updated padding classes. /// /// ## Example /// ```swift @@ -99,7 +99,7 @@ extension HTML { public func padding( _ insets: EdgeInsets, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let classes = EdgeInsets.paddingClasses(from: insets) let newClasses = StyleUtilities.combineClasses(classes, withModifiers: modifiers) return StyleModifier(content: self, classes: newClasses) diff --git a/Sources/WebUI/Styles/Effects/OpacityStyleOperation.swift b/Sources/WebUI/Styles/Effects/OpacityStyleOperation.swift index 5d2a0534..88b0c83d 100644 --- a/Sources/WebUI/Styles/Effects/OpacityStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/OpacityStyleOperation.swift @@ -28,10 +28,10 @@ public struct OpacityStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the opacity style and returns the appropriate CSS classes + /// Applies the opacity style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for opacity styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { ["opacity-\(params.value)"] } @@ -44,13 +44,13 @@ public struct OpacityStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide opacity styling -extension HTML { +extension Markup { /// Sets the opacity of the element with optional modifiers. /// /// - Parameters: /// - value: The opacity value, typically between 0 and 100. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated opacity classes including applied modifiers. + /// - Returns: Markup with updated opacity classes including applied modifiers. /// /// ## Example /// ```swift @@ -61,7 +61,7 @@ extension HTML { public func opacity( _ value: Int, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = OpacityStyleOperation.Parameters(value: value) return OpacityStyleOperation.shared.applyTo( diff --git a/Sources/WebUI/Styles/Effects/OutlineStyleOperation.swift b/Sources/WebUI/Styles/Effects/OutlineStyleOperation.swift index cfb4efdf..7cc44ae2 100644 --- a/Sources/WebUI/Styles/Effects/OutlineStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/OutlineStyleOperation.swift @@ -52,10 +52,10 @@ public struct OutlineStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the outline style and returns the appropriate CSS classes + /// Applies the outline style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for outline styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -90,7 +90,7 @@ public struct OutlineStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide outline styling -extension HTML { +extension Markup { /// Sets outline properties with optional modifiers. /// /// - Parameters: @@ -99,7 +99,7 @@ extension HTML { /// - color: The outline color. /// - offset: The outline offset in pixels. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated outline classes. + /// - Returns: Markup with updated outline classes. /// /// ## Example /// ```swift @@ -118,7 +118,7 @@ extension HTML { color: Color? = nil, offset: Int? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = OutlineStyleOperation.Parameters( width: width, style: style, diff --git a/Sources/WebUI/Styles/Effects/RingStyleOperation.swift b/Sources/WebUI/Styles/Effects/RingStyleOperation.swift index f09b7178..5665907b 100644 --- a/Sources/WebUI/Styles/Effects/RingStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/RingStyleOperation.swift @@ -45,10 +45,10 @@ public struct RingStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the ring style and returns the appropriate CSS classes + /// Applies the ring style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for ring styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] let size = params.size ?? 1 @@ -71,7 +71,7 @@ public struct RingStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide ring styling -extension HTML { +extension Markup { /// Applies ring styling to the element with specified attributes. /// /// Adds rings with custom width, style, and color to specified edges of an element. @@ -80,7 +80,7 @@ extension HTML { /// - size: The width of the ring. /// - color: The ring color. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated ring classes. + /// - Returns: Markup with updated ring classes. /// /// ## Example /// ```swift @@ -92,7 +92,7 @@ extension HTML { size: Int = 1, color: Color? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = RingStyleOperation.Parameters( size: size, color: color diff --git a/Sources/WebUI/Styles/Effects/Shadow/ShadowStyleOperation.swift b/Sources/WebUI/Styles/Effects/Shadow/ShadowStyleOperation.swift index 1c0b7901..9dad5e78 100644 --- a/Sources/WebUI/Styles/Effects/Shadow/ShadowStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/Shadow/ShadowStyleOperation.swift @@ -38,10 +38,10 @@ public struct ShadowStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the shadow style and returns the appropriate CSS classes + /// Applies the shadow style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for shadow styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] let size = params.size ?? ShadowSize.md @@ -64,7 +64,7 @@ public struct ShadowStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide shadow styling -extension HTML { +extension Markup { /// Applies shadow styling to the element with specified attributes. /// /// Adds shadows with custom size and color to an element. @@ -73,7 +73,7 @@ extension HTML { /// - size: The shadow size (sm, md, lg). /// - color: The shadow color. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated shadow classes. + /// - Returns: Markup with updated shadow classes. /// /// ## Example /// ```swift @@ -85,7 +85,7 @@ extension HTML { size: ShadowSize, color: Color? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = ShadowStyleOperation.Parameters( size: size, color: color diff --git a/Sources/WebUI/Styles/Effects/TransformStyleOperation.swift b/Sources/WebUI/Styles/Effects/TransformStyleOperation.swift index 85af0cfe..dbf2af2b 100644 --- a/Sources/WebUI/Styles/Effects/TransformStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/TransformStyleOperation.swift @@ -52,10 +52,10 @@ public struct TransformStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the transform style and returns the appropriate CSS classes + /// Applies the transform style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for transform styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = ["transform"] @@ -100,7 +100,7 @@ public struct TransformStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide transform styling -extension HTML { +extension Markup { /// Applies transformation styling to the element. /// /// Adds classes for scaling, rotating, translating, and skewing, optionally scoped to modifiers. @@ -119,7 +119,7 @@ extension HTML { translate: (x: Int?, y: Int?)? = nil, skew: (x: Int?, y: Int?)? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = TransformStyleOperation.Parameters( scale: scale, rotate: rotate, diff --git a/Sources/WebUI/Styles/Effects/Transition/TransitionStyleOperation.swift b/Sources/WebUI/Styles/Effects/Transition/TransitionStyleOperation.swift index 23bb6600..45d207c7 100644 --- a/Sources/WebUI/Styles/Effects/Transition/TransitionStyleOperation.swift +++ b/Sources/WebUI/Styles/Effects/Transition/TransitionStyleOperation.swift @@ -52,10 +52,10 @@ public struct TransitionStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the transition style and returns the appropriate CSS classes + /// Applies the transition style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for transition styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -88,7 +88,7 @@ public struct TransitionStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide transition styling -extension HTML { +extension Markup { /// Applies transition styling to the element. /// /// Adds classes for animating properties with duration, easing, and delay. @@ -106,7 +106,7 @@ extension HTML { easing: Easing? = nil, delay: Int? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = TransitionStyleOperation.Parameters( property: property, duration: duration, diff --git a/Sources/WebUI/Styles/Interactivity/CursorStyleOperation.swift b/Sources/WebUI/Styles/Interactivity/CursorStyleOperation.swift index e75c1304..f9fb1ce3 100644 --- a/Sources/WebUI/Styles/Interactivity/CursorStyleOperation.swift +++ b/Sources/WebUI/Styles/Interactivity/CursorStyleOperation.swift @@ -38,10 +38,10 @@ public struct CursorStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the cursor style and returns the appropriate CSS classes + /// Applies the cursor style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for cursor styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { ["cursor-\(params.type.rawValue)"] } @@ -54,7 +54,7 @@ public struct CursorStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide cursor styling -extension HTML { +extension Markup { /// Sets the cursor style of the element with optional modifiers. /// /// - Parameters: @@ -73,7 +73,7 @@ extension HTML { public func cursor( _ type: CursorType, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = CursorStyleOperation.Parameters(type: type) return CursorStyleOperation.shared.applyTo( diff --git a/Sources/WebUI/Styles/Layout/Display/DisplayStyleOperation.swift b/Sources/WebUI/Styles/Layout/Display/DisplayStyleOperation.swift index 92c3300f..54ce1d84 100644 --- a/Sources/WebUI/Styles/Layout/Display/DisplayStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Display/DisplayStyleOperation.swift @@ -28,10 +28,10 @@ public struct DisplayStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the display style and returns the appropriate CSS classes + /// Applies the display style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for display styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { ["display-\(params.type.rawValue)"] } @@ -44,7 +44,7 @@ public struct DisplayStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide display styling -extension HTML { +extension Markup { /// Sets the CSS display property with optional modifiers. /// /// - Parameters: @@ -66,7 +66,7 @@ extension HTML { public func display( _ type: DisplayType, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = DisplayStyleOperation.Parameters(type: type) return DisplayStyleOperation.shared.applyTo( diff --git a/Sources/WebUI/Styles/Layout/Display/DisplayTypes.swift b/Sources/WebUI/Styles/Layout/Display/DisplayTypes.swift index 21e9d6e1..440adf38 100644 --- a/Sources/WebUI/Styles/Layout/Display/DisplayTypes.swift +++ b/Sources/WebUI/Styles/Layout/Display/DisplayTypes.swift @@ -43,7 +43,7 @@ public enum Justify: String { /// Distributes items with equal space between and around them. case evenly - /// Provides the raw CSS class value. + /// Provides the raw stylesheet class value. public var rawValue: String { "justify-\(self)" } } diff --git a/Sources/WebUI/Styles/Layout/Display/FlexStyleOperation.swift b/Sources/WebUI/Styles/Layout/Display/FlexStyleOperation.swift index 7c165ed5..7fe5e7e2 100644 --- a/Sources/WebUI/Styles/Layout/Display/FlexStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Display/FlexStyleOperation.swift @@ -52,10 +52,10 @@ public struct FlexStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the flex style and returns the appropriate CSS classes + /// Applies the flex style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for flex styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -155,8 +155,8 @@ public enum FlexGrow: String { case one = "1" } -// Extension for HTML to provide flex styling -extension HTML { +// Extension for Markup to provide flex styling +extension Markup { /// Sets flex container properties with optional modifiers. /// /// - Parameters: @@ -165,7 +165,7 @@ extension HTML { /// - align: How to align items along the cross axis. /// - grow: The flex grow factor. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated flex classes. + /// - Returns: Markup with updated flex classes. /// /// ## Example /// @@ -185,7 +185,7 @@ extension HTML { align: FlexAlign? = nil, grow: FlexGrow? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = FlexStyleOperation.Parameters( direction: direction, justify: justify, diff --git a/Sources/WebUI/Styles/Layout/Display/GridStyleOperation.swift b/Sources/WebUI/Styles/Layout/Display/GridStyleOperation.swift index 1e258532..ca2f76cf 100644 --- a/Sources/WebUI/Styles/Layout/Display/GridStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Display/GridStyleOperation.swift @@ -59,10 +59,10 @@ public struct GridStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the grid style and returns the appropriate CSS classes + /// Applies the grid style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for grid styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes = ["grid"] @@ -112,7 +112,7 @@ public enum GridFlow: String { } // Extension for HTML to provide grid styling -extension HTML { +extension Markup { /// Sets grid container properties with optional modifiers. /// /// - Parameters: @@ -122,7 +122,7 @@ extension HTML { /// - columnSpan: The column span value. /// - rowSpan: The row span value. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated grid classes. + /// - Returns: Markup with updated grid classes. /// /// ## Example /// ```swift @@ -142,7 +142,7 @@ extension HTML { columnSpan: Int? = nil, rowSpan: Int? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = GridStyleOperation.Parameters( columns: columns, rows: rows, diff --git a/Sources/WebUI/Styles/Layout/Display/VisibilityStyleOperation.swift b/Sources/WebUI/Styles/Layout/Display/VisibilityStyleOperation.swift index abcfe582..8a1b1bc0 100644 --- a/Sources/WebUI/Styles/Layout/Display/VisibilityStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Display/VisibilityStyleOperation.swift @@ -28,10 +28,10 @@ public struct VisibilityStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the visibility style and returns the appropriate CSS classes + /// Applies the visibility style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for visibility styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { if params.isHidden { return ["hidden"] @@ -48,13 +48,13 @@ public struct VisibilityStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide visibility styling -extension HTML { +extension Markup { /// Controls the visibility of an element with optional modifiers. /// /// - Parameters: /// - isHidden: Whether the element should be hidden (default: true). /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated visibility classes. + /// - Returns: Markup with updated visibility classes. /// /// ## Example /// ```swift @@ -73,7 +73,7 @@ extension HTML { public func hidden( _ isHidden: Bool = true, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = VisibilityStyleOperation.Parameters(isHidden: isHidden) return VisibilityStyleOperation.shared.applyTo( @@ -88,7 +88,7 @@ extension HTML { /// This provides SwiftUI-style conditional visibility syntax. /// /// - Parameter condition: Boolean condition that determines whether to hide the element - /// - Returns: HTML with conditional visibility applied + /// - Returns: Markup with conditional visibility applied /// /// ## Example /// ```swift @@ -98,11 +98,11 @@ extension HTML { /// Button("Save") /// .hidden(when: !isEditing) /// ``` - public func hidden(when condition: Bool) -> AnyHTML { + public func hidden(when condition: Bool) -> AnyMarkup { if condition { - return AnyHTML(hidden(true)) + return AnyMarkup(hidden(true)) } else { - return AnyHTML(self) + return AnyMarkup(self) } } } diff --git a/Sources/WebUI/Styles/Layout/MarginsStyleOperation.swift b/Sources/WebUI/Styles/Layout/MarginsStyleOperation.swift index 3d99ba19..d955c916 100644 --- a/Sources/WebUI/Styles/Layout/MarginsStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/MarginsStyleOperation.swift @@ -45,10 +45,10 @@ public struct MarginsStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the margin style and returns the appropriate CSS classes + /// Applies the margin style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for margin styling - /// - Returns: An array of CSS class names to be applied + /// - Returns: An array of stylesheet class names to be applied public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -73,7 +73,7 @@ public struct MarginsStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide margin styling -extension HTML { +extension Markup { /// Applies margin styling to the element with one or more edges. /// /// - Parameters: @@ -81,13 +81,13 @@ extension HTML { /// - edges: One or more edges to apply the margin to. Defaults to `.all`. /// - auto: Whether to use automatic margins instead of a specific length. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated margin classes. + /// - Returns: Markup with updated margin classes. public func margins( of length: Int? = 4, at edges: Edge..., auto: Bool = false, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = MarginsStyleOperation.Parameters( length: length, edges: edges, diff --git a/Sources/WebUI/Styles/Layout/Overflow/OverflowStyleOperation.swift b/Sources/WebUI/Styles/Layout/Overflow/OverflowStyleOperation.swift index 3fbac00d..28fde332 100644 --- a/Sources/WebUI/Styles/Layout/Overflow/OverflowStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Overflow/OverflowStyleOperation.swift @@ -38,10 +38,10 @@ public struct OverflowStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the overflow style and returns the appropriate CSS classes + /// Applies the overflow style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for overflow styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { let axisString = params.axis.rawValue.isEmpty ? "" : "-\(params.axis.rawValue)" @@ -56,7 +56,7 @@ public struct OverflowStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide overflow styling -extension HTML { +extension Markup { /// Applies overflow styling to the element. /// /// Sets how overflowing content is handled, optionally on a specific axis and with modifiers. @@ -81,7 +81,7 @@ extension HTML { _ type: OverflowType, axis: Axis = .both, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = OverflowStyleOperation.Parameters( type: type, axis: axis diff --git a/Sources/WebUI/Styles/Layout/PaddingStyleOperation.swift b/Sources/WebUI/Styles/Layout/PaddingStyleOperation.swift index bb651a88..1bda0464 100644 --- a/Sources/WebUI/Styles/Layout/PaddingStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/PaddingStyleOperation.swift @@ -38,10 +38,10 @@ public struct PaddingStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the padding style and returns the appropriate CSS classes + /// Applies the padding style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for padding styling - /// - Returns: An array of CSS class names to be applied + /// - Returns: An array of stylesheet class names to be applied public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -65,7 +65,7 @@ public struct PaddingStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide padding styling -extension HTML { +extension Markup { /// Applies padding styling to the element with one or more edges. /// /// - Parameters: @@ -77,7 +77,7 @@ extension HTML { of length: Int? = 4, at edges: Edge..., on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = PaddingStyleOperation.Parameters( length: length, edges: edges diff --git a/Sources/WebUI/Styles/Layout/Position/PositionStyleOperation.swift b/Sources/WebUI/Styles/Layout/Position/PositionStyleOperation.swift index 71a5731e..512653d2 100644 --- a/Sources/WebUI/Styles/Layout/Position/PositionStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Position/PositionStyleOperation.swift @@ -45,10 +45,10 @@ public struct PositionStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the position style and returns the appropriate CSS classes + /// Applies the position style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for position styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -88,7 +88,7 @@ public struct PositionStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide position styling -extension HTML { +extension Markup { /// Applies positioning styling to the element with one or more edges. /// /// Sets the position type and optional inset values for specified edges, scoped to modifiers if provided. @@ -104,7 +104,7 @@ extension HTML { at edges: Edge..., offset length: Int? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = PositionStyleOperation.Parameters( type: type, edges: edges, diff --git a/Sources/WebUI/Styles/Layout/Scroll/ScrollStyleOperation.swift b/Sources/WebUI/Styles/Layout/Scroll/ScrollStyleOperation.swift index 11858fa0..33bc9c76 100644 --- a/Sources/WebUI/Styles/Layout/Scroll/ScrollStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Scroll/ScrollStyleOperation.swift @@ -66,10 +66,10 @@ public struct ScrollStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the scroll style and returns the appropriate CSS classes + /// Applies the scroll style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for scroll styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -146,10 +146,10 @@ public struct ScrollStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide scroll styling -extension HTML { +extension Markup { /// Applies scroll-related styles to the element. /// - /// Adds Tailwind CSS classes for scroll behavior, margin, padding, and snap properties. + /// Adds Tailwind stylesheet classes for scroll behavior, margin, padding, and snap properties. /// /// - Parameters: /// - behavior: Sets the scroll behavior (smooth or auto). @@ -168,7 +168,7 @@ extension HTML { snapStop: ScrollSnapStop? = nil, snapType: ScrollSnapType? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = ScrollStyleOperation.Parameters( behavior: behavior, margin: margin, diff --git a/Sources/WebUI/Styles/Layout/Sizing/SizingStyleOperation.swift b/Sources/WebUI/Styles/Layout/Sizing/SizingStyleOperation.swift index d9341be0..483fec73 100644 --- a/Sources/WebUI/Styles/Layout/Sizing/SizingStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/Sizing/SizingStyleOperation.swift @@ -134,10 +134,10 @@ public struct SizingStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the frame style and returns the appropriate CSS classes + /// Applies the frame style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for frame styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: FrameParameters) -> [String] { var classes: [String] = [] @@ -159,18 +159,18 @@ public struct SizingStyleOperation: StyleOperation, @unchecked Sendable { return classes } - /// Applies the size style and returns the appropriate CSS classes + /// Applies the size style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for size styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applySizeClasses(params: SizeParameters) -> [String] { ["size-\(params.value.rawValue)"] } - /// Applies the aspect ratio style and returns the appropriate CSS classes + /// Applies the aspect ratio style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for aspect ratio styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyAspectRatioClasses(params: AspectRatioParameters) -> [String] { @@ -193,7 +193,7 @@ public struct SizingStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for Element to provide sizing and layout styling -extension HTML { +extension Markup { /// Sets the width and height of the element with comprehensive SwiftUI-like API. /// /// This method provides control over all width and height properties, supporting @@ -217,7 +217,7 @@ extension HTML { minHeight: SizingValue? = nil, maxHeight: SizingValue? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = SizingStyleOperation.FrameParameters( width: width, height: height, @@ -253,7 +253,7 @@ extension HTML { maxWidth: Double? = nil, minHeight: Double? = nil, maxHeight: Double? = nil - ) -> some HTML { + ) -> some Markup { frame( width: width.map { .spacing(Int($0)) }, height: height.map { .spacing(Int($0)) }, @@ -273,7 +273,7 @@ extension HTML { /// - modifiers: Zero or more modifiers to scope the styles. /// - Returns: A new element with updated sizing classes. public func size(_ size: SizingValue, on modifiers: Modifier...) - -> some HTML + -> some Markup { let params = SizingStyleOperation.SizeParameters(value: size) let classes = SizingStyleOperation.shared.applySizeClasses( @@ -294,7 +294,7 @@ extension HTML { /// - Returns: A new element with aspect ratio classes. public func aspectRatio( _ width: Double, _ height: Double, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = SizingStyleOperation.AspectRatioParameters( width: width, height: height) let classes = SizingStyleOperation.shared.applyAspectRatioClasses( @@ -309,7 +309,7 @@ extension HTML { /// - Parameters: /// - modifiers: Zero or more modifiers to scope the styles. /// - Returns: A new element with square aspect ratio. - public func aspectRatio(on modifiers: Modifier...) -> some HTML { + public func aspectRatio(on modifiers: Modifier...) -> some Markup { let params = SizingStyleOperation.AspectRatioParameters(isSquare: true) let classes = SizingStyleOperation.shared.applyAspectRatioClasses( params: params) @@ -323,7 +323,7 @@ extension HTML { /// - Parameters: /// - modifiers: Zero or more modifiers to scope the styles. /// - Returns: A new element with video aspect ratio. - public func aspectRatioVideo(on modifiers: Modifier...) -> some HTML { + public func aspectRatioVideo(on modifiers: Modifier...) -> some Markup { let params = SizingStyleOperation.AspectRatioParameters(isVideo: true) let classes = SizingStyleOperation.shared.applyAspectRatioClasses( params: params) diff --git a/Sources/WebUI/Styles/Layout/SpacingStyleOperation.swift b/Sources/WebUI/Styles/Layout/SpacingStyleOperation.swift index 933a276e..ff9ca1af 100644 --- a/Sources/WebUI/Styles/Layout/SpacingStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/SpacingStyleOperation.swift @@ -38,10 +38,10 @@ public struct SpacingStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the spacing style and returns the appropriate CSS classes + /// Applies the spacing style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for spacing styling - /// - Returns: An array of CSS class names to be applied + /// - Returns: An array of stylesheet class names to be applied public func applyClasses(params: Parameters) -> [String] { guard let length = params.length else { return [] @@ -65,19 +65,19 @@ public struct SpacingStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide spacing styling -extension HTML { +extension Markup { /// Applies spacing between child elements horizontally and/or vertically. /// /// - Parameters: /// - length: The spacing value in `0.25rem` increments. /// - direction: The direction(s) to apply spacing (`horizontal`, `vertical`, or both). /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated spacing classes. + /// - Returns: Markup with updated spacing classes. public func spacing( of length: Int? = 4, along direction: Axis = .both, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = SpacingStyleOperation.Parameters( length: length, axis: direction diff --git a/Sources/WebUI/Styles/Layout/ZIndexStyleOperation.swift b/Sources/WebUI/Styles/Layout/ZIndexStyleOperation.swift index d1f421a1..ecbe940a 100644 --- a/Sources/WebUI/Styles/Layout/ZIndexStyleOperation.swift +++ b/Sources/WebUI/Styles/Layout/ZIndexStyleOperation.swift @@ -28,10 +28,10 @@ public struct ZIndexStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the z-index style and returns the appropriate CSS classes + /// Applies the z-index style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for z-index styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { ["z-\(params.value)"] } @@ -44,7 +44,7 @@ public struct ZIndexStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide z-index styling -extension HTML { +extension Markup { /// Applies a z-index to the element. /// /// Sets the stacking order of the element, optionally scoped to modifiers. @@ -52,7 +52,7 @@ extension HTML { /// - Parameters: /// - value: Specifies the z-index value as an integer. /// - modifiers: Zero or more modifiers (e.g., `.hover`, `.md`) to scope the styles. - /// - Returns: HTML with updated z-index classes. + /// - Returns: Markup with updated z-index classes. /// /// ## Example /// ```swift @@ -67,7 +67,7 @@ extension HTML { public func zIndex( _ value: Int, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = ZIndexStyleOperation.Parameters(value: value) return ZIndexStyleOperation.shared.applyTo( diff --git a/Sources/WebUI/Styles/Responsive/ResponsiveModifier.swift b/Sources/WebUI/Styles/Responsive/ResponsiveModifier.swift index a0aa4c6d..d5e786ab 100644 --- a/Sources/WebUI/Styles/Responsive/ResponsiveModifier.swift +++ b/Sources/WebUI/Styles/Responsive/ResponsiveModifier.swift @@ -52,34 +52,34 @@ extension Element { /// } /// } /// ``` - public func on(@ResponsiveStyleBuilder _ content: () -> ResponsiveModification) -> some HTML { + public func on(@ResponsiveStyleBuilder _ content: () -> ResponsiveModification) -> some Markup { let builder = ResponsiveBuilder(element: self) let modification = content() modification.apply(to: builder) - return HTMLString(content: builder.element.render()) + return MarkupString(content: builder.element.render()) } } -extension HTML { +extension Markup { /// Applies responsive styling across different breakpoints with a declarative syntax. /// /// This method provides a clean, declarative way to define styles for multiple /// breakpoints in a single block, improving code readability and maintainability. /// /// - Parameter content: A closure defining responsive style configurations using the result builder. - /// - Returns: An HTML element with responsive styles applied. - public func on(@ResponsiveStyleBuilder _ content: () -> ResponsiveModification) -> AnyHTML { - // Wrap HTML in an Element to use responsive functionality - let elementWrapper = HTMLElementWrapper(self) + /// - Returns: A markup element with responsive styles applied. + public func on(@ResponsiveStyleBuilder _ content: () -> ResponsiveModification) -> AnyMarkup { + // Wrap Markup in an Element to use responsive functionality + let elementWrapper = MarkupElementWrapper(self) let builder = ResponsiveBuilder(element: elementWrapper) let modification = content() modification.apply(to: builder) - return AnyHTML(HTMLString(content: builder.element.render())) + return AnyMarkup(MarkupString(content: builder.element.render())) } } -/// A wrapper that converts HTML to Element for responsive functionality -private struct HTMLElementWrapper: Element { +/// A wrapper that converts Markup to Element for responsive functionality +private struct MarkupElementWrapper: Element { private let content: Content init(_ content: Content) { @@ -334,21 +334,21 @@ public class ResponsiveBuilder { self.base = base } - var body: HTMLString { - HTMLString(content: base.render()) + var body: MarkupString { + MarkupString(content: base.render()) } } /// Wrapper to convert HTML back to Element - private struct ElementWrapper: Element { + private struct ElementWrapper: Element { private let htmlContent: T init(_ htmlContent: T) { self.htmlContent = htmlContent } - var body: HTMLString { - HTMLString(content: htmlContent.render()) + var body: MarkupString { + MarkupString(content: htmlContent.render()) } } @@ -373,7 +373,7 @@ public class ResponsiveBuilder { } /// A smart style modifier that deduplicates redundant classes -struct StyleModifierWithDeduplication: HTML { +struct StyleModifierWithDeduplication: Markup { private let content: T private let classes: [String] @@ -427,7 +427,7 @@ struct StyleModifierWithDeduplication: HTML { return Set(classString.split(separator: " ").map(String.init)) } - var body: some HTML { + var body: some Markup { let filteredClasses = filterRedundantModifierClasses(classes) return content.addingClasses(filteredClasses) } diff --git a/Sources/WebUI/Styles/Responsive/ResponsiveNamespace.swift b/Sources/WebUI/Styles/Responsive/ResponsiveNamespace.swift index 754d82d8..3fe96ffc 100644 --- a/Sources/WebUI/Styles/Responsive/ResponsiveNamespace.swift +++ b/Sources/WebUI/Styles/Responsive/ResponsiveNamespace.swift @@ -17,7 +17,7 @@ import Foundation /// ```swift /// // In Document context - works fine without prefix /// struct MyDocument: Document { -/// var body: some HTML { +/// var body: some Markup { /// Text { "Hello" } /// .on { /// md { font(color: .blue(._500)) } // Works fine @@ -27,7 +27,7 @@ import Foundation /// /// // In Element context - use namespace to avoid collision /// struct MyElement: Element { -/// var body: some HTML { +/// var body: some Markup { /// Text { "Hello" } /// .on { /// md { S.font(color: .blue(._500)) } // Use S. prefix diff --git a/Sources/WebUI/Styles/System/Color.swift b/Sources/WebUI/Styles/System/Color.swift index 596c4f57..2d50303a 100644 --- a/Sources/WebUI/Styles/System/Color.swift +++ b/Sources/WebUI/Styles/System/Color.swift @@ -218,12 +218,12 @@ public enum Color { case _950 = 950 } - /// Provides the raw CSS class value for the color and opacity. + /// Provides the raw stylesheet class value for the color and opacity. /// - /// Generates the appropriate string value for use in CSS class names, + /// Generates the appropriate string value for use in stylesheet class names, /// including opacity formatting when specified. /// - /// - Returns: A string representing the color in CSS class format. + /// - Returns: A string representing the color in stylesheet class format. /// /// /// ## Example diff --git a/Sources/WebUI/Styles/System/ElementStyling.swift b/Sources/WebUI/Styles/System/ElementStyling.swift index 773273ad..39b1b024 100644 --- a/Sources/WebUI/Styles/System/ElementStyling.swift +++ b/Sources/WebUI/Styles/System/ElementStyling.swift @@ -2,14 +2,14 @@ import Foundation /// Provides common styling utilities for HTML elements public enum ElementStyling { - /// Applies CSS classes to HTML content + /// Applies stylesheet classes to HTML content /// /// - Parameters: /// - content: The HTML content to apply classes to - /// - classes: The CSS classes to apply - /// - Returns: HTML content with classes applied - public static func applyClasses(_ content: T, classes: [String]) - -> some HTML + /// - classes: The stylesheet classes to apply + /// - Returns: Markup content with classes applied + public static func applyClasses(_ content: T, classes: [String]) + -> some Markup { content.addingClasses(classes) } @@ -17,9 +17,9 @@ public enum ElementStyling { /// Combines base classes with modifier classes /// /// - Parameters: - /// - baseClasses: The base CSS classes + /// - baseClasses: The base stylesheet classes /// - modifiers: The modifiers to apply (e.g., .hover, .md) - /// - Returns: Combined array of CSS classes + /// - Returns: Combined array of stylesheet classes public static func combineClasses( _ baseClasses: [String], withModifiers modifiers: [Modifier] ) -> [String] { @@ -33,31 +33,31 @@ public enum ElementStyling { } /// Extension to provide styling helpers for HTML protocol -extension HTML { - /// Adds CSS classes to an HTML element +extension Markup { + /// Adds stylesheet classes to an HTML element /// - /// - Parameter classNames: The CSS class names to add - /// - Returns: HTML with the classes applied - public func addClass(_ classNames: String...) -> some HTML { + /// - Parameter classNames: The stylesheet class names to add + /// - Returns: Markup with the classes applied + public func addClass(_ classNames: String...) -> some Markup { addingClasses(classNames) } - /// Adds CSS classes to an HTML element + /// Adds stylesheet classes to an HTML element /// - /// - Parameter classNames: The CSS class names to add - /// - Returns: HTML with the classes applied - public func addClasses(_ classNames: [String]) -> some HTML { + /// - Parameter classNames: The stylesheet class names to add + /// - Returns: Markup with the classes applied + public func addClasses(_ classNames: [String]) -> some Markup { addingClasses(classNames) } /// Applies a style with modifier to the element /// /// - Parameters: - /// - baseClasses: The base CSS classes to apply + /// - baseClasses: The base stylesheet classes to apply /// - modifiers: The modifiers to apply (e.g., .hover, .md) - /// - Returns: HTML with the styled classes applied + /// - Returns: Markup with the styled classes applied public func applyStyle(baseClasses: [String], modifiers: [Modifier] = []) - -> some HTML + -> some Markup { let classes = ElementStyling.combineClasses( baseClasses, withModifiers: modifiers) @@ -71,7 +71,7 @@ extension HTML { /// - Parameters: /// - condition: Boolean condition that determines whether to apply the modifier /// - modifier: Closure that applies styling when condition is true - /// - Returns: HTML with conditional styling applied + /// - Returns: Markup with conditional styling applied /// /// ## Example /// ```swift @@ -79,11 +79,11 @@ extension HTML { /// .if(isHighlighted) { $0.background(color: .yellow) } /// .if(isLarge) { $0.font(size: .xl) } /// ``` - public func `if`(_ condition: Bool, _ modifier: (Self) -> T) -> AnyHTML { + public func `if`(_ condition: Bool, _ modifier: (Self) -> T) -> AnyMarkup { if condition { - return AnyHTML(modifier(self)) + return AnyMarkup(modifier(self)) } else { - return AnyHTML(self) + return AnyMarkup(self) } } } diff --git a/Sources/WebUI/Styles/System/StyleOperation.swift b/Sources/WebUI/Styles/System/StyleOperation.swift index ad3eb610..07504c21 100644 --- a/Sources/WebUI/Styles/System/StyleOperation.swift +++ b/Sources/WebUI/Styles/System/StyleOperation.swift @@ -8,10 +8,10 @@ public protocol StyleOperation { /// The parameters type used by this style operation associatedtype Parameters - /// Applies the style operation and returns the appropriate CSS classes + /// Applies the style operation and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for this style operation - /// - Returns: An array of CSS class names to be applied + /// - Returns: An array of stylesheet class names to be applied func applyClasses(params: Parameters) -> [String] } @@ -53,8 +53,8 @@ public struct StyleParameters { } } -/// A modifier to add classes to an HTML element -public struct StyleModifier: HTML { +/// A modifier to add classes to a markup element +public struct StyleModifier: Markup { private let content: T private let classes: [String] @@ -63,21 +63,28 @@ public struct StyleModifier: HTML { self.classes = classes } - public var body: some HTML { + public var body: some Markup { content.addingClasses(classes) } } /// A utility for adapting style operations to Element extensions extension StyleOperation { + /// Applies the style operation and returns the appropriate stylesheet classes (improved clarity) + /// + /// - Parameter configuration: The parameters for this style operation + /// - Returns: An array of stylesheet class names to be applied + public func applyClasses(using configuration: Parameters) -> [String] { + return applyClasses(params: configuration) + } /// Adapts this style operation for use with Element extensions /// /// - Parameters: - /// - content: The HTML content to apply styles to + /// - content: The markup content to apply styles to /// - params: The parameters for this style operation /// - modifiers: The modifiers to apply (e.g., .hover, .md) /// - Returns: A new element with the styles applied - public func applyTo( + public func applyTo( _ content: T, params: Parameters, modifiers: [Modifier] = [] ) -> StyleModifier { let classes = applyClasses(params: params) @@ -94,7 +101,7 @@ extension StyleOperation { /// - params: The parameters for this style operation /// - modifiers: The modifiers to apply (e.g., .hover, .md) /// - Returns: A new element with the styles applied - public func applyToElement( + public func applyToElement( _ element: T, params: Parameters, modifiers: Modifier... ) -> StyleModifier { applyTo(element, params: params, modifiers: modifiers) @@ -125,4 +132,52 @@ extension StyleOperation { _ = applyToBuilder(builder, params: params) } } + + // MARK: - Improved Clarity Methods + + /// Adapts this style operation for use with Element extensions (improved clarity) + /// + /// - Parameters: + /// - content: The markup content to apply styles to + /// - configuration: The parameters for this style operation + /// - modifiers: The modifiers to apply (e.g., .hover, .md) + /// - Returns: A new element with the styles applied + public func applyTo( + _ content: T, using configuration: Parameters, modifiers: [Modifier] = [] + ) -> StyleModifier { + return applyTo(content, params: configuration, modifiers: modifiers) + } + + /// Applies style to an element and returns the modified element (improved clarity) + /// + /// - Parameters: + /// - element: The element to apply styles to + /// - configuration: The parameters for this style operation + /// - modifiers: The modifiers to apply (e.g., .hover, .md) + /// - Returns: A new element with the styles applied + public func applyToElement( + _ element: T, using configuration: Parameters, modifiers: Modifier... + ) -> StyleModifier { + return applyTo(element, params: configuration, modifiers: Array(modifiers)) + } + + /// Internal adapter for use with the responsive builder (improved clarity) + /// + /// - Parameters: + /// - builder: The responsive builder to apply styles to + /// - configuration: The parameters for this style operation + /// - Returns: The builder for method chaining + public func applyToBuilder(_ builder: ResponsiveBuilder, using configuration: Parameters) + -> ResponsiveBuilder + { + return applyToBuilder(builder, params: configuration) + } + + /// Adapts this style operation for use with the Declaritive result builder syntax (improved clarity) + /// + /// - Parameter configuration: The parameters for this style operation + /// - Returns: A responsive modification that can be used in responsive blocks + public func asModification(using configuration: Parameters) -> ResponsiveModification { + return asModification(params: configuration) + } } diff --git a/Sources/WebUI/Styles/Typography/FontStyleOperation.swift b/Sources/WebUI/Styles/Typography/FontStyleOperation.swift index c7372345..19d8f39e 100644 --- a/Sources/WebUI/Styles/Typography/FontStyleOperation.swift +++ b/Sources/WebUI/Styles/Typography/FontStyleOperation.swift @@ -87,10 +87,10 @@ public struct FontStyleOperation: StyleOperation, @unchecked Sendable { } } - /// Applies the font style and returns the appropriate CSS classes + /// Applies the font style and returns the appropriate stylesheet classes /// /// - Parameter params: The parameters for font styling - /// - Returns: An array of CSS class names to be applied to elements + /// - Returns: An array of stylesheet class names to be applied to elements public func applyClasses(params: Parameters) -> [String] { var classes: [String] = [] @@ -119,7 +119,7 @@ public struct FontStyleOperation: StyleOperation, @unchecked Sendable { } // Extension for HTML to provide font styling -extension HTML { +extension Markup { /// Applies font styling to the element with optional modifiers. /// /// This comprehensive method allows controlling all aspects of typography including @@ -167,7 +167,7 @@ extension HTML { color: Color? = nil, family: String? = nil, on modifiers: Modifier... - ) -> some HTML { + ) -> some Markup { let params = FontStyleOperation.Parameters( size: size, weight: weight, diff --git a/Sources/WebUI/Styles/Typography/FontTypes.swift b/Sources/WebUI/Styles/Typography/FontTypes.swift index cdbca154..d4a5b936 100644 --- a/Sources/WebUI/Styles/Typography/FontTypes.swift +++ b/Sources/WebUI/Styles/Typography/FontTypes.swift @@ -1,7 +1,7 @@ /// Represents different font sizes for typography styling. /// /// Provides a consistent typographic scale from extra small to very large sizes, -/// mapping to predefined CSS classes. The scale follows a progressive pattern +/// mapping to predefined stylesheet classes. The scale follows a progressive pattern /// where larger numbers indicate proportionally larger text sizes. /// /// ## Example @@ -92,7 +92,7 @@ public enum Alignment: String { /// Aligns text to the right edge of the container. case right - /// The corresponding CSS class name for this alignment. + /// The corresponding stylesheet class name for this alignment. var className: String { "text-\(rawValue)" } } @@ -126,7 +126,7 @@ public enum Weight: String { /// Extremely bold/black text (900). case black - /// The corresponding CSS class name for this font weight. + /// The corresponding stylesheet class name for this font weight. var className: String { "font-\(rawValue)" } } @@ -154,7 +154,7 @@ public enum Tracking: String { /// Maximum letter spacing (greatest increase in space). case widest - /// The corresponding CSS class name for this tracking value. + /// The corresponding stylesheet class name for this tracking value. var className: String { "tracking-\(rawValue)" } } @@ -182,7 +182,7 @@ public enum Leading: String { /// Maximum line spacing for very open text layouts. case loose - /// The corresponding CSS class name for this line height value. + /// The corresponding stylesheet class name for this line height value. var className: String { "leading-\(rawValue)" } } @@ -214,7 +214,7 @@ public enum Decoration: String { /// Remove line decoration case none = "no-underline" - /// The corresponding CSS class name for this decoration. + /// The corresponding stylesheet class name for this decoration. var className: String { "\(rawValue)" } } @@ -238,6 +238,6 @@ public enum Wrapping: String { /// Prevents text from wrapping to multiple lines. case nowrap - /// The corresponding CSS class name for this wrapping behavior. + /// The corresponding stylesheet class name for this wrapping behavior. var className: String { "text-\(rawValue)" } } diff --git a/Sources/WebUI/Utilities/HTMLEscaper.swift b/Sources/WebUI/Utilities/HTMLEscaper.swift index cf0cb054..006127dc 100644 --- a/Sources/WebUI/Utilities/HTMLEscaper.swift +++ b/Sources/WebUI/Utilities/HTMLEscaper.swift @@ -1,10 +1,10 @@ import Foundation -/// Provides HTML escaping functionality to prevent XSS attacks and ensure proper HTML rendering. +/// Provides markup escaping functionality to prevent XSS attacks and ensure proper markup rendering. /// -/// The `HTMLEscaper` converts special characters that have meaning in HTML -/// into their corresponding HTML entities, ensuring that user content is -/// safely displayed without breaking HTML structure or introducing security +/// The `HTMLEscaper` converts special characters that have meaning in markup +/// into their corresponding markup entities, ensuring that user content is +/// safely displayed without breaking markup structure or introducing security /// vulnerabilities. /// /// ## Example @@ -14,17 +14,17 @@ import Foundation /// // Result: "Hello <script>alert('XSS')</script> & goodbye" /// ``` public struct HTMLEscaper { - /// Escapes special HTML characters in a string to prevent injection and parsing errors. + /// Escapes special markup characters in a string to prevent injection and parsing errors. /// - /// This method converts the following characters to their HTML entities: + /// This method converts the following characters to their markup entities: /// - `&` becomes `&` (must be first to avoid double-escaping) /// - `<` becomes `<` /// - `>` becomes `>` /// - `"` becomes `"` /// - `'` becomes `'` /// - /// - Parameter string: The string containing potentially unsafe HTML characters. - /// - Returns: A string with HTML characters properly escaped. + /// - Parameter string: The string containing potentially unsafe markup characters. + /// - Returns: A string with markup characters properly escaped. /// /// ## Example /// ```swift @@ -41,14 +41,14 @@ public struct HTMLEscaper { .replacingOccurrences(of: "'", with: "'") } - /// Escapes HTML characters specifically for use in HTML attribute values. + /// Escapes markup characters specifically for use in markup attribute values. /// /// This method is optimized for attribute contexts where quotes and ampersands /// are the primary concerns. It performs the same escaping as `escape(_:)` but /// is semantically distinct for clarity of intent. /// - /// - Parameter attributeValue: The string to be used as an HTML attribute value. - /// - Returns: A string safe for use in HTML attribute values. + /// - Parameter attributeValue: The string to be used as a markup attribute value. + /// - Returns: A string safe for use in markup attribute values. /// /// ## Example /// ```swift @@ -60,14 +60,14 @@ public struct HTMLEscaper { escape(attributeValue) } - /// Escapes HTML characters specifically for use in HTML text content. + /// Escapes markup characters specifically for use in markup text content. /// /// This method is optimized for text content contexts where angle brackets /// and ampersands are the primary concerns. Single and double quotes are /// less critical in text content but are still escaped for consistency. /// - /// - Parameter textContent: The string to be used as HTML text content. - /// - Returns: A string safe for use as HTML text content. + /// - Parameter textContent: The string to be used as markup text content. + /// - Returns: A string safe for use as markup text content. /// /// ## Example /// ```swift diff --git a/Sources/WebUI/Utilities/HTMLMinifier.swift b/Sources/WebUI/Utilities/HTMLMinifier.swift index e33acc56..acd7c9e5 100644 --- a/Sources/WebUI/Utilities/HTMLMinifier.swift +++ b/Sources/WebUI/Utilities/HTMLMinifier.swift @@ -1,9 +1,9 @@ import Foundation -/// Provides HTML minification functionality to reduce file size and improve performance. +/// Provides markup minification functionality to reduce file size and improve performance. /// /// The `HTMLMinifier` removes unnecessary whitespace, comments, and redundant -/// formatting from HTML content while preserving the structure and +/// formatting from markup content while preserving the structure and /// functionality of the document. This optimization reduces bandwidth usage /// and improves page load times. /// @@ -21,19 +21,19 @@ import Foundation /// ``` public struct HTMLMinifier { - /// Minifies HTML content by removing unnecessary whitespace and formatting. + /// Minifies markup content by removing unnecessary whitespace and formatting. /// /// This method performs the following optimizations: /// - Removes leading and trailing whitespace from lines /// - Collapses multiple consecutive whitespace characters into single spaces /// - Removes empty lines /// - Preserves content within `

        `, ``, ` & goodbye"
        -    ///   let content: [any HTML] = [
        +    ///   let content: [any Markup] = [
             ///     userInput,
             ///     Heading(.one) { "Title" }
             ///   ]
             ///   ```
             public func render() -> String { self }
         
        -    /// Sanitizes strings for use in CSS variable names.
        +    /// Sanitizes strings for use in stylesheet variable names.
             ///
        -    /// Converts a string into a valid CSS variable name by replacing invalid characters
        +    /// Converts a string into a valid stylesheet variable name by replacing invalid characters
             /// with hyphens and converting to lowercase, ensuring the result is compliant with
        -    /// CSS naming conventions.
        +    /// stylesheet naming conventions.
             ///
        -    /// - Returns: A sanitized string suitable for use as a CSS variable name.
        +    /// - Returns: A sanitized string suitable for use as a stylesheet variable name.
             ///
             /// - Example:
             ///   ```swift
             ///   let rawName = "Button Color!"
        -    ///   let cssName = rawName.sanitizedForCSS() // Returns "button-color-"
        -    ///   let css = "--\(cssName): blue;"
        +    ///   let styleName = rawName.sanitizedForStyleSheet() // Returns "button-color-"
        +    ///   let css = "--\(styleName): blue;"
             ///   ```
        -    public func sanitizedForCSS() -> String {
        +    public func sanitizedForStyleSheet() -> String {
                 self.replacingOccurrences(
                     of: "[^a-zA-Z0-9-]", with: "-", options: .regularExpression
                 )
        @@ -66,4 +66,15 @@ extension String: HTML {
                     .joined(separator: "-")
                     .trimmingCharacters(in: .whitespaces)
             }
        +
        +    // MARK: - Backward Compatibility
        +
        +    /// Backward compatibility alias for `sanitizedForStyleSheet()`.
        +    ///
        +    /// - Deprecated: Use `sanitizedForStyleSheet()` instead.
        +    /// - Returns: A sanitized string suitable for use as a stylesheet variable name.
        +    @available(*, deprecated, message: "Use sanitizedForStyleSheet() instead")
        +    public func sanitizedForCSS() -> String {
        +        return sanitizedForStyleSheet()
        +    }
         }
        diff --git a/Sources/WebUIMarkdown/HTMLRenderer.swift b/Sources/WebUIMarkdown/HTMLRenderer.swift
        index 238b2881..b6851600 100644
        --- a/Sources/WebUIMarkdown/HTMLRenderer.swift
        +++ b/Sources/WebUIMarkdown/HTMLRenderer.swift
        @@ -1,12 +1,12 @@
        -/// A renderer that converts a Markdown Abstract Syntax Tree (AST) into HTML.
        +/// A renderer that converts a Markdown Abstract Syntax Tree (AST) into markup.
         ///
         /// `HtmlRenderer` walks through the Markdown document structure and generates appropriate
        -/// HTML tags for each Markdown element, with special handling for links, code blocks,
        +/// markup tags for each Markdown element, with special handling for links, code blocks,
         /// and other formatting constructs.
        -/// A renderer that converts a Markdown Abstract Syntax Tree (AST) into HTML with configurable code block rendering options.
        +/// A renderer that converts a Markdown Abstract Syntax Tree (AST) into markup with configurable code block rendering options.
         ///
         /// `HtmlRenderer` walks through the Markdown document structure and generates appropriate
        -/// HTML tags for each Markdown element, with special handling for links, code blocks,
        +/// markup tags for each Markdown element, with special handling for links, code blocks,
         /// and other formatting constructs. Code block rendering features such as syntax highlighting,
         /// filename display, copy button, and line numbers can be enabled or disabled via boolean flags.
         ///
        diff --git a/Sources/WebUIMarkdown/WebUIMarkdown.swift b/Sources/WebUIMarkdown/WebUIMarkdown.swift
        index f983fd65..ac3807c9 100644
        --- a/Sources/WebUIMarkdown/WebUIMarkdown.swift
        +++ b/Sources/WebUIMarkdown/WebUIMarkdown.swift
        @@ -3,11 +3,11 @@ import Markdown
         
         /// A module for parsing and rendering Markdown content with front matter support.
         ///
        -/// This module provides functionality to transform Markdown text into HTML and extract
        +/// This module provides functionality to transform Markdown text into markup and extract
         /// front matter metadata, making it suitable for content-driven websites and applications.
         /// A module for parsing and rendering Markdown content with front matter support and configurable code block rendering.
         ///
        -/// This module provides functionality to transform Markdown text into HTML and extract
        +/// This module provides functionality to transform Markdown text into markup and extract
         /// front matter metadata, making it suitable for content-driven websites and applications.
         /// Code block rendering features such as syntax highlighting, filename display, copy button,
         /// and line numbers can be enabled or disabled via boolean flags.
        diff --git a/Tests/WebUITests/Core/DocumentTests.swift b/Tests/WebUITests/Core/DocumentTests.swift
        index 98b62a31..ae20b7d8 100644
        --- a/Tests/WebUITests/Core/DocumentTests.swift
        +++ b/Tests/WebUITests/Core/DocumentTests.swift
        @@ -15,7 +15,7 @@ struct NoDescriptionDocument: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Test content")
             }
         }
        @@ -31,7 +31,7 @@ struct BasicTestDocument: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Hello, world!")
             }
         }
        @@ -55,7 +55,7 @@ struct FullMetadataDocument: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Content")
             }
         }
        @@ -75,7 +75,7 @@ struct FaviconTestDocument: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Favicon Test")
             }
         }
        @@ -97,7 +97,7 @@ struct StructuredDataDocument: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Structured Data Test")
             }
         }
        @@ -121,7 +121,7 @@ struct ScriptTestDocument: Document {
                 ]
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Script Test")
             }
         }
        @@ -142,7 +142,7 @@ struct StylesheetTestDocument: Document {
                 ]
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Stylesheet Test")
             }
         }
        @@ -163,7 +163,7 @@ struct CustomHeadDocument: Document {
                 """
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Text("Custom Head Test")
             }
         }
        diff --git a/Tests/WebUITests/Core/MetadataTests.swift b/Tests/WebUITests/Core/MetadataTests.swift
        index ef86c8f3..259a3776 100644
        --- a/Tests/WebUITests/Core/MetadataTests.swift
        +++ b/Tests/WebUITests/Core/MetadataTests.swift
        @@ -242,7 +242,7 @@ struct MetadataTests {
         
                 #expect(articleData.type == .article)
         
        -        let json = articleData.toJSON()
        +        let json = articleData.convertToJsonString()
                 #expect(json.contains("\"@context\":\"https://schema.org\""))
                 #expect(json.contains("\"@type\":\"Article\""))
                 #expect(json.contains("\"headline\":\"Test Article\""))
        @@ -267,7 +267,7 @@ struct MetadataTests {
         
                 #expect(productData.type == .product)
         
        -        let json = productData.toJSON()
        +        let json = productData.convertToJsonString()
                 #expect(json.contains("\"@type\":\"Product\""))
                 #expect(json.contains("\"name\":\"Test Product\""))
                 #expect(
        @@ -288,7 +288,7 @@ struct MetadataTests {
         
                 #expect(faqData.type == .faqPage)
         
        -        let json = faqData.toJSON()
        +        let json = faqData.convertToJsonString()
                 #expect(json.contains("\"@type\":\"FAQPage\""))
                 #expect(json.contains("\"@type\":\"Question\""))
                 #expect(json.contains("\"name\":\"What is this?\""))
        @@ -301,7 +301,7 @@ struct MetadataTests {
                 let structuredData = StructuredData.organization(
                     name: "Test Org",
                     logo: "https://example.com/logo.png",
        -            url: "https://example.com"
        +            webAddress: "https://example.com"
                 )
         
                 let metadata = Metadata(
        @@ -336,7 +336,7 @@ struct MetadataTests {
                     jobTitle: "Software Engineer",
                     email: "jane@example.com",
                     telephone: "+1-555-123-4567",
        -            url: "https://janedoe.example.com",
        +            webAddress: "https://janedoe.example.com",
                     address: [
                         "streetAddress": "123 Main St",
                         "addressLocality": "Anytown",
        @@ -351,7 +351,7 @@ struct MetadataTests {
         
                 #expect(personData.type == .person)
         
        -        let json = personData.toJSON()
        +        let json = personData.convertToJsonString()
                 #expect(json.contains("\"@context\":\"https://schema.org\""))
                 #expect(json.contains("\"@type\":\"Person\""))
                 #expect(json.contains("\"name\":\"Jane Doe\""))
        diff --git a/Tests/WebUITests/Core/WebsiteTests.swift b/Tests/WebUITests/Core/WebsiteTests.swift
        index 7cc0baa3..13f12c20 100644
        --- a/Tests/WebUITests/Core/WebsiteTests.swift
        +++ b/Tests/WebUITests/Core/WebsiteTests.swift
        @@ -9,18 +9,18 @@ import Testing
         struct PageLayout: Element {
             var title: String
             var description: String
        -    var content: HTMLContentBuilder
        +    var content: MarkupContentBuilder
         
             init(
                 title: String, description: String,
        -        @HTMLBuilder content: @escaping HTMLContentBuilder
        +        @MarkupBuilder content: @escaping MarkupContentBuilder
             ) {
                 self.title = title
                 self.description = description
                 self.content = content
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 BodyWrapper {
                     Header {
                         Stack {
        @@ -48,7 +48,7 @@ struct PageLayout: Element {
                             .padding()
                             .margins(at: .bottom)
         
        -                    HTMLString(content: content().map { $0.render() }.joined())
        +                    MarkupString(content: content().map { $0.render() }.joined())
                         }
                         .padding()
                         .margins(at: .horizontal, auto: true)
        @@ -87,7 +87,7 @@ struct ProjectCard: Element {
             var imageUrl: String
             var link: String
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Stack {
                     Image(
                         source: imageUrl, description: title,
        @@ -141,7 +141,7 @@ struct ExperienceItem: Element {
             var period: String
             var description: String
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Stack {
                     Heading(.headline, role)
                     Text(company)
        @@ -154,7 +154,7 @@ struct SkillCategory: Element {
             var category: String
             var skills: [String]
         
        -    var body: some HTML {
        +    var body: some Markup {
                 Stack {
                     Heading(.subheadline, category)
                     Stack {
        @@ -167,7 +167,7 @@ struct SkillCategory: Element {
         }
         
         struct ContactForm: Element {
        -    var body: some HTML {
        +    var body: some Markup {
                 Form(action: "/submit", method: .post) {
                     Stack {
                         Label(for: "name") { "Name" }
        @@ -193,7 +193,7 @@ struct HomePage: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 PageLayout(
                     title: "Welcome to My Portfolio",
                     description:
        @@ -284,7 +284,7 @@ struct AboutPage: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 PageLayout(
                     title: "About Me",
                     description: "Learn about my background, skills, and experience"
        @@ -384,7 +384,7 @@ struct ProjectsPage: Document {
                 )
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 PageLayout(
                     title: "My Projects",
                     description: "A showcase of my recent work and projects"
        @@ -468,7 +468,7 @@ struct ContactPage: Document {
                 [Script(src: "/js/contact-form.js", attribute: .defer)]
             }
         
        -    var body: some HTML {
        +    var body: some Markup {
                 PageLayout(
                     title: "Contact Me",
                     description:
        @@ -579,7 +579,7 @@ struct Portfolio: Website {
                 ContactPage()
             }
         
        -    var baseURL: String? {
        +    var baseWebAddress: String? {
                 "https://janedoe.dev"
             }
         
        @@ -638,7 +638,7 @@ struct ComprehensiveWebsiteTests {
         
                 #expect(portfolio.metadata.site == "Jane Doe")
                 #expect(portfolio.routes.count == 4)
        -        #expect(portfolio.baseURL == "https://janedoe.dev")
        +        #expect(portfolio.baseWebAddress == "https://janedoe.dev")
                 #expect(portfolio.sitemapEntries?.count == 2)
                 #expect(portfolio.robotsRules?.count == 2)
         
        diff --git a/Tests/WebUITests/ElementTests.swift b/Tests/WebUITests/ElementTests.swift
        index 68b20090..36408773 100644
        --- a/Tests/WebUITests/ElementTests.swift
        +++ b/Tests/WebUITests/ElementTests.swift
        @@ -1361,7 +1361,7 @@ import Testing
         
             @Test("Conditional modifier - type erasure works correctly")
             func testConditionalModifierTypeErasure() async throws {
        -        // This test ensures that the AnyHTML type erasure doesn't break functionality
        +        // This test ensures that the AnyMarkup type erasure doesn't break functionality
                 let elements = [
                     Text("First").if(true) { $0.addClass("first") },
                     Text("Second").hidden(when: false),
        diff --git a/Tests/WebUITests/Styles/StyleModifiersTests.swift b/Tests/WebUITests/Styles/StyleModifiersTests.swift
        index cc0464e5..6c0f4117 100644
        --- a/Tests/WebUITests/Styles/StyleModifiersTests.swift
        +++ b/Tests/WebUITests/Styles/StyleModifiersTests.swift
        @@ -753,7 +753,7 @@ import Testing
                         .init(title: "Hello")
                     }
         
        -            var body: some HTML {
        +            var body: some Markup {
                         Text("Hello")
                             .on {
                                 md {
        @@ -767,7 +767,7 @@ import Testing
                 }
                 // FIXME: If possible remove `S.` prefix
                 struct TestElement: Element {
        -            var body: some HTML {
        +            var body: some Markup {
                         Text("Hello")
                             .on {
                                 md {