govuk-components icon indicating copy to clipboard operation
govuk-components copied to clipboard

Make the library configurable

Open peteryates opened this issue 2 years ago • 3 comments

This is very much a WIP look at adding confguration to the gem. It's a useful feature to have because it will allow for some preferences to be set across entire apps, rather than repeatedly when using components. It also makes it easier for us to bring in breaking changes by allowing them to be introduced in a disabled state and toggle the default at the next major release (see #354).

  • [x] identify the things that should be configurable, things like:
    • default button text
    • default titles
    • headings
    • sizes
    • widths
  • [x] add some tests covering each config option
  • [x] cover the functionality in the guide

Configurable items

Back link

  • [x] text

Breadcrumbs

  • [x] hide_in_print
  • [x] collapse_on_mobile

Cookie banner

  • [x] aria_label
  • [x] hide_in_print

Footer #358

  • [x] copyright
  • [x] meta_licence
  • [x] meta_text

Header

  • [x] logotype
  • [x] menu_button_label
  • [x] navigation_label
  • [x] service_url
  • [x] service_name

Notification banner

  • [x] title_id
  • [x] disable_auto_focus
  • [x] title_heading_level
  • [x] success

Pagination

  • [x] landmark_label
  • [x] next_text
  • [x] previous_text

Phase banner

  • [x] tag
  • [x] text

Section break

  • [x] visible
  • [x] size

Start button

  • [x] as_button

Summary list

  • [x] borders
  • [x] ~~actions~~ (omitted this as I'm not sure it makes sense to be configurable)

Tag

  • [x] colour

Warning text

  • [x] icon_fallback_text
  • [x] icon (not currently configurable)

peteryates avatar Aug 05 '22 18:08 peteryates

Deploy Preview for govuk-components ready!

Name Link
Latest commit bfbe7754b145881f596886f4bde8109ea37ec065
Latest deploy log https://app.netlify.com/sites/govuk-components/deploys/631228fb9ccbfd00097d6333
Deploy Preview https://deploy-preview-355--govuk-components.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Aug 05 '22 18:08 netlify[bot]

I think this is a really nice idea. 🪄

Primer ViewComponents defines a fetch_or_fallback helper method that might be interesting reading.

You might have seen it already, and It's probably a bit too involved for a first pass, but I thought it might be useful nonetheless!

cpjmcquillan avatar Aug 11 '22 11:08 cpjmcquillan

@cpjmcquillan thanks for that Connor. #fetch_or_fallback is such a good idea - way more graceful than doing it ad hoc. Here and in the form builder we're relying on setting default arguments for keyword args, but I think in the helpers (where they're mimicking Rails' method signatures much more closely) it would be a great fit. I'll have a look into using a similar pattern.

peteryates avatar Aug 12 '22 09:08 peteryates