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

Append custom custom classes to labels #397

Merged
merged 2 commits into from
Nov 9, 2022
Merged

Commits on Nov 4, 2022

  1. Append custom custom classes to labels

    Before, custom classes passed in the `label` hash would override any existing
    classes.
    
    For example:
    
    ```erb
    <%= form_with model: @model do |f| %>
      <%= f.govuk_text_area :details, label: { text: "Some details", class: "special-class" } %>
    <% end %>
    ```
    
    would output:
    
    ```html
    <!-- form markup --!>
    
    <label for="model-details-field" class="special-class">
      Some details
    </label>
    
    <!-- form markup --!>
    ```
    
    Taking into consideration how the rest of the library behaves, this behvaiour
    was unexpected and meant users would need to explicitly provide default label
    classes.
    
    This change makes use of the `HTMLAttributes` and `HTMLClasses` traits so that label
    elements build classes as usual —except any custom classes are appended.
    
    For example:
    
    ```erb
    <%= form_with model: @model do |f| %>
      <%= f.govuk_text_area :details, label: { text: "Some details", class: "special-class" } %>
    <% end %>
    ```
    
    would now output:
    
    ```html
    <!-- form markup --!>
    
    <label for="model-details-field" class="govuk-label special-class">
      Some details
    </label>
    
    <!-- form markup --!?
    ```
    
    This change in behaviour will affect users of the gem who are customising label
    classes but _don't_ want default classes to be applied.
    
    I'm not sure if that is something we need to worry about though, since the form
    builder is intended to build GOV.UK (or other brand) forms.
    cpjmcquillan committed Nov 4, 2022
    Configuration menu
    Copy the full SHA
    b72c3c1 View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2022

  1. Append custom classes to hints, legends, captions

    Continuing from the prevoius commit, this change makes the additional
    classes passed in via the hint, legend and caption hashes add to the
    default rather than overwrite it. This makes it more consistent with the
    behaviour in the rest of the library.
    peteryates committed Nov 5, 2022
    Configuration menu
    Copy the full SHA
    63ae6b8 View commit details
    Browse the repository at this point in the history