Module: Ariadne::Form::LabelHelper

Included in:
BaseComponent, BaseInputComponent
Defined in:
app/components/ariadne/form/label_helper.rb

Constant Summary collapse

BASE_LABEL_STYLES =

every label is basically the same, right?

[
  "ariadne:text-sm",
  "ariadne:font-medium",
  "ariadne:leading-none",
  "ariadne:peer-disabled:cursor-not-allowed",
  "ariadne:peer-disabled:opacity-70",
  "ariadne:block",
  "ariadne:mb-2",
  "ariadne:text-gray-900",
  "ariadne:dark:text-zinc-100",
]

Instance Method Summary collapse

Instance Method Details

#label_stylesObject



28
29
30
31
# File 'app/components/ariadne/form/label_helper.rb', line 28

def label_styles
  label_classes = sr_label.present? ? "sr-only" : ""
  merge_tailwind_classes([style(:label), label_classes].join(" "))
end

#render_labelObject



19
20
21
22
23
24
25
26
# File 'app/components/ariadne/form/label_helper.rb', line 19

def render_label
  return unless label.present?

  (:div, class: "ariadne:flex ariadne:items-center ariadne:gap-1") do
    concat((:label, label, class: label_styles, **label_arguments))
    concat((:span, "*", class: "ariadne:text-red-500 ariadne:dark:text-red-400", "aria-hidden": true)) if required?
  end
end