Class: OkonomiUiKit::Components::LinkTo

Inherits:
ButtonBase show all
Defined in:
app/helpers/okonomi_ui_kit/components/link_to.rb

Instance Attribute Summary

Attributes inherited from OkonomiUiKit::Component

#view

Instance Method Summary collapse

Methods inherited from ButtonBase

#build_button_class, #extract_icon_config, #render_button_content

Methods inherited from OkonomiUiKit::Component

#combined_styles, config_class?, config_class_name, config_classes, config_namespace, #config_styles_registry, config_styles_registry, deep_merge, #initialize, #internal_styles_registry, internal_styles_registry, #name, parent_styles_registry, register_styles, resolve_config_classes, #style, #styles, #template_path, #theme_name, #tw_merge, #variant_style

Constructor Details

This class inherits a constructor from OkonomiUiKit::Component

Instance Method Details

#render(name = nil, options = nil, html_options = nil, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/okonomi_ui_kit/components/link_to.rb', line 4

def render(name = nil, options = nil, html_options = nil, &block)
  html_options, options, name = options, name, block if block_given?

  html_options ||= {}
  html_options = html_options.with_indifferent_access

  variant = (html_options.delete(:variant) || "text").to_sym
  color = (html_options.delete(:color) || "default").to_sym
  
  # Extract icon configuration
  icon_config, html_options = extract_icon_config(html_options)

  html_options[:class] = build_button_class(variant: variant, color: color, classes: html_options[:class])

  view.link_to(options, html_options) do
    render_button_content(icon_config, name, &block)
  end
end