Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add button 'type' attribute #43

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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