Sha256: 702c5e582340ed1a5a6ea7a74cee0c241cc0b6ade9371e8d7c0ae0ab31ce79e8

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Kpop
  class FrameComponent < ViewComponent::Base
    include Katalyst::HtmlAttributes
    include Turbo::FramesHelper

    attr_reader :id

    ACTIONS = %w[
      popstate@window->kpop--frame#popstate
      scrim:dismiss@window->kpop--frame#dismiss
      scrim:hide@window->kpop--frame#dismiss
      turbo:before-frame-render->kpop--frame#beforeFrameRender
      turbo:before-stream-render@window->kpop--frame#beforeStreamRender
      turbo:before-visit@window->kpop--frame#beforeVisit
      turbo:frame-load->kpop--frame#frameLoad
    ].freeze

    def initialize(id: "kpop", scrim: "#scrim", **)
      super

      @id    = id
      @scrim = scrim
    end

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

    private

    def default_html_attributes
      {
        class:  "kpop--frame",
        data:   {
          controller:                 "kpop--frame",
          action:                     ACTIONS.join(" "),
          "kpop--frame-scrim-outlet": @scrim,
          turbo_action:               "advance",
        },
        target: "_top",
      }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
katalyst-kpop-3.2.6 app/components/kpop/frame_component.rb
katalyst-kpop-3.2.5 app/components/kpop/frame_component.rb
katalyst-kpop-3.2.4 app/components/kpop/frame_component.rb
katalyst-kpop-3.2.3 app/components/kpop/frame_component.rb
katalyst-kpop-3.2.2 app/components/kpop/frame_component.rb
katalyst-kpop-3.2.1 app/components/kpop/frame_component.rb
katalyst-kpop-3.2.0 app/components/kpop/frame_component.rb
katalyst-kpop-3.1.3 app/components/kpop/frame_component.rb
katalyst-kpop-3.1.2 app/components/kpop/frame_component.rb
katalyst-kpop-3.1.1 app/components/kpop/frame_component.rb
katalyst-kpop-3.1.0 app/components/kpop/frame_component.rb
katalyst-kpop-3.0.2 app/components/kpop/frame_component.rb
katalyst-kpop-3.0.1 app/components/kpop/frame_component.rb