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

New article: Lazy enumerator trick #337

Merged
merged 26 commits into from
Jan 8, 2025
Merged

Conversation

rossta
Copy link
Contributor

@rossta rossta commented Jan 8, 2025

New article time! This one embeds a small React app in an iframe.

I didn’t want to add React to the app just for the demo, so I built it as a separate standalone application hosted on Github pages. The source code lives at https://github.com/joyofrails/ruby-enumeration-demo.

This PR also adds some minor features like footer changes, an about me page, additional acknowledgements, improved text contrast in dark mode.

rossta added 25 commits January 5, 2025 07:00
Why an iframe? So I can host the demo js on a separate static site and
can avoid adding all those dependencies to Joy of Rails.

Why a turbo frame? So we can add pass some custom query params to get
the theme of the demo.
A bit convoluted here, but continuing down this path of keeping the demo
JS in a separate repo: we want to request an iframe URL with query
params with color scheme choices. Dark mode is not kept on the server at
the moment, so I use a Stimulus controller to set the final turbo frame
url on the frontend which is later converted to the appropriate iframe
url on the backend.

Send query params from Ruby to JS to Ruby to JS!!!
With the JS controller I added previously to update the frame src,
there’s no real need to go to the server for the color scheme since we
can query CSS variables from JS.
@rossta rossta force-pushed the article/ruby-enumeration-demo branch from 49bf68d to b8bb2e6 Compare January 8, 2025 04:51
@rossta rossta merged commit e6050a5 into main Jan 8, 2025
9 checks passed
@rossta rossta deleted the article/ruby-enumeration-demo branch January 8, 2025 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant