Module: BetterUi::General::Components::Input::Rating::RatingHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/better_ui/general/components/input/rating/rating_helper.rb

Instance Method Summary collapse

Instance Method Details

#bui_input_rating(name: nil, value: 0, max_stars: 5, readonly: false, half_stars: true, theme: :default, size: :medium, show_value: false, form: nil, classes: '', **options) ⇒ String

Renderizza un componente Rating (Input) interattivo con stelle per valutazioni e feedback.

Examples:

Uso base per inserimento rating

<%= bui_input_rating(name: 'review_rating') %>

Rating read-only per visualizzazione

<%= bui_input_rating(value: 4.5, readonly: true, show_value: true) %>

Con tema e dimensioni personalizzate

<%= bui_input_rating(name: 'quality', theme: :orange, size: :large, max_stars: 10) %>

Con Rails form builder

<%= form_with model: @review do |form| %>
  <%= bui_input_rating(name: :rating, form: form, value: @review.rating, show_value: true) %>
<% end %>

Rating con mezze stelle e valore preimpostato

<%= bui_input_rating(
      name: 'service_rating',
      value: 3.5,
      half_stars: true,
      theme: :green,
      size: :medium,
      show_value: true
    ) %>

Parameters:

  • name (String) (defaults to: nil)

    Nome del campo rating (obbligatorio se non readonly)

  • value (Float, Integer) (defaults to: 0)

    Valore del rating attuale (0.0 - max_stars)

  • max_stars (Integer) (defaults to: 5)

    Numero massimo di stelle (default: 5)

  • readonly (Boolean) (defaults to: false)

    Se il rating è in sola lettura

  • half_stars (Boolean) (defaults to: true)

    Se supportare mezze stelle

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

    Tema del componente (:default, :yellow, :orange, :red, :pink, :purple, :blue, :green, :gray)

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

    Dimensione del componente (:small, :medium, :large)

  • show_value (Boolean) (defaults to: false)

    Se mostrare il valore numerico accanto alle stelle

  • form (ActionView::Helpers::FormBuilder, nil) (defaults to: nil)

    Form builder Rails opzionale

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

    Classi CSS aggiuntive

  • options (Hash)

    Opzioni aggiuntive per attributi HTML

Returns:

  • (String)

    HTML del componente Rating renderizzato



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/helpers/better_ui/general/components/input/rating/rating_helper.rb', line 48

def bui_input_rating(name: nil, value: 0, max_stars: 5, readonly: false, half_stars: true,
                     theme: :default, size: :medium, show_value: false, form: nil,
                     classes: '', **options)
  render BetterUi::General::Input::Rating::Component.new(
    name: name,
    value: value,
    max_stars: max_stars,
    readonly: readonly,
    half_stars: half_stars,
    theme: theme,
    size: size,
    show_value: show_value,
    form: form,
    classes: classes,
    **options
  )
end