Sha256: c1a0c761ac45aab20805938bb79e81698242c3c226f45e1e8aa48e60959cd931

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Kpop
  class ModalComponent < ViewComponent::Base
    include HasHtmlAttributes

    renders_one :title, "Kpop::Modal::TitleComponent"
    renders_one :header
    renders_one :footer

    def initialize(title:, captive: false, fallback_location: nil, layout: nil, **)
      super

      @fallback_location = fallback_location
      @layout            = layout

      # Generate a title bar. This can be overridden by calling title_bar again.
      with_title(title:, captive:) if title.present?
    end

    def inspect
      "#<#{self.class.name} title: #{title.inspect}>"
    end

    private

    def default_html_attributes
      {
        class: "kpop-modal",
        data:  {
          controller:                            "kpop--modal",
          "kpop--modal-current-location-value":  request.path,
          "kpop--modal-fallback-location-value": @fallback_location,
          "kpop--modal-layout-value":            @layout&.to_s&.dasherize,
        },
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
katalyst-kpop-3.0.0.beta.8 app/components/kpop/modal_component.rb
katalyst-kpop-3.0.0.beta.7 app/components/kpop/modal_component.rb
katalyst-kpop-3.0.0.beta.6 app/components/kpop/modal_component.rb
katalyst-kpop-3.0.0.beta.5 app/components/kpop/modal_component.rb
katalyst-kpop-3.0.0.beta.4 app/components/kpop/modal_component.rb
katalyst-kpop-3.0.0.beta.3 app/components/kpop/modal_component.rb
katalyst-kpop-3.0.0.beta.2 app/components/kpop/modal_component.rb
katalyst-kpop-3.0.0.beta.1 app/components/kpop/modal_component.rb