Class: Prose::Component

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

Instance Method Summary collapse

Methods included from Lookbook::OutputHelper

#beautify, #highlight, #markdown, #pretty_json

Constructor Details

#initialize(size: :md, markdown: true, **html_attrs) ⇒ Component

Returns a new instance of Component.



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

def initialize(size: :md, markdown: true, **html_attrs)
  @size = size
  @markdown = markdown
  super(**html_attrs)
end

Instance Method Details

#rendered_contentObject



11
12
13
# File 'app/components/lookbook/prose/component.rb', line 11

def rendered_content
  @markdown ? markdown(content.strip_heredoc) : helpers.raw(content)
end

#size_classObject



15
16
17
18
19
20
21
22
23
24
# File 'app/components/lookbook/prose/component.rb', line 15

def size_class
  case @size
  when :sm
    "prose-sm"
  when :lg
    "prose-lg"
  else
    ""
  end
end