Skip to content

gnorium/web-builders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebBuilders, as used in gnorium.com

HTML, CSS, JS, and SVG DSL builders for Swift, enabling declarative UI construction in Swift environments.

Overview

WebBuilders provides type-safe DSL builders for HTML, CSS, JavaScript, and SVG, allowing you to construct web interfaces using Swift's result builder syntax.

Features

Result Builders:

  • HTML Builder: Type-safe HTML element construction
  • CSS Builder: Declarative CSS styling with compile-time safety
  • JS Builder: JavaScript code generation with type safety
  • SVG Builder: SVG element construction

Installation

Swift Package Manager

Add WebBuilders to your Package.swift:

dependencies: [
    .package(url: "https://github.com/gnorium/web-builders", branch: "main")
]

Then add it to your target dependencies:

.target(
    name: "YourTarget",
    dependencies: [
        .product(name: "WebBuilders", package: "web-builders")
    ]
)

Usage

import HTMLBuilder
import CSSBuilder
import JSBuilder
import SVGBuilder

// Build HTML declaratively
div {
    h1 { "Welcome" }
    p { "Built with Swift" }
}

// Build CSS declaratively
style {
    color(.red)
    fontSize(px(16))
}

// Build JavaScript declaratively
const.myVar |= "Hello"
id("console").log(id("myVar"))

// Build SVG declaratively
svg {
    circle().cx(50).cy(50).r(40)
}

Requirements

  • Swift 6.2+

License

Apache License 2.0 - See LICENSE for details

Contributing

Contributions welcome! Please open an issue or submit a pull request.

Related Packages

About

WebBuilders, as used in gnorium.com

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages