govuk-components 2.0.0b5 → 2.0.0b6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/app/components/govuk_component/accordion_component.html.erb +1 -11
 - data/app/components/govuk_component/accordion_component.rb +18 -31
 - data/app/components/govuk_component/accordion_component/section_component.html.erb +11 -0
 - data/app/components/govuk_component/accordion_component/section_component.rb +41 -0
 - data/app/components/govuk_component/back_link_component.rb +7 -3
 - data/app/components/govuk_component/breadcrumbs_component.html.erb +2 -9
 - data/app/components/govuk_component/breadcrumbs_component.rb +24 -1
 - data/app/components/govuk_component/footer_component.html.erb +4 -4
 - data/app/components/govuk_component/footer_component.rb +45 -7
 - data/app/components/govuk_component/header_component.html.erb +3 -3
 - data/app/components/govuk_component/header_component.rb +2 -2
 - data/app/components/govuk_component/inset_text_component.rb +9 -4
 - data/app/components/govuk_component/notification_banner_component.html.erb +3 -3
 - data/app/components/govuk_component/notification_banner_component.rb +11 -4
 - data/app/components/govuk_component/phase_banner_component.rb +2 -2
 - data/app/components/govuk_component/summary_list_component.rb +3 -1
 - data/app/components/govuk_component/tag_component.rb +8 -14
 - data/app/helpers/govuk_link_helper.rb +84 -35
 - data/app/helpers/govuk_skip_link_helper.rb +7 -2
 - data/lib/govuk/components/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 71ba722e8aa82977774d53d3b6d8352dbceddc1966974f356aca9e4337c9b086
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 193426f137c69991e3d7bf57b005141778ea48d24026158af303450ed326b768
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: eed11ed8f35f73dcf0328cd6d9640037ba2971e105b6258f039eba78b183fb425a8aa2d1b4e632dfa6cecbadb443395659384d14a9ca657bc7fa190f7ebc2222
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bc13182bb9c0ef100fe4ee4bc1ceb09ab98eedfc87a47bf538cc06d7fe5f3a01ab646fdb2f1aee96f04dd0c4760b66fc0d3a1e45b868965a11c145706a5ab5aa
         
     | 
| 
         @@ -1,15 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <%= tag.div(id: @id, class: classes, data: { module: 'govuk-accordion' }, **html_attributes) do %>
         
     | 
| 
       2 
2 
     | 
    
         
             
              <% sections.each do |section| %>
         
     | 
| 
       3 
     | 
    
         
            -
                <%=  
     | 
| 
       4 
     | 
    
         
            -
                  <div class="govuk-accordion__section-header">
         
     | 
| 
       5 
     | 
    
         
            -
                    <h2 class="govuk-accordion__section-heading">
         
     | 
| 
       6 
     | 
    
         
            -
                      <%= tag.span(section.title, id: section.id, class: "govuk-accordion__section-button", aria: { expanded: section.expanded?, controls: section.id(suffix: 'content') }) %>
         
     | 
| 
       7 
     | 
    
         
            -
                    </h2>
         
     | 
| 
       8 
     | 
    
         
            -
                    <% if section.summary.present? %>
         
     | 
| 
       9 
     | 
    
         
            -
                      <%= tag.div(section.summary, id: section.id(suffix: 'summary'), class: %w(govuk-accordion__section-summary govuk-body)) %>
         
     | 
| 
       10 
     | 
    
         
            -
                    <% end %>
         
     | 
| 
       11 
     | 
    
         
            -
                  </div>
         
     | 
| 
       12 
     | 
    
         
            -
                  <%= section %>
         
     | 
| 
       13 
     | 
    
         
            -
                <% end %>
         
     | 
| 
      
 3 
     | 
    
         
            +
                <%= section %>
         
     | 
| 
       14 
4 
     | 
    
         
             
              <% end %>
         
     | 
| 
       15 
5 
     | 
    
         
             
            <% end %>
         
     | 
| 
         @@ -1,12 +1,23 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::AccordionComponent < GovukComponent::Base
         
     | 
| 
       2 
     | 
    
         
            -
              renders_many :sections,  
     | 
| 
      
 2 
     | 
    
         
            +
              renders_many :sections, ->(heading_text: nil, summary_text: nil, expanded: false, classes: [], html_attributes: {}, &block) do
         
     | 
| 
      
 3 
     | 
    
         
            +
                GovukComponent::AccordionComponent::SectionComponent.new(
         
     | 
| 
      
 4 
     | 
    
         
            +
                  classes: classes,
         
     | 
| 
      
 5 
     | 
    
         
            +
                  expanded: expanded,
         
     | 
| 
      
 6 
     | 
    
         
            +
                  heading_level: heading_level,      # set once at parent level, passed to all children
         
     | 
| 
      
 7 
     | 
    
         
            +
                  html_attributes: html_attributes,
         
     | 
| 
      
 8 
     | 
    
         
            +
                  summary_text: summary_text,
         
     | 
| 
      
 9 
     | 
    
         
            +
                  heading_text: heading_text,
         
     | 
| 
      
 10 
     | 
    
         
            +
                  &block
         
     | 
| 
      
 11 
     | 
    
         
            +
                )
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
       3 
13 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              attr_reader :id
         
     | 
| 
      
 14 
     | 
    
         
            +
              attr_reader :id, :heading_level
         
     | 
| 
       5 
15 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
              def initialize(id: nil, classes: [], html_attributes: {})
         
     | 
| 
      
 16 
     | 
    
         
            +
              def initialize(id: nil, heading_level: 2, classes: [], html_attributes: {})
         
     | 
| 
       7 
17 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       8 
18 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                @id 
     | 
