Class: Embed::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- Embed::Component
- Defined in:
- app/components/lookbook/embed/component.rb
Constant Summary collapse
- ACTIONS =
[:inspect, :open]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#preview ⇒ Object
readonly
Returns the value of attribute preview.
-
#scenario ⇒ Object
readonly
Returns the value of attribute scenario.
Instance Method Summary collapse
- #actions ⇒ Object
-
#initialize(scenario:, params: {}, options: {}, **html_attrs) ⇒ Component
constructor
A new instance of Component.
- #panels ⇒ Object
- #params_attrs_str ⇒ Object
- #preview_class ⇒ Object
Constructor Details
#initialize(scenario:, params: {}, options: {}, **html_attrs) ⇒ Component
Returns a new instance of Component.
7 8 9 10 11 12 13 |
# File 'app/components/lookbook/embed/component.rb', line 7 def initialize(scenario:, params: {}, options: {}, **html_attrs) @scenario = scenario @preview = scenario.preview @params = params.to_h @options = .to_h super(**html_attrs) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'app/components/lookbook/embed/component.rb', line 5 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'app/components/lookbook/embed/component.rb', line 5 def params @params end |
#preview ⇒ Object (readonly)
Returns the value of attribute preview.
5 6 7 |
# File 'app/components/lookbook/embed/component.rb', line 5 def preview @preview end |
#scenario ⇒ Object (readonly)
Returns the value of attribute scenario.
5 6 7 |
# File 'app/components/lookbook/embed/component.rb', line 5 def scenario @scenario end |
Instance Method Details
#actions ⇒ Object
23 24 25 |
# File 'app/components/lookbook/embed/component.rb', line 23 def actions .fetch(:actions, ACTIONS).map(&:to_s) end |
#panels ⇒ Object
19 20 21 |
# File 'app/components/lookbook/embed/component.rb', line 19 def panels .fetch(:panels, []).map(&:to_s) end |
#params_attrs_str ⇒ Object
27 28 29 |
# File 'app/components/lookbook/embed/component.rb', line 27 def params_attrs_str params.map { |key, value| "param-#{key}=\"#{value}\"" }.join(" ").strip.html_safe end |
#preview_class ⇒ Object
15 16 17 |
# File 'app/components/lookbook/embed/component.rb', line 15 def preview_class preview.preview_class.name end |