Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/components/pajamas/concerns/checkbox_radio_label_with_help_text.rb')
-rw-r--r--app/components/pajamas/concerns/checkbox_radio_label_with_help_text.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/components/pajamas/concerns/checkbox_radio_label_with_help_text.rb b/app/components/pajamas/concerns/checkbox_radio_label_with_help_text.rb
new file mode 100644
index 00000000000..4ece904fb85
--- /dev/null
+++ b/app/components/pajamas/concerns/checkbox_radio_label_with_help_text.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module Pajamas
+ module Concerns
+ module CheckboxRadioLabelWithHelpText
+ def render_label_with_help_text
+ form.label(method, formatted_label_options) { label_entry }
+ end
+
+ private
+
+ def label_entry
+ if help_text_content
+ content_tag(:span, label_content) +
+ content_tag(:p, help_text_content, class: 'help-text', data: { testid: 'pajamas-component-help-text' })
+ else
+ content_tag(:span, label_content)
+ end
+ end
+
+ def formatted_label_options
+ format_options(
+ options: label_options,
+ css_classes: ['custom-control-label'],
+ additional_options: { value: value }
+ )
+ end
+ end
+ end
+end