Sha256: 7553042cf6dae62e4169c85295ef1171d179bf96aa8ba30edb6fc3e129cd61fa

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

require "css_parser"

module Lookbook
  class InspectorPanel::Component < Lookbook::BaseComponent
    attr_reader :panel_styles, :panel_html, :id

    def initialize(id:, name:, **attrs)
      @id = id
      @name = name
      @system = attrs[:system] || false
      super(**attrs.except(:system))
    end

    def before_render
      if @system == false
        tpl = TemplateParser.new(content)
        @panel_styles = tpl.styles.map { |s| "##{id} #{s}" }.join("\n")
        @panel_html = tpl.content
      end
      @panel_html ||= content
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-1.1.1 app/components/lookbook/inspector_panel/component.rb
lookbook-1.1.0 app/components/lookbook/inspector_panel/component.rb