Skip to content

Commit 5f61bed

Browse files
committed
more html attributes
1 parent 573dfee commit 5f61bed

33 files changed

+428
-309
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PackageDescription
33

44
let defaultSwiftSettings: [SwiftSetting] = [
55
.swiftLanguageMode(.v6),
6-
.enableExperimentalFeature("AvailabilityMacro=swiftHTML 1.0:macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"),
6+
.enableExperimentalFeature("AvailabilityMacro=SwiftHTML 1.0:macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"),
77

88
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
99
.enableUpcomingFeature("MemberImportVisibility"),

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ All standard tags support child elements by default.
225225
// TODO
226226
```
227227

228+
## Future improvements
229+
230+
- [ ] Get rid of `@_exported SGML`
231+
- [ ] Add `OrderedDictionary` support?
228232

229233
## Credits & references
230234

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public struct AutocompleteAttribute: HTMLAttribute {
2+
public var value: String?
3+
4+
public init() {
5+
self.value = nil
6+
}
7+
}
8+
9+
public protocol AutocompleteAttributeModifier {
10+
11+
}
12+
13+
extension AutocompleteAttributeModifier where Self: Attributes & Mutable {
14+
15+
public func autocomplete() -> Self {
16+
setAttribute(AutocompleteAttribute())
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public struct AutofocusAttribute: HTMLAttribute {
2+
public var value: String?
3+
4+
public init() {
5+
self.value = nil
6+
}
7+
}
8+
9+
public protocol AutofocusAttributeModifier {
10+
11+
}
12+
13+
extension AutofocusAttributeModifier where Self: Attributes & Mutable {
14+
15+
public func autofocus() -> Self {
16+
setAttribute(AutofocusAttribute())
17+
}
18+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
public struct BlockingAttribute: HTMLAttribute {
2+
3+
public enum Value: String, Sendable {
4+
case render
5+
}
6+
7+
public var value: String?
8+
9+
public init(
10+
_ value: Value?
11+
) {
12+
self.value = value?.rawValue
13+
}
14+
}
15+
16+
public protocol BlockingAttributeModifier {
17+
18+
}
19+
20+
extension BlockingAttributeModifier where Self: Attributes & Mutable {
21+
22+
public func blocking(
23+
_ value: BlockingAttribute.Value? = .render
24+
) -> Self {
25+
setAttribute(BlockingAttribute(value))
26+
}
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public struct DataAttribute: HTMLAttribute {
2+
3+
public var value: String?
4+
5+
public init(
6+
_ value: String? = nil
7+
) {
8+
self.value = value
9+
}
10+
}
11+
12+
public protocol DataAttributeModifier {
13+
14+
}
15+
16+
extension DataAttributeModifier where Self: Attributes & Mutable {
17+
18+
public func data(
19+
_ value: String?
20+
) -> Self {
21+
setAttribute(DataAttribute(value))
22+
}
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
public struct FetchpriorityAttribute: HTMLAttribute {
2+
3+
public enum Value: String, Sendable {
4+
/// Fetch the external script at a high priority relative to other external scripts.
5+
case high
6+
/// Fetch the external script at a low priority relative to other external scripts.
7+
case low
8+
/// Don't set a preference for the fetch priority. This is the default. It is used if no value or an invalid value is set.
9+
case auto
10+
}
11+
12+
public var value: String?
13+
14+
public init(
15+
_ value: Value?
16+
) {
17+
self.value = value?.rawValue
18+
}
19+
}
20+
21+
public protocol FetchpriorityAttributeModifier {
22+
23+
}
24+
25+
extension FetchpriorityAttributeModifier where Self: Attributes & Mutable {
26+
27+
public func fetchpriority(
28+
_ value: FetchpriorityAttribute.Value?
29+
) -> Self {
30+
setAttribute(FetchpriorityAttribute(value))
31+
}
32+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public struct LabelAttribute: HTMLAttribute {
2+
public var value: String?
3+
4+
public init(
5+
_ value: String? = nil
6+
) {
7+
self.value = value
8+
}
9+
}
10+
11+
public protocol LabelAttributeModifier {
12+
13+
}
14+
15+
extension LabelAttributeModifier where Self: Attributes & Mutable {
16+
17+
public func label(
18+
_ value: String?
19+
) -> Self {
20+
setAttribute(LabelAttribute(value))
21+
}
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public struct MultipleAttribute: HTMLAttribute {
2+
public var value: String?
3+
4+
public init() {
5+
self.value = nil
6+
}
7+
}
8+
9+
public protocol MultipleAttributeModifier {
10+
11+
}
12+
13+
extension MultipleAttributeModifier where Self: Attributes & Mutable {
14+
15+
public func multiple() -> Self {
16+
setAttribute(MultipleAttribute())
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public struct ReadonlyAttribute: HTMLAttribute {
2+
public var value: String?
3+
4+
public init() {
5+
self.value = nil
6+
}
7+
}
8+
9+
public protocol ReadonlyAttributeModifier {
10+
11+
}
12+
13+
extension ReadonlyAttributeModifier where Self: Attributes & Mutable {
14+
15+
public func readonly() -> Self {
16+
setAttribute(ReadonlyAttribute())
17+
}
18+
}

0 commit comments

Comments
 (0)