Module: GovukLinkHelper
- Defined in:
- app/helpers/govuk_link_helper.rb
Instance Method Summary collapse
- #govuk_breadcrumb_link_to(name, href = nil, **kwargs, &block) ⇒ Object
- #govuk_button_classes(inverse: false, secondary: false, warning: false) ⇒ Object
- #govuk_button_link_to(a, b = nil, new_tab: false, disabled: false, inverse: false, secondary: false, warning: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
- #govuk_button_to(a, b = nil, disabled: false, inverse: false, secondary: false, warning: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
- #govuk_footer_link_to(name, href = nil, **kwargs, &block) ⇒ Object
- #govuk_link_classes(inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false) ⇒ Object
- #govuk_link_to(a, b = nil, new_tab: false, inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
- #govuk_mail_to(a, b = nil, inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
Instance Method Details
#govuk_breadcrumb_link_to(name, href = nil, **kwargs, &block) ⇒ Object
54 55 56 57 58 |
# File 'app/helpers/govuk_link_helper.rb', line 54 def (name, href = nil, **kwargs, &block) link_args = { class: "#{brand}-breadcrumbs__link" }.deep_merge_html_attributes(kwargs) link_to(name, href, **link_args, &block) end |
#govuk_button_classes(inverse: false, secondary: false, warning: false) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/govuk_link_helper.rb', line 81 def (inverse: false, secondary: false, warning: false) if [inverse, secondary, warning].count(true) > 1 fail("buttons can only be one of inverse, secondary or warning") end class_names( "#{brand}-button", "#{brand}-button--inverse" => inverse, "#{brand}-button--secondary" => secondary, "#{brand}-button--warning" => warning, ) end |
#govuk_button_link_to(a, b = nil, new_tab: false, disabled: false, inverse: false, secondary: false, warning: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/govuk_link_helper.rb', line 41 def (a, b = nil, new_tab: false, disabled: false, inverse: false, secondary: false, warning: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) (block_given?) ? (name, href = nil, a) : (name, href = a, b) = (new_tab:, disabled:, inverse:, secondary:, warning:, **kwargs) = build_text(name, new_tab:, visually_hidden_prefix:, visually_hidden_suffix:) if block_given? link_to(href, **, &block) else link_to(, href, **) end end |
#govuk_button_to(a, b = nil, disabled: false, inverse: false, secondary: false, warning: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/govuk_link_helper.rb', line 28 def (a, b = nil, disabled: false, inverse: false, secondary: false, warning: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) (block_given?) ? (name, href = nil, a) : (name, href = a, b) = (new_tab: false, disabled:, inverse:, secondary:, warning:, **kwargs) = build_text(name, visually_hidden_prefix:, visually_hidden_suffix:) if block_given? (href, **, &block) else (, href, **) end end |
#govuk_footer_link_to(name, href = nil, **kwargs, &block) ⇒ Object
60 61 62 63 64 |
# File 'app/helpers/govuk_link_helper.rb', line 60 def (name, href = nil, **kwargs, &block) link_args = { class: "#{brand}-footer__link" }.deep_merge_html_attributes(kwargs) link_to(name, href, **link_args, &block) end |
#govuk_link_classes(inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/govuk_link_helper.rb', line 66 def govuk_link_classes(inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false) if [text_colour, inverse, muted].count(true) > 1 fail("links can be only be one of text_colour, inverse or muted") end class_names( "#{brand}-link", "#{brand}-link--inverse" => inverse, "#{brand}-link--muted" => muted, "#{brand}-link--no-underline" => no_underline, "#{brand}-link--no-visited-state" => no_visited_state, "#{brand}-link--text-colour" => text_colour, ) end |
#govuk_link_to(a, b = nil, new_tab: false, inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/govuk_link_helper.rb', line 6 def govuk_link_to(a, b = nil, new_tab: false, inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) (block_given?) ? (name, href = nil, a) : (name, href = a, b) link_args = extract_link_args(new_tab:, inverse:, muted:, no_underline:, no_visited_state:, text_colour:, **kwargs) link_text = build_text(name, new_tab:, visually_hidden_prefix:, visually_hidden_suffix:) if block_given? link_to(href, **link_args, &block) else link_to(link_text, href, **link_args) end end |
#govuk_mail_to(a, b = nil, inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/helpers/govuk_link_helper.rb', line 19 def govuk_mail_to(a, b = nil, inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false, visually_hidden_prefix: nil, visually_hidden_suffix: nil, **kwargs, &block) (block_given?) ? (email_address, name = a, nil) : (email_address, name = a, b) link_args = extract_link_args(inverse:, muted:, no_underline:, no_visited_state:, text_colour:, **kwargs) link_text = build_text(name, visually_hidden_prefix:, visually_hidden_suffix:) mail_to(email_address, link_text, **link_args, &block) end |