-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement air quality alerts in styled forecasts view #76
Implement air quality alerts in styled forecasts view #76
Commits on Nov 5, 2024
-
Add air quality alert styling colours to Tailwind
As these class names will be dynamically generated in the template, we need to explicitly include all of them in our Tailwind config file ‘safelist’, or else they will not be included in the build: https://tailwindcss.com/docs/content-configuration#safelisting-classes
Configuration menu - View commit details
-
Copy full SHA for e59ea14 - Browse repository at this point
Copy the full SHA e59ea14View commit details -
Refactor turbo stream implementation for updating forecasts
This approach, of returning via a turbo stream template, gives us more flexibility to apply changes to multple distinct elements within the page. In our case, we want to re render the pollen, UV and temperature predictions, but we’ll also want to re render the alert guidance component in the next commit.
Configuration menu - View commit details
-
Copy full SHA for 2c1b806 - Browse repository at this point
Copy the full SHA 2c1b806View commit details -
Create partial for rendering alert guidance
This will be triggered by the turbo stream in the previous commit, and will be rendered when there is an air quality alert. I have also removed the bold tags from the guidance text as they are not part of the designs.
Configuration menu - View commit details
-
Copy full SHA for f351951 - Browse repository at this point
Copy the full SHA f351951View commit details -
Add styles for incorporating alerts into air pollution tabs
The rules that govern which styles should apply are quite complex, so I have ended up with a slightly verbose implementation that hopefully is at least fairly clear. The order in which the classes are listed is also important - the ‘inactive’ class needs to be below ‘active’ in order to override it. There are two versions of each of the DAQI alert classes. This is unfortunate but allows us to simplify the Javascript code that toggles the selected classes.
Configuration menu - View commit details
-
Copy full SHA for b38b200 - Browse repository at this point
Copy the full SHA b38b200View commit details -
We will use this in our air pollution tabs when there is an alert.
Configuration menu - View commit details
-
Copy full SHA for d684306 - Browse repository at this point
Copy the full SHA d684306View commit details -
Create new DayTab view component
This component will allow us to store the logic required to calculate the styling required, which vary according to each DAQI level. Add background colour class util to air pollution prediction We will use this to generate the colour used in the forecast tabs.
Configuration menu - View commit details
-
Copy full SHA for 01a7aa4 - Browse repository at this point
Copy the full SHA 01a7aa4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9820a51 - Browse repository at this point
Copy the full SHA 9820a51View commit details -
Update JS active/inactive class toggle
We now need to toggle an inactive class as well as an active class, because of the interaction of the active class with the daqi-level classes. In cases of alerts, we want to override the active class with the relevant daqi-level class, but where that tab is not active, we want to override that again with our inactive styling.
Configuration menu - View commit details
-
Copy full SHA for 8109bce - Browse repository at this point
Copy the full SHA 8109bceView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2d0c48a - Browse repository at this point
Copy the full SHA 2d0c48aView commit details -
The integration tests in CI were complaining about overlapping elements on a button because of he icon on the new air pollution tab. It doesn’t matter that it overlaps, so I’ve introduced this alternative syntax to fix the issue.
Configuration menu - View commit details
-
Copy full SHA for 16567ec - Browse repository at this point
Copy the full SHA 16567ecView commit details
Commits on Nov 6, 2024
-
Update alert stylings for air pollution tabs
If today has an alert, we always want to display the alert stylings. For tomorrow and the day after tomorrow, if they have alerts, we only want to display the alert stylings when the tab is selected. I have opted for a slightly verbose Javascript implementation that extends the Stimulus code that was already in place, rather than bringing the tabs into the Turbo stream that is already in place for this action. However, if any part of this design becomes any more complex, this would probably be a good candidate to refactor along those lines.
Configuration menu - View commit details
-
Copy full SHA for e060cec - Browse repository at this point
Copy the full SHA e060cecView commit details -
Update integration tests to check for alert classes
We need to update our integration tests to allow us to explicitly set DAQI values, so that we can check that the correct class for that value has been set on the active tab where there is an alert.
Configuration menu - View commit details
-
Copy full SHA for 6eca99a - Browse repository at this point
Copy the full SHA 6eca99aView commit details