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

Implement air quality alerts in styled forecasts view #76

Merged

Commits on Nov 5, 2024

  1. 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
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    e59ea14 View commit details
    Browse the repository at this point in the history
  2. 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.
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    2c1b806 View commit details
    Browse the repository at this point in the history
  3. 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.
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    f351951 View commit details
    Browse the repository at this point in the history
  4. 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.
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    b38b200 View commit details
    Browse the repository at this point in the history
  5. Add exclamation triangle icon

    We will use this in our air pollution tabs when there is an alert.
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    d684306 View commit details
    Browse the repository at this point in the history
  6. 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.
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    01a7aa4 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    9820a51 View commit details
    Browse the repository at this point in the history
  8. 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.
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    8109bce View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    2d0c48a View commit details
    Browse the repository at this point in the history
  10. Fix Cuprite error

    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.
    patrickjfl committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    16567ec View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2024

  1. 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.
    patrickjfl committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    e060cec View commit details
    Browse the repository at this point in the history
  2. 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.
    patrickjfl committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    6eca99a View commit details
    Browse the repository at this point in the history