Module: Bootstrap4RailsComponents::ApplicationHelper

Defined in:
app/helpers/bootstrap4_rails_components/application_helper.rb

Overview

Core rendering helper methods

Instance Method Summary collapse

Instance Method Details

#uiObject

‘ui` is an initiator method so that this system allows for extension when used in a cascade of frameworks, for example when building a custom design system that is based on Bootstrap4. One would utilize this the `ui` method to initiate this engine and then call a specific framework / system as a second method.

Example use for bootstrap4: <%= ui.bootstrap(:my_component, :optional_trait1, :optional_trait2, option: :value, option2: :value2) %>

Real-world usage: A normal button link with a tooltip: <%= ui.bootstrap(:button, :primary, body: ‘Get Started’, href: marketing_page_path, tooltip: ‘Save big!’) %>

A complex ajax-y delete button: <%= ui.bootstrap(:button, :primary, disabled: user.payments.any?, method: :delete, href: user_path(user), confirm: “Please confirm #Bootstrap4RailsComponents::ApplicationHelper.useruser.name should be deleted”, disable_with: ui.bootstrap(:icon, :loader), remote: true, tooltip: “Permanently delete #Bootstrap4RailsComponents::ApplicationHelper.useruser.name” render_if: user.admin?) %>



21
22
23
# File 'app/helpers/bootstrap4_rails_components/application_helper.rb', line 21

def ui
  @ui ||= Bootstrap4RailsComponents::UI::Base.new(get_view_context)
end