| 
      
 19 
     | 
    
         
            +
                @id            = id
         
     | 
| 
      
 20 
     | 
    
         
            +
                @heading_level = heading_tag(heading_level)
         
     | 
| 
       10 
21 
     | 
    
         
             
              end
         
     | 
| 
       11 
22 
     | 
    
         | 
| 
       12 
23 
     | 
    
         
             
            private
         
     | 
| 
         @@ -15,33 +26,9 @@ private 
     | 
|
| 
       15 
26 
     | 
    
         
             
                %w(govuk-accordion)
         
     | 
| 
       16 
27 
     | 
    
         
             
              end
         
     | 
| 
       17 
28 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
               
     | 
| 
       19 
     | 
    
         
            -
                 
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                alias_method :expanded?, :expanded
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                def initialize(title:, summary: nil, expanded: false, classes: [], html_attributes: {})
         
     | 
| 
       24 
     | 
    
         
            -
                  super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                  @title    = title
         
     | 
| 
       27 
     | 
    
         
            -
                  @summary  = summary
         
     | 
| 
       28 
     | 
    
         
            -
                  @expanded = expanded
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                def id(suffix: nil)
         
     | 
| 
       32 
     | 
    
         
            -
                  [title.parameterize, suffix].compact.join('-')
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                def call
         
     | 
| 
       36 
     | 
    
         
            -
                  tag.div(content, id: id(suffix: 'content'), class: %w(govuk-accordion__section-content), aria: { labelledby: id })
         
     | 
| 
       37 
     | 
    
         
            -
                end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
              private
         
     | 
| 
      
 29 
     | 
    
         
            +
              def heading_tag(level)
         
     | 
| 
      
 30 
     | 
    
         
            +
                fail(ArgumentError, "heading_level must be 1-6") unless level.in?(1..6)
         
     | 
| 
       40 
31 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                 
     | 
| 
       42 
     | 
    
         
            -
                  %w(govuk-accordion__section).tap do |classes|
         
     | 
