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

Add "struct update" syntax to pass props to component (..props instead of with props) #2024

Merged
merged 24 commits into from
Sep 6, 2021

Conversation

Xavientois
Copy link
Contributor

Description

Update macros to use struct-update inspired syntax for props rather than with.

Now, you can write the following:

let user = yew::Props(...) 

<Comp name="Josh" ..user />

Fixes #1636

Checklist

  • I have run cargo make pr-flow
  • I have reviewed my own code
  • I have added tests

@github-actions
Copy link

github-actions bot commented Aug 30, 2021

Visit the preview URL for this PR (updated for commit 79599d9):

https://yew-rs--pr2024-add-double-dot-prop-hfiqz3dr.web.app

(expires Mon, 13 Sep 2021 00:22:56 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link
Contributor

@mc1098 mc1098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this syntax over the previous and the extra effort to make it so that you can set properties at the same time as using this new syntax is really nice!

The restriction of using this syntax at the end of the component props list, to me, is not an issue at all - it's consistent with Rust's syntax and I personally think it reads better when you have it at the end :)

A few requested changes from me but nothing too major really.
I think the naming of this syntax is worthwhile getting pinned down and using consistently throughout the docs and error messages but see my comment below for more on that particular point.

packages/yew-macro/src/props/component.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/props/component.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/props/prop.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/props/prop.rs Outdated Show resolved Hide resolved
packages/yew-macro/tests/html_macro/component-fail.stderr Outdated Show resolved Hide resolved
website/docs/concepts/html/components.md Outdated Show resolved Hide resolved
Copy link
Contributor

@mc1098 mc1098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One span tweak and one Nit :)

packages/yew-macro/tests/html_macro/component-fail.stderr Outdated Show resolved Hide resolved
website/docs/concepts/html/components.md Outdated Show resolved Hide resolved
Copy link
Contributor

@mc1098 mc1098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more round of tweaks and then I'm happy to approve this PR :D

packages/yew-macro/src/props/component.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/props/component.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@mc1098 mc1098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🎉

Copy link
Member

@siku2 siku2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a few nits.

packages/yew-macro/src/props/component.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/props/prop.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/props/component.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/props/component.rs Outdated Show resolved Hide resolved
siku2
siku2 previously approved these changes Sep 5, 2021
Copy link
Member

@siku2 siku2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the conflicts 🙏. Should be g2g after they're resolved though.

@mergify mergify bot dismissed siku2’s stale review September 5, 2021 23:45

Pull request has been modified.

@siku2 siku2 merged commit eeddcb9 into yewstack:master Sep 6, 2021
@Xavientois Xavientois deleted the add-double-dot-prop-syntax branch September 6, 2021 12:33
@voidpumpkin voidpumpkin added A-yew Area: The main yew crate A-yew-macro Area: The yew-macro crate labels Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate A-yew-macro Area: The yew-macro crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Rust's .. syntax instead of with in html!
4 participants