Sha256: 4cb6738f4bf8801da7736bc9f2d3135605a43e8d65126a8afad28f9e7a3b0f05

Contents?: true

Size: 1.43 KB

Versions: 17

Compression:

Stored size: 1.43 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 :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
        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

17 entries across 17 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.87 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.9 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.8 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.7 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.6 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.5 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.4 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.3 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.2 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86.1 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.86 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.85 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.84 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.83.3 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.83.2 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.83.1 app/components/ariadne/form/radio_button/component.rb
ariadne_view_components-0.0.83 app/components/ariadne/form/radio_button/component.rb