| 
       43 
     | 
    
         
            -
                    classes.append("govuk-accordion__section--expanded") if expanded?
         
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
                %(h#{level})
         
     | 
| 
       46 
33 
     | 
    
         
             
              end
         
     | 
| 
       47 
34 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%= tag.div(id: id(suffix: 'section'), class: classes, **html_attributes) do %>
         
     | 
| 
      
 2 
     | 
    
         
            +
              <div class="govuk-accordion__section-header">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <%= content_tag(heading_level, class: "govuk-accordion__section-heading") do %>
         
     | 
| 
      
 4 
     | 
    
         
            +
                  <%= tag.span(heading_content, id: id, class: "govuk-accordion__section-button", aria: { expanded: expanded?, controls: id(suffix: 'content') }) %>
         
     | 
| 
      
 5 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 6 
     | 
    
         
            +
                <% if summary_content.present? %>
         
     | 
| 
      
 7 
     | 
    
         
            +
                  <%= tag.div(summary_content, id: id(suffix: 'summary'), class: %w(govuk-accordion__section-summary govuk-body)) %>
         
     | 
| 
      
 8 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 9 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 10 
     | 
    
         
            +
              <%= tag.div(content, id: id(suffix: 'content'), class: %w(govuk-accordion__section-content), aria: { labelledby: id }) %>
         
     | 
| 
      
 11 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class GovukComponent::AccordionComponent::SectionComponent < GovukComponent::Base
         
     | 
| 
      
 2 
     | 
    
         
            +
              attr_reader :heading_text, :summary_text, :expanded, :heading_level
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              renders_one :heading_html
         
     | 
| 
      
 5 
     | 
    
         
            +
              renders_one :summary_html
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              alias_method :expanded?, :expanded
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def initialize(heading_text:, summary_text:, expanded:, heading_level:, classes: [], html_attributes: {})
         
     | 
| 
      
 10 
     | 
    
         
            +
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                @heading_text  = heading_text
         
     | 
| 
      
 13 
     | 
    
         
            +
                @summary_text  = summary_text
         
     | 
| 
      
 14 
     | 
    
         
            +
                @expanded      = expanded
         
     | 
| 
      
 15 
     | 
    
         
            +
                @heading_level = heading_level
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              def id(suffix: nil)
         
     | 
| 
      
 19 
     | 
    
         
            +
                # generate a random number if we don't have heading_text to avoid attempting
         
     | 
| 
      
 20 
     | 
    
         
            +
                # to parameterize a potentially-huge chunk of HTML
         
     | 
| 
      
 21 
     | 
    
         
            +
                @prefix ||= heading_text&.parameterize || SecureRandom.hex(4)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                [@prefix, suffix].compact.join('-')
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              def heading_content
         
     | 
| 
      
 27 
     | 
    
         
            +
                heading_html || heading_text || fail(ArgumentError, "no heading_text or heading_html")
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              def summary_content
         
     | 
| 
      
 31 
     | 
    
         
            +
                summary_html || summary_text
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            private
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def default_classes
         
     | 
| 
      
 37 
     | 
    
         
            +
                %w(govuk-accordion__section).tap do |classes|
         
     | 
| 
      
 38 
     | 
    
         
            +
                  classes.append("govuk-accordion__section--expanded") if expanded?
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::BackLinkComponent < GovukComponent::Base
         
     | 
| 
       2 
     | 
    
         
            -
              attr_reader :text, :href 
     | 
| 
      
 2 
     | 
    
         
            +
              attr_reader :text, :href
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              def initialize( 
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize(href:, text: nil, classes: nil, html_attributes: {})
         
     | 
| 
       5 
5 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                @text = text
         
     | 
| 
         @@ -9,11 +9,15 @@ class GovukComponent::BackLinkComponent < GovukComponent::Base 
     | 
|
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              def call
         
     | 
| 
       12 
     | 
    
         
            -
                link_to( 
     | 
| 
      
 12 
     | 
    
         
            +
                link_to(link_content, href, class: classes, **html_attributes)
         
     | 
| 
       13 
13 
     | 
    
         
             
              end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            private
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
      
 17 
     | 
    
         
            +
              def link_content
         
     | 
| 
      
 18 
     | 
    
         
            +
                text || content || fail(ArgumentError, "no text or content")
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       17 
21 
     | 
    
         
             
              def default_classes
         
     | 
| 
       18 
22 
     | 
    
         
             
                %w(govuk-back-link)
         
     | 
| 
       19 
23 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,14 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <%= tag.div(class: classes, **html_attributes) do %>
         
     | 
| 
       2 
2 
     | 
    
         
             
              <ol class="govuk-breadcrumbs__list">
         
     | 
| 
       3 
     | 
    
         
            -
                <% @breadcrumbs.each do | 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
                  <% if link.present? %>
         
     | 
| 
       6 
     | 
    
         
            -
                    <li class="govuk-breadcrumbs__list-item">
         
     | 
| 
       7 
     | 
    
         
            -
                      <%= link_to(text, link, class: "govuk-breadcrumbs__link") %>
         
     | 
| 
       8 
     | 
    
         
            -
                    </li>
         
     | 
| 
       9 
     | 
    
         
            -
                  <% else %>
         
     | 
| 
       10 
     | 
    
         
            -
                    <%= tag.li(text, class: "govuk-breadcrumbs__list-item", aria: { current: "page" }) %>
         
     | 
| 
       11 
     | 
    
         
            -
                  <% end %>
         
     | 
| 
      
 3 
     | 
    
         
            +
                <% @breadcrumbs.each do |link| %>
         
     | 
| 
      
 4 
     | 
    
         
            +
                  <%= link %>
         
     | 
| 
       12 
5 
     | 
    
         
             
                <% end %>
         
     | 
| 
       13 
6 
     | 
    
         
             
              </ol>
         
     | 
| 
       14 
7 
     | 
    
         
             
            <% end %>
         
     | 
| 
         @@ -4,7 +4,7 @@ class GovukComponent::BreadcrumbsComponent < GovukComponent::Base 
     | 
|
| 
       4 
4 
     | 
    
         
             
              def initialize(breadcrumbs:, hide_in_print: false, collapse_on_mobile: false, classes: [], html_attributes: {})
         
     | 
| 
       5 
5 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                @breadcrumbs        = breadcrumbs
         
     | 
| 
      
 7 
     | 
    
         
            +
                @breadcrumbs        = build_list(breadcrumbs)
         
     | 
| 
       8 
8 
     | 
    
         
             
                @hide_in_print      = hide_in_print
         
     | 
| 
       9 
9 
     | 
    
         
             
                @collapse_on_mobile = collapse_on_mobile
         
     | 
| 
       10 
10 
     | 
    
         
             
              end
         
     | 
| 
         @@ -17,4 +17,27 @@ private 
     | 
|
| 
       17 
17 
     | 
    
         
             
                  classes << "govuk-breadcrumbs--collapse-on-mobile" if collapse_on_mobile
         
     | 
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              def build_list(breadcrumbs)
         
     | 
| 
      
 22 
     | 
    
         
            +
                case breadcrumbs
         
     | 
| 
      
 23 
     | 
    
         
            +
                when Array
         
     | 
| 
      
 24 
     | 
    
         
            +
                  breadcrumbs.map { |item| build_list_item(item) }
         
     | 
| 
      
 25 
     | 
    
         
            +
                when Hash
         
     | 
| 
      
 26 
     | 
    
         
            +
                  breadcrumbs.map { |text, link| build_list_item(text, link) }
         
     | 
| 
      
 27 
     | 
    
         
            +
                else
         
     | 
| 
      
 28 
     | 
    
         
            +
                  fail(ArgumentError, "breadcrumb must be an array or hash")
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              def build_list_item(text, link = nil)
         
     | 
| 
      
 33 
     | 
    
         
            +
                if link.present?
         
     | 
| 
      
 34 
     | 
    
         
            +
                  list_item { link_to(text, link, class: "govuk-breadcrumbs__link") }
         
     | 
| 
      
 35 
     | 
    
         
            +
                else
         
     | 
| 
      
 36 
     | 
    
         
            +
                  list_item(aria: { current: "page" }) { text }
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              def list_item(html_attributes = {}, &block)
         
     | 
| 
      
 41 
     | 
    
         
            +
                tag.li(class: "govuk-breadcrumbs__list-item", **html_attributes, &block)
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
       20 
43 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <%= tag.footer(class: classes, role: 'contentinfo', **html_attributes) do %>
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 2 
     | 
    
         
            +
              <%= tag.div(class: container_classes, **container_html_attributes) do %>
         
     | 
| 
      
 3 
     | 
    
         
            +
                <%= tag.div(class: meta_classes, **meta_html_attributes) do %>
         
     | 
| 
       4 
4 
     | 
    
         
             
                  <% if meta.present? %>
         
     | 
| 
       5 
5 
     | 
    
         
             
                    <%= meta %>
         
     | 
| 
       6 
6 
     | 
    
         
             
                  <% else %>
         
     | 
| 
         @@ -35,6 +35,6 @@ 
     | 
|
| 
       35 
35 
     | 
    
         
             
                      <%= tag.div(copyright, class: "govuk-footer__meta-item") %>
         
     | 
| 
       36 
36 
     | 
    
         
             
                    </div>
         
     | 
| 
       37 
37 
     | 
    
         
             
                  <% end %>
         
     | 
| 
       38 
     | 
    
         
            -
                 
     | 
| 
       39 
     | 
    
         
            -
               
     | 
| 
      
 38 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 39 
     | 
    
         
            +
              <% end %>
         
     | 
| 
       40 
40 
     | 
    
         
             
            <% end %>
         
     | 
| 
         @@ -1,16 +1,34 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::FooterComponent < GovukComponent::Base
         
     | 
| 
       2 
     | 
    
         
            -
              renders_one : 
     | 
| 
      
 2 
     | 
    
         
            +
              renders_one :meta_html
         
     | 
| 
       3 
3 
     | 
    
         
             
              renders_one :meta
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
              attr_reader :meta_items, :meta_items_title, :meta_licence, :copyright
         
     | 
| 
      
 5 
     | 
    
         
            +
              attr_reader :meta_items, :meta_text, :meta_items_title, :meta_licence, :copyright, :custom_container_classes
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
              def initialize( 
     | 
| 
      
 7 
     | 
    
         
            +
              def initialize(
         
     | 
| 
      
 8 
     | 
    
         
            +
                classes: [],
         
     | 
| 
      
 9 
     | 
    
         
            +
                container_classes: [],
         
     | 
| 
      
 10 
     | 
    
         
            +
                container_html_attributes: {},
         
     | 
| 
      
 11 
     | 
    
         
            +
                copyright_text: default_copright_text,
         
     | 
| 
      
 12 
     | 
    
         
            +
                copyright_url: default_copyright_url,
         
     | 
| 
      
 13 
     | 
    
         
            +
                html_attributes: {},
         
     | 
| 
      
 14 
     | 
    
         
            +
                meta_items: {},
         
     | 
| 
      
 15 
     | 
    
         
            +
                meta_items_title: "Support links",
         
     | 
| 
      
 16 
     | 
    
         
            +
                meta_licence: nil,
         
     | 
| 
      
 17 
     | 
    
         
            +
                meta_text: nil,
         
     | 
| 
      
 18 
     | 
    
         
            +
                meta_classes: [],
         
     | 
| 
      
 19 
     | 
    
         
            +
                meta_html_attributes: {}
         
     | 
| 
      
 20 
     | 
    
         
            +
              )
         
     | 
| 
       8 
21 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       9 
22 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                @ 
     | 
| 
       11 
     | 
    
         
            -
                @ 
     | 
| 
       12 
     | 
    
         
            -
                @ 
     | 
| 
       13 
     | 
    
         
            -
                @ 
     | 
| 
      
 23 
     | 
    
         
            +
                @meta_text                        = meta_text
         
     | 
| 
      
 24 
     | 
    
         
            +
                @meta_items                       = build_meta_links(meta_items)
         
     | 
| 
      
 25 
     | 
    
         
            +
                @meta_items_title                 = meta_items_title
         
     | 
| 
      
 26 
     | 
    
         
            +
                @meta_licence                     = meta_licence
         
     | 
| 
      
 27 
     | 
    
         
            +
                @custom_meta_classes              = meta_classes
         
     | 
| 
      
 28 
     | 
    
         
            +
                @custom_meta_html_attributes      = meta_html_attributes
         
     | 
| 
      
 29 
     | 
    
         
            +
                @copyright                        = build_copyright(copyright_text, copyright_url)
         
     | 
| 
      
 30 
     | 
    
         
            +
                @custom_container_classes         = container_classes
         
     | 
| 
      
 31 
     | 
    
         
            +
                @custom_container_html_attributes = container_html_attributes
         
     | 
| 
       14 
32 
     | 
    
         
             
              end
         
     | 
| 
       15 
33 
     | 
    
         | 
| 
       16 
34 
     | 
    
         
             
            private
         
     | 
| 
         @@ -19,6 +37,26 @@ private 
     | 
|
| 
       19 
37 
     | 
    
         
             
                %w(govuk-footer)
         
     | 
| 
       20 
38 
     | 
    
         
             
              end
         
     | 
| 
       21 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
              def container_classes
         
     | 
| 
      
 41 
     | 
    
         
            +
                combine_classes(%w(govuk-width-container), custom_container_classes)
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def meta_content
         
     | 
| 
      
 45 
     | 
    
         
            +
                meta_html || meta_text
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              def meta_classes
         
     | 
| 
      
 49 
     | 
    
         
            +
                %w(govuk-footer__meta).append(@custom_meta_classes)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              def meta_html_attributes
         
     | 
| 
      
 53 
     | 
    
         
            +
                @custom_meta_html_attributes
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              def container_html_attributes
         
     | 
| 
      
 57 
     | 
    
         
            +
                @custom_container_html_attributes
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
       22 
60 
     | 
    
         
             
              def build_meta_links(links)
         
     | 
| 
       23 
61 
     | 
    
         
             
                return [] if links.blank?
         
     | 
| 
       24 
62 
     | 
    
         | 
| 
         @@ -21,17 +21,17 @@ 
     | 
|
| 
       21 
21 
     | 
    
         
             
                  <% end %>
         
     | 
| 
       22 
22 
     | 
    
         
             
                </div>
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                <% if service_name.present? ||  
     | 
| 
      
 24 
     | 
    
         
            +
                <% if service_name.present? || navigation_items.present? %>
         
     | 
| 
       25 
25 
     | 
    
         
             
                  <div class="govuk-header__content">
         
     | 
| 
       26 
26 
     | 
    
         
             
                    <% if service_name.present? %>
         
     | 
| 
       27 
27 
     | 
    
         
             
                      <%= link_to(service_name, service_url, class: %w(govuk-header__link govuk-header__link--service-name)) %>
         
     | 
| 
       28 
28 
     | 
    
         
             
                    <% end %>
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
                    <% if  
     | 
| 
      
 30 
     | 
    
         
            +
                    <% if navigation_items.any? %>
         
     | 
| 
       31 
31 
     | 
    
         
             
                      <%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), aria: { controls: "navigation", label: menu_button_label }) %>
         
     | 
| 
       32 
32 
     | 
    
         
             
                      <nav>
         
     | 
| 
       33 
33 
     | 
    
         
             
                        <%= tag.ul(class: navigation_classes, id: "navigation", aria: { label: navigation_label }) do %>
         
     | 
| 
       34 
     | 
    
         
            -
                          <%  
     | 
| 
      
 34 
     | 
    
         
            +
                          <% navigation_items.each do |item| %>
         
     | 
| 
       35 
35 
     | 
    
         
             
                            <%= tag.li(class: item.classes.append(item.active_class), **item.html_attributes) do %>
         
     | 
| 
       36 
36 
     | 
    
         
             
                              <% if item.link? %>
         
     | 
| 
       37 
37 
     | 
    
         
             
                                <%= link_to(item.text, item.href, class: "govuk-header__link") %>
         
     | 
| 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::HeaderComponent < GovukComponent::Base
         
     | 
| 
       2 
     | 
    
         
            -
              renders_many : 
     | 
| 
      
 2 
     | 
    
         
            +
              renders_many :navigation_items, "NavigationItem"
         
     | 
| 
       3 
3 
     | 
    
         
             
              renders_one :custom_logo
         
     | 
| 
       4 
4 
     | 
    
         
             
              renders_one :product_name, "ProductName"
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
         @@ -52,7 +52,7 @@ private 
     | 
|
| 
       52 
52 
     | 
    
         
             
                combine_classes(%w(govuk-header__container govuk-width-container), custom_container_classes)
         
     | 
| 
       53 
53 
     | 
    
         
             
              end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
              class  
     | 
| 
      
 55 
     | 
    
         
            +
              class NavigationItem < GovukComponent::Base
         
     | 
| 
       56 
56 
     | 
    
         
             
                attr_reader :text, :href, :active
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                def initialize(text:, href: nil, active: false, classes: [], html_attributes: {})
         
     | 
| 
         @@ -1,22 +1,27 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::InsetTextComponent < GovukComponent::Base
         
     | 
| 
       2 
     | 
    
         
            -
              attr_reader :text
         
     | 
| 
      
 2 
     | 
    
         
            +
              attr_reader :text, :id
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              def initialize(text: nil, classes: [], html_attributes: {})
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize(text: nil, id: nil, classes: [], html_attributes: {})
         
     | 
| 
       5 
5 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                @text = text
         
     | 
| 
      
 8 
     | 
    
         
            +
                @id   = id
         
     | 
| 
       8 
9 
     | 
    
         
             
              end
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
              def call
         
     | 
| 
       11 
     | 
    
         
            -
                tag.div(class: classes, **html_attributes) {  
     | 
| 
      
 12 
     | 
    
         
            +
                tag.div(class: classes, id: id, **html_attributes) { inset_text_content }
         
     | 
| 
       12 
13 
     | 
    
         
             
              end
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
              def render?
         
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 16 
     | 
    
         
            +
                inset_text_content.present?
         
     | 
| 
       16 
17 
     | 
    
         
             
              end
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
       18 
19 
     | 
    
         
             
            private
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
              def inset_text_content
         
     | 
| 
      
 22 
     | 
    
         
            +
                content.presence || text
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       20 
25 
     | 
    
         
             
              def default_classes
         
     | 
| 
       21 
26 
     | 
    
         
             
                %w(govuk-inset-text)
         
     | 
| 
       22 
27 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <%= tag.div(class: classes, role:  
     | 
| 
      
 1 
     | 
    
         
            +
            <%= tag.div(class: classes, role: role, aria: { labelledby: title_id }, data: data_params, **html_attributes) do %>
         
     | 
| 
       2 
2 
     | 
    
         
             
              <div class="govuk-notification-banner__header">
         
     | 
| 
       3 
3 
     | 
    
         
             
                <%= content_tag(title_tag, class: "govuk-notification-banner__title", id: title_id) do %>
         
     | 
| 
       4 
     | 
    
         
            -
                  <%=  
     | 
| 
      
 4 
     | 
    
         
            +
                  <%= title_content %>
         
     | 
| 
       5 
5 
     | 
    
         
             
                <% end %>
         
     | 
| 
       6 
6 
     | 
    
         
             
              </div>
         
     | 
| 
       7 
7 
     | 
    
         
             
              <div class="govuk-notification-banner__content">
         
     | 
| 
         @@ -9,6 +9,6 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  <%= heading %>
         
     | 
| 
       10 
10 
     | 
    
         
             
                <% end %>
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                <%= content %>
         
     | 
| 
      
 12 
     | 
    
         
            +
                <%= content || text %>
         
     | 
| 
       13 
13 
     | 
    
         
             
              </div>
         
     | 
| 
       14 
14 
     | 
    
         
             
            <% end %>
         
     | 
| 
         @@ -1,20 +1,23 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::NotificationBannerComponent < GovukComponent::Base
         
     | 
| 
       2 
     | 
    
         
            -
              attr_reader : 
     | 
| 
      
 2 
     | 
    
         
            +
              attr_reader :title_text, :title_id, :text, :success, :title_heading_level, :disable_auto_focus, :role
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
      
 4 
     | 
    
         
            +
              renders_one :title_html
         
     | 
| 
       4 
5 
     | 
    
         
             
              renders_many :headings, "Heading"
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
              def initialize( 
     | 
| 
      
 7 
     | 
    
         
            +
              def initialize(title_text: nil, text: nil, role: "region", success: false, title_heading_level: 2, title_id: "govuk-notification-banner-title", disable_auto_focus: nil, classes: [], html_attributes: {})
         
     | 
| 
       7 
8 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                @ 
     | 
| 
      
 10 
     | 
    
         
            +
                @title_text          = title_text
         
     | 
| 
       10 
11 
     | 
    
         
             
                @title_id            = title_id
         
     | 
| 
      
 12 
     | 
    
         
            +
                @text                = text
         
     | 
| 
      
 13 
     | 
    
         
            +
                @role                = role
         
     | 
| 
       11 
14 
     | 
    
         
             
                @success             = success
         
     | 
| 
       12 
15 
     | 
    
         
             
                @title_heading_level = title_heading_level
         
     | 
| 
       13 
16 
     | 
    
         
             
                @disable_auto_focus  = disable_auto_focus
         
     | 
| 
       14 
17 
     | 
    
         
             
              end
         
     | 
| 
       15 
18 
     | 
    
         | 
| 
       16 
19 
     | 
    
         
             
              def render?
         
     | 
| 
       17 
     | 
    
         
            -
                headings.any? || content.present?
         
     | 
| 
      
 20 
     | 
    
         
            +
                headings.any? || text.present? || content.present?
         
     | 
| 
       18 
21 
     | 
    
         
             
              end
         
     | 
| 
       19 
22 
     | 
    
         | 
| 
       20 
23 
     | 
    
         
             
              def classes
         
     | 
| 
         @@ -25,6 +28,10 @@ class GovukComponent::NotificationBannerComponent < GovukComponent::Base 
     | 
|
| 
       25 
28 
     | 
    
         
             
                %(govuk-notification-banner--success) if success
         
     | 
| 
       26 
29 
     | 
    
         
             
              end
         
     | 
| 
       27 
30 
     | 
    
         | 
| 
      
 31 
     | 
    
         
            +
              def title_content
         
     | 
| 
      
 32 
     | 
    
         
            +
                title_html || title_text
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       28 
35 
     | 
    
         
             
              def title_tag
         
     | 
| 
       29 
36 
     | 
    
         
             
                fail "title_heading_level must be a number between 1 and 6" unless title_heading_level.is_a?(Integer) && title_heading_level.in?(1..6)
         
     | 
| 
       30 
37 
     | 
    
         | 
| 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::PhaseBannerComponent < GovukComponent::Base
         
     | 
| 
       2 
2 
     | 
    
         
             
              attr_reader :text, :phase_tag
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              def initialize( 
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize(tag: nil, text: nil, classes: [], html_attributes: {})
         
     | 
| 
       5 
5 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                @phase_tag =  
     | 
| 
      
 7 
     | 
    
         
            +
                @phase_tag = tag
         
     | 
| 
       8 
8 
     | 
    
         
             
                @text      = text
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
         @@ -46,9 +46,11 @@ private 
     | 
|
| 
       46 
46 
     | 
    
         
             
                end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
                def action
         
     | 
| 
      
 49 
     | 
    
         
            +
                  link_classes = govuk_link_classes.append(action_classes).flatten
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
       49 
51 
     | 
    
         
             
                  tag.dd(class: "govuk-summary-list__actions") do
         
     | 
| 
       50 
52 
     | 
    
         
             
                    if href.present?
         
     | 
| 
       51 
     | 
    
         
            -
                       
     | 
| 
      
 53 
     | 
    
         
            +
                      link_to(href, class: link_classes, **action_attributes) do
         
     | 
| 
       52 
54 
     | 
    
         
             
                        safe_join([text, tag.span(visually_hidden_text, class: "govuk-visually-hidden")])
         
     | 
| 
       53 
55 
     | 
    
         
             
                      end
         
     | 
| 
       54 
56 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1,19 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GovukComponent::TagComponent < GovukComponent::Base
         
     | 
| 
       2 
2 
     | 
    
         
             
              attr_reader :text, :colour
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              COLOURS = %w(
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                turquoise
         
     | 
| 
       8 
     | 
    
         
            -
                blue
         
     | 
| 
       9 
     | 
    
         
            -
                red
         
     | 
| 
       10 
     | 
    
         
            -
                purple
         
     | 
| 
       11 
     | 
    
         
            -
                pink
         
     | 
| 
       12 
     | 
    
         
            -
                orange
         
     | 
| 
       13 
     | 
    
         
            -
                yellow
         
     | 
| 
       14 
     | 
    
         
            -
              ).freeze
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              def initialize(text:, colour: nil, classes: [], html_attributes: {})
         
     | 
| 
      
 4 
     | 
    
         
            +
              COLOURS = %w(grey green turquoise blue red purple pink orange yellow).freeze
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def initialize(text: nil, colour: nil, classes: [], html_attributes: {})
         
     | 
| 
       17 
7 
     | 
    
         
             
                super(classes: classes, html_attributes: html_attributes)
         
     | 
| 
       18 
8 
     | 
    
         | 
| 
       19 
9 
     | 
    
         
             
                @text   = text
         
     | 
| 
         @@ -21,11 +11,15 @@ class GovukComponent::TagComponent < GovukComponent::Base 
     | 
|
| 
       21 
11 
     | 
    
         
             
              end
         
     | 
| 
       22 
12 
     | 
    
         | 
| 
       23 
13 
     | 
    
         
             
              def call
         
     | 
| 
       24 
     | 
    
         
            -
                tag.strong( 
     | 
| 
      
 14 
     | 
    
         
            +
                tag.strong(tag_content, class: classes.append(colour_class), **html_attributes)
         
     | 
| 
       25 
15 
     | 
    
         
             
              end
         
     | 
| 
       26 
16 
     | 
    
         | 
| 
       27 
17 
     | 
    
         
             
            private
         
     | 
| 
       28 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
              def tag_content
         
     | 
| 
      
 20 
     | 
    
         
            +
                @text || content || fail(ArgumentError, "no text or content")
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       29 
23 
     | 
    
         
             
              def default_classes
         
     | 
| 
       30 
24 
     | 
    
         
             
                %w(govuk-tag)
         
     | 
| 
       31 
25 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,61 +1,110 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module GovukLinkHelper
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 2 
     | 
    
         
            +
              LINK_STYLES = {
         
     | 
| 
      
 3 
     | 
    
         
            +
                inverse:          "govuk-link--inverse",
         
     | 
| 
      
 4 
     | 
    
         
            +
                muted:            "govuk-link--muted",
         
     | 
| 
      
 5 
     | 
    
         
            +
                no_underline:     "govuk-link--no-underline",
         
     | 
| 
      
 6 
     | 
    
         
            +
                no_visited_state: "govuk-link--no-visited-state",
         
     | 
| 
      
 7 
     | 
    
         
            +
                text_colour:      "govuk-link--text-colour",
         
     | 
| 
      
 8 
     | 
    
         
            +
              }.freeze
         
     | 
| 
       4 
9 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
      
 10 
     | 
    
         
            +
              BUTTON_STYLES = {
         
     | 
| 
      
 11 
     | 
    
         
            +
                disabled:  "govuk-button--disabled",
         
     | 
| 
      
 12 
     | 
    
         
            +
                secondary: "govuk-button--secondary",
         
     | 
| 
      
 13 
     | 
    
         
            +
                warning:   "govuk-button--warning",
         
     | 
| 
      
 14 
     | 
    
         
            +
              }.freeze
         
     | 
| 
       7 
15 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
              def  
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
      
 16 
     | 
    
         
            +
              def govuk_link_classes(*styles, default_class: 'govuk-link')
         
     | 
| 
      
 17 
     | 
    
         
            +
                if (invalid_styles = (styles - LINK_STYLES.keys)) && invalid_styles.any?
         
     | 
| 
      
 18 
     | 
    
         
            +
                  fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{LINK_STYLES.keys.to_sentence}")
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
       10 
20 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 21 
     | 
    
         
            +
                [default_class] + LINK_STYLES.values_at(*styles).compact
         
     | 
| 
       12 
22 
     | 
    
         
             
              end
         
     | 
| 
       13 
23 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
              def  
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 24 
     | 
    
         
            +
              def govuk_button_classes(*styles, default_class: 'govuk-button')
         
     | 
| 
      
 25 
     | 
    
         
            +
                if (invalid_styles = (styles - BUTTON_STYLES.keys)) && invalid_styles.any?
         
     | 
| 
      
 26 
     | 
    
         
            +
                  fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{BUTTON_STYLES.keys.to_sentence}")
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                [default_class] + BUTTON_STYLES.values_at(*styles).compact
         
     | 
| 
       16 
30 
     | 
    
         
             
              end
         
     | 
| 
       17 
31 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
              def govuk_link_to(name = nil, options = nil, extra_options = {}, &block)
         
     | 
| 
      
 33 
     | 
    
         
            +
                extra_options = options if block_given?
         
     | 
| 
      
 34 
     | 
    
         
            +
                html_options = build_html_options(extra_options)
         
     | 
| 
       19 
35 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                   
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  text_colour_class(text_colour),
         
     | 
| 
       26 
     | 
    
         
            -
                  inverse_class(inverse),
         
     | 
| 
       27 
     | 
    
         
            -
                  no_underline_class(no_underline),
         
     | 
| 
       28 
     | 
    
         
            -
                ]
         
     | 
| 
      
 36 
     | 
    
         
            +
                if block_given?
         
     | 
| 
      
 37 
     | 
    
         
            +
                  link_to(name, html_options, &block)
         
     | 
| 
      
 38 
     | 
    
         
            +
                else
         
     | 
| 
      
 39 
     | 
    
         
            +
                  link_to(name, options, html_options)
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
       29 
41 
     | 
    
         
             
              end
         
     | 
| 
       30 
42 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
              def  
     | 
| 
       32 
     | 
    
         
            -
                 
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
              def govuk_mail_to(email_address, name = nil, extra_options = {}, &block)
         
     | 
| 
      
 44 
     | 
    
         
            +
                extra_options = name if block_given?
         
     | 
| 
      
 45 
     | 
    
         
            +
                html_options = build_html_options(extra_options)
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                if block_given?
         
     | 
| 
      
 48 
     | 
    
         
            +
                  mail_to(email_address, html_options, &block)
         
     | 
| 
      
 49 
     | 
    
         
            +
                else
         
     | 
| 
      
 50 
     | 
    
         
            +
                  mail_to(email_address, name, html_options)
         
     | 
| 
       34 
51 
     | 
    
         
             
                end
         
     | 
| 
       35 
52 
     | 
    
         
             
              end
         
     | 
| 
       36 
53 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
              def  
     | 
| 
       38 
     | 
    
         
            -
                 
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
              def govuk_button_to(name = nil, options = nil, extra_options = {}, &block)
         
     | 
| 
      
 55 
     | 
    
         
            +
                extra_options = options if block_given?
         
     | 
| 
      
 56 
     | 
    
         
            +
                html_options = build_html_options(extra_options, style: :button)
         
     | 
| 
       40 
57 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
                if block_given?
         
     | 
| 
      
 59 
     | 
    
         
            +
                  button_to(name, html_options, &block)
         
     | 
| 
      
 60 
     | 
    
         
            +
                else
         
     | 
| 
      
 61 
     | 
    
         
            +
                  button_to(name, options, html_options)
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
       43 
63 
     | 
    
         
             
              end
         
     | 
| 
       44 
64 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
              def  
     | 
| 
       46 
     | 
    
         
            -
                 
     | 
| 
      
 65 
     | 
    
         
            +
              def govuk_breadcrumb_link_to(name = nil, options = nil, extra_options = {}, &block)
         
     | 
| 
      
 66 
     | 
    
         
            +
                extra_options = options if block_given?
         
     | 
| 
      
 67 
     | 
    
         
            +
                html_options = build_html_options(extra_options, style: :breadcrumb)
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                if block_given?
         
     | 
| 
      
 70 
     | 
    
         
            +
                  link_to(name, html_options, &block)
         
     | 
| 
      
 71 
     | 
    
         
            +
                else
         
     | 
| 
      
 72 
     | 
    
         
            +
                  link_to(name, options, html_options)
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
       47 
74 
     | 
    
         
             
              end
         
     | 
| 
       48 
75 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
            private
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              def build_html_options(provided_options, style: :link)
         
     | 
| 
      
 79 
     | 
    
         
            +
                styles = case style
         
     | 
| 
      
 80 
     | 
    
         
            +
                         when :link       then LINK_STYLES
         
     | 
| 
      
 81 
     | 
    
         
            +
                         when :button     then BUTTON_STYLES
         
     | 
| 
      
 82 
     | 
    
         
            +
                         else {}
         
     | 
| 
      
 83 
     | 
    
         
            +
                         end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                remaining_options = provided_options&.slice!(*styles.keys)
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                return {} unless (style_classes = build_style_classes(style, provided_options))
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                inject_class(remaining_options, class_name: style_classes)
         
     | 
| 
       51 
90 
     | 
    
         
             
              end
         
     | 
| 
       52 
91 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
              def  
     | 
| 
       54 
     | 
    
         
            -
                 
     | 
| 
      
 92 
     | 
    
         
            +
              def build_style_classes(style, provided_options)
         
     | 
| 
      
 93 
     | 
    
         
            +
                keys = *provided_options&.keys
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                case style
         
     | 
| 
      
 96 
     | 
    
         
            +
                when :link then govuk_link_classes(*keys)
         
     | 
| 
      
 97 
     | 
    
         
            +
                when :button then govuk_button_classes(*keys)
         
     | 
| 
      
 98 
     | 
    
         
            +
                when :breadcrumb then %w(govuk-breadcrumbs__link)
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
       55 
100 
     | 
    
         
             
              end
         
     | 
| 
       56 
101 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
              def  
     | 
| 
       58 
     | 
    
         
            -
                 
     | 
| 
      
 102 
     | 
    
         
            +
              def inject_class(attributes, class_name:)
         
     | 
| 
      
 103 
     | 
    
         
            +
                attributes ||= {}
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                attributes.with_indifferent_access.tap do |attrs|
         
     | 
| 
      
 106 
     | 
    
         
            +
                  attrs[:class] = Array.wrap(attrs[:class]).prepend(class_name).flatten
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
       59 
108 
     | 
    
         
             
              end
         
     | 
| 
       60 
109 
     | 
    
         
             
            end
         
     | 
| 
       61 
110 
     | 
    
         | 
| 
         @@ -1,6 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module GovukSkipLinkHelper
         
     | 
| 
       2 
     | 
    
         
            -
              def govuk_skip_link(text: 'Skip to main content', href: '#main-content')
         
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 2 
     | 
    
         
            +
              def govuk_skip_link(text: 'Skip to main content', href: '#main-content', classes: [], **html_attributes, &block)
         
     | 
| 
      
 3 
     | 
    
         
            +
                link_classes = Array.wrap(classes).append('govuk-skip-link')
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                return link_to(href, class: link_classes, **html_attributes, &block) if block_given?
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                link_to(text, href, class: link_classes, **html_attributes)
         
     | 
| 
       4 
8 
     | 
    
         
             
              end
         
     | 
| 
       5 
9 
     | 
    
         
             
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       6 
11 
     | 
    
         
             
            ActiveSupport.on_load(:action_view) { include GovukSkipLinkHelper }
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: govuk-components
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.0b6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - DfE developers
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-07-19 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activemodel
         
     | 
| 
         @@ -163,6 +163,8 @@ files: 
     | 
|
| 
       163 
163 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       164 
164 
     | 
    
         
             
            - app/components/govuk_component/accordion_component.html.erb
         
     | 
| 
       165 
165 
     | 
    
         
             
            - app/components/govuk_component/accordion_component.rb
         
     | 
| 
      
 166 
     | 
    
         
            +
            - app/components/govuk_component/accordion_component/section_component.html.erb
         
     | 
| 
      
 167 
     | 
    
         
            +
            - app/components/govuk_component/accordion_component/section_component.rb
         
     | 
| 
       166 
168 
     | 
    
         
             
            - app/components/govuk_component/back_link_component.rb
         
     | 
| 
       167 
169 
     | 
    
         
             
            - app/components/govuk_component/base.rb
         
     | 
| 
       168 
170 
     | 
    
         
             
            - app/components/govuk_component/breadcrumbs_component.html.erb
         
     |