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

Build examples with trunk #1559

Merged
merged 59 commits into from
Sep 21, 2020
Merged

Build examples with trunk #1559

merged 59 commits into from
Sep 21, 2020

Conversation

siku2
Copy link
Member

@siku2 siku2 commented Sep 15, 2020

Description

Gone are the days of Bash scripts and thrown-together Python servers - trunk makes for a much better experience when it comes to building and serving Yew apps.
I'm also going through each example to bring them up to speed and add a helpful README which includes a list of potential improvements; hopefully encourage people to contribute to existing examples instead of creating new ones.

The new system will make it much easier to build all examples and I would like to use that chance to host them somewhere (Maybe GitHub Pages?). This will close #850 too.

Closes: #1568
Closes: #1534
Closes: #1368
Closes: #1289
Closes: #171 (oh man, that's an old one)

TODO

Somewhat related issues

List of examples that I deem satisfactory

Check them out!

Changes

OPEN

0. boids

Made some significant changes to this one.
The reason being that I wanted to have at least one more "finished" example.

1. counter

2. crm

Modified to make the example more modular.
What used to be a single component handling a lot of message spaghetti is now split into dedicated components.

3. custom_components

Should be updated or removed
REMOVED

4. dashboard

5. file_upload

6. fragments

Should be updated or removed
REMOVED

7. futures_wp

Renamed to just "futures" because we no longer need the ugly wasm-pack hack.
Make use of yewtil's LinkFuture trait.

8. game_of_life

Split code across two files.

9. inner_html

10. js_callback

Make use of wasm-bindgen's ability to automatically load js files without having to include them in the HTML.
Split the bindings into a separate file for clarity.

Trunk Issue: trunk-rs/trunk#40

11. keyed_list

Split into multiple files for clarity.

12. large_table

This example was removed because it's quite literally just a large table...
"game_of_life" offers a far superior but not quite as large table experience and "keyed_list" takes care of the large part.

13. minimal

Removed because this example is very similar to "counter" but it can only count to one.
A "minimal" example should either demonstrate every aspect of Yew's API in a small application or be a template.

14. minimal_wp

This example was removed because it's the same as "minimal" but for wasm-pack.
Different approaches to building apps should be explored through templates, not the examples.

15. mount_point

16. multi_thread

Trunk Issue: trunk-rs/trunk#46.

17. nested_list

18. node_refs

19. npm_and_rest

Renamed to "ccxt_and_gravatar" because it has nothing to do with NPM.
Updated the services to be more ergonomic and added display for the Gravatar profile.

Example should be updated or put out of its misery
REMOVED

20. pub_sub

Should be updated

20.5 router

Added this example to replace the old yew-router examples.
You know how it goes, it ended up becoming one of the most examples.

21. store

22. textarea

Removed because it's literally just a textarea.
Other examples like todomvc use similar concepts for something more useful.

23. timer

24. todomvc

Split State into a separate file to make it more manageable.
Updated TodoMVC CSS to latest version.

25. two_apps

26. webgl

@siku2 siku2 added ergonomics A-examples Area: The examples labels Sep 15, 2020
@siku2
Copy link
Member Author

siku2 commented Sep 15, 2020

This will result in a lot of "changes" simply due to renaming and splitting of files. I'm keeping a log of all the notable changes to keep it manageable.

_PR.md Outdated Show resolved Hide resolved
@jstarry
Copy link
Member

jstarry commented Sep 20, 2020

I think this covers this issue too: #1016


Edit: It doesn't totally cover the styling aspect actually

@siku2
Copy link
Member Author

siku2 commented Sep 20, 2020

@jstarry Yeah, I noticed that issue too.
Perhaps we should close it anyway because adding styling to the examples should be done for each one separately. It's unreasonable to update all of them in a single go (please ignore the irony with regards to this very pull request).
I've also added styling as an "improvement" to each example that needs it so we don't really need the issue for visibility.

Speaking of that issue though, @ZainlessBrombie has done some terrific styling work for some examples but it seems like it was never integrated. Perhaps we can try to salvage some of it?

I thought it would be great to use `unimplemented!()` in case the component doesn't have any properties.
This helps avoid the mistake of forgetting to update the change method when adding props later on.
What I didn't consider is that just because the props are () that doesn't mean that Yew isn't going to call it...
So yeah, it's still a good idea for update, but certainly not for change.
@siku2 siku2 marked this pull request as ready for review September 21, 2020 01:44
@siku2
Copy link
Member Author

siku2 commented Sep 21, 2020

Okay, deep breaths.... The final item on my list is updating the newly added router example to work on a subpath instead of the root (because we'll host it at /router instead of / and yew-router obviously doesn't like that).
But that's it!

@jstarry
Copy link
Member

jstarry commented Sep 21, 2020

Awesome, feel free to remove custom_components, fragments, and npm_and_rest examples. I'm not sure they add much value.

@siku2
Copy link
Member Author

siku2 commented Sep 21, 2020

Almost forgot about those, yeah. I'm pretty sure they can be removed - we have enough examples as is.
I will take a final look at all of this after I've gotten some rest.

@siku2
Copy link
Member Author

siku2 commented Sep 21, 2020

Just ran the final test and everything is working...

...except for serving the sub-routes of the router example.
Usually we can host SPAs on GitHub Pages using a 404.html files which is served when nothing else matches, but that doesn't work in subdirectories (Thanks GitHub).
So the router example is kind of broken (I mean, it works until you reload the page... That's at least some success).

So yet again GitHub has failed us...

@siku2
Copy link
Member Author

siku2 commented Sep 21, 2020

Let's finally merge this though. We can switch the hosting provider in a new PR, this one has grown way too big already.

@siku2 siku2 merged commit c946b99 into yewstack:master Sep 21, 2020
@siku2 siku2 deleted the trunk-examples branch September 21, 2020 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment