Module: Irelia::ComponentsHelper

Includes:
ActionView::Helpers::UrlHelper
Included in:
ComponentPreview
Defined in:
app/helpers/irelia/components_helper.rb

Constant Summary collapse

IRELIA_COMPONENTS_HELPERS =
{
  account_switcher: "Irelia::AccountSwitcher::Component",
  avatar: "Irelia::Avatar::Component",
  app_shell: "Irelia::AppShell::Component",
  button: "Irelia::Button::Component",
  breadcrumbs: "Irelia::Breadcrumbs::Component",
  card: "Irelia::Card::Component",
  container: "Irelia::Container::Component",
  div: "Irelia::Div::Component",
  divider: "Irelia::Divider::Component",
  dropdown: "Irelia::Dropdown::Component",
  empty_collection: "Irelia::EmptyCollection::Component",
  flex: "Irelia::Flex::Component",
  html: "Irelia::Html::Component",
  icon: "Irelia::Icon::Component",
  modal: "Irelia::Modal::Component",
  notification: "Irelia::Notification::Component",
  page_header: "Irelia::PageHeader::Component",
  sidebar: "Irelia::Sidebar::Component",
  stack: "Irelia::Stack::Component",
  table: "Irelia::Table::Component",
  navbar: "Irelia::Navbar::Component",
  navbar_section: "Irelia::Navbar::Section::Component",
  navbar_separator: "Irelia::Navbar::Separator::Component",
  navigation: "Irelia::Navigation::Component",
  split_screen: "Irelia::SplitScreen::Component"
}.freeze

Instance Method Summary collapse

Instance Method Details

#irelia_button_to(name = nil, options = nil, args = nil, &block) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/irelia/components_helper.rb', line 39

def irelia_button_to(name = nil, options = nil, args = nil, &block)
  args, options = options, name if args.nil?
  options ||= {}
  args ||= {}
  args[:html_options] ||= {}
  args[:html_options][:class] ||= args[:class]

  component = Irelia::Button::Component.new(skip_tag: true, **args)
  component_attributes = component.class.dry_initializer.definitions.keys

  if block
    component.with_content(capture(&block))
  elsif name != options
    component.with_content(name)
  end

  html_options = args.merge(component.html_options)

  button_to(options, html_options.except(*component_attributes)) do
    render(component)
  end
end