Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] **BREAKING** Add component wrapper to character count component #4353

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
maxwords ||= nil
threshold ||= nil
textarea ||= {}
%>
<% if maxlength || maxwords %>
<%= content_tag :div,
class: "gem-c-character-count govuk-character-count",
data: {

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-character-count govuk-character-count")
component_helper.add_data_attribute({
module: "govuk-character-count",
maxlength: maxlength,
maxwords: maxwords,
threshold: threshold
} do %>
})

%>
<% if maxlength || maxwords %>
<%= tag.div(**component_helper.all_attributes) do %>
<%= render "govuk_publishing_components/components/textarea", { id: id, character_count: true }.merge(textarea.symbolize_keys) %>

<div id="<%= id %>-info" class="govuk-hint govuk-character-count__message">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Form character count
description: Help users enter text when there is a limit on the number of characters they can type
govuk_frontend_components:
- character-count
uses_component_wrapper_helper: true
accessibility_criteria: |
The component must:

Expand Down
Loading