Sha256: 5d835b2505b3c9c46016e1697a924ac29ab09edd14ab4f303d8a01b369d21f86

Contents?: true

Size: 1.84 KB

Versions: 19

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

module Ariadne
  module Form
    # :nodoc:
    module Group
      class Component < Ariadne::Form::BaseComponent
        VERTICAL = :vertical
        HORIZONTAL = :horizontal
        RELATIVE = :relative
        DEFAULT_LAYOUT = VERTICAL
        LAYOUTS = [VERTICAL, HORIZONTAL, RELATIVE].freeze

        accepts_html_attributes do |html_attrs|
          html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(layout:), html_attrs[:class]].join(" "))
        end

        attr_reader :layout

        def initialize(inputs:, builder:, form:, layout: DEFAULT_LAYOUT, **system_arguments)
          @inputs = inputs
          @builder = builder
          @form = form
          @layout = layout
          @system_arguments = system_arguments
        end

        def input_or_component(input)
          if input.respond_to?(:to_component)
            input.to_component
          else
            input
          end
        end

        style do
          base do
          end

          variants do
            layout do
              vertical do
                [
                  "ariadne-space-y-8",
                ]
              end

              horizontal do
                [
                  "ariadne-flex",
                  "ariadne-flex-row",
                  "ariadne-align-center",
                  "ariadne-space-x-2",
                ]
              end

              relative do
                [
                  "ariadne-relative",
                ]
              end

              right do
                [
                  "ariadne-mt-6",
                  "ariadne-flex",
                  "ariadne-items-center",
                  "ariadne-justify-end",
                  "ariadne-gap-x-6",
                ]
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.92 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.91 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.90 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.89.1 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.89 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.88 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.87 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.9 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.8 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.7 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.6 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.5 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.4 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.3 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.2 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86.1 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.86 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.85 app/components/ariadne/form/group/component.rb
ariadne_view_components-0.0.84 app/components/ariadne/form/group/component.rb