Sha256: 846db1ed0cd692ac50ecf4d4c0823dcf761359774b4c24070c03129ef1fd7ed8

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

# typed: false
# frozen_string_literal: true

module Ariadne
  module Form
    module RadioButton
      class Component < Ariadne::Form::BaseInputComponent
        option :name
        option :value
        option :label, default: proc { false }
        option :selected, default: proc { false }

        option :label_classes, default: -> { "" }
        option :label_arguments, default: -> { {} }

        accepts_html_attributes do |html_attrs|
          html_attrs[:name] = @name
          html_attrs[:value] = @value
          html_attrs[:id] = id
          html_attrs[:checked] = @selected

          html_attrs
        end

        def id
          "#{@name}_#{@value}"
        end

        def input_styles
          Ariadne::ViewComponents.tailwind_merger.merge([style(:input), html_attrs[:class]].join(" "))
        end

        def label_styles
          Ariadne::ViewComponents.tailwind_merger.merge([style(:label), label_classes].join(" "))
        end

        style(:input) do
          base do
            [
              "ariadne-h-4",
              "ariadne-w-4",
              "ariadne-border-gray-300",
              "ariadne-text-indigo-600",
              "focus:ariadne-ring-indigo-600",
            ]
          end
        end

        style(:label) do
          base do
            [
              "ariadne-ml-3",
              "ariadne-block",
              "ariadne-text-sm",
              "ariadne-font-medium",
              "ariadne-leading-6",
              "ariadne-text-gray-900",
            ]
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.92 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.91 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.90 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.89.1 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.89 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.88 app/components/ariadne/form/radio_button/component.rb