Class: EmbedCodeDropdown::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- EmbedCodeDropdown::Component
- Defined in:
- app/components/lookbook/embed_code_dropdown/component.rb
Instance Attribute Summary collapse
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#preview ⇒ Object
readonly
Returns the value of attribute preview.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #app_path ⇒ Object
- #embed_code ⇒ Object
- #embed_url ⇒ Object
- #external_embed_params ⇒ Object
-
#initialize(preview:, target:, pages:, params:, policy:, **html_attrs) ⇒ Component
constructor
A new instance of Component.
- #preview_name ⇒ Object
Constructor Details
#initialize(preview:, target:, pages:, params:, policy:, **html_attrs) ⇒ Component
Returns a new instance of Component.
5 6 7 8 9 10 11 12 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 5 def initialize(preview:, target:, pages:, params:, policy:, **html_attrs) @preview = preview @target = target @pages = pages @policy = policy @params = params.deep_symbolize_keys super(**html_attrs) end |
Instance Attribute Details
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
3 4 5 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 3 def pages @pages end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 3 def params @params end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
3 4 5 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 3 def policy @policy end |
#preview ⇒ Object (readonly)
Returns the value of attribute preview.
3 4 5 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 3 def preview @preview end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
3 4 5 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 3 def target @target end |
Instance Method Details
#app_path ⇒ Object
14 15 16 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 14 def app_path helpers.lookbook_home_url end |
#embed_code ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 27 def = content_tag("lookbook-embed", app: app_path, preview: preview_name, scenario: target.name, **) { "" } escape_once end |
#embed_url ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 36 def props = { preview: preview_name, scenario: target.name, **.transform_keys { |k| k.tr("-", "_") } }.to_json "#{app_path}embed?props=#{CGI.escape(props)}" end |
#external_embed_params ⇒ Object
22 23 24 25 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 22 def permitted = params.select { |key, val| key.to_s != "_display" } permitted.transform_keys! { |key| "param-#{key}" } end |
#preview_name ⇒ Object
18 19 20 |
# File 'app/components/lookbook/embed_code_dropdown/component.rb', line 18 def preview_name preview.preview_class_name end |