Skip to content

Version 2.0.0

Compare
Choose a tag to compare
@peteryates peteryates released this 18 Aug 14:11
3815d63

This is a big release and many components have been rewritten to take advantage of new functionality in ViewComponent.

Huge, huge thanks to @cpjmcquillan and @paulrobertlloyd for their help in putting this release together and to @boardfish and @BroiSatse for helping solve problems along the way!

Changes to the library

  • aim for parity with the official GOV.UK Nunjucks macros (@paulrobertlloyd)
  • move from ViewComponent slots v1 to v2
  • switch specs from Capybara to RSpec HTML Matchers
  • deprecate the #add_slot_name (formerly #slot_name) helpers, this syntax has been adopted by ViewComponent itself
    in slots v2, so we no longer need to do it ourselves
  • make code meet (most of) the GOV.UK Rubocop 4.0.0 standards
  • added Component to the end of each component's name (Accordion to AccordionComponent). This helps avoid repetition in some places, i.e., Tabs#tabs
  • link helpers wrap their original Rails counterparts more closely, they can be called with either a URL, path or Rails-style action and controller arguments
  • there are now #govuk_link_classes and #govuk_button_classes helpers you can use in conjunction with other Rails's other link helpers like #link_to_if and #link_to_unless
  • add support for GOV.UK Frontend 3.13.0

The changes were logged in #158 and links to the relevant PRs are listed. The work as a whole is detailed in the Version 2.0.0 GitHub project.

Changes

More changes have been made than would be sensible to list in a single changelog entry. Details on specific components can be found in #158 and upgrades to bring in line with their Nunjucks counterparts are listed in #202.

Upgrade guide

  • component names now match those listed in the GOV.UK Design System docs with Component on the end, so 'Notification banner' is GovukComponent::NotificationBannerComponent. The helpers remain unchanged except:

    • govuk_start_now_button is now govuk_start_button
    • govuk_warning is now govuk_warning_text
  • keyword argument names now match those in the Nunjucks originals, but here we use snake_case instead of camelCase - in a summary list action you'd use visually_hidden_text instead of `visuallyHidd>

  • any _html arguments in the original Nunjucks macros are now slots, we can pass in a block of HTML instead:

    <%= govuk_notification_banner do |nb| %>
      <% nb.title_html do %>
        <h3>Add something useful here!</h3>
      <% end %>
    
      <% nb.heading(text: 'Something excellent happened') %>
    <% end %>
  • slots are now called using their name directly, component.slot(:slot_name, ...) becomes component.slot_name(...)

  • check the examples page for sample code

Support

As always, if you run into any problems in upgrading, please raise an issue on GitHub or ask a question in #developers on DfE Slack or #software-development on cross-gov Slack.