Class: InspectorPanel::Component

Inherits:
Lookbook::BaseComponent
  • Object
show all
Defined in:
app/components/lookbook/inspector_panel/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, **attrs) ⇒ Component

Returns a new instance of Component.



5
6
7
8
# File 'app/components/lookbook/inspector_panel/component.rb', line 5

def initialize(name:, **attrs)
  @name = name
  super(**attrs)
end

Instance Attribute Details

#panel_htmlObject (readonly)

Returns the value of attribute panel_html.



3
4
5
# File 'app/components/lookbook/inspector_panel/component.rb', line 3

def panel_html
  @panel_html
end

#panel_stylesObject (readonly)

Returns the value of attribute panel_styles.



3
4
5
# File 'app/components/lookbook/inspector_panel/component.rb', line 3

def panel_styles
  @panel_styles
end

Instance Method Details

#before_renderObject



14
15
16
17
18
# File 'app/components/lookbook/inspector_panel/component.rb', line 14

def before_render
  styles, html = StylesExtractor.call(content)
  @panel_styles = styles.map { |s| "##{id} #{s}" }.join("\n")
  @panel_html = html.html_safe
end

#idObject



10
11
12
# File 'app/components/lookbook/inspector_panel/component.rb', line 10

def id
  Utils.id("panel", @name)
end