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

Upgrade the package #136

Merged
merged 3 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public protocol AutoplayAttribute: Attribute {
/// <tag autoplay />
/// ```
func autoplay() -> Self

func autoplay(_ condition: Bool) -> Self
}

extension AutoplayAttribute where Self: ContentNode {
Expand Down Expand Up @@ -273,6 +275,8 @@ public protocol CheckedAttribute: Attribute {
/// <tag checked />
/// ```
func checked() -> Self

func checked(_ condition: Bool) -> Self
}

extension CheckedAttribute where Self: ContentNode {
Expand Down Expand Up @@ -625,6 +629,8 @@ public protocol DisabledAttribute: Attribute {
/// <tag disabled />
/// ```
func disabled() -> Self

func disabled(_ condition: Bool) -> Self
}

extension DisabledAttribute where Self: ContentNode {
Expand Down Expand Up @@ -914,6 +920,8 @@ public protocol HiddenAttribute: Attribute {
/// <tag hidden />
/// ```
func hidden() -> Self

func hidden(_ condition: Bool) -> Self
}

extension HiddenAttribute where Self: ContentNode {
Expand Down Expand Up @@ -1878,6 +1886,8 @@ public protocol ReadyOnlyAttribute: Attribute {
/// <tag readonly />
/// ```
func readonly() -> Self

func readonly(_ condition: Bool) -> Self
}

extension ReadyOnlyAttribute where Self: ContentNode {
Expand Down Expand Up @@ -1953,6 +1963,8 @@ public protocol RequiredAttribute: Attribute {
/// <tag required />
/// ```
func required() -> Self

func required(_ condition: Bool) -> Self
}

extension RequiredAttribute where Self: ContentNode {
Expand Down Expand Up @@ -2278,20 +2290,30 @@ public protocol SourceAttribute: Attribute {
/// <tag src="" />
/// ```
func source(_ value: String) -> Self

func source(_ value: EnvironmentValue) -> Self
}

extension SourceAttribute where Self: ContentNode {

internal func mutate(source value: String) -> Self {
return self.mutate(key: "src", value: value)
}

internal func mutate(source value: EnvironmentValue) -> Self {
return self.mutate(key: "src", value: value)
}
}

extension SourceAttribute where Self: EmptyNode {

internal func mutate(source value: String) -> Self {
return self.mutate(key: "src", value: value)
}

internal func mutate(source value: EnvironmentValue) -> Self {
return self.mutate(key: "src", value: value)
}
}

/// The protocol provides the element with the start handler.
Expand Down
9 changes: 9 additions & 0 deletions Sources/HTMLKit/Abstraction/Elements/BasicElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ extension Html: GlobalAttributes, GlobalEventAttributes {
public func hidden() -> Html {
return mutate(hidden: "hidden")
}

public func hidden(_ condition: Bool) -> Html {

if condition {
return mutate(hidden: "hidden")
}

return self
}

public func inputMode(_ value: String) -> Html {
return mutate(inputmode: value)
Expand Down
Loading