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

Yew Function Component Support #23

Closed
futursolo opened this issue Aug 20, 2021 · 6 comments
Closed

Yew Function Component Support #23

futursolo opened this issue Aug 20, 2021 · 6 comments
Labels
enhancement New feature or request yew This issue is Yew specific

Comments

@futursolo
Copy link
Owner

futursolo commented Aug 20, 2021

This issue aims to experiment with hooks API that will be adopted with the upcoming function component for Yew 0.19.

@futursolo
Copy link
Owner Author

futursolo commented Aug 20, 2021

There're two sets of APIs that will be introduced:

  1. use_style and use_style! API.
    The function flavour of this hook will accept the same argument as Style::new and the macro flavour will accept the same argument as the upcoming procedural macro.

  2. styled_component(MyComponent) + css!

This API will introduce a styled_component attribute which will be equivalent to the original function_component from yew but also injects a manager instance with use_context at the beginning of the function component.

Purposed Syntax:

use stylist::yew::styled_component;

#[styled_component(MyComponent)]
fn my_component() -> Html {
    html! {
        <div class=css!(r#"color: red;"#)>
            {"Styled Text!"}
        </div>
    }
}

(The syntax for the css! API is tentative as procedural macro is not landed on master yet.)

Both APIs will be context aware.

@futursolo futursolo changed the title Hooks API Yew Function Component Support Aug 20, 2021
@futursolo futursolo added enhancement New feature or request yew This issue is Yew specific labels Aug 20, 2021
@futursolo futursolo mentioned this issue Aug 21, 2021
5 tasks
@WorldSEnder
Copy link
Collaborator

WorldSEnder commented Aug 30, 2021

I'm currently experimenting with having a branch that tracks yew@next until the release of 0.19. This could then host the hooks implementation. Current show stopper is yewdux not being updated to yewstack/yew#1961 yet. Guess it has to wait a bit.

@WorldSEnder
Copy link
Collaborator

The working parts live on the yew-next branch now

@futursolo
Copy link
Owner Author

I do plan to cut at least one more release before introducing hooks (switching to track yew master) so I am fine with it lives on a different branch for now.

@futursolo
Copy link
Owner Author

futursolo commented Sep 16, 2021

As per yewstack/yew#2052, I think the Yew 0.19 release is imminent.

I have updated the master branch to track master branch of Yew and implemented the styled_component API.

So as soon as Yew 0.19 is released we can release a version with function component support.

@futursolo
Copy link
Owner Author

futursolo commented Sep 16, 2021

The Yewdux and yewtil::store example have been replaced with Context API Example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request yew This issue is Yew specific
Projects
None yet
Development

No branches or pull requests

2 participants