Module: BetterUi::ApplicationHelper
- Defined in:
- app/helpers/better_ui/application_helper.rb
Overview
View helpers for rendering BetterUi components with a concise API.
All helpers follow the bui_<component> naming convention and delegate
to the corresponding ViewComponent class.
Instance Method Summary collapse
-
#bui_action_messages(messages = [], **options) ⇒ String
Renders action messages (alerts/flash messages).
-
#bui_avatar(**options) {|avatar| ... } ⇒ String
Renders an avatar component for displaying user images or initials.
-
#bui_badge(**options) { ... } ⇒ String
Renders a badge component.
-
#bui_breadcrumb(**options) {|breadcrumb| ... } ⇒ String
Renders a breadcrumb navigation component.
-
#bui_button(**options) { ... } ⇒ String
Renders a button component.
-
#bui_card(**options) {|card| ... } ⇒ String
Renders a card component.
-
#bui_checkbox(name, **options) ⇒ String
Renders a checkbox component.
-
#bui_checkbox_group(name, collection, **options) ⇒ String
Renders a checkbox group component.
-
#bui_container(**options) { ... } ⇒ String
Renders a container component for constraining content width.
-
#bui_date_input(name, **options) {|input| ... } ⇒ String
Renders a date input component.
-
#bui_dialog(**options) {|dialog| ... } ⇒ String
Renders a dialog component.
-
#bui_dialog_alert(**options) {|alert| ... } ⇒ String
Renders an alert dialog component.
-
#bui_dialog_confirm(**options) {|confirm| ... } ⇒ String
Renders a confirm dialog component.
-
#bui_divider(**options) ⇒ String
Renders a divider component for visually separating content.
-
#bui_drawer_header(**options) {|header| ... } ⇒ String
Renders a drawer header component.
-
#bui_drawer_layout(**options) {|layout| ... } ⇒ String
Renders a drawer layout component with header, sidebar, and main content areas.
-
#bui_drawer_nav_group(**options) {|group| ... } ⇒ String
Renders a drawer navigation group with title and items.
-
#bui_drawer_nav_item(label, href, **options) {|item| ... } ⇒ String
Renders a drawer navigation item.
-
#bui_drawer_sidebar(**options) {|sidebar| ... } ⇒ String
Renders a drawer sidebar component.
-
#bui_dropdown(**options) {|dropdown| ... } ⇒ String
Renders a dropdown menu component for actions, navigation, or context menus.
-
#bui_email_input(name, **options) {|input| ... } ⇒ String
Renders an email input component.
-
#bui_fa_icon(name, **options) ⇒ String
Renders a FontAwesome icon component.
-
#bui_heading(**options) {|heading| ... } ⇒ String
Renders a heading component.
-
#bui_link(href, **options) { ... } ⇒ String
Renders a link component.
-
#bui_number_input(name, **options) {|input| ... } ⇒ String
Renders a number input component.
-
#bui_pagination(**options) {|pagination| ... } ⇒ String
Renders a pagination component for navigating between pages.
-
#bui_pagination_for(pagy, **options) {|pagination| ... } ⇒ String
Renders a pagination component from a Pagy object.
-
#bui_password_input(name, **options) {|input| ... } ⇒ String
Renders a password input component with visibility toggle.
-
#bui_progress(**options) ⇒ String
Renders a progress bar component.
-
#bui_select(name, collection, **options) {|select| ... } ⇒ String
Renders a custom select dropdown component.
-
#bui_spinner(**options) ⇒ String
Renders a spinner (loading indicator) component.
-
#bui_tab(id:, label:, **options) {|tab| ... } ⇒ String
Renders a standalone tab component (used outside container context).
-
#bui_tab_panel(id:, **options) { ... } ⇒ String
Renders a standalone tab panel component (used outside container context).
-
#bui_table(**options) {|table| ... } ⇒ String
Renders a table component.
-
#bui_tabs(**options) {|tabs| ... } ⇒ String
Renders a tabs container component.
-
#bui_tag(**options) { ... } ⇒ String
Renders a tag component.
-
#bui_tel_input(name, **options) {|input| ... } ⇒ String
Renders a telephone input component.
-
#bui_text_input(name, **options) {|input| ... } ⇒ String
Renders a text input component.
-
#bui_textarea(name, **options) {|textarea| ... } ⇒ String
Renders a textarea component.
-
#bui_time_input(name, **options) {|input| ... } ⇒ String
Renders a time input component.
-
#bui_tooltip(text, **options) { ... } ⇒ String
Renders a tooltip component that wraps content and shows a tooltip on hover.
Instance Method Details
#bui_action_messages(messages = [], **options) ⇒ String
Renders action messages (alerts/flash messages).
193 194 195 |
# File 'app/helpers/better_ui/application_helper.rb', line 193 def ( = [], **) render BetterUi::ActionMessagesComponent.new(messages: , **) end |
#bui_avatar(**options) {|avatar| ... } ⇒ String
Renders an avatar component for displaying user images or initials.
106 107 108 |
# File 'app/helpers/better_ui/application_helper.rb', line 106 def bui_avatar(**, &block) render BetterUi::AvatarComponent.new(**), &block end |
#bui_badge(**options) { ... } ⇒ String
Renders a badge component.
284 285 286 |
# File 'app/helpers/better_ui/application_helper.rb', line 284 def bui_badge(**, &block) render BetterUi::BadgeComponent.new(**), &block end |
#bui_breadcrumb(**options) {|breadcrumb| ... } ⇒ String
Renders a breadcrumb navigation component.
870 871 872 |
# File 'app/helpers/better_ui/application_helper.rb', line 870 def (**, &block) render BetterUi::Breadcrumb::BreadcrumbComponent.new(**), &block end |
#bui_button(**options) { ... } ⇒ String
Renders a button component.
40 41 42 |
# File 'app/helpers/better_ui/application_helper.rb', line 40 def (**, &block) render BetterUi::ButtonComponent.new(**), &block end |
#bui_card(**options) {|card| ... } ⇒ String
Renders a card component.
83 84 85 |
# File 'app/helpers/better_ui/application_helper.rb', line 83 def bui_card(**, &block) render BetterUi::CardComponent.new(**), &block end |
#bui_checkbox(name, **options) ⇒ String
Renders a checkbox component.
498 499 500 |
# File 'app/helpers/better_ui/application_helper.rb', line 498 def bui_checkbox(name, **) render BetterUi::Forms::CheckboxComponent.new(name: name, **) end |
#bui_checkbox_group(name, collection, **options) ⇒ String
Renders a checkbox group component.
527 528 529 |
# File 'app/helpers/better_ui/application_helper.rb', line 527 def bui_checkbox_group(name, collection, **) render BetterUi::Forms::CheckboxGroupComponent.new(name: name, collection: collection, **) end |
#bui_container(**options) { ... } ⇒ String
Renders a container component for constraining content width.
125 126 127 |
# File 'app/helpers/better_ui/application_helper.rb', line 125 def bui_container(**, &block) render BetterUi::ContainerComponent.new(**), &block end |
#bui_date_input(name, **options) {|input| ... } ⇒ String
Renders a date input component.
400 401 402 |
# File 'app/helpers/better_ui/application_helper.rb', line 400 def bui_date_input(name, **, &block) render BetterUi::Forms::TextInputComponent.new(name: name, type: :date, **), &block end |
#bui_dialog(**options) {|dialog| ... } ⇒ String
Renders a dialog component.
683 684 685 |
# File 'app/helpers/better_ui/application_helper.rb', line 683 def bui_dialog(**, &block) render BetterUi::Dialog::DialogComponent.new(**), &block end |
#bui_dialog_alert(**options) {|alert| ... } ⇒ String
Renders an alert dialog component.
703 704 705 |
# File 'app/helpers/better_ui/application_helper.rb', line 703 def bui_dialog_alert(**, &block) render BetterUi::Dialog::AlertComponent.new(**), &block end |
#bui_dialog_confirm(**options) {|confirm| ... } ⇒ String
Renders a confirm dialog component.
724 725 726 |
# File 'app/helpers/better_ui/application_helper.rb', line 724 def bui_dialog_confirm(**, &block) render BetterUi::Dialog::ConfirmComponent.new(**), &block end |
#bui_divider(**options) ⇒ String
Renders a divider component for visually separating content.
308 309 310 |
# File 'app/helpers/better_ui/application_helper.rb', line 308 def bui_divider(**) render BetterUi::DividerComponent.new(**) end |
#bui_drawer_header(**options) {|header| ... } ⇒ String
Renders a drawer header component.
620 621 622 |
# File 'app/helpers/better_ui/application_helper.rb', line 620 def bui_drawer_header(**, &block) render BetterUi::Drawer::HeaderComponent.new(**), &block end |
#bui_drawer_layout(**options) {|layout| ... } ⇒ String
Renders a drawer layout component with header, sidebar, and main content areas.
580 581 582 |
# File 'app/helpers/better_ui/application_helper.rb', line 580 def bui_drawer_layout(**, &block) render BetterUi::Drawer::LayoutComponent.new(**), &block end |
#bui_drawer_nav_group(**options) {|group| ... } ⇒ String
Renders a drawer navigation group with title and items.
656 657 658 |
# File 'app/helpers/better_ui/application_helper.rb', line 656 def bui_drawer_nav_group(**, &block) render BetterUi::Drawer::NavGroupComponent.new(**), &block end |
#bui_drawer_nav_item(label, href, **options) {|item| ... } ⇒ String
Renders a drawer navigation item.
639 640 641 |
# File 'app/helpers/better_ui/application_helper.rb', line 639 def bui_drawer_nav_item(label, href, **, &block) render BetterUi::Drawer::NavItemComponent.new(label: label, href: href, **), &block end |
#bui_drawer_sidebar(**options) {|sidebar| ... } ⇒ String
Renders a drawer sidebar component.
600 601 602 |
# File 'app/helpers/better_ui/application_helper.rb', line 600 def (**, &block) render BetterUi::Drawer::SidebarComponent.new(**), &block end |
#bui_dropdown(**options) {|dropdown| ... } ⇒ String
Renders a dropdown menu component for actions, navigation, or context menus.
902 903 904 |
# File 'app/helpers/better_ui/application_helper.rb', line 902 def bui_dropdown(**, &block) render BetterUi::Dropdown::DropdownComponent.new(**), &block end |
#bui_email_input(name, **options) {|input| ... } ⇒ String
Renders an email input component.
374 375 376 |
# File 'app/helpers/better_ui/application_helper.rb', line 374 def bui_email_input(name, **, &block) render BetterUi::Forms::TextInputComponent.new(name: name, type: :email, **), &block end |
#bui_fa_icon(name, **options) ⇒ String
Renders a FontAwesome icon component.
260 261 262 |
# File 'app/helpers/better_ui/application_helper.rb', line 260 def bui_fa_icon(name, **) render BetterUi::FaIconComponent.new(name: name, **) end |
#bui_heading(**options) {|heading| ... } ⇒ String
Renders a heading component.
150 151 152 |
# File 'app/helpers/better_ui/application_helper.rb', line 150 def bui_heading(**, &block) render BetterUi::HeadingComponent.new(**), &block end |
#bui_link(href, **options) { ... } ⇒ String
Renders a link component.
62 63 64 |
# File 'app/helpers/better_ui/application_helper.rb', line 62 def bui_link(href, **, &block) render BetterUi::LinkComponent.new(href: href, **), &block end |
#bui_number_input(name, **options) {|input| ... } ⇒ String
Renders a number input component.
437 438 439 |
# File 'app/helpers/better_ui/application_helper.rb', line 437 def bui_number_input(name, **, &block) render BetterUi::Forms::NumberInputComponent.new(name: name, **), &block end |
#bui_pagination(**options) {|pagination| ... } ⇒ String
Renders a pagination component for navigating between pages.
945 946 947 |
# File 'app/helpers/better_ui/application_helper.rb', line 945 def bui_pagination(**, &block) render BetterUi::Pagination::PaginationComponent.new(**), &block end |
#bui_pagination_for(pagy, **options) {|pagination| ... } ⇒ String
Renders a pagination component from a Pagy object.
Convenience helper for Pagy users. Extracts current_page, total_pages,
total_count, and per_page from the Pagy object. Does not add a Pagy
gem dependency -- uses the host app's pagy_url_for helper.
966 967 968 969 970 971 972 973 974 975 976 |
# File 'app/helpers/better_ui/application_helper.rb', line 966 def bui_pagination_for(pagy, **, &block) url_proc = .delete(:url) || ->(page) { pagy_url_for(pagy, page) } render BetterUi::Pagination::PaginationComponent.new( current_page: pagy.page, total_pages: pagy.last, url: url_proc, total_count: pagy.count, per_page: pagy.vars[:items], ** ), &block end |
#bui_password_input(name, **options) {|input| ... } ⇒ String
Renders a password input component with visibility toggle.
453 454 455 |
# File 'app/helpers/better_ui/application_helper.rb', line 453 def bui_password_input(name, **, &block) render BetterUi::Forms::PasswordInputComponent.new(name: name, **), &block end |
#bui_progress(**options) ⇒ String
Renders a progress bar component.
215 216 217 |
# File 'app/helpers/better_ui/application_helper.rb', line 215 def bui_progress(**) render BetterUi::ProgressComponent.new(**) end |
#bui_select(name, collection, **options) {|select| ... } ⇒ String
Renders a custom select dropdown component.
557 558 559 |
# File 'app/helpers/better_ui/application_helper.rb', line 557 def bui_select(name, collection, **, &block) render BetterUi::Forms::SelectComponent.new(name: name, collection: collection, **), &block end |
#bui_spinner(**options) ⇒ String
Renders a spinner (loading indicator) component.
233 234 235 |
# File 'app/helpers/better_ui/application_helper.rb', line 233 def bui_spinner(**) render BetterUi::SpinnerComponent.new(**) end |
#bui_tab(id:, label:, **options) {|tab| ... } ⇒ String
Renders a standalone tab component (used outside container context).
830 831 832 |
# File 'app/helpers/better_ui/application_helper.rb', line 830 def bui_tab(id:, label:, **, &block) render BetterUi::Tabs::TabComponent.new(id: id, label: label, **), &block end |
#bui_tab_panel(id:, **options) { ... } ⇒ String
Renders a standalone tab panel component (used outside container context).
846 847 848 |
# File 'app/helpers/better_ui/application_helper.rb', line 846 def bui_tab_panel(id:, **, &block) render BetterUi::Tabs::PanelComponent.new(id: id, **), &block end |
#bui_table(**options) {|table| ... } ⇒ String
Renders a table component.
Supports two modes:
- Slot-based: Define header, rows, and cells manually using slots
- Collection-based: Pass a collection and column definitions