项目作者: johngarrett

项目描述 :
A Swift DSL for generating HTML and CSS documents
高级语言: Swift
项目地址: git://github.com/johngarrett/HyperSwift.git
创建时间: 2020-07-17T22:44:15Z
项目社区:https://github.com/johngarrett/HyperSwift

开源协议:GNU General Public License v3.0

下载


HyperSwift - a HTML and CSS Generator

Swift 5.2
@garrepi

About

HyperSwift (name pending) is a DSL written purely in Swift aimed to generate HTML styled with CSS.

Main Features

  • Vertical and Horizontal stack wrappers
  • Native HTML Elements
  • CSS Stylesheet generation

    Code Snippits

    505 Page from garrepi.dev:
    ```swift
    import HyperSwift

VStack(justify: .center, align: .center) {
HStack(justify: .spaceEvenly, align: .center) {
Image(url: “/images/error_bomb.png”)
.width(100)
.height(100)
Header(.header3) { “HTTP 500” }
.font(weight: “bold”, size: 40, family: “SF Mono”)
}
Paragraph(fiveOfiveMessage)
}
.backgroundColor(GColors.lightRed)
.textAlign(.center)
.margin(5, .percent)
.display(.flex)
.shadow(x: 20, y: 30, color: GColors.cardShadow)
.border(width: 1, color: .black)

  1. ![output](https://media.discordapp.net/attachments/732426870100066455/733822598504513566/unknown.png)
  2. #### CSS
  3. To add CSS to the stylesheet, you have to call one of the functions defined in [CSSExtensions.swift](/Sources/HyperSwift/API/CSS/CSSExtensions.swift).
  4. If an element has a class name, the styles will automatically be added to [CSSStyleSheet.swift](/Sources/HyperSwift/API/CSS/CSSStyleSheet.swift)'s stylesheet.
  5. Calling `.generateStyleSheet()` on [CSSStyleSheet.swift](/Sources/HyperSwift/API/CSS/CSSStyleSheet.swift) will return a string containing the stylesheet.
  6. #### Examples
  7. HyperSwift is being used on [garrepi.dev](https://www.garrepi.dev) as we speak! Checkout the source code [here](https://github.com/johngarrett/garrepi.dev/).
  8. #### Usage
  9. in your `Package.swift`:
  10. ```swift
  11. . . .
  12. .package(url: "https://github.com/johngarrett/HyperSwift", .branch("main")),
  13. . . .

Contributing

I would love help with this — there’s a lot that needs to get done.

I have little free time and an even little-er ability to focus on one project. Feel free to send in a PR with ideas, suggestions, or actual code!

reach out to me on twitter if you have questions I can answer