Sha256: f4962bf0d4c7f618b37883b66c11e4139601f73da900447ddf28890a50537b68

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 KB

Contents

# typed: false
# frozen_string_literal: true

module Ariadne
  module UI
    module Combobox
      module Item
        class Component < BaseComponent
          option :label
          option :as, default: proc { :link } # :button

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

            # html_attrs["data-input-filter-target"] = "searchString"
            if as == :link && !html_attrs[:target]
              html_attrs[:target] = "_top"
            end
          end

          def initialize(**options)
            super(**options)
          end

          style do
            base do
              [
                "ariadne-flex",
                "ariadne-gap-0.5",
                "ariadne-items-center",
                "ariadne-ps-2",
                "ariadne-pe-1",
                "ariadne-rounded",
                "!ariadne-ring-0",
                "hover:ariadne-bg-zinc-100",
                "hover:dark:ariadne-bg-zinc-800",
                "focus-within:ariadne-bg-zinc-100",
                "focus-within:dark:ariadne-bg-zinc-800",
              ]
            end
            variants do
              as do
                button do
                  "ariadne-appearance-none ariadne-inline-flex ariadne-w-full"
                end

                link do
                  "ariadne-cursor-pointer"
                end
              end
            end
          end

          def link?
            as == :link
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.79.2 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.79.1 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.79 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.78 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.77 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.76.1 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.76 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.75 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.74.1 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.74 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.73 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.72 app/components/ariadne/ui/combobox/item/component.rb
ariadne_view_components-0.0.71 app/components/ariadne/ui/combobox/item/component.rb