Sha256: e8e308201f1c875d24a2342930fd0e9faa1c553897894bec18f6b55e61558a98

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 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 "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

3 entries across 3 versions & 1 rubygems

Version Path
govuk_publishing_components-3.3.0 app/views/components/_radio.html.erb
govuk_publishing_components-3.2.1 app/views/components/_radio.html.erb
govuk_publishing_components-3.2.0 app/views/components/_radio.html.erb