Module: BetterUi::General::Components::Link::LinkHelper

Included in:
BetterUi::General::Components::Link
Defined in:
app/helpers/better_ui/general/components/link/link_helper.rb

Instance Method Summary collapse

Instance Method Details

Genera un link usando BetterUi::General::Link::Component

Examples:

Uso base

bui_link("Home", href: "/")
bui_link("Contatti", href: "/contact", theme: :blue)

Con icona

bui_link("Dashboard", href: "/admin", icon: "home", theme: :green)

Link attivo

bui_link("Pagina corrente", href: "/current", active: true)

Link disabilitato (diventa span)

bui_link("Non disponibile", disabled: true)

Con attributi Turbo

bui_link("Elimina", href: "/delete", method: :delete, 
         data: { confirm: "Sei sicuro?" }, theme: :red)

Con opzioni avanzate

bui_link(
  "Link esterno",
  href: "https://example.com",
  theme: :violet,
  orientation: :vertical,
  style: :bold,
  size: :large,
  icon: "external-link",
  target: "_blank",
  id: "external-link",
  class: "custom-link"
)

Parameters:

  • label (String)

    testo del link

  • href (String) (defaults to: nil)

    URL di destinazione (nil per semplice testo)

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

    tema del colore (:default, :white, etc.)

  • orientation (Symbol) (defaults to: :horizontal)

    orientamento (:horizontal, :vertical)

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

    stile (:default, :underline, :bold, :text)

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

    dimensione (:small, :medium, :large)

  • icon (String) (defaults to: nil)

    icona opzionale

  • active (Boolean) (defaults to: false)

    stato attivo del link

  • disabled (Boolean) (defaults to: false)

    stato disabilitato del link

  • data (Hash) (defaults to: {})

    attributi data

  • method (Symbol) (defaults to: nil)

    metodo HTTP (per Turbo)

  • target (String) (defaults to: nil)

    target del link

  • html_options (Hash)

    opzioni HTML aggiuntive

Returns:

  • (String)

    HTML del link renderizzato



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/helpers/better_ui/general/components/link/link_helper.rb', line 53

def bui_link(
  label,
  href: nil,
  theme: :white,
  orientation: :horizontal,
  style: :default,
  size: :medium,
  icon: nil,
  active: false,
  disabled: false,
  data: {},
  method: nil,
  target: nil,
  **html_options,
  &block
)
  render BetterUi::General::Link::Component.new(
    label: label,
    href: href,
    theme: theme,
    orientation: orientation,
    style: style,
    size: size,
    icon: icon,
    active: active,
    disabled: disabled,
    data: data,
    method: method,
    target: target,
    **html_options
  ), &block
end