Skip to content

Commit

Permalink
feat: add button 'type' attribute (#43)
Browse files Browse the repository at this point in the history
* feat: add button type attribute

* fix: extension to button tag attributes

* remove ExpressibleByStringLiteral
  • Loading branch information
alephao authored Sep 23, 2024
1 parent 4d9d137 commit bec31e2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Sources/Elementary/HtmlAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ public extension HTMLAttribute where Tag == HTMLTag.link {
}
}

// button tag attributes
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
public extension HTMLAttribute where Tag == HTMLTag.button {
struct ButtonType: Sendable {
var value: String

init(value: String) {
self.value = value
}

public static let submit = ButtonType(value: "submit")
public static let reset = ButtonType(value: "reset")
public static let button = ButtonType(value: "button")
}

static func type(_ value: ButtonType) -> Self {
HTMLAttribute(name: "type", value: value.value)
}
}

// href attribute
public extension HTMLTrait.Attributes {
protocol href {}
Expand Down

0 comments on commit bec31e2

Please sign in to comment.