Module: BetterUi::General::Components::Tabs::TabHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/better_ui/general/components/tabs/tab_helper.rb

Instance Method Summary collapse

Instance Method Details

#bui_tab(text:, target:, active: false, icon: nil, disabled: false, badge: nil, theme: :default, size: :medium, classes: '', **options) ⇒ String

Crea una singola tab all’interno di un container tabs

Examples:

Uso base

<%= bui_tab(text: "Generale", target: "generale", active: true) %>

Con icona e badge

<%= bui_tab(text: "Messaggi", target: "messages", icon: "envelope", badge: "3") %>

Tab disabilitata

<%= bui_tab(text: "Premium", target: "premium", disabled: true, icon: "star") %>

Con temi personalizzati

<%= bui_tab(text: "Errori", target: "errors", theme: :red, badge: "12") %>

Con attributi personalizzati

<%= bui_tab(text: "Settings", target: "settings", classes: "font-bold", data: { testid: "settings-tab" }) %>

Parameters:

  • text (String)

    il testo da visualizzare nella tab

  • target (String)

    l’ID del pannello associato a questa tab

  • active (Boolean) (defaults to: false)

    se questa tab è attualmente attiva

  • icon (String) (defaults to: nil)

    il nome dell’icona opzionale da visualizzare

  • disabled (Boolean) (defaults to: false)

    se questa tab è disabilitata

  • badge (String) (defaults to: nil)

    il testo/numero del badge opzionale

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

    il tema di colore della tab (:default, :blue, :red, :green, :yellow, :violet, :orange, :rose, :white)

  • size (Symbol) (defaults to: :medium)

    la dimensione della tab (:small, :medium, :large)

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

    classi CSS aggiuntive da applicare alla tab

  • options (Hash)

    attributi HTML aggiuntivi da applicare all’elemento

Returns:

  • (String)

    l’HTML della tab



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/helpers/better_ui/general/components/tabs/tab_helper.rb', line 36

def bui_tab(text:, target:, active: false, icon: nil, disabled: false, badge: nil, 
           theme: :default, size: :medium, classes: '', **options)
  render BetterUi::General::Tabs::TabComponent.new(
    text: text,
    target: target,
    active: active,
    icon: icon,
    disabled: disabled,
    badge: badge,
    theme: theme,
    size: size,
    classes: classes,
    **options
  )
end