Module: ViewComponent::Storybook::ContentConcern

Extended by:
ActiveSupport::Concern
Included in:
Slots::SlotConfig, StoryConfig
Defined in:
lib/view_component/storybook/content_concern.rb

Instance Method Summary collapse

Instance Method Details

#content(content = nil, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/view_component/storybook/content_concern.rb', line 12

def content(content = nil, &block)
  case content
  when Storybook::Controls::ControlConfig
    @content_control = content.param(content_param)
    @content_block = nil
  when String
    @content_control = nil
    @content_block = proc { content }
  else
    @content_control = nil
    @content_block = block
  end
end

#resolve_content_block(params) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/view_component/storybook/content_concern.rb', line 26

def resolve_content_block(params)
  if content_control
    content = content_control.value_from_params(params)
    proc { content }
  else
    content_block
  end
end