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

An HTTP request example and a tailwindcss styling example #305

Merged
merged 9 commits into from
Dec 28, 2021

Conversation

attriaayush
Copy link
Contributor

I created this example (since I could not find an existing one) to get a feel for the developer experience of using a crate like reqwasm and styling with TailwindCSS when using sycamore.

This example makes a GET request to CountAPI that simply increments everytime you visit the page or refresh the page i.e. counting page visits. I picked this example since I just wanted to create a really simple HTTP request to fetch some json data and then be able to display that data which then further updates a Signal and resulting into updating the relevant component.

This also includes a little styling with TailwindCSS since the docs here suggested that the styling part is still under works.

To test, you can run trunk serve --open which should build everything and the serve the page.

@attriaayush attriaayush changed the title Example with a HTTP request and tailwindcss styling An example with a HTTP request and tailwindcss styling Nov 28, 2021
@lukechu10
Copy link
Member

I think it would be better to separate http requests using reqwasm and styling using tailwindcss into 2 distinct examples instead of combining them into one. What do you think?

@attriaayush
Copy link
Contributor Author

I think it would be better to separate http requests using reqwasm and styling using tailwindcss into 2 distinct examples instead of combining them into one. What do you think?

Thanks for reviewing the pull request.

That makes sense and I agree. More than happy to split this example into two distinct examples.

@attriaayush attriaayush changed the title An example with a HTTP request and tailwindcss styling An HTTP request example and a tailwindcss styling example Nov 30, 2021
@attriaayush
Copy link
Contributor Author

attriaayush commented Nov 30, 2021

@lukechu10
I have split this into two distinct examples. Still using the same base of http request example using reqwasm but this time isolating the tailwindcss styling setup into a different example that just simply builds on top of the previous example with a unique website_id.

Hope these are useful examples.

Copy link
Member

@lukechu10 lukechu10 left a comment

Choose a reason for hiding this comment

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

I'm not sure if it's best to have the tailwindcss example also include http request but I think it's fine for now.

examples/page-visit-counter-tailwindcss/index.html Outdated Show resolved Hide resolved
examples/page-visit-counter-tailwindcss/index.scss Outdated Show resolved Hide resolved
examples/page-visit-counter-tailwindcss/src/main.rs Outdated Show resolved Hide resolved
examples/page-visit-counter-tailwindcss/src/main.rs Outdated Show resolved Hide resolved
examples/page-visit-counter-tailwindcss/src/main.rs Outdated Show resolved Hide resolved
examples/page-visit-counter/src/main.rs Outdated Show resolved Hide resolved
@lukechu10
Copy link
Member

Also CI is failing because latest reqwasm uses edition 2021 which needs rust 1.56 and sycamore's MSRV is currently 1.53.
I sent a PR to reqwasm changing edition back to 2018.

@lukechu10 lukechu10 added the A-examples Area: examples label Nov 30, 2021
@attriaayush
Copy link
Contributor Author

attriaayush commented Nov 30, 2021

@lukechu10
Appreciate the feedback, I believe that all should be addressed now.

I'm not sure if it's best to have the tailwindcss example also include http request but I think it's fine for now.

My thinking behind this was that tailwindcss is just a styling layer and it could potentially be added to any existing example. In this case now that we have an isolated example for http why not just extend it and style the relevant component. Also majority of the time projects do contain http requests and styling thought it might represent that side of it in a really simple form.

attriaayush and others added 5 commits November 30, 2021 22:15
Update examples/page-visit-counter-tailwindcss/Trunk.toml

Co-authored-by: Luke Chu <37006668+lukechu10@users.noreply.github.com>

Update examples/page-visit-counter-tailwindcss/src/main.rs

Co-authored-by: Luke Chu <37006668+lukechu10@users.noreply.github.com>

Update examples/page-visit-counter-tailwindcss/src/main.rs

Co-authored-by: Luke Chu <37006668+lukechu10@users.noreply.github.com>
Copy link
Member

@lukechu10 lukechu10 left a comment

Choose a reason for hiding this comment

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

lgtm. I'm just waiting for reqwasm to push a new release so that it's compatible with rust 1.53

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2021

Codecov Report

Merging #305 (dd1d2f1) into master (7738584) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #305      +/-   ##
==========================================
- Coverage   73.21%   73.20%   -0.01%     
==========================================
  Files          38       40       +2     
  Lines        5313     5431     +118     
==========================================
+ Hits         3890     3976      +86     
- Misses       1423     1455      +32     
Impacted Files Coverage Δ
website/src/main.rs 0.81% <0.00%> (-0.01%) ⬇️
packages/sycamore/src/builder/html.rs 100.00% <0.00%> (ø)
packages/sycamore/src/builder/agnostic/mod.rs 65.55% <0.00%> (ø)
packages/sycamore-macro/src/component/mod.rs 76.25% <0.00%> (+0.78%) ⬆️
packages/sycamore/src/utils/render.rs 58.49% <0.00%> (+0.96%) ⬆️
packages/sycamore/src/utils/hydrate/mod.rs 79.16% <0.00%> (+3.75%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7738584...dd1d2f1. Read the comment docs.

attriaayush and others added 2 commits December 4, 2021 14:23
@lukechu10
Copy link
Member

I removed the non-tailwind example because in retrospect, I think it's better to not have duplicated code

@lukechu10 lukechu10 merged commit 0194a5d into sycamore-rs:master Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-examples Area: examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants