Sha256: 54912f6dbf6f5a447626c2d24b006104a5a2b16ac959951369f78f79649cb2bd

Contents?: true

Size: 1.31 KB

Versions: 61

Compression:

Stored size: 1.31 KB

Contents

<%
  id_prefix ||= "radio-#{SecureRandom.hex(4)}"
  items ||= []
%>
<% items.each_with_index do |item, index| %>
  <% if item === :or %>
    <span class="gem-c-radio__block-text">
      <%= t('components.radio.or') %>
    </span>
  <% else %>
    <%
      item_next = items[index + 1] unless index === items.size - 1
      label_id = item[:id] ? item[:id] : "#{id_prefix}-#{index}"
      label_hint_id = "label-hint-#{SecureRandom.hex(4)}" if item[:hint_text].present?
    %>
    <div
      class="
        gem-c-radio
        <%= 'gem-c-radio--margin-bottom-0' if item_next === :or && item[:hint_text].present? %>
      "
    >
      <input
        class="gem-c-radio__input"
        id="<%= label_id %>"
        name="<%= name %>"
        type="radio"
        value="<%= item[:value] %>"
        <%= "checked" if item[:checked] %>
        <% if label_hint_id %>
          aria-describedby="<%= label_hint_id %>"
        <% end %>
      >
      <%= render "govuk_publishing_components/components/label", {
        hint_id: label_hint_id,
        html_for: label_id,
        classes: 'gem-c-radio__label',
        text_classes: 'gem-c-radio__label__text',
        hint_text_classes: 'gem-c-radio__label__hint',
        hint_text: item[:hint_text],
        text: item[:text],
        bold: item[:bold]
      } %>
    </div>
  <% end %>
<% end %>

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
govuk_publishing_components-9.6.0 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.5.3 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.5.2 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.5.1 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.5.0 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.4.0 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.3.6 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.3.5 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.3.4 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.3.3 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.3.2 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.3.1 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.3.0 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.2.3 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.2.2 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.2.1 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.2.0 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.1.1 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.1.0 app/views/govuk_publishing_components/components/_radio.html.erb
govuk_publishing_components-9.0.1 app/views/govuk_publishing_components/components/_radio.html.erb