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

Drive page content with URL parameters #116

Merged
merged 6 commits into from
Nov 18, 2024
Merged

Drive page content with URL parameters #116

merged 6 commits into from
Nov 18, 2024

Conversation

jdudley1123
Copy link
Member

Context

Currently switching zone or day involves a lot of JS and passing of variables. The forecast (the tabs), the map, and the predictions (UV, pollen, temperature) are all handled separately which makes the logic complex.

Changes in this PR

This PR changes the page content to be driven by the URL parameters zone and day. The existing Turbo frames/stream are replaced by a single Turbo frame for the whole forecast + map + predictions block, which is updated by a form containing the zone and day information.

This has the added benefit that shared URLs can be more specific.

The day parameter in the URL is used to select the day forecast and to style the tab components.

The classes still refer to the active tab as 'today', but we'll clean that up later.
Currently the map loads to today's map. We need it to check which day and pollution state it's rendering when it loads.
Changing the frame will mean we lose the map, so we need to reinitialize it on connection.
Because the form is within the Turbo frame, only the frame will be affected, and will load a new forecast with the updated parameters from the form.
Now we're using a single Turbo frame for the forecast, map, and predictions, we can get rid of the old frames and streaming.
Following the same pattern we established for the zone selector, we remove the link from each tab and instead add a hidden form field and submit the form when a tab is clicked on.
@jdudley1123 jdudley1123 merged commit 14aafd0 into develop Nov 18, 2024
2 checks passed
@jdudley1123 jdudley1123 deleted the url-params-3 branch November 18, 2024 16:14
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