Module: Lookbook::ComponentHelper
- Defined in:
- app/helpers/lookbook/component_helper.rb
Instance Method Summary collapse
- #class_names(*args) ⇒ Object
- #code(language = "ruby", **opts, &block) ⇒ Object
- #icon(name, size: 4, **attrs) ⇒ Object
- #render_component(name, **attrs, &block) ⇒ Object (also: #component)
Instance Method Details
#class_names(*args) ⇒ Object
17 18 19 20 |
# File 'app/helpers/lookbook/component_helper.rb', line 17 def class_names(*args) tokens = build_tag_values(*args).flat_map { |value| value.to_s.split(/\s+/) }.uniq safe_join(tokens, " ") end |
#code(language = "ruby", **opts, &block) ⇒ Object
12 13 14 |
# File 'app/helpers/lookbook/component_helper.rb', line 12 def code(language = "ruby", **opts, &block) render_component "code", language: language, **opts, &block end |
#icon(name, size: 4, **attrs) ⇒ Object
8 9 10 |
# File 'app/helpers/lookbook/component_helper.rb', line 8 def icon(name, size: 4, **attrs) render_component "icon", name: name, size: size, **attrs end |
#render_component(name, **attrs, &block) ⇒ Object Also known as: component
3 4 5 6 |
# File 'app/helpers/lookbook/component_helper.rb', line 3 def render_component(name, **attrs, &block) attrs[:classes] = class_names(attrs[:class]) render "lookbook/components/#{name.underscore}", **attrs.except(:class), &block end |