Module: BetterUi::General::Components::Dropdown::ItemHelper

Included in:
Application::Sidebar::Component, ApplicationHelper
Defined in:
app/helpers/better_ui/general/components/dropdown/item_helper.rb

Instance Method Summary collapse

Instance Method Details

#bui_dropdown_item(text = nil, icon: nil, href: nil, theme: :default, disabled: false, active: false, classes: '', **options) ⇒ String

Crea un elemento del menu dropdown.

Examples:

Uso base

<%= bui_dropdown_item("Modifica") %>

Con icona

<%= bui_dropdown_item("Elimina", icon: "trash") %>

Come link

<%= bui_dropdown_item("Profilo", href: "/profile", icon: "user") %>

Con tema colorato

<%= bui_dropdown_item("Azione pericolosa", theme: :red, icon: "trash") %>

Disabilitato

<%= bui_dropdown_item("Non disponibile", disabled: true) %>

Uso con sintassi keyword (backward compatible)

<%= bui_dropdown_item(text: "Modifica legacy") %>

Parameters:

  • text (String) (defaults to: nil)

    Il testo dell’elemento (obbligatorio)

  • icon (String) (defaults to: nil)

    Il nome dell’icona da mostrare (“edit”, “trash”, “share”, “user”, “cog”, “logout”)

  • href (String) (defaults to: nil)

    L’URL per renderlo un link

  • theme (Symbol) (defaults to: :default)

    Il tema colore (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)

  • disabled (Boolean) (defaults to: false)

    Se l’elemento è disabilitato

  • active (Boolean) (defaults to: false)

    Se l’elemento è attivo/selezionato

  • classes (String) (defaults to: '')

    Classi CSS aggiuntive

  • options (Hash)

    Attributi HTML aggiuntivi

Returns:

  • (String)

    Il markup HTML dell’elemento dropdown



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/better_ui/general/components/dropdown/item_helper.rb', line 40

def bui_dropdown_item(
  text = nil,
  icon: nil,
  href: nil,
  theme: :default,
  disabled: false,
  active: false,
  classes: '',
  **options
)
  # Supporta sia sintassi posizionale che keyword per backward compatibility
  item_text = text || options.delete(:text)
  
  render BetterUi::General::Dropdown::ItemComponent.new(
    text: item_text,
    icon: icon,
    href: href,
    theme: theme,
    disabled: disabled,
    active: active,
    classes: classes,
    **options
  )
end