Module: Govuk::Components

Includes:
ActiveSupport::Configurable
Defined in:
lib/govuk/components/engine.rb,
lib/govuk/components/version.rb,
lib/govuk/components/helpers/css_utilities.rb

Defined Under Namespace

Modules: Helpers Classes: Engine

Defaults collapse

DEFAULTS =

Default components configuration

:brand sets the value used to prefix all classes, used to allow the components to be branded for alternative (similar) design systems :default_back_link_text Default text for the back link, defaults to Back :default_breadcrumbs_collapse_on_mobile false :default_breadcrumbs_hide_in_print false :default_cookie_banner_aria_label “Cookie banner” :default_cookie_banner_hide_in_print true :default_error_prefix Text to use at the start of the page title tag when there is an error on the page. Default is ‘Error: ’ :default_exit_this_page_redirect_url The URL that the exit this page component links to by default. Defaults to www.bbc.co.uk/weather :default_exit_this_page_text The default text that forms the link. Defaults to ‘Exit this page’ :default_exit_this_page_activated_text Text announced by screen readers when Exit this Page has been activated via the keyboard shortcut. Default in govuk-frontend is ‘Exiting page.’ Defaults to nil so govuk-frontend value is used unless overridden. :default_exit_this_page_timed_out_text Text announced by screen readers when the keyboard shortcut has timed out without successful activation. Default in govuk-frontend is ‘Exit this page expired.’ Defaults to nil so govuk-frontend value is used unless overridden. :default_exit_this_page_press_two_more_times_text Text announced by screen readers when the user must press Shift two more times to activate the button. Default in govuk-frontend is ‘Shift, press 2 more times to exit.’ Defaults to nil so govuk-frontend value is used unless overridden. :default_exit_this_page_press_one_more_time_text Text announced by screen readers when the user must press Shift one more time to activate the button. Default in govuk-frontend is ‘Shift, press 1 more time to exit.’ Defaults to nil so govuk-frontend value is used unless overridden. :default_header_navigation_label ‘Navigation menu’ :default_header_menu_button_label ‘Show or hide navigation menu’ :default_header_homepage_url ‘/’ :default_header_service_name nil :default_header_service_url ‘/’ :default_footer_meta_text nil :default_footer_copyright_text ‘© Crown copyright’ :default_footer_copyright_urlwww.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/” :default_pagination_landmark_label “Pagination” :default_pagination_next_text Default ‘next’ text for pagination. An Array where the first item is visible and the second visually hidden. Defaults to [“Next”, “page”] :default_pagination_previous_text Default ‘previous’ text for pagination. An Array where the first item is visible and the second visually hidden. Defaults to [“Previous”, “page”] :default_phase_banner_tag nil :default_phase_banner_text nil :default_section_break_visible false :default_section_break_size Size of the section break, possible values: m, l and xl. Defaults to nil. :default_tag_colour the default colour for tags, possible values: grey, green, turquoise, blue, red, purple, pink, orange, yellow. Defaults to nil :default_start_button_as_button false :default_summary_list_borders true :default_notification_banner_title_id “govuk-notification-banner-title” :default_notification_disable_auto_focus nil :default_notification_title_heading_level 2 :default_notification_title_success false :default_warning_text_icon_fallback_text “Warning” :default_warning_text_icon “!”

:require_summary_list_action_visually_hidden_text when true forces visually hidden text to be set for every action. It can still be explicitly skipped by passing in nil. Defaults to false :enable_auto_table_scopes automatically adds a scope of ‘col’ to th elements in thead and ‘row’ to th elements in tbody.

{
  brand: 'govuk',
  default_back_link_text: 'Back',
  default_breadcrumbs_collapse_on_mobile: false,
  default_breadcrumbs_hide_in_print: false,
  default_cookie_banner_aria_label: "Cookie banner",
  default_cookie_banner_hide_in_print: true,
  default_error_prefix: "Error: ",
  default_exit_this_page_redirect_url: "https://www.bbc.co.uk/weather",
  default_exit_this_page_text: "Exit this page",
  default_exit_this_page_activated_text: nil,
  default_exit_this_page_timed_out_text: nil,
  default_exit_this_page_press_two_more_times_text: nil,
  default_exit_this_page_press_one_more_time_text: nil,
  default_header_navigation_label: 'Menu',
  default_header_menu_button_label: 'Show or hide menu',
  default_header_homepage_url: '/',
  default_header_service_name: nil,
  default_header_service_url: '/',
  default_footer_meta_text: nil,
  default_footer_copyright_text: '© Crown copyright',
  default_footer_copyright_url: "https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/",
  default_pagination_landmark_label: "Pagination",
  default_pagination_next_text: %w(Next page),
  default_pagination_previous_text: %w(Previous page),
  default_phase_banner_tag: nil,
  default_phase_banner_text: nil,
  default_section_break_visible: false,
  default_section_break_size: nil,
  default_tag_colour: nil,
  default_start_button_as_button: false,
  default_summary_list_borders: true,
  default_notification_banner_title_id: "govuk-notification-banner-title",
  default_notification_disable_auto_focus: nil,
  default_notification_title_heading_level: 2,
  default_notification_title_success: false,
  default_warning_text_icon_fallback_text: "Warning",
  default_warning_text_icon: "!",
  default_link_new_tab_text: "(opens in new tab)",
  require_summary_list_action_visually_hidden_text: false,
  enable_auto_table_scopes: true,
}.freeze

Constant Summary collapse

VERSION =
'5.3.0'.freeze

Class Method Summary collapse

Class Method Details

.configure {|config| ... } ⇒ Object

Configure the form builder in the usual manner. All of the keys in DEFAULTS can be configured as per the example below

Examples:

Govuk::Components.configure do |conf|
  conf.do_some_things = 'yes'
end

Yields:

  • (config)


16
17
18
# File 'lib/govuk/components/engine.rb', line 16

def configure
  yield(config)
end

.reset!Object

Note:

This method is only really intended for use to clean up during testing

Resets each of the configurable values to its default



24
25
26
27
28
# File 'lib/govuk/components/engine.rb', line 24

def reset!
  configure do |c|
    DEFAULTS.each { |k, v| c.send("#{k}=", v) }
  end
end