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

Upgrade the package #136

merged 3 commits into from
Jul 10, 2023

Conversation

mattesmohr
Copy link
Member

@mattesmohr mattesmohr commented Jul 2, 2023

This merge tackles the latest ideas and issues (#134, #138).

Conditional attributes

In the past you had to use the modify method to alter an attribute for an element based on a condition.

Input()
    .modify(if: true) {
       $0.checked()
    }

Now you can use the condition on the attribute with the same result.

Input()
   .checked(true)

Keep in mind not every attribute has a conditional option for now. I have added it to attributes, where I think it makes the most sense. If you find an attribute in the future, where you think it makes sense, let me know.

The modify method still exists. I am thinking about to remove it as we can use an if let to unwrap an optional too, but thats a topic for a different time.

Environment value

You can now pass an environment value to an attribute. Currently it is only available for the source attribute. The same applies here as for the conditional attributes, I am not sure for what attribute it makes sense or doesn't.

@EnvironmentObject(Asset.self)
asset

Figure {
    Image()
        .source(asset.path) /// was not possible before
    FigureCaption {
       asset.caption /// was possible before
    }
}

@mattesmohr mattesmohr merged commit 228a2e0 into main Jul 10, 2023
@mattesmohr mattesmohr deleted the upgrade/htmlkit-3.0-6 branch July 10, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant