Class: BetterUi::General::Input::Rating::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Input::Rating::Component
- Defined in:
- app/components/better_ui/general/input/rating/component.rb
Constant Summary collapse
- RATING_THEME =
Costanti con classi Tailwind dirette
{ default: 'text-yellow-400', yellow: 'text-yellow-400', orange: 'text-orange-400', red: 'text-red-400', pink: 'text-pink-400', purple: 'text-purple-400', blue: 'text-blue-400', green: 'text-green-400', gray: 'text-gray-400' }.freeze
- RATING_SIZE =
{ small: 'text-sm', medium: 'text-xl', large: 'text-3xl' }.freeze
- RATING_EMPTY_COLOR =
'text-gray-300'.freeze
- RATING_HALF_COLOR =
'text-yellow-300'.freeze
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#half_stars ⇒ Object
readonly
Returns the value of attribute half_stars.
-
#max_stars ⇒ Object
readonly
Returns the value of attribute max_stars.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#readonly ⇒ Object
readonly
Returns the value of attribute readonly.
-
#show_value ⇒ Object
readonly
Returns the value of attribute show_value.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name: nil, value: 0, max_stars: 5, readonly: false, half_stars: true, theme: :default, size: :medium, show_value: false, form: nil, classes: '', **options) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(name: nil, value: 0, max_stars: 5, readonly: false, half_stars: true, theme: :default, size: :medium, show_value: false, form: nil, classes: '', **options) ⇒ Component
Returns a new instance of Component.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 44 def initialize(name: nil, value: 0, max_stars: 5, readonly: false, half_stars: true, theme: :default, size: :medium, show_value: false, form: nil, classes: '', **) @name = name @value = value.to_f @max_stars = max_stars.to_i @readonly = readonly @half_stars = half_stars @theme = theme.to_sym @size = size.to_sym @show_value = show_value @form = form @classes = classes = validate_params end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def classes @classes end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def form @form end |
#half_stars ⇒ Object (readonly)
Returns the value of attribute half_stars.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def half_stars @half_stars end |
#max_stars ⇒ Object (readonly)
Returns the value of attribute max_stars.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def max_stars @max_stars end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def end |
#readonly ⇒ Object (readonly)
Returns the value of attribute readonly.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def readonly @readonly end |
#show_value ⇒ Object (readonly)
Returns the value of attribute show_value.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def show_value @show_value end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def size @size end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def theme @theme end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
30 31 32 |
# File 'app/components/better_ui/general/input/rating/component.rb', line 30 def value @value end |