Module: BetterUi::General::Components::Text::TextHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/better_ui/general/components/text/text_helper.rb

Instance Method Summary collapse

Instance Method Details

#bui_text(text = nil, theme: :default, size: :medium, align: :left, weight: :normal, style: :normal, classes: '', **html_options, &block) ⇒ String

Genera un testo usando BetterUi::General::Text::Component

Examples:

Uso base

bui_text("Testo semplice")
bui_text("Testo importante", theme: :blue, weight: :bold)

Con dimensioni e stili

bui_text("Titolo grande", size: :xl, weight: :bold)
bui_text("Testo sottile", theme: :muted, size: :small)

Con allineamento

bui_text("Testo centrato", align: :center)
bui_text("Testo giustificato", align: :justify)

Con stili tipografici

bui_text("Testo corsivo", style: :italic)
bui_text("Testo sottolineato", style: :underline)

Con blocco Ruby

bui_text(theme: :green, weight: :semibold) do
  "Contenuto complesso con <strong>HTML</strong>".html_safe
end

Con attributi HTML personalizzati

bui_text("Testo con ID", 
         theme: :blue, 
         id: "my-text",
         data: { action: "click->handler#process" })

Per sostituire paragrafi standard

# Invece di: <p class="text-gray-600">Descrizione</p>
bui_text("Descrizione", theme: :gray)

Combinazioni complesse

bui_text("Messaggio di errore", 
         theme: :red, 
         size: :small, 
         weight: :medium,
         classes: "mb-2")

Parameters:

  • text (String) (defaults to: nil)

    testo da mostrare (nil se si usa blocco)

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

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

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

    dimensione (:xs, :small, :medium, :large, :xl, :“2xl”)

  • align (Symbol) (defaults to: :left)

    allineamento (:left, :center, :right, :justify)

  • weight (Symbol) (defaults to: :normal)

    peso font (:thin, :light, :normal, :medium, :semibold, :bold, :extrabold)

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

    stile (:normal, :italic, :underline, :line_through)

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

    classi CSS aggiuntive

  • html_options (Hash)

    opzioni HTML aggiuntive

Returns:

  • (String)

    HTML del testo renderizzato



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/helpers/better_ui/general/components/text/text_helper.rb', line 57

def bui_text(
  text = nil,
  theme: :default,
  size: :medium,
  align: :left,
  weight: :normal,
  style: :normal,
  classes: '',
  **html_options,
  &block
)
  render BetterUi::General::Text::Component.new(
    text: text,
    theme: theme,
    size: size,
    align: align,
    weight: weight,
    style: style,
    classes: classes,
    **html_options
  ), &block
end