Sha256: abea6aae27dc0c4eac0505071bc99f0b6d52d3109ef662ca7b09290f7d4b6ea1
Contents?: true
Size: 1.47 KB
Versions: 9
Compression:
Stored size: 1.47 KB
Contents
module Lookbook class Embed::Inspector::Component < Lookbook::BaseComponent attr_reader :target, :context, :scenarios, :panels, :options, :actions def initialize(target:, context: nil, options: nil, scenarios: nil, panels: nil, actions: nil, **html_attrs) @target = target @context = context.to_h @options = options.to_h @panels = Array(panels) @actions = Array(actions).map(&:to_sym) @scenarios = Array(scenarios) super(**html_attrs) end def id Utils.id( "embed-inspector", "#{scenarios.map(&:name).join}#{options.to_json}#{actions.to_json}#{panels.to_json}".hash ) end def data context.fetch(:data, Store.new) end def params context.fetch(:params, {}).to_h end def dynamic_display_options context.fetch(:dynamic_display_options, {}).to_h end def static_display_options context.fetch(:static_display_options, {}).to_h end def display_action?(name) actions.include?(name) end def scenario_select_options scenarios.map { |scenario| [scenario.label, helpers.lookbook_embed_path(scenario.lookup_path)] } end def display_option_controls? options.fetch(:display_option_controls, true) end def drawer? panels.any? end protected def alpine_data [alpine_encode(id), "$store.pages.embeds"].join(",") end def alpine_component "embedInspectorComponent" end end end
Version data entries
9 entries across 9 versions & 1 rubygems