|
1 | 1 | # swift-html-css-pointfree |
2 | 2 |
|
| 3 | +[](https://github.com/coenttb/swift-html-css-pointfree/actions/workflows/ci.yml) |
| 4 | + |
| 5 | + |
| 6 | +Integration layer combining HTML types, CSS types, and PointFree HTML rendering for type-safe web development. |
| 7 | + |
3 | 8 | ⚠️ **This is an integration package. For end-user development, please use [coenttb/swift-html](https://github.com/coenttb/swift-html) instead.** |
4 | 9 |
|
5 | 10 | ## Overview |
6 | 11 |
|
7 | | -This package serves as an integration layer that combines: |
| 12 | +This package provides the integration layer that bridges: |
8 | 13 | - [swift-html-types](https://github.com/coenttb/swift-html-types) - Type definitions for HTML elements and attributes |
9 | | -- [swift-css-types](https://github.com/coenttb/swift-css-types) - Type definitions for CSS properties and values |
| 14 | +- [swift-css-types](https://github.com/coenttb/swift-css-types) - Type definitions for CSS properties and values |
10 | 15 | - [pointfree-html](https://github.com/coenttb/pointfree-html) - HTML rendering engine |
11 | 16 |
|
12 | | -It provides the foundational PointFree HTML integration that powers the higher-level [swift-html](https://github.com/coenttb/swift-html) package. |
| 17 | +It serves as the foundational PointFree HTML integration layer for the [swift-html](https://github.com/coenttb/swift-html) package. |
| 18 | + |
| 19 | +## Features |
| 20 | + |
| 21 | +- PointFree HTML extensions for HTML elements (HTMLElements+PointFreeHTML) |
| 22 | +- PointFree HTML extensions for HTML attributes (HTMLAttributes+PointFreeHTML) |
| 23 | +- PointFree HTML extensions for CSS properties (CSS+PointFreeHTML) |
| 24 | +- Combined HTML and CSS functionality (HTML+CSS+PointFreeHTML) |
| 25 | +- Type-safe CSS property application on HTML elements |
| 26 | +- Media query support for responsive design |
| 27 | +- Pseudo-class support for interactive styling |
| 28 | + |
| 29 | +## Installation |
| 30 | + |
| 31 | +### For End Users |
13 | 32 |
|
14 | | -## For Developers |
| 33 | +**Use [coenttb/swift-html](https://github.com/coenttb/swift-html) instead.** The swift-html package provides a complete, developer-friendly API for building type-safe HTML and CSS in Swift. |
15 | 34 |
|
16 | | -**👉 Use [coenttb/swift-html](https://github.com/coenttb/swift-html) for your projects.** |
| 35 | +### For Package Developers |
17 | 36 |
|
18 | | -The `swift-html` package provides a complete, developer-friendly API for building type-safe HTML and CSS in Swift with a SwiftUI-like syntax: |
| 37 | +If you need to use this integration layer directly: |
19 | 38 |
|
20 | 39 | ```swift |
21 | | -import HTML |
| 40 | +dependencies: [ |
| 41 | + .package(url: "https://github.com/coenttb/swift-html-css-pointfree", from: "0.0.1") |
| 42 | +] |
| 43 | +``` |
| 44 | + |
| 45 | +Then add the appropriate module to your target dependencies: |
| 46 | + |
| 47 | +```swift |
| 48 | +.target( |
| 49 | + name: "YourTarget", |
| 50 | + dependencies: [ |
| 51 | + .product(name: "HTMLCSSPointFreeHTML", package: "swift-html-css-pointfree"), |
| 52 | + // Or specific modules: |
| 53 | + // .product(name: "CSSPointFreeHTML", package: "swift-html-css-pointfree"), |
| 54 | + // .product(name: "HTMLElementsPointFreeHTML", package: "swift-html-css-pointfree"), |
| 55 | + // .product(name: "HTMLAttributesPointFreeHTML", package: "swift-html-css-pointfree"), |
| 56 | + ] |
| 57 | +) |
| 58 | +``` |
| 59 | + |
| 60 | +## Quick Start |
| 61 | + |
| 62 | +```swift |
| 63 | +import HTMLCSSPointFreeHTML |
| 64 | +import PointFreeHTML |
22 | 65 |
|
23 | 66 | let document = HTMLDocument { |
24 | | - div { |
25 | | - h1 { "Type-safe HTML" } |
26 | | - .color(light: .blue, dark: .red) |
27 | | - .fontSize(.px(24)) |
28 | | - p { "With type-safe CSS!" } |
29 | | - .marginTop(.px(10)) |
30 | | - } |
| 67 | + ContentDivision { |
| 68 | + "Hello World" |
| 69 | + } |
| 70 | + .color(.red) |
| 71 | + .backgroundColor(.hex("F0F0F0")) |
31 | 72 | } |
| 73 | + |
| 74 | +let html = String(bytes: document.render(), encoding: .utf8)! |
32 | 75 | ``` |
33 | 76 |
|
34 | | -## Package Architecture |
| 77 | +## Usage Examples |
35 | 78 |
|
36 | | -This integration package consists of several modules: |
| 79 | +### Applying CSS Properties |
37 | 80 |
|
38 | | -- **HTMLElements+PointFreeHTML** - PointFree HTML extensions for HTML elements |
39 | | -- **HTMLAttributes+PointFreeHTML** - PointFree HTML extensions for HTML attributes |
40 | | -- **CSS+PointFreeHTML** - PointFree HTML extensions for CSS properties |
41 | | -- **HTML+CSS+PointFreeHTML** - Combined HTML and CSS functionality |
| 81 | +```swift |
| 82 | +import HTMLCSSPointFreeHTML |
42 | 83 |
|
43 | | -## Installation (Internal Use Only) |
| 84 | +// Apply color with type safety |
| 85 | +let styledDiv = ContentDivision { |
| 86 | + "Styled content" |
| 87 | +} |
| 88 | +.color(.blue) |
| 89 | +.fontSize(.px(16)) |
| 90 | +.padding(.rem(1)) |
| 91 | +``` |
44 | 92 |
|
45 | | -This package is typically used as a dependency by other packages in the ecosystem. If you need to use it directly: |
| 93 | +### Media Queries |
46 | 94 |
|
47 | 95 | ```swift |
48 | | -dependencies: [ |
49 | | - .package(url: "https://github.com/coenttb/swift-html-css-pointfree", from: "0.0.1") |
50 | | -] |
| 96 | +// Responsive styling |
| 97 | +let responsiveDiv = ContentDivision { |
| 98 | + "Responsive content" |
| 99 | +} |
| 100 | +.padding(.rem(1), media: .mobile) |
| 101 | +.padding(.rem(2), media: .tablet) |
| 102 | +.padding(.rem(3), media: .desktop) |
| 103 | +``` |
| 104 | + |
| 105 | +### Pseudo-Classes |
| 106 | + |
| 107 | +```swift |
| 108 | +// Interactive styling |
| 109 | +let interactiveLink = Anchor(href: "/path") { |
| 110 | + "Hover me" |
| 111 | +} |
| 112 | +.color(.blue) |
| 113 | +.color(.red, pseudo: .hover) |
| 114 | +``` |
| 115 | + |
| 116 | +### Multiple Properties |
| 117 | + |
| 118 | +```swift |
| 119 | +let complexElement = ContentDivision { |
| 120 | + Paragraph { |
| 121 | + "Complex styling" |
| 122 | + } |
| 123 | + .color(.named(.darkblue)) |
| 124 | + .fontSize(.px(18)) |
| 125 | +} |
| 126 | +.backgroundColor(.hex("FFFFFF")) |
| 127 | +.padding(.rem(2)) |
| 128 | +.margin(.px(10)) |
| 129 | +``` |
| 130 | + |
| 131 | +## Package Architecture |
| 132 | + |
| 133 | +### Modules |
| 134 | + |
| 135 | +- **CSSPointFreeHTML** - CSS property extensions for PointFree HTML elements |
| 136 | +- **HTMLElementsPointFreeHTML** - HTML element definitions with PointFree HTML support |
| 137 | +- **HTMLAttributesPointFreeHTML** - HTML attribute extensions for PointFree HTML |
| 138 | +- **HTMLCSSPointFreeHTML** - Combined HTML+CSS functionality (umbrella module) |
| 139 | + |
| 140 | +### Module Dependencies |
| 141 | + |
| 142 | +``` |
| 143 | +HTMLCSSPointFreeHTML |
| 144 | +├── CSSPointFreeHTML |
| 145 | +│ ├── swift-css-types (CSSTypes) |
| 146 | +│ └── pointfree-html (PointFreeHTML) |
| 147 | +├── HTMLElementsPointFreeHTML |
| 148 | +│ ├── swift-html-types (HTMLElementTypes) |
| 149 | +│ ├── HTMLAttributesPointFreeHTML |
| 150 | +│ └── pointfree-html (PointFreeHTML) |
| 151 | +└── HTMLAttributesPointFreeHTML |
| 152 | + ├── swift-html-types (HTMLAttributeTypes) |
| 153 | + └── pointfree-html (PointFreeHTML) |
51 | 154 | ``` |
52 | 155 |
|
53 | 156 | ## Related Packages |
54 | 157 |
|
55 | 158 | ### For End Users |
56 | | -* **[swift-html](https://www.github.com/coenttb/swift-html)** - **👈 Start here!** Complete Swift DSL for HTML and CSS |
| 159 | +* [swift-html](https://www.github.com/coenttb/swift-html) - Complete Swift DSL for type-safe HTML and CSS |
57 | 160 |
|
58 | 161 | ### Foundation Packages |
59 | | -* [swift-html-types](https://www.github.com/coenttb/swift-html-types) - HTML type definitions |
60 | | -* [swift-css-types](https://www.github.com/coenttb/swift-css-types) - CSS type definitions |
61 | | -* [pointfree-html](https://www.github.com/coenttb/pointfree-html) - HTML rendering engine |
| 162 | +* [swift-html-types](https://www.github.com/coenttb/swift-html-types) - Type definitions for HTML elements and attributes |
| 163 | +* [swift-css-types](https://www.github.com/coenttb/swift-css-types) - Type definitions for CSS properties and values |
| 164 | +* [pointfree-html](https://www.github.com/coenttb/pointfree-html) - Efficient HTML rendering engine |
62 | 165 |
|
63 | | -## Contribution |
| 166 | +## License |
| 167 | + |
| 168 | +This project is licensed under the Apache 2.0 License. See [LICENSE](LICENSE) for details. |
| 169 | + |
| 170 | +## Contributing |
64 | 171 |
|
65 | 172 | Contributions are welcome! Please feel free to submit a Pull Request. |
66 | 173 |
|
67 | 174 | ## Feedback |
68 | 175 |
|
69 | | -If you have suggestions or find issues, please open a GitHub issue. Your feedback helps make this project better for everyone. |
| 176 | +If you have suggestions or find issues, please open a GitHub issue. |
70 | 177 |
|
71 | 178 | > [Subscribe to my newsletter](http://coenttb.com/en/newsletter/subscribe) |
72 | 179 | > |
73 | 180 | > [Follow me on X](http://x.com/coenttb) |
74 | | -> |
| 181 | +> |
75 | 182 | > [Connect on LinkedIn](https://www.linkedin.com/in/tenthijeboonkkamp) |
76 | | -
|
77 | | -## License |
78 | | - |
79 | | -This project is licensed under the Apache 2.0 License. See [LICENSE](LICENSE) for details. |
|
0 commit comments