Sha256: fe3c0c0571e12f9b97cbc5562d16a03f01cf9c5dfc427818fecf8c4b7c79337d

Contents?: true

Size: 988 Bytes

Versions: 4

Compression:

Stored size: 988 Bytes

Contents

<%
  add_gem_component_stylesheet("error-message")
  add_gem_component_stylesheet("character-count")

  id ||= "character-count-#{SecureRandom.hex(4)}"
  maxlength ||= nil
  maxwords ||= nil
  threshold ||= nil
  textarea ||= {}

  textarea[:textarea_id] = id
%>
<% if maxlength || maxwords %>
  <%= content_tag :div,
    class: "gem-c-character-count govuk-character-count",
    data: {
      module: "govuk-character-count",
      maxlength: maxlength,
      maxwords: maxwords,
      threshold: threshold
    } do %>

    <%= render "govuk_publishing_components/components/textarea", { textarea_id: id, character_count: true, margin_bottom: 1 }.merge(textarea.symbolize_keys) %>

    <div id="<%= id %>-info" class="govuk-hint govuk-character-count__message">
      <%= t("components.character_count.body", number: maxlength || maxwords, type: maxwords ? t("components.character_count.type.words") : t("components.character_count.type.characters")) %>
    </div>
  <% end %>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_character_count.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_character_count.html.erb
govuk_publishing_components-50.0.1 app/views/govuk_publishing_components/components/_character_count.html.erb
govuk_publishing_components-50.0.0 app/views/govuk_publishing_components/components/_character_count.html.erb